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 | /** |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 17 | * Returns the role of the local node for the specified device, without |
| 18 | * triggering master selection. |
| 19 | * |
Yuta HIGUCHI | 2d48ced | 2014-10-04 21:35:03 -0700 | [diff] [blame] | 20 | * @param deviceId the the identifier of the device |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 21 | * @return role of the current node |
| 22 | */ |
| 23 | MastershipRole getLocalRole(DeviceId deviceId); |
| 24 | |
| 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 | */ |
| 32 | MastershipRole requestRoleFor(DeviceId deviceId); |
| 33 | |
| 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 |
| 37 | * for this device, no action will be taken. |
| 38 | * |
| 39 | * @param deviceId the identifier of the device |
| 40 | */ |
| 41 | void relinquishMastership(DeviceId deviceId); |
| 42 | |
| 43 | /** |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 44 | * 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 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 49 | NodeId getMasterFor(DeviceId deviceId); |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 50 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 51 | /** |
| 52 | * Returns the devices for which a controller is master. |
| 53 | * |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 54 | * @param nodeId the ID of the controller |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 55 | * @return a set of device IDs |
| 56 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 57 | Set<DeviceId> getDevicesOf(NodeId nodeId); |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 58 | |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 59 | /** |
Ayaka Koshibe | 3de43ca | 2014-09-26 16:40:23 -0700 | [diff] [blame] | 60 | * Returns the mastership term service for getting read-only |
| 61 | * term information. |
Ayaka Koshibe | b70d34b | 2014-09-25 15:43:01 -0700 | [diff] [blame] | 62 | * |
| 63 | * @return the MastershipTermService for this mastership manager |
| 64 | */ |
| 65 | MastershipTermService requestTermService(); |
| 66 | |
| 67 | /** |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame] | 68 | * Adds the specified mastership change listener. |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 69 | * |
| 70 | * @param listener the mastership listener |
| 71 | */ |
| 72 | void addListener(MastershipListener listener); |
| 73 | |
| 74 | /** |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame] | 75 | * Removes the specified mastership change listener. |
Ayaka Koshibe | 8b3270f | 2014-09-22 13:44:42 -0700 | [diff] [blame] | 76 | * |
| 77 | * @param listener the mastership listener |
| 78 | */ |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 79 | void removeListener(MastershipListener listener); |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 80 | |
| 81 | } |