blob: ffee162c98ab181e62b068801d2be15fa4a50cb5 [file] [log] [blame]
tomca90c462014-09-22 11:40:58 -07001package org.onlab.onos.cluster;
2
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -07003import java.util.Set;
4
5import org.onlab.onos.net.DeviceId;
6import org.onlab.onos.net.MastershipRole;
7
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 */
14public interface MastershipService {
15
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 *
20 * @return role of the current node
21 */
22 MastershipRole getLocalRole(DeviceId deviceId);
23
24 /**
25 * Returns the mastership status of the local controller for a given
26 * device forcing master selection if necessary.
27 *
28 * @param deviceId the the identifier of the device
29 * @return the role of this controller instance
30 */
31 MastershipRole requestRoleFor(DeviceId deviceId);
32
33 /**
34 * Abandons mastership of the specified device on the local node thus
35 * forcing selection of a new master. If the local node is not a master
Ayaka Koshibec4047702014-10-07 14:43:52 -070036 * for this device, no master selection will occur.
tomb41d1ac2014-09-24 01:51:24 -070037 *
38 * @param deviceId the identifier of the device
39 */
40 void relinquishMastership(DeviceId deviceId);
41
42 /**
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070043 * Returns the current master for a given device.
44 *
45 * @param deviceId the identifier of the device
46 * @return the ID of the master controller for the device
47 */
tome4729872014-09-23 00:37:37 -070048 NodeId getMasterFor(DeviceId deviceId);
tomca90c462014-09-22 11:40:58 -070049
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070050 /**
51 * Returns the devices for which a controller is master.
52 *
tome4729872014-09-23 00:37:37 -070053 * @param nodeId the ID of the controller
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070054 * @return a set of device IDs
55 */
tome4729872014-09-23 00:37:37 -070056 Set<DeviceId> getDevicesOf(NodeId nodeId);
tomca90c462014-09-22 11:40:58 -070057
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070058 /**
Ayaka Koshibe3de43ca2014-09-26 16:40:23 -070059 * Returns the mastership term service for getting read-only
60 * term information.
Ayaka Koshibeb70d34b2014-09-25 15:43:01 -070061 *
62 * @return the MastershipTermService for this mastership manager
63 */
64 MastershipTermService requestTermService();
65
66 /**
tomfc9a4ff2014-09-22 18:22:47 -070067 * Adds the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070068 *
69 * @param listener the mastership listener
70 */
71 void addListener(MastershipListener listener);
72
73 /**
tomfc9a4ff2014-09-22 18:22:47 -070074 * Removes the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070075 *
76 * @param listener the mastership listener
77 */
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070078 void removeListener(MastershipListener listener);
tomca90c462014-09-22 11:40:58 -070079
80}