Yuta HIGUCHI

Revert "Refactored code in an attempt to break dependency cycles"

This reverts commit 195af6e6.
Showing 59 changed files with 361 additions and 275 deletions
...@@ -4,8 +4,8 @@ import org.apache.karaf.shell.commands.Argument; ...@@ -4,8 +4,8 @@ import org.apache.karaf.shell.commands.Argument;
4 import org.apache.karaf.shell.commands.Command; 4 import org.apache.karaf.shell.commands.Command;
5 import org.onlab.onos.cli.AbstractShellCommand; 5 import org.onlab.onos.cli.AbstractShellCommand;
6 import org.onlab.onos.cluster.NodeId; 6 import org.onlab.onos.cluster.NodeId;
7 +import org.onlab.onos.net.MastershipRole;
7 import org.onlab.onos.net.device.DeviceMastershipAdminService; 8 import org.onlab.onos.net.device.DeviceMastershipAdminService;
8 -import org.onlab.onos.net.device.DeviceMastershipRole;
9 9
10 import static org.onlab.onos.net.DeviceId.deviceId; 10 import static org.onlab.onos.net.DeviceId.deviceId;
11 11
...@@ -31,7 +31,7 @@ public class DeviceRoleCommand extends AbstractShellCommand { ...@@ -31,7 +31,7 @@ public class DeviceRoleCommand extends AbstractShellCommand {
31 @Override 31 @Override
32 protected void execute() { 32 protected void execute() {
33 DeviceMastershipAdminService service = get(DeviceMastershipAdminService.class); 33 DeviceMastershipAdminService service = get(DeviceMastershipAdminService.class);
34 - DeviceMastershipRole mastershipRole = DeviceMastershipRole.valueOf(role.toUpperCase()); 34 + MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase());
35 service.setRole(new NodeId(node), deviceId(uri), mastershipRole); 35 service.setRole(new NodeId(node), deviceId(uri), mastershipRole);
36 } 36 }
37 37
......
...@@ -2,7 +2,7 @@ package org.onlab.onos.cli.net; ...@@ -2,7 +2,7 @@ package org.onlab.onos.cli.net;
2 2
3 import org.apache.karaf.shell.console.Completer; 3 import org.apache.karaf.shell.console.Completer;
4 import org.apache.karaf.shell.console.completer.StringsCompleter; 4 import org.apache.karaf.shell.console.completer.StringsCompleter;
5 -import org.onlab.onos.net.device.DeviceMastershipRole; 5 +import org.onlab.onos.net.MastershipRole;
6 6
7 import java.util.List; 7 import java.util.List;
8 import java.util.SortedSet; 8 import java.util.SortedSet;
...@@ -16,9 +16,9 @@ public class RoleCompleter implements Completer { ...@@ -16,9 +16,9 @@ public class RoleCompleter implements Completer {
16 // Delegate string completer 16 // Delegate string completer
17 StringsCompleter delegate = new StringsCompleter(); 17 StringsCompleter delegate = new StringsCompleter();
18 SortedSet<String> strings = delegate.getStrings(); 18 SortedSet<String> strings = delegate.getStrings();
19 - strings.add(DeviceMastershipRole.MASTER.toString().toLowerCase()); 19 + strings.add(MastershipRole.MASTER.toString().toLowerCase());
20 - strings.add(DeviceMastershipRole.STANDBY.toString().toLowerCase()); 20 + strings.add(MastershipRole.STANDBY.toString().toLowerCase());
21 - strings.add(DeviceMastershipRole.NONE.toString().toLowerCase()); 21 + strings.add(MastershipRole.NONE.toString().toLowerCase());
22 22
23 // Now let the completer do the work for figuring out what to offer. 23 // Now let the completer do the work for figuring out what to offer.
24 return delegate.complete(buffer, cursor, candidates); 24 return delegate.complete(buffer, cursor, candidates);
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Representation of a relationship role of a controller instance to a device 4 * Representation of a relationship role of a controller instance to a device
5 * or a region of network environment. 5 * or a region of network environment.
6 */ 6 */
7 -public enum DeviceMastershipRole { 7 +public enum MastershipRole {
8 8
9 /** 9 /**
10 * Represents a relationship where the controller instance is the master 10 * Represents a relationship where the controller instance is the master
......
...@@ -2,6 +2,7 @@ package org.onlab.onos.net.device; ...@@ -2,6 +2,7 @@ package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.cluster.NodeId; 3 import org.onlab.onos.cluster.NodeId;
4 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.MastershipRole;
5 6
6 /** 7 /**
7 * Service for administering the inventory of device masterships. 8 * Service for administering the inventory of device masterships.
...@@ -15,6 +16,6 @@ public interface DeviceMastershipAdminService { ...@@ -15,6 +16,6 @@ public interface DeviceMastershipAdminService {
15 * @param deviceId device identifier 16 * @param deviceId device identifier
16 * @param role requested role 17 * @param role requested role
17 */ 18 */
18 - void setRole(NodeId instance, DeviceId deviceId, DeviceMastershipRole role); 19 + void setRole(NodeId instance, DeviceId deviceId, MastershipRole role);
19 20
20 } 21 }
......
...@@ -4,6 +4,7 @@ import java.util.Set; ...@@ -4,6 +4,7 @@ import java.util.Set;
4 4
5 import org.onlab.onos.cluster.NodeId; 5 import org.onlab.onos.cluster.NodeId;
6 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
7 +import org.onlab.onos.net.MastershipRole;
7 8
8 /** 9 /**
9 * Service responsible for determining the controller instance mastership of 10 * Service responsible for determining the controller instance mastership of
...@@ -20,7 +21,7 @@ public interface DeviceMastershipService { ...@@ -20,7 +21,7 @@ public interface DeviceMastershipService {
20 * @param deviceId the the identifier of the device 21 * @param deviceId the the identifier of the device
21 * @return role of the current node 22 * @return role of the current node
22 */ 23 */
23 - DeviceMastershipRole getLocalRole(DeviceId deviceId); 24 + MastershipRole getLocalRole(DeviceId deviceId);
24 25
25 /** 26 /**
26 * Returns the mastership status of the local controller for a given 27 * Returns the mastership status of the local controller for a given
...@@ -29,7 +30,7 @@ public interface DeviceMastershipService { ...@@ -29,7 +30,7 @@ public interface DeviceMastershipService {
29 * @param deviceId the the identifier of the device 30 * @param deviceId the the identifier of the device
30 * @return the role of this controller instance 31 * @return the role of this controller instance
31 */ 32 */
32 - DeviceMastershipRole requestRoleFor(DeviceId deviceId); 33 + MastershipRole requestRoleFor(DeviceId deviceId);
33 34
34 /** 35 /**
35 * Abandons mastership of the specified device on the local node thus 36 * Abandons mastership of the specified device on the local node thus
......
...@@ -4,6 +4,7 @@ import java.util.Set; ...@@ -4,6 +4,7 @@ import java.util.Set;
4 4
5 import org.onlab.onos.cluster.NodeId; 5 import org.onlab.onos.cluster.NodeId;
6 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
7 +import org.onlab.onos.net.MastershipRole;
7 import org.onlab.onos.store.Store; 8 import org.onlab.onos.store.Store;
8 9
9 /** 10 /**
...@@ -20,7 +21,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -20,7 +21,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
20 * @param deviceId device identifier 21 * @param deviceId device identifier
21 * @return established or newly negotiated mastership role 22 * @return established or newly negotiated mastership role
22 */ 23 */
23 - DeviceMastershipRole requestRole(DeviceId deviceId); 24 + MastershipRole requestRole(DeviceId deviceId);
24 25
25 /** 26 /**
26 * Returns the role of a device for a specific controller instance. 27 * Returns the role of a device for a specific controller instance.
...@@ -29,7 +30,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -29,7 +30,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
29 * @param deviceId the device identifiers 30 * @param deviceId the device identifiers
30 * @return the role 31 * @return the role
31 */ 32 */
32 - DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId); 33 + MastershipRole getRole(NodeId nodeId, DeviceId deviceId);
33 34
34 /** 35 /**
35 * Returns the master for a device. 36 * Returns the master for a device.
......
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.net.Device; 3 import org.onlab.onos.net.Device;
4 +import org.onlab.onos.net.MastershipRole;
4 import org.onlab.onos.net.provider.Provider; 5 import org.onlab.onos.net.provider.Provider;
5 6
6 /** 7 /**
...@@ -29,6 +30,6 @@ public interface DeviceProvider extends Provider { ...@@ -29,6 +30,6 @@ public interface DeviceProvider extends Provider {
29 * @param device affected device 30 * @param device affected device
30 * @param newRole newly determined mastership role 31 * @param newRole newly determined mastership role
31 */ 32 */
32 - void roleChanged(Device device, DeviceMastershipRole newRole); 33 + void roleChanged(Device device, MastershipRole newRole);
33 34
34 } 35 }
......
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 +import org.onlab.onos.net.MastershipRole;
4 import org.onlab.onos.net.provider.ProviderService; 5 import org.onlab.onos.net.provider.ProviderService;
5 6
6 import java.util.List; 7 import java.util.List;
...@@ -52,6 +53,6 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> { ...@@ -52,6 +53,6 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> {
52 * @param deviceId identity of the device 53 * @param deviceId identity of the device
53 * @param role mastership role that was asserted but failed 54 * @param role mastership role that was asserted but failed
54 */ 55 */
55 - void unableToAssertRole(DeviceId deviceId, DeviceMastershipRole role); 56 + void unableToAssertRole(DeviceId deviceId, MastershipRole role);
56 57
57 } 58 }
......
...@@ -2,6 +2,7 @@ package org.onlab.onos.net.device; ...@@ -2,6 +2,7 @@ package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.net.Device; 3 import org.onlab.onos.net.Device;
4 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.MastershipRole;
5 import org.onlab.onos.net.Port; 6 import org.onlab.onos.net.Port;
6 import org.onlab.onos.net.PortNumber; 7 import org.onlab.onos.net.PortNumber;
7 8
...@@ -42,7 +43,7 @@ public interface DeviceService { ...@@ -42,7 +43,7 @@ public interface DeviceService {
42 * @return designated mastership role 43 * @return designated mastership role
43 */ 44 */
44 //XXX do we want this method here when MastershipService already does? 45 //XXX do we want this method here when MastershipService already does?
45 - DeviceMastershipRole getRole(DeviceId deviceId); 46 + MastershipRole getRole(DeviceId deviceId);
46 47
47 48
48 /** 49 /**
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.store;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 +import org.onlab.onos.net.device.DeviceMastershipTerm;
4 5
5 //TODO: Consider renaming to DeviceClockProviderService? 6 //TODO: Consider renaming to DeviceClockProviderService?
6 /** 7 /**
7 * Interface for feeding term information to a logical clock service 8 * Interface for feeding term information to a logical clock service
8 * that vends per device timestamps. 9 * that vends per device timestamps.
9 */ 10 */
10 -public interface DeviceClockProviderService { 11 +public interface ClockProviderService {
11 12
12 /** 13 /**
13 * Updates the mastership term for the specified deviceId. 14 * Updates the mastership term for the specified deviceId.
...@@ -15,5 +16,5 @@ public interface DeviceClockProviderService { ...@@ -15,5 +16,5 @@ public interface DeviceClockProviderService {
15 * @param deviceId device identifier. 16 * @param deviceId device identifier.
16 * @param term mastership term. 17 * @param term mastership term.
17 */ 18 */
18 - public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term); 19 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term);
19 } 20 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.store;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 4
...@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId; ...@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId;
6 /** 6 /**
7 * Interface for a logical clock service that vends per device timestamps. 7 * Interface for a logical clock service that vends per device timestamps.
8 */ 8 */
9 -public interface DeviceClockService { 9 +public interface ClockService {
10 10
11 /** 11 /**
12 * Returns a new timestamp for the specified deviceId. 12 * Returns a new timestamp for the specified deviceId.
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.store;
2 2
3 /** 3 /**
4 * Opaque version structure. 4 * Opaque version structure.
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.store;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 4
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.store;
2 2
3 import java.util.Objects; 3 import java.util.Objects;
4 4
......
1 package org.onlab.onos.cluster; 1 package org.onlab.onos.cluster;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 +import org.onlab.onos.net.MastershipRole;
4 import org.onlab.onos.net.device.DeviceMastershipListener; 5 import org.onlab.onos.net.device.DeviceMastershipListener;
5 -import org.onlab.onos.net.device.DeviceMastershipRole;
6 import org.onlab.onos.net.device.DeviceMastershipService; 6 import org.onlab.onos.net.device.DeviceMastershipService;
7 import org.onlab.onos.net.device.DeviceMastershipTermService; 7 import org.onlab.onos.net.device.DeviceMastershipTermService;
8 8
...@@ -13,12 +13,12 @@ import java.util.Set; ...@@ -13,12 +13,12 @@ import java.util.Set;
13 */ 13 */
14 public class MastershipServiceAdapter implements DeviceMastershipService { 14 public class MastershipServiceAdapter implements DeviceMastershipService {
15 @Override 15 @Override
16 - public DeviceMastershipRole getLocalRole(DeviceId deviceId) { 16 + public MastershipRole getLocalRole(DeviceId deviceId) {
17 return null; 17 return null;
18 } 18 }
19 19
20 @Override 20 @Override
21 - public DeviceMastershipRole requestRoleFor(DeviceId deviceId) { 21 + public MastershipRole requestRoleFor(DeviceId deviceId) {
22 return null; 22 return null;
23 } 23 }
24 24
......
...@@ -2,6 +2,7 @@ package org.onlab.onos.net.device; ...@@ -2,6 +2,7 @@ package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.net.Device; 3 import org.onlab.onos.net.Device;
4 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.MastershipRole;
5 import org.onlab.onos.net.Port; 6 import org.onlab.onos.net.Port;
6 import org.onlab.onos.net.PortNumber; 7 import org.onlab.onos.net.PortNumber;
7 8
...@@ -27,7 +28,7 @@ public class DeviceServiceAdapter implements DeviceService { ...@@ -27,7 +28,7 @@ public class DeviceServiceAdapter implements DeviceService {
27 } 28 }
28 29
29 @Override 30 @Override
30 - public DeviceMastershipRole getRole(DeviceId deviceId) { 31 + public MastershipRole getRole(DeviceId deviceId) {
31 return null; 32 return null;
32 } 33 }
33 34
......
...@@ -18,10 +18,10 @@ import org.onlab.onos.cluster.NodeId; ...@@ -18,10 +18,10 @@ import org.onlab.onos.cluster.NodeId;
18 import org.onlab.onos.event.AbstractListenerRegistry; 18 import org.onlab.onos.event.AbstractListenerRegistry;
19 import org.onlab.onos.event.EventDeliveryService; 19 import org.onlab.onos.event.EventDeliveryService;
20 import org.onlab.onos.net.DeviceId; 20 import org.onlab.onos.net.DeviceId;
21 +import org.onlab.onos.net.MastershipRole;
21 import org.onlab.onos.net.device.DeviceMastershipAdminService; 22 import org.onlab.onos.net.device.DeviceMastershipAdminService;
22 import org.onlab.onos.net.device.DeviceMastershipEvent; 23 import org.onlab.onos.net.device.DeviceMastershipEvent;
23 import org.onlab.onos.net.device.DeviceMastershipListener; 24 import org.onlab.onos.net.device.DeviceMastershipListener;
24 -import org.onlab.onos.net.device.DeviceMastershipRole;
25 import org.onlab.onos.net.device.DeviceMastershipService; 25 import org.onlab.onos.net.device.DeviceMastershipService;
26 import org.onlab.onos.net.device.DeviceMastershipStore; 26 import org.onlab.onos.net.device.DeviceMastershipStore;
27 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate; 27 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
...@@ -73,13 +73,13 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -73,13 +73,13 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
73 } 73 }
74 74
75 @Override 75 @Override
76 - public void setRole(NodeId nodeId, DeviceId deviceId, DeviceMastershipRole role) { 76 + public void setRole(NodeId nodeId, DeviceId deviceId, MastershipRole role) {
77 checkNotNull(nodeId, NODE_ID_NULL); 77 checkNotNull(nodeId, NODE_ID_NULL);
78 checkNotNull(deviceId, DEVICE_ID_NULL); 78 checkNotNull(deviceId, DEVICE_ID_NULL);
79 checkNotNull(role, ROLE_NULL); 79 checkNotNull(role, ROLE_NULL);
80 80
81 DeviceMastershipEvent event = null; 81 DeviceMastershipEvent event = null;
82 - if (role.equals(DeviceMastershipRole.MASTER)) { 82 + if (role.equals(MastershipRole.MASTER)) {
83 event = store.setMaster(nodeId, deviceId); 83 event = store.setMaster(nodeId, deviceId);
84 } else { 84 } else {
85 event = store.setStandby(nodeId, deviceId); 85 event = store.setStandby(nodeId, deviceId);
...@@ -91,7 +91,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -91,7 +91,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
91 } 91 }
92 92
93 @Override 93 @Override
94 - public DeviceMastershipRole getLocalRole(DeviceId deviceId) { 94 + public MastershipRole getLocalRole(DeviceId deviceId) {
95 checkNotNull(deviceId, DEVICE_ID_NULL); 95 checkNotNull(deviceId, DEVICE_ID_NULL);
96 return store.getRole(clusterService.getLocalNode().id(), deviceId); 96 return store.getRole(clusterService.getLocalNode().id(), deviceId);
97 } 97 }
...@@ -108,7 +108,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -108,7 +108,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
108 } 108 }
109 109
110 @Override 110 @Override
111 - public DeviceMastershipRole requestRoleFor(DeviceId deviceId) { 111 + public MastershipRole requestRoleFor(DeviceId deviceId) {
112 checkNotNull(deviceId, DEVICE_ID_NULL); 112 checkNotNull(deviceId, DEVICE_ID_NULL);
113 return store.requestRole(deviceId); 113 return store.requestRole(deviceId);
114 } 114 }
......
...@@ -18,14 +18,13 @@ import org.onlab.onos.event.AbstractListenerRegistry; ...@@ -18,14 +18,13 @@ import org.onlab.onos.event.AbstractListenerRegistry;
18 import org.onlab.onos.event.EventDeliveryService; 18 import org.onlab.onos.event.EventDeliveryService;
19 import org.onlab.onos.net.Device; 19 import org.onlab.onos.net.Device;
20 import org.onlab.onos.net.DeviceId; 20 import org.onlab.onos.net.DeviceId;
21 +import org.onlab.onos.net.MastershipRole;
21 import org.onlab.onos.net.Port; 22 import org.onlab.onos.net.Port;
22 import org.onlab.onos.net.PortNumber; 23 import org.onlab.onos.net.PortNumber;
23 import org.onlab.onos.net.device.DeviceAdminService; 24 import org.onlab.onos.net.device.DeviceAdminService;
24 -import org.onlab.onos.net.device.DeviceClockProviderService;
25 import org.onlab.onos.net.device.DeviceDescription; 25 import org.onlab.onos.net.device.DeviceDescription;
26 import org.onlab.onos.net.device.DeviceEvent; 26 import org.onlab.onos.net.device.DeviceEvent;
27 import org.onlab.onos.net.device.DeviceListener; 27 import org.onlab.onos.net.device.DeviceListener;
28 -import org.onlab.onos.net.device.DeviceMastershipRole;
29 import org.onlab.onos.net.device.DeviceProvider; 28 import org.onlab.onos.net.device.DeviceProvider;
30 import org.onlab.onos.net.device.DeviceProviderRegistry; 29 import org.onlab.onos.net.device.DeviceProviderRegistry;
31 import org.onlab.onos.net.device.DeviceProviderService; 30 import org.onlab.onos.net.device.DeviceProviderService;
...@@ -40,6 +39,7 @@ import org.onlab.onos.net.device.DeviceMastershipTermService; ...@@ -40,6 +39,7 @@ import org.onlab.onos.net.device.DeviceMastershipTermService;
40 import org.onlab.onos.net.device.PortDescription; 39 import org.onlab.onos.net.device.PortDescription;
41 import org.onlab.onos.net.provider.AbstractProviderRegistry; 40 import org.onlab.onos.net.provider.AbstractProviderRegistry;
42 import org.onlab.onos.net.provider.AbstractProviderService; 41 import org.onlab.onos.net.provider.AbstractProviderService;
42 +import org.onlab.onos.store.ClockProviderService;
43 import org.slf4j.Logger; 43 import org.slf4j.Logger;
44 44
45 /** 45 /**
...@@ -81,7 +81,7 @@ public class DeviceManager ...@@ -81,7 +81,7 @@ public class DeviceManager
81 protected DeviceMastershipTermService termService; 81 protected DeviceMastershipTermService termService;
82 82
83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 - protected DeviceClockProviderService clockProviderService; 84 + protected ClockProviderService clockProviderService;
85 85
86 @Activate 86 @Activate
87 public void activate() { 87 public void activate() {
...@@ -117,7 +117,7 @@ public class DeviceManager ...@@ -117,7 +117,7 @@ public class DeviceManager
117 } 117 }
118 118
119 @Override 119 @Override
120 - public DeviceMastershipRole getRole(DeviceId deviceId) { 120 + public MastershipRole getRole(DeviceId deviceId) {
121 checkNotNull(deviceId, DEVICE_ID_NULL); 121 checkNotNull(deviceId, DEVICE_ID_NULL);
122 return mastershipService.getLocalRole(deviceId); 122 return mastershipService.getLocalRole(deviceId);
123 } 123 }
...@@ -142,8 +142,8 @@ public class DeviceManager ...@@ -142,8 +142,8 @@ public class DeviceManager
142 } 142 }
143 143
144 // Applies the specified role to the device; ignores NONE 144 // Applies the specified role to the device; ignores NONE
145 - private void applyRole(DeviceId deviceId, DeviceMastershipRole newRole) { 145 + private void applyRole(DeviceId deviceId, MastershipRole newRole) {
146 - if (newRole.equals(DeviceMastershipRole.NONE)) { 146 + if (newRole.equals(MastershipRole.NONE)) {
147 Device device = store.getDevice(deviceId); 147 Device device = store.getDevice(deviceId);
148 // FIXME: Device might not be there yet. (eventual consistent) 148 // FIXME: Device might not be there yet. (eventual consistent)
149 if (device == null) { 149 if (device == null) {
...@@ -201,9 +201,9 @@ public class DeviceManager ...@@ -201,9 +201,9 @@ public class DeviceManager
201 201
202 log.info("Device {} connected", deviceId); 202 log.info("Device {} connected", deviceId);
203 // check my Role 203 // check my Role
204 - DeviceMastershipRole role = mastershipService.requestRoleFor(deviceId); 204 + MastershipRole role = mastershipService.requestRoleFor(deviceId);
205 205
206 - if (role != DeviceMastershipRole.MASTER) { 206 + if (role != MastershipRole.MASTER) {
207 // TODO: Do we need to explicitly tell the Provider that 207 // TODO: Do we need to explicitly tell the Provider that
208 // this instance is no longer the MASTER? probably not 208 // this instance is no longer the MASTER? probably not
209 return; 209 return;
...@@ -216,7 +216,7 @@ public class DeviceManager ...@@ -216,7 +216,7 @@ public class DeviceManager
216 return; 216 return;
217 } 217 }
218 // tell clock provider if this instance is the master 218 // tell clock provider if this instance is the master
219 - clockProviderService.setDeviceMastershipTerm(deviceId, term); 219 + clockProviderService.setMastershipTerm(deviceId, term);
220 220
221 DeviceEvent event = store.createOrUpdateDevice(provider().id(), 221 DeviceEvent event = store.createOrUpdateDevice(provider().id(),
222 deviceId, deviceDescription); 222 deviceId, deviceDescription);
...@@ -255,7 +255,7 @@ public class DeviceManager ...@@ -255,7 +255,7 @@ public class DeviceManager
255 // but if I was the last STANDBY connection, etc. and no one else 255 // but if I was the last STANDBY connection, etc. and no one else
256 // was there to mark the device offline, this instance may need to 256 // was there to mark the device offline, this instance may need to
257 // temporarily request for Master Role and mark offline. 257 // temporarily request for Master Role and mark offline.
258 - if (!mastershipService.getLocalRole(deviceId).equals(DeviceMastershipRole.MASTER)) { 258 + if (!mastershipService.getLocalRole(deviceId).equals(MastershipRole.MASTER)) {
259 log.debug("Device {} disconnected, but I am not the master", deviceId); 259 log.debug("Device {} disconnected, but I am not the master", deviceId);
260 //let go of any role anyways 260 //let go of any role anyways
261 mastershipService.relinquishMastership(deviceId); 261 mastershipService.relinquishMastership(deviceId);
...@@ -302,11 +302,11 @@ public class DeviceManager ...@@ -302,11 +302,11 @@ public class DeviceManager
302 } 302 }
303 303
304 @Override 304 @Override
305 - public void unableToAssertRole(DeviceId deviceId, DeviceMastershipRole role) { 305 + public void unableToAssertRole(DeviceId deviceId, MastershipRole role) {
306 // FIXME: implement response to this notification 306 // FIXME: implement response to this notification
307 log.warn("Failed to assert role [{}] onto Device {}", role, 307 log.warn("Failed to assert role [{}] onto Device {}", role,
308 deviceId); 308 deviceId);
309 - if (role == DeviceMastershipRole.MASTER) { 309 + if (role == MastershipRole.MASTER) {
310 mastershipService.relinquishMastership(deviceId); 310 mastershipService.relinquishMastership(deviceId);
311 } 311 }
312 } 312 }
...@@ -333,16 +333,16 @@ public class DeviceManager ...@@ -333,16 +333,16 @@ public class DeviceManager
333 333
334 if (term.master().equals(myNodeId)) { 334 if (term.master().equals(myNodeId)) {
335 // only set the new term if I am the master 335 // only set the new term if I am the master
336 - clockProviderService.setDeviceMastershipTerm(did, term); 336 + clockProviderService.setMastershipTerm(did, term);
337 } 337 }
338 - applyRole(did, DeviceMastershipRole.MASTER); 338 + applyRole(did, MastershipRole.MASTER);
339 } else { 339 } else {
340 - applyRole(did, DeviceMastershipRole.STANDBY); 340 + applyRole(did, MastershipRole.STANDBY);
341 } 341 }
342 } else { 342 } else {
343 //device dead to node, give up 343 //device dead to node, give up
344 mastershipService.relinquishMastership(did); 344 mastershipService.relinquishMastership(did);
345 - applyRole(did, DeviceMastershipRole.STANDBY); 345 + applyRole(did, MastershipRole.STANDBY);
346 } 346 }
347 } 347 }
348 } 348 }
......
...@@ -20,7 +20,7 @@ import org.onlab.packet.IpPrefix; ...@@ -20,7 +20,7 @@ import org.onlab.packet.IpPrefix;
20 20
21 import static org.junit.Assert.assertEquals; 21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertNull; 22 import static org.junit.Assert.assertNull;
23 -import static org.onlab.onos.net.device.DeviceMastershipRole.*; 23 +import static org.onlab.onos.net.MastershipRole.*;
24 24
25 /** 25 /**
26 * Test codifying the mastership service contracts. 26 * Test codifying the mastership service contracts.
......
...@@ -17,16 +17,15 @@ import org.onlab.onos.event.Event; ...@@ -17,16 +17,15 @@ import org.onlab.onos.event.Event;
17 import org.onlab.onos.event.impl.TestEventDispatcher; 17 import org.onlab.onos.event.impl.TestEventDispatcher;
18 import org.onlab.onos.net.Device; 18 import org.onlab.onos.net.Device;
19 import org.onlab.onos.net.DeviceId; 19 import org.onlab.onos.net.DeviceId;
20 +import org.onlab.onos.net.MastershipRole;
20 import org.onlab.onos.net.Port; 21 import org.onlab.onos.net.Port;
21 import org.onlab.onos.net.PortNumber; 22 import org.onlab.onos.net.PortNumber;
22 import org.onlab.onos.net.device.DefaultDeviceDescription; 23 import org.onlab.onos.net.device.DefaultDeviceDescription;
23 import org.onlab.onos.net.device.DefaultPortDescription; 24 import org.onlab.onos.net.device.DefaultPortDescription;
24 import org.onlab.onos.net.device.DeviceAdminService; 25 import org.onlab.onos.net.device.DeviceAdminService;
25 -import org.onlab.onos.net.device.DeviceClockProviderService;
26 import org.onlab.onos.net.device.DeviceDescription; 26 import org.onlab.onos.net.device.DeviceDescription;
27 import org.onlab.onos.net.device.DeviceEvent; 27 import org.onlab.onos.net.device.DeviceEvent;
28 import org.onlab.onos.net.device.DeviceListener; 28 import org.onlab.onos.net.device.DeviceListener;
29 -import org.onlab.onos.net.device.DeviceMastershipRole;
30 import org.onlab.onos.net.device.DeviceProvider; 29 import org.onlab.onos.net.device.DeviceProvider;
31 import org.onlab.onos.net.device.DeviceProviderRegistry; 30 import org.onlab.onos.net.device.DeviceProviderRegistry;
32 import org.onlab.onos.net.device.DeviceProviderService; 31 import org.onlab.onos.net.device.DeviceProviderService;
...@@ -36,6 +35,7 @@ import org.onlab.onos.net.device.DeviceMastershipTermService; ...@@ -36,6 +35,7 @@ import org.onlab.onos.net.device.DeviceMastershipTermService;
36 import org.onlab.onos.net.device.PortDescription; 35 import org.onlab.onos.net.device.PortDescription;
37 import org.onlab.onos.net.provider.AbstractProvider; 36 import org.onlab.onos.net.provider.AbstractProvider;
38 import org.onlab.onos.net.provider.ProviderId; 37 import org.onlab.onos.net.provider.ProviderId;
38 +import org.onlab.onos.store.ClockProviderService;
39 import org.onlab.onos.store.trivial.impl.SimpleDeviceStore; 39 import org.onlab.onos.store.trivial.impl.SimpleDeviceStore;
40 import org.onlab.packet.IpPrefix; 40 import org.onlab.packet.IpPrefix;
41 41
...@@ -161,7 +161,7 @@ public class DeviceManagerTest { ...@@ -161,7 +161,7 @@ public class DeviceManagerTest {
161 @Test 161 @Test
162 public void getRole() { 162 public void getRole() {
163 connectDevice(DID1, SW1); 163 connectDevice(DID1, SW1);
164 - assertEquals("incorrect role", DeviceMastershipRole.MASTER, service.getRole(DID1)); 164 + assertEquals("incorrect role", MastershipRole.MASTER, service.getRole(DID1));
165 } 165 }
166 166
167 @Ignore("disabled until we settle the device-mastership wiring") 167 @Ignore("disabled until we settle the device-mastership wiring")
...@@ -169,9 +169,9 @@ public class DeviceManagerTest { ...@@ -169,9 +169,9 @@ public class DeviceManagerTest {
169 public void setRole() throws InterruptedException { 169 public void setRole() throws InterruptedException {
170 connectDevice(DID1, SW1); 170 connectDevice(DID1, SW1);
171 validateEvents(DEVICE_ADDED, DEVICE_MASTERSHIP_CHANGED); 171 validateEvents(DEVICE_ADDED, DEVICE_MASTERSHIP_CHANGED);
172 - assertEquals("incorrect role", DeviceMastershipRole.STANDBY, service.getRole(DID1)); 172 + assertEquals("incorrect role", MastershipRole.STANDBY, service.getRole(DID1));
173 assertEquals("incorrect device", DID1, provider.deviceReceived.id()); 173 assertEquals("incorrect device", DID1, provider.deviceReceived.id());
174 - assertEquals("incorrect role", DeviceMastershipRole.STANDBY, provider.roleReceived); 174 + assertEquals("incorrect role", MastershipRole.STANDBY, provider.roleReceived);
175 } 175 }
176 176
177 @Test 177 @Test
...@@ -246,7 +246,7 @@ public class DeviceManagerTest { ...@@ -246,7 +246,7 @@ public class DeviceManagerTest {
246 246
247 private class TestProvider extends AbstractProvider implements DeviceProvider { 247 private class TestProvider extends AbstractProvider implements DeviceProvider {
248 private Device deviceReceived; 248 private Device deviceReceived;
249 - private DeviceMastershipRole roleReceived; 249 + private MastershipRole roleReceived;
250 250
251 public TestProvider() { 251 public TestProvider() {
252 super(PID); 252 super(PID);
...@@ -257,7 +257,7 @@ public class DeviceManagerTest { ...@@ -257,7 +257,7 @@ public class DeviceManagerTest {
257 } 257 }
258 258
259 @Override 259 @Override
260 - public void roleChanged(Device device, DeviceMastershipRole newRole) { 260 + public void roleChanged(Device device, MastershipRole newRole) {
261 deviceReceived = device; 261 deviceReceived = device;
262 roleReceived = newRole; 262 roleReceived = newRole;
263 } 263 }
...@@ -275,8 +275,8 @@ public class DeviceManagerTest { ...@@ -275,8 +275,8 @@ public class DeviceManagerTest {
275 private static class TestMastershipService 275 private static class TestMastershipService
276 extends MastershipServiceAdapter { 276 extends MastershipServiceAdapter {
277 @Override 277 @Override
278 - public DeviceMastershipRole getLocalRole(DeviceId deviceId) { 278 + public MastershipRole getLocalRole(DeviceId deviceId) {
279 - return DeviceMastershipRole.MASTER; 279 + return MastershipRole.MASTER;
280 } 280 }
281 281
282 @Override 282 @Override
...@@ -285,8 +285,8 @@ public class DeviceManagerTest { ...@@ -285,8 +285,8 @@ public class DeviceManagerTest {
285 } 285 }
286 286
287 @Override 287 @Override
288 - public DeviceMastershipRole requestRoleFor(DeviceId deviceId) { 288 + public MastershipRole requestRoleFor(DeviceId deviceId) {
289 - return DeviceMastershipRole.MASTER; 289 + return MastershipRole.MASTER;
290 } 290 }
291 291
292 @Override 292 @Override
...@@ -336,10 +336,10 @@ public class DeviceManagerTest { ...@@ -336,10 +336,10 @@ public class DeviceManagerTest {
336 } 336 }
337 337
338 private final class TestClockProviderService implements 338 private final class TestClockProviderService implements
339 - DeviceClockProviderService { 339 + ClockProviderService {
340 340
341 @Override 341 @Override
342 - public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 342 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
343 // TODO Auto-generated method stub 343 // TODO Auto-generated method stub
344 } 344 }
345 } 345 }
......
...@@ -24,10 +24,10 @@ import org.onlab.onos.net.DefaultDevice; ...@@ -24,10 +24,10 @@ import org.onlab.onos.net.DefaultDevice;
24 import org.onlab.onos.net.Device; 24 import org.onlab.onos.net.Device;
25 import org.onlab.onos.net.Device.Type; 25 import org.onlab.onos.net.Device.Type;
26 import org.onlab.onos.net.DeviceId; 26 import org.onlab.onos.net.DeviceId;
27 +import org.onlab.onos.net.MastershipRole;
27 import org.onlab.onos.net.Port; 28 import org.onlab.onos.net.Port;
28 import org.onlab.onos.net.PortNumber; 29 import org.onlab.onos.net.PortNumber;
29 import org.onlab.onos.net.device.DeviceListener; 30 import org.onlab.onos.net.device.DeviceListener;
30 -import org.onlab.onos.net.device.DeviceMastershipRole;
31 import org.onlab.onos.net.device.DeviceService; 31 import org.onlab.onos.net.device.DeviceService;
32 import org.onlab.onos.net.flow.CompletedBatchOperation; 32 import org.onlab.onos.net.flow.CompletedBatchOperation;
33 import org.onlab.onos.net.flow.DefaultFlowEntry; 33 import org.onlab.onos.net.flow.DefaultFlowEntry;
...@@ -364,7 +364,7 @@ public class FlowRuleManagerTest { ...@@ -364,7 +364,7 @@ public class FlowRuleManagerTest {
364 } 364 }
365 365
366 @Override 366 @Override
367 - public DeviceMastershipRole getRole(DeviceId deviceId) { 367 + public MastershipRole getRole(DeviceId deviceId) {
368 return null; 368 return null;
369 } 369 }
370 370
......
...@@ -19,10 +19,10 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -19,10 +19,10 @@ import org.onlab.onos.net.ConnectPoint;
19 import org.onlab.onos.net.Device; 19 import org.onlab.onos.net.Device;
20 import org.onlab.onos.net.DeviceId; 20 import org.onlab.onos.net.DeviceId;
21 import org.onlab.onos.net.Host; 21 import org.onlab.onos.net.Host;
22 +import org.onlab.onos.net.MastershipRole;
22 import org.onlab.onos.net.Port; 23 import org.onlab.onos.net.Port;
23 import org.onlab.onos.net.PortNumber; 24 import org.onlab.onos.net.PortNumber;
24 import org.onlab.onos.net.device.DeviceListener; 25 import org.onlab.onos.net.device.DeviceListener;
25 -import org.onlab.onos.net.device.DeviceMastershipRole;
26 import org.onlab.onos.net.device.DeviceService; 26 import org.onlab.onos.net.device.DeviceService;
27 import org.onlab.onos.net.flow.instructions.Instruction; 27 import org.onlab.onos.net.flow.instructions.Instruction;
28 import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction; 28 import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction;
...@@ -189,7 +189,7 @@ public class HostMonitorTest { ...@@ -189,7 +189,7 @@ public class HostMonitorTest {
189 } 189 }
190 190
191 @Override 191 @Override
192 - public DeviceMastershipRole getRole(DeviceId deviceId) { 192 + public MastershipRole getRole(DeviceId deviceId) {
193 return null; 193 return null;
194 } 194 }
195 195
......
1 package org.onlab.onos.net.link.impl; 1 package org.onlab.onos.net.link.impl;
2 2
3 import com.google.common.collect.ImmutableSet; 3 import com.google.common.collect.ImmutableSet;
4 -
5 import org.junit.After; 4 import org.junit.After;
6 import org.junit.Before; 5 import org.junit.Before;
7 import org.junit.Test; 6 import org.junit.Test;
...@@ -10,6 +9,7 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -10,6 +9,7 @@ import org.onlab.onos.net.ConnectPoint;
10 import org.onlab.onos.net.Device; 9 import org.onlab.onos.net.Device;
11 import org.onlab.onos.net.DeviceId; 10 import org.onlab.onos.net.DeviceId;
12 import org.onlab.onos.net.Link; 11 import org.onlab.onos.net.Link;
12 +import org.onlab.onos.net.MastershipRole;
13 import org.onlab.onos.net.PortNumber; 13 import org.onlab.onos.net.PortNumber;
14 import org.onlab.onos.net.link.DefaultLinkDescription; 14 import org.onlab.onos.net.link.DefaultLinkDescription;
15 import org.onlab.onos.net.link.LinkAdminService; 15 import org.onlab.onos.net.link.LinkAdminService;
...@@ -22,7 +22,6 @@ import org.onlab.onos.net.link.LinkService; ...@@ -22,7 +22,6 @@ import org.onlab.onos.net.link.LinkService;
22 import org.onlab.onos.net.provider.AbstractProvider; 22 import org.onlab.onos.net.provider.AbstractProvider;
23 import org.onlab.onos.net.provider.ProviderId; 23 import org.onlab.onos.net.provider.ProviderId;
24 import org.onlab.onos.event.impl.TestEventDispatcher; 24 import org.onlab.onos.event.impl.TestEventDispatcher;
25 -import org.onlab.onos.net.device.DeviceMastershipRole;
26 import org.onlab.onos.net.device.impl.DeviceManager; 25 import org.onlab.onos.net.device.impl.DeviceManager;
27 import org.onlab.onos.store.trivial.impl.SimpleLinkStore; 26 import org.onlab.onos.store.trivial.impl.SimpleLinkStore;
28 27
...@@ -244,7 +243,7 @@ public class LinkManagerTest { ...@@ -244,7 +243,7 @@ public class LinkManagerTest {
244 243
245 private class TestProvider extends AbstractProvider implements LinkProvider { 244 private class TestProvider extends AbstractProvider implements LinkProvider {
246 private Device deviceReceived; 245 private Device deviceReceived;
247 - private DeviceMastershipRole roleReceived; 246 + private MastershipRole roleReceived;
248 247
249 public TestProvider() { 248 public TestProvider() {
250 super(PID); 249 super(PID);
......
...@@ -6,5 +6,5 @@ public final class ClusterManagementMessageSubjects { ...@@ -6,5 +6,5 @@ public final class ClusterManagementMessageSubjects {
6 // avoid instantiation 6 // avoid instantiation
7 private ClusterManagementMessageSubjects() {} 7 private ClusterManagementMessageSubjects() {}
8 8
9 - public static final MessageSubject CLUSTER_MEMBERSHIP_EVENT = new MessageSubject("cluster-membership-event"); 9 + public static final MessageSubject CLUSTER_MEMBERSHIP_EVENT = new MessageSubject("CLUSTER_MEMBERSHIP_EVENT");
10 } 10 }
......
1 package org.onlab.onos.store.cluster.impl; 1 package org.onlab.onos.store.cluster.impl;
2 2
3 -import org.onlab.onos.cluster.ControllerNode; 3 +import org.onlab.onos.cluster.DefaultControllerNode;
4 import org.onlab.onos.cluster.NodeId; 4 import org.onlab.onos.cluster.NodeId;
5 import org.onlab.packet.IpPrefix; 5 import org.onlab.packet.IpPrefix;
6 6
...@@ -18,7 +18,7 @@ public interface ClusterNodesDelegate { ...@@ -18,7 +18,7 @@ public interface ClusterNodesDelegate {
18 * @param tcpPort node TCP listen port 18 * @param tcpPort node TCP listen port
19 * @return the controller node 19 * @return the controller node
20 */ 20 */
21 - ControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort); 21 + DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort);
22 22
23 /** 23 /**
24 * Notifies about cluster node going offline. 24 * Notifies about cluster node going offline.
......
1 package org.onlab.onos.store.cluster.impl; 1 package org.onlab.onos.store.cluster.impl;
2 2
3 +import com.google.common.cache.Cache;
4 +import com.google.common.cache.CacheBuilder;
5 +import com.google.common.cache.RemovalListener;
6 +import com.google.common.cache.RemovalNotification;
3 import com.google.common.collect.ImmutableSet; 7 import com.google.common.collect.ImmutableSet;
4 8
5 import org.apache.felix.scr.annotations.Activate; 9 import org.apache.felix.scr.annotations.Activate;
...@@ -14,16 +18,8 @@ import org.onlab.onos.cluster.DefaultControllerNode; ...@@ -14,16 +18,8 @@ import org.onlab.onos.cluster.DefaultControllerNode;
14 import org.onlab.onos.cluster.NodeId; 18 import org.onlab.onos.cluster.NodeId;
15 import org.onlab.onos.store.AbstractStore; 19 import org.onlab.onos.store.AbstractStore;
16 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService; 20 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService;
17 -import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 21 +import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager;
18 -import org.onlab.onos.store.cluster.messaging.ClusterMessage;
19 -import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
20 -import org.onlab.onos.store.cluster.messaging.MessageSubject;
21 -import org.onlab.onos.store.cluster.messaging.impl.ClusterMessageSerializer;
22 -import org.onlab.onos.store.cluster.messaging.impl.MessageSubjectSerializer;
23 -import org.onlab.onos.store.serializers.KryoPoolUtil;
24 -import org.onlab.onos.store.serializers.KryoSerializer;
25 import org.onlab.packet.IpPrefix; 22 import org.onlab.packet.IpPrefix;
26 -import org.onlab.util.KryoPool;
27 import org.slf4j.Logger; 23 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory; 24 import org.slf4j.LoggerFactory;
29 25
...@@ -31,6 +27,7 @@ import java.io.IOException; ...@@ -31,6 +27,7 @@ import java.io.IOException;
31 import java.util.Map; 27 import java.util.Map;
32 import java.util.Set; 28 import java.util.Set;
33 import java.util.concurrent.ConcurrentHashMap; 29 import java.util.concurrent.ConcurrentHashMap;
30 +import java.util.concurrent.TimeUnit;
34 31
35 import static org.onlab.onos.cluster.ControllerNode.State; 32 import static org.onlab.onos.cluster.ControllerNode.State;
36 import static org.onlab.packet.IpPrefix.valueOf; 33 import static org.onlab.packet.IpPrefix.valueOf;
...@@ -46,33 +43,17 @@ public class DistributedClusterStore ...@@ -46,33 +43,17 @@ public class DistributedClusterStore
46 43
47 private final Logger log = LoggerFactory.getLogger(getClass()); 44 private final Logger log = LoggerFactory.getLogger(getClass());
48 45
49 - private ControllerNode localNode; 46 + private DefaultControllerNode localNode;
50 - private final Map<NodeId, ControllerNode> nodes = new ConcurrentHashMap<>(); 47 + private final Map<NodeId, DefaultControllerNode> nodes = new ConcurrentHashMap<>();
51 private final Map<NodeId, State> states = new ConcurrentHashMap<>(); 48 private final Map<NodeId, State> states = new ConcurrentHashMap<>();
52 - 49 + private final Cache<NodeId, ControllerNode> livenessCache = CacheBuilder.newBuilder()
53 - private static final KryoSerializer SERIALIZER = new KryoSerializer() { 50 + .maximumSize(1000)
54 - @Override 51 + .expireAfterWrite(ClusterCommunicationManager.HEART_BEAT_INTERVAL_MILLIS * 3, TimeUnit.MILLISECONDS)
55 - protected void setupKryoPool() { 52 + .removalListener(new LivenessCacheRemovalListener()).build();
56 - serializerPool = KryoPool.newBuilder()
57 - .register(KryoPoolUtil.API)
58 - .register(ClusterMessage.class, new ClusterMessageSerializer())
59 - .register(ClusterMembershipEvent.class)
60 - .register(byte[].class)
61 - .register(MessageSubject.class, new MessageSubjectSerializer())
62 - .build()
63 - .populate(1);
64 - }
65 - };
66 53
67 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 54 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
68 private ClusterCommunicationAdminService clusterCommunicationAdminService; 55 private ClusterCommunicationAdminService clusterCommunicationAdminService;
69 56
70 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
71 - private ClusterCommunicationService clusterCommunicator;
72 -
73 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
74 - private ClusterMonitorService clusterMonitor;
75 -
76 private final ClusterNodesDelegate nodesDelegate = new InnerNodesDelegate(); 57 private final ClusterNodesDelegate nodesDelegate = new InnerNodesDelegate();
77 58
78 @Activate 59 @Activate
...@@ -80,15 +61,10 @@ public class DistributedClusterStore ...@@ -80,15 +61,10 @@ public class DistributedClusterStore
80 loadClusterDefinition(); 61 loadClusterDefinition();
81 establishSelfIdentity(); 62 establishSelfIdentity();
82 63
83 - clusterCommunicator.addSubscriber( 64 + // Start-up the comm service and prime it with the loaded nodes.
84 - ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT, 65 + clusterCommunicationAdminService.initialize(localNode, nodesDelegate);
85 - new ClusterMembershipEventListener()); 66 + for (DefaultControllerNode node : nodes.values()) {
86 - 67 + clusterCommunicationAdminService.addNode(node);
87 - // Start-up the monitor service and prime it with the loaded nodes.
88 - clusterMonitor.initialize(localNode, nodesDelegate);
89 -
90 - for (ControllerNode node : nodes.values()) {
91 - clusterMonitor.addNode(node);
92 } 68 }
93 log.info("Started"); 69 log.info("Started");
94 } 70 }
...@@ -154,78 +130,22 @@ public class DistributedClusterStore ...@@ -154,78 +130,22 @@ public class DistributedClusterStore
154 @Override 130 @Override
155 public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) { 131 public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) {
156 DefaultControllerNode node = new DefaultControllerNode(nodeId, ip, tcpPort); 132 DefaultControllerNode node = new DefaultControllerNode(nodeId, ip, tcpPort);
157 - addNodeInternal(node); 133 + nodes.put(nodeId, node);
158 - 134 + clusterCommunicationAdminService.addNode(node);
159 - try {
160 - clusterCommunicator.broadcast(
161 - new ClusterMessage(
162 - localNode.id(),
163 - ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT,
164 - SERIALIZER.encode(
165 - new ClusterMembershipEvent(
166 - ClusterMembershipEventType.NEW_MEMBER,
167 - node))));
168 - } catch (IOException e) {
169 - // TODO: In a setup where cluster membership is not static (i.e. not everything has the same picture)
170 - // we'll need a more consistent/dependable way to replicate membership events.
171 - log.error("Failed to notify peers of a new cluster member", e);
172 - }
173 -
174 return node; 135 return node;
175 } 136 }
176 137
177 - private void addNodeInternal(ControllerNode node) {
178 - nodes.put(node.id(), node);
179 - }
180 -
181 @Override 138 @Override
182 public void removeNode(NodeId nodeId) { 139 public void removeNode(NodeId nodeId) {
183 - ControllerNode node = removeNodeInternal(nodeId);
184 -
185 - if (node != null) {
186 - try {
187 - clusterCommunicator.broadcast(
188 - new ClusterMessage(
189 - localNode.id(),
190 - ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT,
191 - SERIALIZER.encode(
192 - new ClusterMembershipEvent(
193 - ClusterMembershipEventType.LEAVING_MEMBER,
194 - node))));
195 - } catch (IOException e) {
196 - // TODO: In a setup where cluster membership is not static (i.e. not everything has the same picture)
197 - // we'll need a more consistent/dependable way to replicate membership events.
198 - log.error("Failed to notify peers of a existing cluster member leaving.", e);
199 - }
200 - }
201 -
202 - }
203 -
204 - private ControllerNode removeNodeInternal(NodeId nodeId) {
205 if (nodeId.equals(localNode.id())) { 140 if (nodeId.equals(localNode.id())) {
206 nodes.clear(); 141 nodes.clear();
207 nodes.put(localNode.id(), localNode); 142 nodes.put(localNode.id(), localNode);
208 - return localNode;
209 -
210 - }
211 - // Remove the other node.
212 - ControllerNode node = nodes.remove(nodeId);
213 - return node;
214 - }
215 143
216 - private class ClusterMembershipEventListener implements ClusterMessageHandler { 144 + } else {
217 - @Override 145 + // Remove the other node.
218 - public void handle(ClusterMessage message) { 146 + DefaultControllerNode node = nodes.remove(nodeId);
219 - 147 + if (node != null) {
220 - log.info("Received cluster membership event from peer: {}", message.sender()); 148 + clusterCommunicationAdminService.removeNode(node);
221 - ClusterMembershipEvent event = (ClusterMembershipEvent) SERIALIZER.decode(message.payload());
222 - if (event.type() == ClusterMembershipEventType.NEW_MEMBER) {
223 - log.info("Node {} is added", event.node().id());
224 - addNodeInternal(event.node());
225 - }
226 - if (event.type() == ClusterMembershipEventType.LEAVING_MEMBER) {
227 - log.info("Node {} is removed ", event.node().id());
228 - removeNodeInternal(event.node().id());
229 } 149 }
230 } 150 }
231 } 151 }
...@@ -233,12 +153,13 @@ public class DistributedClusterStore ...@@ -233,12 +153,13 @@ public class DistributedClusterStore
233 // Entity to handle back calls from the connection manager. 153 // Entity to handle back calls from the connection manager.
234 private class InnerNodesDelegate implements ClusterNodesDelegate { 154 private class InnerNodesDelegate implements ClusterNodesDelegate {
235 @Override 155 @Override
236 - public ControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) { 156 + public DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
237 - ControllerNode node = nodes.get(nodeId); 157 + DefaultControllerNode node = nodes.get(nodeId);
238 if (node == null) { 158 if (node == null) {
239 node = (DefaultControllerNode) addNode(nodeId, ip, tcpPort); 159 node = (DefaultControllerNode) addNode(nodeId, ip, tcpPort);
240 } 160 }
241 states.put(nodeId, State.ACTIVE); 161 states.put(nodeId, State.ACTIVE);
162 + livenessCache.put(nodeId, node);
242 return node; 163 return node;
243 } 164 }
244 165
...@@ -252,4 +173,14 @@ public class DistributedClusterStore ...@@ -252,4 +173,14 @@ public class DistributedClusterStore
252 removeNode(nodeId); 173 removeNode(nodeId);
253 } 174 }
254 } 175 }
176 +
177 + private class LivenessCacheRemovalListener implements RemovalListener<NodeId, ControllerNode> {
178 +
179 + @Override
180 + public void onRemoval(RemovalNotification<NodeId, ControllerNode> entry) {
181 + NodeId nodeId = entry.getKey();
182 + log.warn("Failed to receive heartbeats from controller: " + nodeId);
183 + nodesDelegate.nodeVanished(nodeId);
184 + }
185 + }
255 } 186 }
......
...@@ -4,6 +4,8 @@ import static com.google.common.base.Preconditions.checkArgument; ...@@ -4,6 +4,8 @@ import static com.google.common.base.Preconditions.checkArgument;
4 4
5 import java.io.IOException; 5 import java.io.IOException;
6 import java.util.Set; 6 import java.util.Set;
7 +import java.util.Timer;
8 +import java.util.TimerTask;
7 9
8 import org.apache.felix.scr.annotations.Activate; 10 import org.apache.felix.scr.annotations.Activate;
9 import org.apache.felix.scr.annotations.Component; 11 import org.apache.felix.scr.annotations.Component;
...@@ -14,6 +16,10 @@ import org.apache.felix.scr.annotations.Service; ...@@ -14,6 +16,10 @@ import org.apache.felix.scr.annotations.Service;
14 import org.onlab.onos.cluster.ClusterService; 16 import org.onlab.onos.cluster.ClusterService;
15 import org.onlab.onos.cluster.ControllerNode; 17 import org.onlab.onos.cluster.ControllerNode;
16 import org.onlab.onos.cluster.NodeId; 18 import org.onlab.onos.cluster.NodeId;
19 +import org.onlab.onos.store.cluster.impl.ClusterMembershipEvent;
20 +import org.onlab.onos.store.cluster.impl.ClusterMembershipEventType;
21 +import org.onlab.onos.store.cluster.impl.ClusterNodesDelegate;
22 +import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService;
17 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 23 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
18 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 24 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
19 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 25 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
...@@ -32,7 +38,7 @@ import org.slf4j.LoggerFactory; ...@@ -32,7 +38,7 @@ import org.slf4j.LoggerFactory;
32 @Component(immediate = true) 38 @Component(immediate = true)
33 @Service 39 @Service
34 public class ClusterCommunicationManager 40 public class ClusterCommunicationManager
35 - implements ClusterCommunicationService { 41 + implements ClusterCommunicationService, ClusterCommunicationAdminService {
36 42
37 private final Logger log = LoggerFactory.getLogger(getClass()); 43 private final Logger log = LoggerFactory.getLogger(getClass());
38 44
...@@ -41,6 +47,10 @@ public class ClusterCommunicationManager ...@@ -41,6 +47,10 @@ public class ClusterCommunicationManager
41 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
42 private ClusterService clusterService; 48 private ClusterService clusterService;
43 49
50 + private ClusterNodesDelegate nodesDelegate;
51 + private final Timer timer = new Timer("onos-controller-heatbeats");
52 + public static final long HEART_BEAT_INTERVAL_MILLIS = 1000L;
53 +
44 // TODO: This probably should not be a OSGi service. 54 // TODO: This probably should not be a OSGi service.
45 private MessagingService messagingService; 55 private MessagingService messagingService;
46 56
...@@ -50,6 +60,7 @@ public class ClusterCommunicationManager ...@@ -50,6 +60,7 @@ public class ClusterCommunicationManager
50 serializerPool = KryoPool.newBuilder() 60 serializerPool = KryoPool.newBuilder()
51 .register(KryoPoolUtil.API) 61 .register(KryoPoolUtil.API)
52 .register(ClusterMessage.class, new ClusterMessageSerializer()) 62 .register(ClusterMessage.class, new ClusterMessageSerializer())
63 + .register(ClusterMembershipEvent.class)
53 .register(byte[].class) 64 .register(byte[].class)
54 .register(MessageSubject.class, new MessageSubjectSerializer()) 65 .register(MessageSubject.class, new MessageSubjectSerializer())
55 .build() 66 .build()
...@@ -123,6 +134,61 @@ public class ClusterCommunicationManager ...@@ -123,6 +134,61 @@ public class ClusterCommunicationManager
123 messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber)); 134 messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber));
124 } 135 }
125 136
137 + @Override
138 + public void initialize(ControllerNode localNode,
139 + ClusterNodesDelegate delegate) {
140 + this.localNode = localNode;
141 + this.nodesDelegate = delegate;
142 + this.addSubscriber(new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"), new ClusterMemebershipEventHandler());
143 + timer.schedule(new KeepAlive(), 0, HEART_BEAT_INTERVAL_MILLIS);
144 + }
145 +
146 + @Override
147 + public void addNode(ControllerNode node) {
148 + //members.put(node.id(), node);
149 + }
150 +
151 + @Override
152 + public void removeNode(ControllerNode node) {
153 + broadcast(new ClusterMessage(
154 + localNode.id(),
155 + new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"),
156 + SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.LEAVING_MEMBER, node))));
157 + //members.remove(node.id());
158 + }
159 +
160 + // Sends a heart beat to all peers.
161 + private class KeepAlive extends TimerTask {
162 +
163 + @Override
164 + public void run() {
165 + broadcast(new ClusterMessage(
166 + localNode.id(),
167 + new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"),
168 + SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.HEART_BEAT, localNode))));
169 + }
170 + }
171 +
172 + private class ClusterMemebershipEventHandler implements ClusterMessageHandler {
173 +
174 + @Override
175 + public void handle(ClusterMessage message) {
176 +
177 + ClusterMembershipEvent event = SERIALIZER.decode(message.payload());
178 + ControllerNode node = event.node();
179 + if (event.type() == ClusterMembershipEventType.HEART_BEAT) {
180 + log.info("Node {} sent a hearbeat", node.id());
181 + nodesDelegate.nodeDetected(node.id(), node.ip(), node.tcpPort());
182 + } else if (event.type() == ClusterMembershipEventType.LEAVING_MEMBER) {
183 + log.info("Node {} is leaving", node.id());
184 + nodesDelegate.nodeRemoved(node.id());
185 + } else if (event.type() == ClusterMembershipEventType.UNREACHABLE_MEMBER) {
186 + log.info("Node {} is unreachable", node.id());
187 + nodesDelegate.nodeVanished(node.id());
188 + }
189 + }
190 + }
191 +
126 private final class InternalClusterMessageHandler implements MessageHandler { 192 private final class InternalClusterMessageHandler implements MessageHandler {
127 193
128 private final ClusterMessageHandler handler; 194 private final ClusterMessageHandler handler;
...@@ -142,4 +208,4 @@ public class ClusterCommunicationManager ...@@ -142,4 +208,4 @@ public class ClusterCommunicationManager
142 } 208 }
143 } 209 }
144 } 210 }
145 -}
...\ No newline at end of file ...\ No newline at end of file
211 +}
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.store.common.impl; ...@@ -3,7 +3,7 @@ package org.onlab.onos.store.common.impl;
3 import java.util.Map; 3 import java.util.Map;
4 4
5 import org.onlab.onos.cluster.NodeId; 5 import org.onlab.onos.cluster.NodeId;
6 -import org.onlab.onos.net.device.Timestamp; 6 +import org.onlab.onos.store.Timestamp;
7 7
8 import com.google.common.collect.ImmutableMap; 8 import com.google.common.collect.ImmutableMap;
9 9
......
...@@ -4,7 +4,7 @@ import java.util.Map; ...@@ -4,7 +4,7 @@ import java.util.Map;
4 import java.util.Set; 4 import java.util.Set;
5 5
6 import org.onlab.onos.cluster.NodeId; 6 import org.onlab.onos.cluster.NodeId;
7 -import org.onlab.onos.net.device.VersionedValue; 7 +import org.onlab.onos.store.VersionedValue;
8 8
9 import com.google.common.collect.ImmutableMap; 9 import com.google.common.collect.ImmutableMap;
10 import com.google.common.collect.ImmutableSet; 10 import com.google.common.collect.ImmutableSet;
......
...@@ -4,7 +4,7 @@ import static com.google.common.base.Preconditions.checkArgument; ...@@ -4,7 +4,7 @@ import static com.google.common.base.Preconditions.checkArgument;
4 4
5 import java.util.Objects; 5 import java.util.Objects;
6 6
7 -import org.onlab.onos.net.device.Timestamp; 7 +import org.onlab.onos.store.Timestamp;
8 8
9 import com.google.common.base.MoreObjects; 9 import com.google.common.base.MoreObjects;
10 import com.google.common.collect.ComparisonChain; 10 import com.google.common.collect.ComparisonChain;
......
...@@ -7,8 +7,8 @@ import java.util.Map; ...@@ -7,8 +7,8 @@ import java.util.Map;
7 import org.onlab.onos.cluster.NodeId; 7 import org.onlab.onos.cluster.NodeId;
8 import org.onlab.onos.net.Device; 8 import org.onlab.onos.net.Device;
9 import org.onlab.onos.net.DeviceId; 9 import org.onlab.onos.net.DeviceId;
10 -import org.onlab.onos.net.device.Timestamp; 10 +import org.onlab.onos.store.Timestamp;
11 -import org.onlab.onos.net.device.VersionedValue; 11 +import org.onlab.onos.store.VersionedValue;
12 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement; 12 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement;
13 13
14 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID) 14 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID)
......
...@@ -9,8 +9,8 @@ import java.util.Set; ...@@ -9,8 +9,8 @@ import java.util.Set;
9 import org.onlab.onos.cluster.NodeId; 9 import org.onlab.onos.cluster.NodeId;
10 import org.onlab.onos.net.Device; 10 import org.onlab.onos.net.Device;
11 import org.onlab.onos.net.DeviceId; 11 import org.onlab.onos.net.DeviceId;
12 -import org.onlab.onos.net.device.Timestamp; 12 +import org.onlab.onos.store.Timestamp;
13 -import org.onlab.onos.net.device.VersionedValue; 13 +import org.onlab.onos.store.VersionedValue;
14 import org.onlab.onos.store.common.impl.AntiEntropyReply; 14 import org.onlab.onos.store.common.impl.AntiEntropyReply;
15 15
16 import com.google.common.collect.ImmutableMap; 16 import com.google.common.collect.ImmutableMap;
......
...@@ -11,10 +11,10 @@ import org.apache.felix.scr.annotations.Component; ...@@ -11,10 +11,10 @@ import org.apache.felix.scr.annotations.Component;
11 import org.apache.felix.scr.annotations.Deactivate; 11 import org.apache.felix.scr.annotations.Deactivate;
12 import org.apache.felix.scr.annotations.Service; 12 import org.apache.felix.scr.annotations.Service;
13 import org.onlab.onos.net.DeviceId; 13 import org.onlab.onos.net.DeviceId;
14 -import org.onlab.onos.net.device.DeviceClockProviderService;
15 -import org.onlab.onos.net.device.DeviceClockService;
16 import org.onlab.onos.net.device.DeviceMastershipTerm; 14 import org.onlab.onos.net.device.DeviceMastershipTerm;
17 -import org.onlab.onos.net.device.Timestamp; 15 +import org.onlab.onos.store.ClockProviderService;
16 +import org.onlab.onos.store.ClockService;
17 +import org.onlab.onos.store.Timestamp;
18 import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp; 18 import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp;
19 import org.slf4j.Logger; 19 import org.slf4j.Logger;
20 20
...@@ -23,7 +23,7 @@ import org.slf4j.Logger; ...@@ -23,7 +23,7 @@ import org.slf4j.Logger;
23 */ 23 */
24 @Component(immediate = true) 24 @Component(immediate = true)
25 @Service 25 @Service
26 -public class DeviceClockManager implements DeviceClockService, DeviceClockProviderService { 26 +public class DeviceClockManager implements ClockService, ClockProviderService {
27 27
28 private final Logger log = getLogger(getClass()); 28 private final Logger log = getLogger(getClass());
29 29
...@@ -51,7 +51,7 @@ public class DeviceClockManager implements DeviceClockService, DeviceClockProvid ...@@ -51,7 +51,7 @@ public class DeviceClockManager implements DeviceClockService, DeviceClockProvid
51 } 51 }
52 52
53 @Override 53 @Override
54 - public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 54 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
55 deviceMastershipTerms.put(deviceId, term); 55 deviceMastershipTerms.put(deviceId, term);
56 } 56 }
57 } 57 }
......
...@@ -26,16 +26,16 @@ import org.onlab.onos.net.PortNumber; ...@@ -26,16 +26,16 @@ import org.onlab.onos.net.PortNumber;
26 import org.onlab.onos.net.SparseAnnotations; 26 import org.onlab.onos.net.SparseAnnotations;
27 import org.onlab.onos.net.device.DefaultDeviceDescription; 27 import org.onlab.onos.net.device.DefaultDeviceDescription;
28 import org.onlab.onos.net.device.DefaultPortDescription; 28 import org.onlab.onos.net.device.DefaultPortDescription;
29 -import org.onlab.onos.net.device.DeviceClockService;
30 import org.onlab.onos.net.device.DeviceDescription; 29 import org.onlab.onos.net.device.DeviceDescription;
31 import org.onlab.onos.net.device.DeviceEvent; 30 import org.onlab.onos.net.device.DeviceEvent;
32 import org.onlab.onos.net.device.DeviceStore; 31 import org.onlab.onos.net.device.DeviceStore;
33 import org.onlab.onos.net.device.DeviceStoreDelegate; 32 import org.onlab.onos.net.device.DeviceStoreDelegate;
34 import org.onlab.onos.net.device.PortDescription; 33 import org.onlab.onos.net.device.PortDescription;
35 -import org.onlab.onos.net.device.Timestamp;
36 -import org.onlab.onos.net.device.Timestamped;
37 import org.onlab.onos.net.provider.ProviderId; 34 import org.onlab.onos.net.provider.ProviderId;
38 import org.onlab.onos.store.AbstractStore; 35 import org.onlab.onos.store.AbstractStore;
36 +import org.onlab.onos.store.ClockService;
37 +import org.onlab.onos.store.Timestamp;
38 +import org.onlab.onos.store.Timestamped;
39 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 39 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
40 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 40 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
41 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 41 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
...@@ -105,7 +105,7 @@ public class GossipDeviceStore ...@@ -105,7 +105,7 @@ public class GossipDeviceStore
105 private final Set<DeviceId> availableDevices = Sets.newConcurrentHashSet(); 105 private final Set<DeviceId> availableDevices = Sets.newConcurrentHashSet();
106 106
107 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 107 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
108 - protected DeviceClockService clockService; 108 + protected ClockService clockService;
109 109
110 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 110 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
111 protected ClusterCommunicationService clusterCommunicator; 111 protected ClusterCommunicationService clusterCommunicator;
......
...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl; ...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.device.DeviceDescription; 4 import org.onlab.onos.net.device.DeviceDescription;
5 -import org.onlab.onos.net.device.Timestamped;
6 import org.onlab.onos.net.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 +import org.onlab.onos.store.Timestamped;
7 7
8 /** 8 /**
9 * Information published by GossipDeviceStore to notify peers of a device 9 * Information published by GossipDeviceStore to notify peers of a device
......
...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl; ...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.device.DeviceDescription; 4 import org.onlab.onos.net.device.DeviceDescription;
5 -import org.onlab.onos.net.device.Timestamped;
6 import org.onlab.onos.net.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 +import org.onlab.onos.store.Timestamped;
7 7
8 import com.esotericsoftware.kryo.Kryo; 8 import com.esotericsoftware.kryo.Kryo;
9 import com.esotericsoftware.kryo.Serializer; 9 import com.esotericsoftware.kryo.Serializer;
......
1 package org.onlab.onos.store.device.impl; 1 package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 -import org.onlab.onos.net.device.Timestamp; 4 +import org.onlab.onos.store.Timestamp;
5 5
6 /** 6 /**
7 * Information published by GossipDeviceStore to notify peers of a device 7 * Information published by GossipDeviceStore to notify peers of a device
......
1 package org.onlab.onos.store.device.impl; 1 package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 -import org.onlab.onos.net.device.Timestamp; 4 +import org.onlab.onos.store.Timestamp;
5 5
6 import com.esotericsoftware.kryo.Kryo; 6 import com.esotericsoftware.kryo.Kryo;
7 import com.esotericsoftware.kryo.Serializer; 7 import com.esotericsoftware.kryo.Serializer;
......
1 package org.onlab.onos.store.device.impl; 1 package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 -import org.onlab.onos.net.device.Timestamp; 4 +import org.onlab.onos.store.Timestamp;
5 5
6 /** 6 /**
7 * Information published by GossipDeviceStore to notify peers of a device 7 * Information published by GossipDeviceStore to notify peers of a device
......
...@@ -4,8 +4,8 @@ import java.util.List; ...@@ -4,8 +4,8 @@ import java.util.List;
4 4
5 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.device.PortDescription; 6 import org.onlab.onos.net.device.PortDescription;
7 -import org.onlab.onos.net.device.Timestamped;
8 import org.onlab.onos.net.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 +import org.onlab.onos.store.Timestamped;
9 9
10 /** 10 /**
11 * Information published by GossipDeviceStore to notify peers of a port 11 * Information published by GossipDeviceStore to notify peers of a port
......
...@@ -4,8 +4,8 @@ import java.util.List; ...@@ -4,8 +4,8 @@ import java.util.List;
4 4
5 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.device.PortDescription; 6 import org.onlab.onos.net.device.PortDescription;
7 -import org.onlab.onos.net.device.Timestamped;
8 import org.onlab.onos.net.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 +import org.onlab.onos.store.Timestamped;
9 9
10 import com.esotericsoftware.kryo.Kryo; 10 import com.esotericsoftware.kryo.Kryo;
11 import com.esotericsoftware.kryo.Serializer; 11 import com.esotericsoftware.kryo.Serializer;
......
...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl; ...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.device.PortDescription; 4 import org.onlab.onos.net.device.PortDescription;
5 -import org.onlab.onos.net.device.Timestamped;
6 import org.onlab.onos.net.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 +import org.onlab.onos.store.Timestamped;
7 7
8 /** 8 /**
9 * Information published by GossipDeviceStore to notify peers of a port 9 * Information published by GossipDeviceStore to notify peers of a port
......
...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl; ...@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.device.PortDescription; 4 import org.onlab.onos.net.device.PortDescription;
5 -import org.onlab.onos.net.device.Timestamped;
6 import org.onlab.onos.net.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 +import org.onlab.onos.store.Timestamped;
7 7
8 import com.esotericsoftware.kryo.Kryo; 8 import com.esotericsoftware.kryo.Kryo;
9 import com.esotericsoftware.kryo.Serializer; 9 import com.esotericsoftware.kryo.Serializer;
......
...@@ -23,15 +23,15 @@ import org.onlab.onos.net.DefaultLink; ...@@ -23,15 +23,15 @@ import org.onlab.onos.net.DefaultLink;
23 import org.onlab.onos.net.DeviceId; 23 import org.onlab.onos.net.DeviceId;
24 import org.onlab.onos.net.Link; 24 import org.onlab.onos.net.Link;
25 import org.onlab.onos.net.LinkKey; 25 import org.onlab.onos.net.LinkKey;
26 -import org.onlab.onos.net.device.DeviceClockService;
27 -import org.onlab.onos.net.device.Timestamp;
28 -import org.onlab.onos.net.device.VersionedValue;
29 import org.onlab.onos.net.link.LinkDescription; 26 import org.onlab.onos.net.link.LinkDescription;
30 import org.onlab.onos.net.link.LinkEvent; 27 import org.onlab.onos.net.link.LinkEvent;
31 import org.onlab.onos.net.link.LinkStore; 28 import org.onlab.onos.net.link.LinkStore;
32 import org.onlab.onos.net.link.LinkStoreDelegate; 29 import org.onlab.onos.net.link.LinkStoreDelegate;
33 import org.onlab.onos.net.provider.ProviderId; 30 import org.onlab.onos.net.provider.ProviderId;
34 import org.onlab.onos.store.AbstractStore; 31 import org.onlab.onos.store.AbstractStore;
32 +import org.onlab.onos.store.ClockService;
33 +import org.onlab.onos.store.Timestamp;
34 +import org.onlab.onos.store.VersionedValue;
35 import org.slf4j.Logger; 35 import org.slf4j.Logger;
36 36
37 import com.google.common.collect.HashMultimap; 37 import com.google.common.collect.HashMultimap;
...@@ -71,7 +71,7 @@ public class OnosDistributedLinkStore ...@@ -71,7 +71,7 @@ public class OnosDistributedLinkStore
71 private final Multimap<DeviceId, VersionedValue<Link>> dstLinks = HashMultimap.create(); 71 private final Multimap<DeviceId, VersionedValue<Link>> dstLinks = HashMultimap.create();
72 72
73 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 73 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
74 - protected DeviceClockService clockService; 74 + protected ClockService clockService;
75 75
76 @Activate 76 @Activate
77 public void activate() { 77 public void activate() {
......
...@@ -2,6 +2,8 @@ package org.onlab.onos.store.cluster.impl; ...@@ -2,6 +2,8 @@ package org.onlab.onos.store.cluster.impl;
2 2
3 import org.junit.After; 3 import org.junit.After;
4 import org.junit.Before; 4 import org.junit.Before;
5 +import org.junit.Ignore;
6 +import org.junit.Test;
5 import org.onlab.onos.cluster.DefaultControllerNode; 7 import org.onlab.onos.cluster.DefaultControllerNode;
6 import org.onlab.onos.cluster.NodeId; 8 import org.onlab.onos.cluster.NodeId;
7 import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager; 9 import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager;
...@@ -9,6 +11,12 @@ import org.onlab.onos.store.cluster.messaging.impl.MessageSerializer; ...@@ -9,6 +11,12 @@ import org.onlab.onos.store.cluster.messaging.impl.MessageSerializer;
9 import org.onlab.netty.NettyMessagingService; 11 import org.onlab.netty.NettyMessagingService;
10 import org.onlab.packet.IpPrefix; 12 import org.onlab.packet.IpPrefix;
11 13
14 +import java.util.concurrent.CountDownLatch;
15 +import java.util.concurrent.TimeUnit;
16 +
17 +import static org.junit.Assert.assertEquals;
18 +import static org.junit.Assert.assertTrue;
19 +
12 /** 20 /**
13 * Tests of the cluster communication manager. 21 * Tests of the cluster communication manager.
14 */ 22 */
...@@ -25,6 +33,9 @@ public class ClusterCommunicationManagerTest { ...@@ -25,6 +33,9 @@ public class ClusterCommunicationManagerTest {
25 private ClusterCommunicationManager ccm1; 33 private ClusterCommunicationManager ccm1;
26 private ClusterCommunicationManager ccm2; 34 private ClusterCommunicationManager ccm2;
27 35
36 + private TestDelegate cnd1 = new TestDelegate();
37 + private TestDelegate cnd2 = new TestDelegate();
38 +
28 private DefaultControllerNode node1 = new DefaultControllerNode(N1, IP, P1); 39 private DefaultControllerNode node1 = new DefaultControllerNode(N1, IP, P1);
29 private DefaultControllerNode node2 = new DefaultControllerNode(N2, IP, P2); 40 private DefaultControllerNode node2 = new DefaultControllerNode(N2, IP, P2);
30 41
...@@ -37,10 +48,15 @@ public class ClusterCommunicationManagerTest { ...@@ -37,10 +48,15 @@ public class ClusterCommunicationManagerTest {
37 messagingService.activate(); 48 messagingService.activate();
38 49
39 ccm1 = new ClusterCommunicationManager(); 50 ccm1 = new ClusterCommunicationManager();
51 +// ccm1.serializationService = messageSerializer;
40 ccm1.activate(); 52 ccm1.activate();
41 53
42 ccm2 = new ClusterCommunicationManager(); 54 ccm2 = new ClusterCommunicationManager();
55 +// ccm2.serializationService = messageSerializer;
43 ccm2.activate(); 56 ccm2.activate();
57 +
58 + ccm1.initialize(node1, cnd1);
59 + ccm2.initialize(node2, cnd2);
44 } 60 }
45 61
46 @After 62 @After
...@@ -48,4 +64,70 @@ public class ClusterCommunicationManagerTest { ...@@ -48,4 +64,70 @@ public class ClusterCommunicationManagerTest {
48 ccm1.deactivate(); 64 ccm1.deactivate();
49 ccm2.deactivate(); 65 ccm2.deactivate();
50 } 66 }
51 -}
...\ No newline at end of file ...\ No newline at end of file
67 +
68 + @Ignore("FIXME: failing randomly?")
69 + @Test
70 + public void connect() throws Exception {
71 + cnd1.latch = new CountDownLatch(1);
72 + cnd2.latch = new CountDownLatch(1);
73 +
74 + ccm1.addNode(node2);
75 + validateDelegateEvent(cnd1, Op.DETECTED, node2.id());
76 + validateDelegateEvent(cnd2, Op.DETECTED, node1.id());
77 + }
78 +
79 + @Test
80 + @Ignore
81 + public void disconnect() throws Exception {
82 + cnd1.latch = new CountDownLatch(1);
83 + cnd2.latch = new CountDownLatch(1);
84 +
85 + ccm1.addNode(node2);
86 + validateDelegateEvent(cnd1, Op.DETECTED, node2.id());
87 + validateDelegateEvent(cnd2, Op.DETECTED, node1.id());
88 +
89 + cnd1.latch = new CountDownLatch(1);
90 + cnd2.latch = new CountDownLatch(1);
91 + ccm1.deactivate();
92 +//
93 +// validateDelegateEvent(cnd2, Op.VANISHED, node1.id());
94 + }
95 +
96 + private void validateDelegateEvent(TestDelegate delegate, Op op, NodeId nodeId)
97 + throws InterruptedException {
98 + assertTrue("did not connect in time", delegate.latch.await(2500, TimeUnit.MILLISECONDS));
99 + assertEquals("incorrect event", op, delegate.op);
100 + assertEquals("incorrect event node", nodeId, delegate.nodeId);
101 + }
102 +
103 + enum Op { DETECTED, VANISHED, REMOVED };
104 +
105 + private class TestDelegate implements ClusterNodesDelegate {
106 +
107 + Op op;
108 + CountDownLatch latch;
109 + NodeId nodeId;
110 +
111 + @Override
112 + public DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
113 + latch(nodeId, Op.DETECTED);
114 + return new DefaultControllerNode(nodeId, ip, tcpPort);
115 + }
116 +
117 + @Override
118 + public void nodeVanished(NodeId nodeId) {
119 + latch(nodeId, Op.VANISHED);
120 + }
121 +
122 + @Override
123 + public void nodeRemoved(NodeId nodeId) {
124 + latch(nodeId, Op.REMOVED);
125 + }
126 +
127 + private void latch(NodeId nodeId, Op op) {
128 + this.op = op;
129 + this.nodeId = nodeId;
130 + latch.countDown();
131 + }
132 + }
133 +}
......
...@@ -5,7 +5,7 @@ import static org.junit.Assert.*; ...@@ -5,7 +5,7 @@ import static org.junit.Assert.*;
5 import java.nio.ByteBuffer; 5 import java.nio.ByteBuffer;
6 6
7 import org.junit.Test; 7 import org.junit.Test;
8 -import org.onlab.onos.net.device.Timestamp; 8 +import org.onlab.onos.store.Timestamp;
9 import org.onlab.util.KryoPool; 9 import org.onlab.util.KryoPool;
10 10
11 import com.google.common.testing.EqualsTester; 11 import com.google.common.testing.EqualsTester;
......
...@@ -5,8 +5,8 @@ import static org.junit.Assert.*; ...@@ -5,8 +5,8 @@ import static org.junit.Assert.*;
5 import java.nio.ByteBuffer; 5 import java.nio.ByteBuffer;
6 6
7 import org.junit.Test; 7 import org.junit.Test;
8 -import org.onlab.onos.net.device.Timestamp; 8 +import org.onlab.onos.store.Timestamp;
9 -import org.onlab.onos.net.device.Timestamped; 9 +import org.onlab.onos.store.Timestamped;
10 import org.onlab.util.KryoPool; 10 import org.onlab.util.KryoPool;
11 11
12 import com.google.common.testing.EqualsTester; 12 import com.google.common.testing.EqualsTester;
......
...@@ -35,7 +35,6 @@ import org.onlab.onos.net.PortNumber; ...@@ -35,7 +35,6 @@ import org.onlab.onos.net.PortNumber;
35 import org.onlab.onos.net.SparseAnnotations; 35 import org.onlab.onos.net.SparseAnnotations;
36 import org.onlab.onos.net.device.DefaultDeviceDescription; 36 import org.onlab.onos.net.device.DefaultDeviceDescription;
37 import org.onlab.onos.net.device.DefaultPortDescription; 37 import org.onlab.onos.net.device.DefaultPortDescription;
38 -import org.onlab.onos.net.device.DeviceClockService;
39 import org.onlab.onos.net.device.DeviceDescription; 38 import org.onlab.onos.net.device.DeviceDescription;
40 import org.onlab.onos.net.device.DeviceEvent; 39 import org.onlab.onos.net.device.DeviceEvent;
41 import org.onlab.onos.net.device.DeviceStore; 40 import org.onlab.onos.net.device.DeviceStore;
...@@ -43,6 +42,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; ...@@ -43,6 +42,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate;
43 import org.onlab.onos.net.device.DeviceMastershipTerm; 42 import org.onlab.onos.net.device.DeviceMastershipTerm;
44 import org.onlab.onos.net.device.PortDescription; 43 import org.onlab.onos.net.device.PortDescription;
45 import org.onlab.onos.net.provider.ProviderId; 44 import org.onlab.onos.net.provider.ProviderId;
45 +import org.onlab.onos.store.ClockService;
46 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 46 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
47 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 47 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
48 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 48 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
...@@ -96,7 +96,7 @@ public class GossipDeviceStoreTest { ...@@ -96,7 +96,7 @@ public class GossipDeviceStoreTest {
96 private DeviceStore deviceStore; 96 private DeviceStore deviceStore;
97 97
98 private DeviceClockManager deviceClockManager; 98 private DeviceClockManager deviceClockManager;
99 - private DeviceClockService clockService; 99 + private ClockService clockService;
100 100
101 @BeforeClass 101 @BeforeClass
102 public static void setUpBeforeClass() throws Exception { 102 public static void setUpBeforeClass() throws Exception {
...@@ -113,8 +113,8 @@ public class GossipDeviceStoreTest { ...@@ -113,8 +113,8 @@ public class GossipDeviceStoreTest {
113 deviceClockManager.activate(); 113 deviceClockManager.activate();
114 clockService = deviceClockManager; 114 clockService = deviceClockManager;
115 115
116 - deviceClockManager.setDeviceMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1)); 116 + deviceClockManager.setMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1));
117 - deviceClockManager.setDeviceMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2)); 117 + deviceClockManager.setMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2));
118 118
119 ClusterCommunicationService clusterCommunicator = new TestClusterCommunicationService(); 119 ClusterCommunicationService clusterCommunicator = new TestClusterCommunicationService();
120 ClusterService clusterService = new TestClusterService(); 120 ClusterService clusterService = new TestClusterService();
...@@ -556,7 +556,7 @@ public class GossipDeviceStoreTest { ...@@ -556,7 +556,7 @@ public class GossipDeviceStoreTest {
556 private static final class TestGossipDeviceStore extends GossipDeviceStore { 556 private static final class TestGossipDeviceStore extends GossipDeviceStore {
557 557
558 public TestGossipDeviceStore( 558 public TestGossipDeviceStore(
559 - DeviceClockService clockService, 559 + ClockService clockService,
560 ClusterService clusterService, 560 ClusterService clusterService,
561 ClusterCommunicationService clusterCommunicator) { 561 ClusterCommunicationService clusterCommunicator) {
562 this.clockService = clockService; 562 this.clockService = clockService;
......
...@@ -14,8 +14,8 @@ import org.apache.felix.scr.annotations.Service; ...@@ -14,8 +14,8 @@ import org.apache.felix.scr.annotations.Service;
14 import org.onlab.onos.cluster.ClusterService; 14 import org.onlab.onos.cluster.ClusterService;
15 import org.onlab.onos.cluster.NodeId; 15 import org.onlab.onos.cluster.NodeId;
16 import org.onlab.onos.net.DeviceId; 16 import org.onlab.onos.net.DeviceId;
17 +import org.onlab.onos.net.MastershipRole;
17 import org.onlab.onos.net.device.DeviceMastershipEvent; 18 import org.onlab.onos.net.device.DeviceMastershipEvent;
18 -import org.onlab.onos.net.device.DeviceMastershipRole;
19 import org.onlab.onos.net.device.DeviceMastershipStore; 19 import org.onlab.onos.net.device.DeviceMastershipStore;
20 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate; 20 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
21 import org.onlab.onos.net.device.DeviceMastershipTerm; 21 import org.onlab.onos.net.device.DeviceMastershipTerm;
...@@ -76,7 +76,7 @@ implements DeviceMastershipStore { ...@@ -76,7 +76,7 @@ implements DeviceMastershipStore {
76 } 76 }
77 77
78 @Override 78 @Override
79 - public DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId) { 79 + public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
80 byte[] did = serialize(deviceId); 80 byte[] did = serialize(deviceId);
81 byte[] nid = serialize(nodeId); 81 byte[] nid = serialize(nodeId);
82 82
...@@ -84,17 +84,17 @@ implements DeviceMastershipStore { ...@@ -84,17 +84,17 @@ implements DeviceMastershipStore {
84 if (current == null) { 84 if (current == null) {
85 if (standbys.containsEntry(did, nid)) { 85 if (standbys.containsEntry(did, nid)) {
86 //was previously standby, or set to standby from master 86 //was previously standby, or set to standby from master
87 - return DeviceMastershipRole.STANDBY; 87 + return MastershipRole.STANDBY;
88 } else { 88 } else {
89 - return DeviceMastershipRole.NONE; 89 + return MastershipRole.NONE;
90 } 90 }
91 } else { 91 } else {
92 if (current.equals(nodeId)) { 92 if (current.equals(nodeId)) {
93 //*should* be in unusable, not always 93 //*should* be in unusable, not always
94 - return DeviceMastershipRole.MASTER; 94 + return MastershipRole.MASTER;
95 } else { 95 } else {
96 //may be in backups or unusable from earlier retirement 96 //may be in backups or unusable from earlier retirement
97 - return DeviceMastershipRole.STANDBY; 97 + return MastershipRole.STANDBY;
98 } 98 }
99 } 99 }
100 } 100 }
...@@ -107,7 +107,7 @@ implements DeviceMastershipStore { ...@@ -107,7 +107,7 @@ implements DeviceMastershipStore {
107 ILock lock = theInstance.getLock(LOCK); 107 ILock lock = theInstance.getLock(LOCK);
108 lock.lock(); 108 lock.lock();
109 try { 109 try {
110 - DeviceMastershipRole role = getRole(nodeId, deviceId); 110 + MastershipRole role = getRole(nodeId, deviceId);
111 switch (role) { 111 switch (role) {
112 case MASTER: 112 case MASTER:
113 //reinforce mastership 113 //reinforce mastership
...@@ -157,7 +157,7 @@ implements DeviceMastershipStore { ...@@ -157,7 +157,7 @@ implements DeviceMastershipStore {
157 } 157 }
158 158
159 @Override 159 @Override
160 - public DeviceMastershipRole requestRole(DeviceId deviceId) { 160 + public MastershipRole requestRole(DeviceId deviceId) {
161 NodeId local = clusterService.getLocalNode().id(); 161 NodeId local = clusterService.getLocalNode().id();
162 byte [] did = serialize(deviceId); 162 byte [] did = serialize(deviceId);
163 byte [] lnid = serialize(local); 163 byte [] lnid = serialize(local);
...@@ -165,7 +165,7 @@ implements DeviceMastershipStore { ...@@ -165,7 +165,7 @@ implements DeviceMastershipStore {
165 ILock lock = theInstance.getLock(LOCK); 165 ILock lock = theInstance.getLock(LOCK);
166 lock.lock(); 166 lock.lock();
167 try { 167 try {
168 - DeviceMastershipRole role = getRole(local, deviceId); 168 + MastershipRole role = getRole(local, deviceId);
169 switch (role) { 169 switch (role) {
170 case MASTER: 170 case MASTER:
171 evict(lnid, did); 171 evict(lnid, did);
...@@ -179,7 +179,7 @@ implements DeviceMastershipStore { ...@@ -179,7 +179,7 @@ implements DeviceMastershipStore {
179 masters.put(did, lnid); 179 masters.put(did, lnid);
180 evict(lnid, did); 180 evict(lnid, did);
181 updateTerm(did); 181 updateTerm(did);
182 - role = DeviceMastershipRole.MASTER; 182 + role = MastershipRole.MASTER;
183 break; 183 break;
184 default: 184 default:
185 log.warn("unknown Mastership Role {}", role); 185 log.warn("unknown Mastership Role {}", role);
...@@ -210,7 +210,7 @@ implements DeviceMastershipStore { ...@@ -210,7 +210,7 @@ implements DeviceMastershipStore {
210 ILock lock = theInstance.getLock(LOCK); 210 ILock lock = theInstance.getLock(LOCK);
211 lock.lock(); 211 lock.lock();
212 try { 212 try {
213 - DeviceMastershipRole role = getRole(nodeId, deviceId); 213 + MastershipRole role = getRole(nodeId, deviceId);
214 switch (role) { 214 switch (role) {
215 case MASTER: 215 case MASTER:
216 event = reelect(nodeId, deviceId); 216 event = reelect(nodeId, deviceId);
...@@ -239,7 +239,7 @@ implements DeviceMastershipStore { ...@@ -239,7 +239,7 @@ implements DeviceMastershipStore {
239 ILock lock = theInstance.getLock(LOCK); 239 ILock lock = theInstance.getLock(LOCK);
240 lock.lock(); 240 lock.lock();
241 try { 241 try {
242 - DeviceMastershipRole role = getRole(nodeId, deviceId); 242 + MastershipRole role = getRole(nodeId, deviceId);
243 switch (role) { 243 switch (role) {
244 case MASTER: 244 case MASTER:
245 event = reelect(nodeId, deviceId); 245 event = reelect(nodeId, deviceId);
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.store.cluster.impl; ...@@ -3,7 +3,7 @@ package org.onlab.onos.store.cluster.impl;
3 import static org.junit.Assert.assertEquals; 3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNull; 4 import static org.junit.Assert.assertNull;
5 import static org.junit.Assert.assertTrue; 5 import static org.junit.Assert.assertTrue;
6 -import static org.onlab.onos.net.device.DeviceMastershipRole.*; 6 +import static org.onlab.onos.net.MastershipRole.*;
7 7
8 import java.util.Map; 8 import java.util.Map;
9 import java.util.Set; 9 import java.util.Set;
......
...@@ -3,18 +3,18 @@ package org.onlab.onos.store.device.impl; ...@@ -3,18 +3,18 @@ package org.onlab.onos.store.device.impl;
3 import org.apache.felix.scr.annotations.Component; 3 import org.apache.felix.scr.annotations.Component;
4 import org.apache.felix.scr.annotations.Service; 4 import org.apache.felix.scr.annotations.Service;
5 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
6 -import org.onlab.onos.net.device.DeviceClockProviderService;
7 import org.onlab.onos.net.device.DeviceMastershipTerm; 6 import org.onlab.onos.net.device.DeviceMastershipTerm;
7 +import org.onlab.onos.store.ClockProviderService;
8 8
9 // FIXME: Code clone in onos-core-trivial, onos-core-hz-net 9 // FIXME: Code clone in onos-core-trivial, onos-core-hz-net
10 /** 10 /**
11 - * Dummy implementation of {@link DeviceClockProviderService}. 11 + * Dummy implementation of {@link ClockProviderService}.
12 */ 12 */
13 @Component(immediate = true) 13 @Component(immediate = true)
14 @Service 14 @Service
15 -public class NoOpClockProviderService implements DeviceClockProviderService { 15 +public class NoOpClockProviderService implements ClockProviderService {
16 16
17 @Override 17 @Override
18 - public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 18 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
19 } 19 }
20 } 20 }
......
...@@ -18,11 +18,11 @@ import org.onlab.onos.net.DeviceId; ...@@ -18,11 +18,11 @@ import org.onlab.onos.net.DeviceId;
18 import org.onlab.onos.net.Element; 18 import org.onlab.onos.net.Element;
19 import org.onlab.onos.net.Link; 19 import org.onlab.onos.net.Link;
20 import org.onlab.onos.net.LinkKey; 20 import org.onlab.onos.net.LinkKey;
21 +import org.onlab.onos.net.MastershipRole;
21 import org.onlab.onos.net.Port; 22 import org.onlab.onos.net.Port;
22 import org.onlab.onos.net.PortNumber; 23 import org.onlab.onos.net.PortNumber;
23 import org.onlab.onos.net.device.DefaultDeviceDescription; 24 import org.onlab.onos.net.device.DefaultDeviceDescription;
24 import org.onlab.onos.net.device.DefaultPortDescription; 25 import org.onlab.onos.net.device.DefaultPortDescription;
25 -import org.onlab.onos.net.device.DeviceMastershipRole;
26 import org.onlab.onos.net.device.DeviceMastershipTerm; 26 import org.onlab.onos.net.device.DeviceMastershipTerm;
27 import org.onlab.onos.net.provider.ProviderId; 27 import org.onlab.onos.net.provider.ProviderId;
28 import org.onlab.packet.IpAddress; 28 import org.onlab.packet.IpAddress;
...@@ -59,7 +59,7 @@ public final class KryoPoolUtil { ...@@ -59,7 +59,7 @@ public final class KryoPoolUtil {
59 DefaultControllerNode.class, 59 DefaultControllerNode.class,
60 DefaultDevice.class, 60 DefaultDevice.class,
61 DefaultDeviceDescription.class, 61 DefaultDeviceDescription.class,
62 - DeviceMastershipRole.class, 62 + MastershipRole.class,
63 Port.class, 63 Port.class,
64 DefaultPortDescription.class, 64 DefaultPortDescription.class,
65 Element.class, 65 Element.class,
...@@ -75,7 +75,7 @@ public final class KryoPoolUtil { ...@@ -75,7 +75,7 @@ public final class KryoPoolUtil {
75 .register(ConnectPoint.class, new ConnectPointSerializer()) 75 .register(ConnectPoint.class, new ConnectPointSerializer())
76 .register(DefaultLink.class, new DefaultLinkSerializer()) 76 .register(DefaultLink.class, new DefaultLinkSerializer())
77 .register(DeviceMastershipTerm.class, new MastershipTermSerializer()) 77 .register(DeviceMastershipTerm.class, new MastershipTermSerializer())
78 - .register(DeviceMastershipRole.class, new MastershipRoleSerializer()) 78 + .register(MastershipRole.class, new MastershipRoleSerializer())
79 79
80 .build(); 80 .build();
81 81
......
1 package org.onlab.onos.store.serializers; 1 package org.onlab.onos.store.serializers;
2 2
3 -import org.onlab.onos.net.device.DeviceMastershipRole; 3 +import org.onlab.onos.net.MastershipRole;
4 4
5 import com.esotericsoftware.kryo.Kryo; 5 import com.esotericsoftware.kryo.Kryo;
6 import com.esotericsoftware.kryo.Serializer; 6 import com.esotericsoftware.kryo.Serializer;
...@@ -8,12 +8,12 @@ import com.esotericsoftware.kryo.io.Input; ...@@ -8,12 +8,12 @@ import com.esotericsoftware.kryo.io.Input;
8 import com.esotericsoftware.kryo.io.Output; 8 import com.esotericsoftware.kryo.io.Output;
9 9
10 /** 10 /**
11 - * Kryo Serializer for {@link org.onlab.onos.net.device.DeviceMastershipRole}. 11 + * Kryo Serializer for {@link org.onlab.onos.net.MastershipRole}.
12 */ 12 */
13 -public class MastershipRoleSerializer extends Serializer<DeviceMastershipRole> { 13 +public class MastershipRoleSerializer extends Serializer<MastershipRole> {
14 14
15 /** 15 /**
16 - * Creates {@link DeviceMastershipRole} serializer instance. 16 + * Creates {@link MastershipRole} serializer instance.
17 */ 17 */
18 public MastershipRoleSerializer() { 18 public MastershipRoleSerializer() {
19 // non-null, immutable 19 // non-null, immutable
...@@ -21,13 +21,13 @@ public class MastershipRoleSerializer extends Serializer<DeviceMastershipRole> { ...@@ -21,13 +21,13 @@ public class MastershipRoleSerializer extends Serializer<DeviceMastershipRole> {
21 } 21 }
22 22
23 @Override 23 @Override
24 - public DeviceMastershipRole read(Kryo kryo, Input input, Class<DeviceMastershipRole> type) { 24 + public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) {
25 final String role = kryo.readObject(input, String.class); 25 final String role = kryo.readObject(input, String.class);
26 - return DeviceMastershipRole.valueOf(role); 26 + return MastershipRole.valueOf(role);
27 } 27 }
28 28
29 @Override 29 @Override
30 - public void write(Kryo kryo, Output output, DeviceMastershipRole object) { 30 + public void write(Kryo kryo, Output output, MastershipRole object) {
31 kryo.writeObject(output, object.toString()); 31 kryo.writeObject(output, object.toString());
32 } 32 }
33 33
......
...@@ -21,9 +21,9 @@ import org.onlab.onos.net.Device; ...@@ -21,9 +21,9 @@ import org.onlab.onos.net.Device;
21 import org.onlab.onos.net.DeviceId; 21 import org.onlab.onos.net.DeviceId;
22 import org.onlab.onos.net.Link; 22 import org.onlab.onos.net.Link;
23 import org.onlab.onos.net.LinkKey; 23 import org.onlab.onos.net.LinkKey;
24 +import org.onlab.onos.net.MastershipRole;
24 import org.onlab.onos.net.PortNumber; 25 import org.onlab.onos.net.PortNumber;
25 import org.onlab.onos.net.SparseAnnotations; 26 import org.onlab.onos.net.SparseAnnotations;
26 -import org.onlab.onos.net.device.DeviceMastershipRole;
27 import org.onlab.onos.net.device.DeviceMastershipTerm; 27 import org.onlab.onos.net.device.DeviceMastershipTerm;
28 import org.onlab.onos.net.provider.ProviderId; 28 import org.onlab.onos.net.provider.ProviderId;
29 import org.onlab.packet.IpAddress; 29 import org.onlab.packet.IpAddress;
...@@ -115,7 +115,7 @@ public class KryoSerializerTest { ...@@ -115,7 +115,7 @@ public class KryoSerializerTest {
115 testSerialized(PIDA); 115 testSerialized(PIDA);
116 testSerialized(new NodeId("bar")); 116 testSerialized(new NodeId("bar"));
117 testSerialized(DeviceMastershipTerm.of(new NodeId("foo"), 2)); 117 testSerialized(DeviceMastershipTerm.of(new NodeId("foo"), 2));
118 - for (DeviceMastershipRole role : DeviceMastershipRole.values()) { 118 + for (MastershipRole role : MastershipRole.values()) {
119 testSerialized(role); 119 testSerialized(role);
120 } 120 }
121 } 121 }
......
...@@ -3,18 +3,18 @@ package org.onlab.onos.store.trivial.impl; ...@@ -3,18 +3,18 @@ package org.onlab.onos.store.trivial.impl;
3 import org.apache.felix.scr.annotations.Component; 3 import org.apache.felix.scr.annotations.Component;
4 import org.apache.felix.scr.annotations.Service; 4 import org.apache.felix.scr.annotations.Service;
5 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
6 -import org.onlab.onos.net.device.DeviceClockProviderService;
7 import org.onlab.onos.net.device.DeviceMastershipTerm; 6 import org.onlab.onos.net.device.DeviceMastershipTerm;
7 +import org.onlab.onos.store.ClockProviderService;
8 8
9 //FIXME: Code clone in onos-core-trivial, onos-core-hz-net 9 //FIXME: Code clone in onos-core-trivial, onos-core-hz-net
10 /** 10 /**
11 - * Dummy implementation of {@link DeviceClockProviderService}. 11 + * Dummy implementation of {@link ClockProviderService}.
12 */ 12 */
13 @Component(immediate = true) 13 @Component(immediate = true)
14 @Service 14 @Service
15 -public class NoOpClockProviderService implements DeviceClockProviderService { 15 +public class NoOpClockProviderService implements ClockProviderService {
16 16
17 @Override 17 @Override
18 - public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 18 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
19 } 19 }
20 } 20 }
......
...@@ -17,8 +17,8 @@ import org.onlab.onos.cluster.ControllerNode; ...@@ -17,8 +17,8 @@ import org.onlab.onos.cluster.ControllerNode;
17 import org.onlab.onos.cluster.DefaultControllerNode; 17 import org.onlab.onos.cluster.DefaultControllerNode;
18 import org.onlab.onos.cluster.NodeId; 18 import org.onlab.onos.cluster.NodeId;
19 import org.onlab.onos.net.DeviceId; 19 import org.onlab.onos.net.DeviceId;
20 +import org.onlab.onos.net.MastershipRole;
20 import org.onlab.onos.net.device.DeviceMastershipEvent; 21 import org.onlab.onos.net.device.DeviceMastershipEvent;
21 -import org.onlab.onos.net.device.DeviceMastershipRole;
22 import org.onlab.onos.net.device.DeviceMastershipStore; 22 import org.onlab.onos.net.device.DeviceMastershipStore;
23 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate; 23 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
24 import org.onlab.onos.net.device.DeviceMastershipTerm; 24 import org.onlab.onos.net.device.DeviceMastershipTerm;
...@@ -64,7 +64,7 @@ public class SimpleMastershipStore ...@@ -64,7 +64,7 @@ public class SimpleMastershipStore
64 64
65 @Override 65 @Override
66 public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) { 66 public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
67 - DeviceMastershipRole role = getRole(nodeId, deviceId); 67 + MastershipRole role = getRole(nodeId, deviceId);
68 68
69 synchronized (this) { 69 synchronized (this) {
70 switch (role) { 70 switch (role) {
...@@ -106,10 +106,10 @@ public class SimpleMastershipStore ...@@ -106,10 +106,10 @@ public class SimpleMastershipStore
106 } 106 }
107 107
108 @Override 108 @Override
109 - public DeviceMastershipRole requestRole(DeviceId deviceId) { 109 + public MastershipRole requestRole(DeviceId deviceId) {
110 //query+possible reelection 110 //query+possible reelection
111 NodeId node = instance.id(); 111 NodeId node = instance.id();
112 - DeviceMastershipRole role = getRole(node, deviceId); 112 + MastershipRole role = getRole(node, deviceId);
113 113
114 switch (role) { 114 switch (role) {
115 case MASTER: 115 case MASTER:
...@@ -121,7 +121,7 @@ public class SimpleMastershipStore ...@@ -121,7 +121,7 @@ public class SimpleMastershipStore
121 if (rel == null) { 121 if (rel == null) {
122 masterMap.put(deviceId, node); 122 masterMap.put(deviceId, node);
123 termMap.put(deviceId, new AtomicInteger()); 123 termMap.put(deviceId, new AtomicInteger());
124 - role = DeviceMastershipRole.MASTER; 124 + role = MastershipRole.MASTER;
125 } 125 }
126 backups.add(node); 126 backups.add(node);
127 } 127 }
...@@ -132,7 +132,7 @@ public class SimpleMastershipStore ...@@ -132,7 +132,7 @@ public class SimpleMastershipStore
132 masterMap.put(deviceId, node); 132 masterMap.put(deviceId, node);
133 termMap.put(deviceId, new AtomicInteger()); 133 termMap.put(deviceId, new AtomicInteger());
134 backups.add(node); 134 backups.add(node);
135 - role = DeviceMastershipRole.MASTER; 135 + role = MastershipRole.MASTER;
136 } 136 }
137 break; 137 break;
138 default: 138 default:
...@@ -142,22 +142,22 @@ public class SimpleMastershipStore ...@@ -142,22 +142,22 @@ public class SimpleMastershipStore
142 } 142 }
143 143
144 @Override 144 @Override
145 - public DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId) { 145 + public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
146 //just query 146 //just query
147 NodeId current = masterMap.get(deviceId); 147 NodeId current = masterMap.get(deviceId);
148 - DeviceMastershipRole role; 148 + MastershipRole role;
149 149
150 if (current == null) { 150 if (current == null) {
151 if (backups.contains(nodeId)) { 151 if (backups.contains(nodeId)) {
152 - role = DeviceMastershipRole.STANDBY; 152 + role = MastershipRole.STANDBY;
153 } else { 153 } else {
154 - role = DeviceMastershipRole.NONE; 154 + role = MastershipRole.NONE;
155 } 155 }
156 } else { 156 } else {
157 if (current.equals(nodeId)) { 157 if (current.equals(nodeId)) {
158 - role = DeviceMastershipRole.MASTER; 158 + role = MastershipRole.MASTER;
159 } else { 159 } else {
160 - role = DeviceMastershipRole.STANDBY; 160 + role = MastershipRole.STANDBY;
161 } 161 }
162 } 162 }
163 return role; 163 return role;
...@@ -175,7 +175,7 @@ public class SimpleMastershipStore ...@@ -175,7 +175,7 @@ public class SimpleMastershipStore
175 175
176 @Override 176 @Override
177 public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) { 177 public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
178 - DeviceMastershipRole role = getRole(nodeId, deviceId); 178 + MastershipRole role = getRole(nodeId, deviceId);
179 synchronized (this) { 179 synchronized (this) {
180 switch (role) { 180 switch (role) {
181 case MASTER: 181 case MASTER:
......
...@@ -15,8 +15,8 @@ import com.google.common.collect.Sets; ...@@ -15,8 +15,8 @@ import com.google.common.collect.Sets;
15 import static org.junit.Assert.assertEquals; 15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNull; 16 import static org.junit.Assert.assertNull;
17 import static org.junit.Assert.assertTrue; 17 import static org.junit.Assert.assertTrue;
18 +import static org.onlab.onos.net.MastershipRole.*;
18 import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*; 19 import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*;
19 -import static org.onlab.onos.net.device.DeviceMastershipRole.*;
20 20
21 /** 21 /**
22 * Test for the simple MastershipStore implementation. 22 * Test for the simple MastershipStore implementation.
......
...@@ -7,11 +7,11 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -7,11 +7,11 @@ import org.apache.felix.scr.annotations.Reference;
7 import org.apache.felix.scr.annotations.ReferenceCardinality; 7 import org.apache.felix.scr.annotations.ReferenceCardinality;
8 import org.onlab.onos.net.Device; 8 import org.onlab.onos.net.Device;
9 import org.onlab.onos.net.DeviceId; 9 import org.onlab.onos.net.DeviceId;
10 +import org.onlab.onos.net.MastershipRole;
10 import org.onlab.onos.net.PortNumber; 11 import org.onlab.onos.net.PortNumber;
11 import org.onlab.onos.net.device.DefaultDeviceDescription; 12 import org.onlab.onos.net.device.DefaultDeviceDescription;
12 import org.onlab.onos.net.device.DefaultPortDescription; 13 import org.onlab.onos.net.device.DefaultPortDescription;
13 import org.onlab.onos.net.device.DeviceDescription; 14 import org.onlab.onos.net.device.DeviceDescription;
14 -import org.onlab.onos.net.device.DeviceMastershipRole;
15 import org.onlab.onos.net.device.DeviceProvider; 15 import org.onlab.onos.net.device.DeviceProvider;
16 import org.onlab.onos.net.device.DeviceProviderRegistry; 16 import org.onlab.onos.net.device.DeviceProviderRegistry;
17 import org.onlab.onos.net.device.DeviceProviderService; 17 import org.onlab.onos.net.device.DeviceProviderService;
...@@ -91,7 +91,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -91,7 +91,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
91 } 91 }
92 92
93 @Override 93 @Override
94 - public void roleChanged(Device device, DeviceMastershipRole newRole) { 94 + public void roleChanged(Device device, MastershipRole newRole) {
95 switch (newRole) { 95 switch (newRole) {
96 case MASTER: 96 case MASTER:
97 controller.setRole(dpid(device.id().uri()), RoleState.MASTER); 97 controller.setRole(dpid(device.id().uri()), RoleState.MASTER);
...@@ -144,16 +144,16 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -144,16 +144,16 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
144 144
145 @Override 145 @Override
146 public void roleAssertFailed(Dpid dpid, RoleState role) { 146 public void roleAssertFailed(Dpid dpid, RoleState role) {
147 - DeviceMastershipRole failed; 147 + MastershipRole failed;
148 switch (role) { 148 switch (role) {
149 case MASTER: 149 case MASTER:
150 - failed = DeviceMastershipRole.MASTER; 150 + failed = MastershipRole.MASTER;
151 break; 151 break;
152 case EQUAL: 152 case EQUAL:
153 - failed = DeviceMastershipRole.STANDBY; 153 + failed = MastershipRole.STANDBY;
154 break; 154 break;
155 case SLAVE: 155 case SLAVE:
156 - failed = DeviceMastershipRole.NONE; 156 + failed = MastershipRole.NONE;
157 break; 157 break;
158 default: 158 default:
159 LOG.warn("unknown role {}", role); 159 LOG.warn("unknown role {}", role);
......
...@@ -5,7 +5,7 @@ import static org.junit.Assert.assertNotNull; ...@@ -5,7 +5,7 @@ import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertNull; 5 import static org.junit.Assert.assertNull;
6 import static org.junit.Assert.assertTrue; 6 import static org.junit.Assert.assertTrue;
7 import static org.onlab.onos.net.Device.Type.*; 7 import static org.onlab.onos.net.Device.Type.*;
8 -import static org.onlab.onos.net.device.DeviceMastershipRole.*; 8 +import static org.onlab.onos.net.MastershipRole.*;
9 9
10 import java.util.ArrayList; 10 import java.util.ArrayList;
11 import java.util.HashMap; 11 import java.util.HashMap;
...@@ -20,8 +20,8 @@ import org.junit.Test; ...@@ -20,8 +20,8 @@ import org.junit.Test;
20 import org.onlab.onos.net.DefaultDevice; 20 import org.onlab.onos.net.DefaultDevice;
21 import org.onlab.onos.net.Device; 21 import org.onlab.onos.net.Device;
22 import org.onlab.onos.net.DeviceId; 22 import org.onlab.onos.net.DeviceId;
23 +import org.onlab.onos.net.MastershipRole;
23 import org.onlab.onos.net.device.DeviceDescription; 24 import org.onlab.onos.net.device.DeviceDescription;
24 -import org.onlab.onos.net.device.DeviceMastershipRole;
25 import org.onlab.onos.net.device.DeviceProvider; 25 import org.onlab.onos.net.device.DeviceProvider;
26 import org.onlab.onos.net.device.DeviceProviderRegistry; 26 import org.onlab.onos.net.device.DeviceProviderRegistry;
27 import org.onlab.onos.net.device.DeviceProviderService; 27 import org.onlab.onos.net.device.DeviceProviderService;
...@@ -143,7 +143,7 @@ public class OpenFlowDeviceProviderTest { ...@@ -143,7 +143,7 @@ public class OpenFlowDeviceProviderTest {
143 Set<DeviceId> connected = new HashSet<>(); 143 Set<DeviceId> connected = new HashSet<>();
144 Multimap<DeviceId, PortDescription> ports = HashMultimap.create(); 144 Multimap<DeviceId, PortDescription> ports = HashMultimap.create();
145 PortDescription descr = null; 145 PortDescription descr = null;
146 - Map<DeviceMastershipRole, Dpid> roles = new HashMap<>(); 146 + Map<MastershipRole, Dpid> roles = new HashMap<>();
147 147
148 @Override 148 @Override
149 public DeviceProviderService register(DeviceProvider provider) { 149 public DeviceProviderService register(DeviceProvider provider) {
...@@ -195,7 +195,7 @@ public class OpenFlowDeviceProviderTest { ...@@ -195,7 +195,7 @@ public class OpenFlowDeviceProviderTest {
195 } 195 }
196 196
197 @Override 197 @Override
198 - public void unableToAssertRole(DeviceId deviceId, DeviceMastershipRole role) { 198 + public void unableToAssertRole(DeviceId deviceId, MastershipRole role) {
199 roles.put(role, Dpid.dpid(deviceId.uri())); 199 roles.put(role, Dpid.dpid(deviceId.uri()));
200 } 200 }
201 201
......