Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cluster; |
| 2 | |
| 3 | import java.util.Set; |
| 4 | |
| 5 | import org.onlab.onos.net.DeviceId; |
| 6 | import org.onlab.onos.net.MastershipRole; |
| 7 | |
| 8 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 9 | * Manages inventory of mastership roles for devices, across controller |
| 10 | * instances; not intended for direct use. |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 11 | */ |
| 12 | public interface MastershipStore { |
| 13 | |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 14 | // three things to map: NodeId, DeviceId, MastershipRole |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 15 | |
| 16 | /** |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 17 | * Requests role of the local node for the specified device. |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 18 | * |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 19 | * @param deviceId device identifier |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 20 | * @return established or newly negotiated mastership role |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 21 | */ |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 22 | MastershipRole requestRole(DeviceId deviceId); |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 25 | * Returns the role of a device for a specific controller instance. |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 26 | * |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 27 | * @param nodeId the instance identifier |
| 28 | * @param deviceId the device identifiers |
| 29 | * @return the role |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 30 | */ |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 31 | MastershipRole getRole(NodeId nodeId, DeviceId deviceId); |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Returns the master for a device. |
| 35 | * |
| 36 | * @param deviceId the device identifier |
| 37 | * @return the instance identifier of the master |
| 38 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 39 | NodeId getMaster(DeviceId deviceId); |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Returns the devices that a controller instance is master of. |
| 43 | * |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 44 | * @param nodeId the instance identifier |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 45 | * @return a set of device identifiers |
| 46 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 47 | Set<DeviceId> getDevices(NodeId nodeId); |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 50 | * Sets a device's role for a specified controller instance. |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 51 | * |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 52 | * @param nodeId controller instance identifier |
| 53 | * @param deviceId device identifier |
| 54 | * @param role new role |
| 55 | * @return a mastership event |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 56 | */ |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 57 | MastershipEvent setRole(NodeId nodeId, DeviceId deviceId, |
| 58 | MastershipRole role); |
Ayaka Koshibe | 8d504a9 | 2014-09-22 17:07:36 -0700 | [diff] [blame] | 59 | } |