blob: 728e77d7d01f83bddda415aeceb478a997332585 [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;
7
8/**
tome4729872014-09-23 00:37:37 -07009 * Manages inventory of mastership roles for devices, across controller
10 * instances; not intended for direct use.
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070011 */
12public interface MastershipStore {
13
tome4729872014-09-23 00:37:37 -070014 // three things to map: NodeId, DeviceId, MastershipRole
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070015
16 /**
17 * Sets a device's role for a specified controller instance.
18 *
19 * @param instance controller instance identifier
20 * @param deviceId device identifier
21 * @param role new role
22 * @return a mastership event
23 */
tome4729872014-09-23 00:37:37 -070024 MastershipEvent setRole(NodeId instance, DeviceId deviceId,
tomfc9a4ff2014-09-22 18:22:47 -070025 MastershipRole role);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070026
27 /**
28 * Adds or updates the mastership information for a device.
29 *
30 * @param instance controller instance identifier
31 * @param deviceId device identifier
32 * @param role new role
33 * @return a mastership event
34 */
tome4729872014-09-23 00:37:37 -070035 MastershipEvent addOrUpdateDevice(NodeId instance, DeviceId deviceId,
tomfc9a4ff2014-09-22 18:22:47 -070036 MastershipRole role);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070037
38 /**
39 * Returns the master for a device.
40 *
41 * @param deviceId the device identifier
42 * @return the instance identifier of the master
43 */
tome4729872014-09-23 00:37:37 -070044 NodeId getMaster(DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070045
46 /**
47 * Returns the devices that a controller instance is master of.
48 *
tome4729872014-09-23 00:37:37 -070049 * @param nodeId the instance identifier
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070050 * @return a set of device identifiers
51 */
tome4729872014-09-23 00:37:37 -070052 Set<DeviceId> getDevices(NodeId nodeId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070053
54 /**
55 * Returns the role of a device for a specific controller instance.
56 *
tome4729872014-09-23 00:37:37 -070057 * @param nodeId the instance identifier
tomfc9a4ff2014-09-22 18:22:47 -070058 * @param deviceId the device identifiers
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070059 * @return the role
60 */
tome4729872014-09-23 00:37:37 -070061 MastershipRole getRole(NodeId nodeId, DeviceId deviceId);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070062}