blob: 18683eaa48b66739b0f4d2134529b7c8f222bac9 [file] [log] [blame]
Madan Jampani58819b42014-10-09 13:48:51 -07001package org.onlab.onos.net.device;
tomca90c462014-09-22 11:40:58 -07002
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -07003import java.util.Set;
4
Madan Jampani58819b42014-10-09 13:48:51 -07005import org.onlab.onos.cluster.NodeId;
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -07006import org.onlab.onos.net.DeviceId;
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -07007
tomca90c462014-09-22 11:40:58 -07008/**
9 * Service responsible for determining the controller instance mastership of
10 * a device in a clustered environment. This is the central authority for
11 * determining mastership, but is not responsible for actually applying it
12 * to the devices; this falls on the device service.
13 */
Madan Jampani58819b42014-10-09 13:48:51 -070014public interface DeviceMastershipService {
tomca90c462014-09-22 11:40:58 -070015
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070016 /**
tomb41d1ac2014-09-24 01:51:24 -070017 * Returns the role of the local node for the specified device, without
18 * triggering master selection.
19 *
Yuta HIGUCHI2d48ced2014-10-04 21:35:03 -070020 * @param deviceId the the identifier of the device
tomb41d1ac2014-09-24 01:51:24 -070021 * @return role of the current node
22 */
Madan Jampani195af6e2014-10-09 15:01:17 -070023 DeviceMastershipRole getLocalRole(DeviceId deviceId);
tomb41d1ac2014-09-24 01:51:24 -070024
25 /**
26 * Returns the mastership status of the local controller for a given
27 * device forcing master selection if necessary.
28 *
29 * @param deviceId the the identifier of the device
30 * @return the role of this controller instance
31 */
Madan Jampani195af6e2014-10-09 15:01:17 -070032 DeviceMastershipRole requestRoleFor(DeviceId deviceId);
tomb41d1ac2014-09-24 01:51:24 -070033
34 /**
35 * Abandons mastership of the specified device on the local node thus
36 * forcing selection of a new master. If the local node is not a master
Ayaka Koshibec4047702014-10-07 14:43:52 -070037 * for this device, no master selection will occur.
tomb41d1ac2014-09-24 01:51:24 -070038 *
39 * @param deviceId the identifier of the device
40 */
41 void relinquishMastership(DeviceId deviceId);
42
43 /**
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070044 * Returns the current master for a given device.
45 *
46 * @param deviceId the identifier of the device
47 * @return the ID of the master controller for the device
48 */
tome4729872014-09-23 00:37:37 -070049 NodeId getMasterFor(DeviceId deviceId);
tomca90c462014-09-22 11:40:58 -070050
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070051 /**
52 * Returns the devices for which a controller is master.
53 *
tome4729872014-09-23 00:37:37 -070054 * @param nodeId the ID of the controller
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070055 * @return a set of device IDs
56 */
tome4729872014-09-23 00:37:37 -070057 Set<DeviceId> getDevicesOf(NodeId nodeId);
tomca90c462014-09-22 11:40:58 -070058
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070059 /**
Ayaka Koshibe3de43ca2014-09-26 16:40:23 -070060 * Returns the mastership term service for getting read-only
61 * term information.
Ayaka Koshibeb70d34b2014-09-25 15:43:01 -070062 *
63 * @return the MastershipTermService for this mastership manager
64 */
Madan Jampani58819b42014-10-09 13:48:51 -070065 DeviceMastershipTermService requestTermService();
Ayaka Koshibeb70d34b2014-09-25 15:43:01 -070066
67 /**
tomfc9a4ff2014-09-22 18:22:47 -070068 * Adds the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070069 *
70 * @param listener the mastership listener
71 */
Madan Jampani58819b42014-10-09 13:48:51 -070072 void addListener(DeviceMastershipListener listener);
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070073
74 /**
tomfc9a4ff2014-09-22 18:22:47 -070075 * Removes the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070076 *
77 * @param listener the mastership listener
78 */
Madan Jampani58819b42014-10-09 13:48:51 -070079 void removeListener(DeviceMastershipListener listener);
tomca90c462014-09-22 11:40:58 -070080
81}