blob: 8da4aa577df7ef0eb5710ff457fff04676af29c2 [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 /**
17 * Returns the current master for a given device.
18 *
19 * @param deviceId the identifier of the device
20 * @return the ID of the master controller for the device
21 */
tome4729872014-09-23 00:37:37 -070022 NodeId getMasterFor(DeviceId deviceId);
tomca90c462014-09-22 11:40:58 -070023
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070024 /**
25 * Returns the devices for which a controller is master.
26 *
tome4729872014-09-23 00:37:37 -070027 * @param nodeId the ID of the controller
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070028 * @return a set of device IDs
29 */
tome4729872014-09-23 00:37:37 -070030 Set<DeviceId> getDevicesOf(NodeId nodeId);
tomca90c462014-09-22 11:40:58 -070031
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070032 /**
33 * Returns the mastership status of this controller for a given device.
34 *
35 * @param deviceId the the identifier of the device
36 * @return the role of this controller instance
37 */
38 MastershipRole requestRoleFor(DeviceId deviceId);
39
tom0872a172014-09-23 11:24:26 -070040 // TODO: add facet for requesting a different master than the current one;
41 // abandon mastership (due to loss of connection)
42
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070043 /**
tomfc9a4ff2014-09-22 18:22:47 -070044 * Adds the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070045 *
46 * @param listener the mastership listener
47 */
48 void addListener(MastershipListener listener);
49
50 /**
tomfc9a4ff2014-09-22 18:22:47 -070051 * Removes the specified mastership change listener.
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -070052 *
53 * @param listener the mastership listener
54 */
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070055 void removeListener(MastershipListener listener);
tomca90c462014-09-22 11:40:58 -070056
57}