blob: 9c1b3e67fd09a48039b4403e563693052b569106 [file] [log] [blame]
Madan Jampani58819b42014-10-09 13:48:51 -07001package org.onlab.onos.net.device;
Ayaka Koshibe8d504a92014-09-22 17:07:36 -07002
3import java.util.Set;
4
Madan Jampani58819b42014-10-09 13:48:51 -07005import org.onlab.onos.cluster.NodeId;
Ayaka Koshibe8d504a92014-09-22 17:07:36 -07006import org.onlab.onos.net.DeviceId;
tomf80c9722014-09-24 14:49:18 -07007import org.onlab.onos.store.Store;
Ayaka Koshibe8d504a92014-09-22 17:07:36 -07008
9/**
tome4729872014-09-23 00:37:37 -070010 * Manages inventory of mastership roles for devices, across controller
11 * instances; not intended for direct use.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070012 */
Madan Jampani58819b42014-10-09 13:48:51 -070013public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, DeviceMastershipStoreDelegate> {
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070014
tome4729872014-09-23 00:37:37 -070015 // three things to map: NodeId, DeviceId, MastershipRole
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070016
17 /**
tomb41d1ac2014-09-24 01:51:24 -070018 * Requests role of the local node for the specified device.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070019 *
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070020 * @param deviceId device identifier
tomb41d1ac2014-09-24 01:51:24 -070021 * @return established or newly negotiated mastership role
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070022 */
Madan Jampani195af6e2014-10-09 15:01:17 -070023 DeviceMastershipRole requestRole(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070024
25 /**
tomb41d1ac2014-09-24 01:51:24 -070026 * Returns the role of a device for a specific controller instance.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070027 *
tomb41d1ac2014-09-24 01:51:24 -070028 * @param nodeId the instance identifier
29 * @param deviceId the device identifiers
30 * @return the role
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070031 */
Madan Jampani195af6e2014-10-09 15:01:17 -070032 DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070033
34 /**
35 * Returns the master for a device.
36 *
37 * @param deviceId the device identifier
38 * @return the instance identifier of the master
39 */
tome4729872014-09-23 00:37:37 -070040 NodeId getMaster(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070041
42 /**
43 * Returns the devices that a controller instance is master of.
44 *
tome4729872014-09-23 00:37:37 -070045 * @param nodeId the instance identifier
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070046 * @return a set of device identifiers
47 */
tome4729872014-09-23 00:37:37 -070048 Set<DeviceId> getDevices(NodeId nodeId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070049
50 /**
tomb41d1ac2014-09-24 01:51:24 -070051 * Sets a device's role for a specified controller instance.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070052 *
tomb41d1ac2014-09-24 01:51:24 -070053 * @param nodeId controller instance identifier
54 * @param deviceId device identifier
tomb41d1ac2014-09-24 01:51:24 -070055 * @return a mastership event
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070056 */
Madan Jampani58819b42014-10-09 13:48:51 -070057 DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibeb70d34b2014-09-25 15:43:01 -070058
59 /**
60 * Returns the current master and number of past mastership hand-offs
61 * (terms) for a device.
62 *
63 * @param deviceId the device identifier
64 * @return the current master's ID and the term value for device, or null
65 */
Madan Jampani58819b42014-10-09 13:48:51 -070066 DeviceMastershipTerm getTermFor(DeviceId deviceId);
Ayaka Koshibed9f693e2014-09-29 18:04:54 -070067
68 /**
Ayaka Koshibec4047702014-10-07 14:43:52 -070069 * Sets a controller instance's mastership role to STANDBY for a device.
70 * If the role is MASTER, another controller instance will be selected
71 * as a candidate master.
Ayaka Koshibed9f693e2014-09-29 18:04:54 -070072 *
73 * @param nodeId the controller instance identifier
Ayaka Koshibec4047702014-10-07 14:43:52 -070074 * @param deviceId device to revoke mastership role for
Ayaka Koshibed9f693e2014-09-29 18:04:54 -070075 * @return a mastership event
76 */
Madan Jampani58819b42014-10-09 13:48:51 -070077 DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibec4047702014-10-07 14:43:52 -070078
79 /**
80 * Allows a controller instance to give up its current role for a device.
81 * If the role is MASTER, another controller instance will be selected
82 * as a candidate master.
83 *
84 * @param nodeId the controller instance identifier
85 * @param deviceId device to revoke mastership role for
86 * @return a mastership event
87 */
Madan Jampani58819b42014-10-09 13:48:51 -070088 DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibec4047702014-10-07 14:43:52 -070089
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070090}