blob: dad4a75e8a2aa0c4f1b5d9565ad4a0ffc49f48a1 [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 */
23 MastershipEvent setRole(
24 InstanceId instance, DeviceId deviceId, MastershipRole role);
25
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 */
34 MastershipEvent addOrUpdateDevice(
35 InstanceId instance, DeviceId deviceId, MastershipRole role);
36
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 *
48 * @param instanceId the instance identifier
49 * @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
57 * @param deviceId the device identifiers
58 * @return the role
59 */
60 MastershipRole getRole(InstanceId instanceId, DeviceId deviceId);
61}