blob: 31b4bcc89ce713c64b990616d7b0adccdebc8a6a [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
36 * for this device, no action will be taken.
37 *
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 /**
tomfc9a4ff2014-09-22 18:22:47 -070059 * Adds the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070060 *
61 * @param listener the mastership listener
62 */
63 void addListener(MastershipListener listener);
64
65 /**
tomfc9a4ff2014-09-22 18:22:47 -070066 * Removes the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070067 *
68 * @param listener the mastership listener
69 */
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070070 void removeListener(MastershipListener listener);
tomca90c462014-09-22 11:40:58 -070071
72}