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