tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cluster; |
| 2 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 3 | import java.util.Set; |
| 4 | |
| 5 | import org.onlab.onos.net.DeviceId; |
| 6 | import org.onlab.onos.net.MastershipRole; |
| 7 | |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 8 | /** |
| 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 | */ |
| 14 | public interface MastershipService { |
| 15 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 16 | /** |
| 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 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 22 | NodeId getMasterFor(DeviceId deviceId); |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 23 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Returns the devices for which a controller is master. |
| 26 | * |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 27 | * @param nodeId the ID of the controller |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 28 | * @return a set of device IDs |
| 29 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 30 | Set<DeviceId> getDevicesOf(NodeId nodeId); |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 31 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 32 | /** |
| 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 | |
tom | 0872a17 | 2014-09-23 11:24:26 -0700 | [diff] [blame^] | 40 | // TODO: add facet for requesting a different master than the current one; |
| 41 | // abandon mastership (due to loss of connection) |
| 42 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 43 | /** |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame] | 44 | * Adds the specified mastership change listener. |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 45 | * |
| 46 | * @param listener the mastership listener |
| 47 | */ |
| 48 | void addListener(MastershipListener listener); |
| 49 | |
| 50 | /** |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame] | 51 | * Removes the specified mastership change listener. |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 52 | * |
| 53 | * @param listener the mastership listener |
| 54 | */ |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 55 | void removeListener(MastershipListener listener); |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 56 | |
| 57 | } |