blob: 67eeff5fa61f02e326b3f4ebf81c9caf8fc876c7 [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/**
9 * Manages inventory of mastership roles for devices, across controller instances.
10 */
11public interface MastershipStore {
12
13 // three things to map: InstanceId, DeviceId, MastershipRole
14
15 /**
16 * Sets a device's role for a specified controller instance.
17 *
18 * @param instance controller instance identifier
19 * @param deviceId device identifier
20 * @param role new role
21 * @return a mastership event
22 */
tomfc9a4ff2014-09-22 18:22:47 -070023 MastershipEvent setRole(InstanceId instance, DeviceId deviceId,
24 MastershipRole role);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070025
26 /**
27 * Adds or updates the mastership information for a device.
28 *
29 * @param instance controller instance identifier
30 * @param deviceId device identifier
31 * @param role new role
32 * @return a mastership event
33 */
tomfc9a4ff2014-09-22 18:22:47 -070034 MastershipEvent addOrUpdateDevice(InstanceId instance, DeviceId deviceId,
35 MastershipRole role);
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070036
37 /**
38 * Returns the master for a device.
39 *
40 * @param deviceId the device identifier
41 * @return the instance identifier of the master
42 */
43 InstanceId getMaster(DeviceId deviceId);
44
45 /**
46 * Returns the devices that a controller instance is master of.
47 *
tomfc9a4ff2014-09-22 18:22:47 -070048 * @param instanceId the instance identifier
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070049 * @return a set of device identifiers
50 */
51 Set<DeviceId> getDevices(InstanceId instanceId);
52
53 /**
54 * Returns the role of a device for a specific controller instance.
55 *
56 * @param instanceId the instance identifier
tomfc9a4ff2014-09-22 18:22:47 -070057 * @param deviceId the device identifiers
Ayaka Koshibe8d504a92014-09-22 17:07:36 -070058 * @return the role
59 */
60 MastershipRole getRole(InstanceId instanceId, DeviceId deviceId);
61}