added more mastership-related interfaces
Change-Id: I3c5da1e2a4346d6e557232c5f896b32a7268ec39
Showing
6 changed files
with
86 additions
and
3 deletions
1 | +package org.onlab.onos.cluster; | ||
2 | + | ||
3 | +import org.onlab.onos.net.DeviceId; | ||
4 | +import org.onlab.onos.net.MastershipRole; | ||
5 | + | ||
6 | +/** | ||
7 | + * Service for administering the inventory of device masterships. | ||
8 | + */ | ||
9 | +public interface MastershipAdminService { | ||
10 | + | ||
11 | + /** | ||
12 | + * Applies the current mastership role for the specified device. | ||
13 | + * | ||
14 | + * @param instance controller instance identifier | ||
15 | + * @param deviceId device identifier | ||
16 | + * @param role requested role | ||
17 | + */ | ||
18 | + void setRole(InstanceId instance, DeviceId deviceId, MastershipRole role); | ||
19 | + | ||
20 | +} |
... | @@ -4,7 +4,7 @@ import org.onlab.onos.event.AbstractEvent; | ... | @@ -4,7 +4,7 @@ import org.onlab.onos.event.AbstractEvent; |
4 | import org.onlab.onos.net.DeviceId; | 4 | import org.onlab.onos.net.DeviceId; |
5 | 5 | ||
6 | /** | 6 | /** |
7 | - * Describes infrastructure device event. | 7 | + * Describes a device mastership event. |
8 | */ | 8 | */ |
9 | public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> { | 9 | public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> { |
10 | 10 | ... | ... |
... | @@ -5,6 +5,6 @@ import org.onlab.onos.event.EventListener; | ... | @@ -5,6 +5,6 @@ import org.onlab.onos.event.EventListener; |
5 | /** | 5 | /** |
6 | * Entity capable of receiving device mastership-related events. | 6 | * Entity capable of receiving device mastership-related events. |
7 | */ | 7 | */ |
8 | -public interface MastershipListener extends EventListener<MastershipEvent>{ | 8 | +public interface MastershipListener extends EventListener<MastershipEvent> { |
9 | 9 | ||
10 | } | 10 | } | ... | ... |
... | @@ -49,6 +49,6 @@ public interface MastershipService { | ... | @@ -49,6 +49,6 @@ public interface MastershipService { |
49 | * | 49 | * |
50 | * @param listener the mastership listener | 50 | * @param listener the mastership listener |
51 | */ | 51 | */ |
52 | - void removeListemer(MastershipListener listener); | 52 | + void removeListener(MastershipListener listener); |
53 | 53 | ||
54 | } | 54 | } | ... | ... |
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; | ||
7 | + | ||
8 | +/** | ||
9 | + * Manages inventory of mastership roles for devices, across controller instances. | ||
10 | + */ | ||
11 | +public 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 | +} |
... | @@ -13,7 +13,9 @@ public interface DeviceAdminService { | ... | @@ -13,7 +13,9 @@ public interface DeviceAdminService { |
13 | * | 13 | * |
14 | * @param deviceId device identifier | 14 | * @param deviceId device identifier |
15 | * @param role requested role | 15 | * @param role requested role |
16 | + * @deprecated Will be removed in favor of MastershipAdminService.setRole() | ||
16 | */ | 17 | */ |
18 | + @Deprecated | ||
17 | void setRole(DeviceId deviceId, MastershipRole role); | 19 | void setRole(DeviceId deviceId, MastershipRole role); |
18 | 20 | ||
19 | /** | 21 | /** | ... | ... |
-
Please register or login to post a comment