blob: 3e2ee03dd5e0d7e16c89998971d4c094df12920b [file] [log] [blame]
Ayaka Koshibe8d504a92014-09-22 17:07:36 -07001package org.onlab.onos.cluster;
2
3import java.util.Set;
4
5import org.onlab.onos.net.DeviceId;
6import org.onlab.onos.net.MastershipRole;
7
8/**
tome4729872014-09-23 00:37:37 -07009 * Manages inventory of mastership roles for devices, across controller
10 * instances; not intended for direct use.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070011 */
12public interface MastershipStore {
13
tome4729872014-09-23 00:37:37 -070014 // three things to map: NodeId, DeviceId, MastershipRole
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070015
16 /**
tomb41d1ac2014-09-24 01:51:24 -070017 * Requests role of the local node for the specified device.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070018 *
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070019 * @param deviceId device identifier
tomb41d1ac2014-09-24 01:51:24 -070020 * @return established or newly negotiated mastership role
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070021 */
tomb41d1ac2014-09-24 01:51:24 -070022 MastershipRole requestRole(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070023
24 /**
tomb41d1ac2014-09-24 01:51:24 -070025 * Returns the role of a device for a specific controller instance.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070026 *
tomb41d1ac2014-09-24 01:51:24 -070027 * @param nodeId the instance identifier
28 * @param deviceId the device identifiers
29 * @return the role
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070030 */
tomb41d1ac2014-09-24 01:51:24 -070031 MastershipRole getRole(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070032
33 /**
34 * Returns the master for a device.
35 *
36 * @param deviceId the device identifier
37 * @return the instance identifier of the master
38 */
tome4729872014-09-23 00:37:37 -070039 NodeId getMaster(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070040
41 /**
42 * Returns the devices that a controller instance is master of.
43 *
tome4729872014-09-23 00:37:37 -070044 * @param nodeId the instance identifier
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070045 * @return a set of device identifiers
46 */
tome4729872014-09-23 00:37:37 -070047 Set<DeviceId> getDevices(NodeId nodeId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070048
49 /**
tomb41d1ac2014-09-24 01:51:24 -070050 * Sets a device's role for a specified controller instance.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070051 *
tomb41d1ac2014-09-24 01:51:24 -070052 * @param nodeId controller instance identifier
53 * @param deviceId device identifier
54 * @param role new role
55 * @return a mastership event
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070056 */
tomb41d1ac2014-09-24 01:51:24 -070057 MastershipEvent setRole(NodeId nodeId, DeviceId deviceId,
58 MastershipRole role);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070059}