blob: eae664d6555d427ccacd5ff017207ad0b05f86be [file] [log] [blame]
Ayaka Koshibe8d504a92014-09-22 17:07:36 -07001package org.onlab.onos.cluster;
2
3import java.util.Set;
4
5import org.onlab.onos.net.DeviceId;
6import org.onlab.onos.net.MastershipRole;
tomf80c9722014-09-24 14:49:18 -07007import org.onlab.onos.store.Store;
Ayaka Koshibe8d504a92014-09-22 17:07:36 -07008
9/**
tome4729872014-09-23 00:37:37 -070010 * Manages inventory of mastership roles for devices, across controller
11 * instances; not intended for direct use.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070012 */
tomf80c9722014-09-24 14:49:18 -070013public interface MastershipStore extends Store<MastershipEvent, MastershipStoreDelegate> {
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070014
tome4729872014-09-23 00:37:37 -070015 // three things to map: NodeId, DeviceId, MastershipRole
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070016
17 /**
tomb41d1ac2014-09-24 01:51:24 -070018 * Requests role of the local node for the specified device.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070019 *
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070020 * @param deviceId device identifier
tomb41d1ac2014-09-24 01:51:24 -070021 * @return established or newly negotiated mastership role
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070022 */
tomb41d1ac2014-09-24 01:51:24 -070023 MastershipRole requestRole(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070024
25 /**
tomb41d1ac2014-09-24 01:51:24 -070026 * Returns the role of a device for a specific controller instance.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070027 *
tomb41d1ac2014-09-24 01:51:24 -070028 * @param nodeId the instance identifier
29 * @param deviceId the device identifiers
30 * @return the role
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070031 */
tomb41d1ac2014-09-24 01:51:24 -070032 MastershipRole getRole(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070033
34 /**
35 * Returns the master for a device.
36 *
37 * @param deviceId the device identifier
38 * @return the instance identifier of the master
39 */
tome4729872014-09-23 00:37:37 -070040 NodeId getMaster(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070041
42 /**
43 * Returns the devices that a controller instance is master of.
44 *
tome4729872014-09-23 00:37:37 -070045 * @param nodeId the instance identifier
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070046 * @return a set of device identifiers
47 */
tome4729872014-09-23 00:37:37 -070048 Set<DeviceId> getDevices(NodeId nodeId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070049
50 /**
tomb41d1ac2014-09-24 01:51:24 -070051 * Sets a device's role for a specified controller instance.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070052 *
tomb41d1ac2014-09-24 01:51:24 -070053 * @param nodeId controller instance identifier
54 * @param deviceId device identifier
55 * @param role new role
56 * @return a mastership event
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070057 */
tomb41d1ac2014-09-24 01:51:24 -070058 MastershipEvent setRole(NodeId nodeId, DeviceId deviceId,
59 MastershipRole role);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070060}