tom

Merge remote-tracking branch 'origin/master'

Showing 60 changed files with 285 additions and 371 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;
8 import org.onlab.onos.net.device.DeviceMastershipAdminService; 7 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 - MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase()); 34 + DeviceMastershipRole mastershipRole = DeviceMastershipRole.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.MastershipRole; 5 +import org.onlab.onos.net.device.DeviceMastershipRole;
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(MastershipRole.MASTER.toString().toLowerCase()); 19 + strings.add(DeviceMastershipRole.MASTER.toString().toLowerCase());
20 - strings.add(MastershipRole.STANDBY.toString().toLowerCase()); 20 + strings.add(DeviceMastershipRole.STANDBY.toString().toLowerCase());
21 - strings.add(MastershipRole.NONE.toString().toLowerCase()); 21 + strings.add(DeviceMastershipRole.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.store; 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.device.DeviceMastershipTerm;
5 4
6 //TODO: Consider renaming to DeviceClockProviderService? 5 //TODO: Consider renaming to DeviceClockProviderService?
7 /** 6 /**
8 * Interface for feeding term information to a logical clock service 7 * Interface for feeding term information to a logical clock service
9 * that vends per device timestamps. 8 * that vends per device timestamps.
10 */ 9 */
11 -public interface ClockProviderService { 10 +public interface DeviceClockProviderService {
12 11
13 /** 12 /**
14 * Updates the mastership term for the specified deviceId. 13 * Updates the mastership term for the specified deviceId.
...@@ -16,5 +15,5 @@ public interface ClockProviderService { ...@@ -16,5 +15,5 @@ public interface ClockProviderService {
16 * @param deviceId device identifier. 15 * @param deviceId device identifier.
17 * @param term mastership term. 16 * @param term mastership term.
18 */ 17 */
19 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term); 18 + public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term);
20 } 19 }
......
1 -package org.onlab.onos.store; 1 +package org.onlab.onos.net.device;
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 ClockService { 9 +public interface DeviceClockService {
10 10
11 /** 11 /**
12 * Returns a new timestamp for the specified deviceId. 12 * Returns a new timestamp for the specified deviceId.
......
...@@ -2,7 +2,6 @@ package org.onlab.onos.net.device; ...@@ -2,7 +2,6 @@ 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;
6 5
7 /** 6 /**
8 * Service for administering the inventory of device masterships. 7 * Service for administering the inventory of device masterships.
...@@ -16,6 +15,6 @@ public interface DeviceMastershipAdminService { ...@@ -16,6 +15,6 @@ public interface DeviceMastershipAdminService {
16 * @param deviceId device identifier 15 * @param deviceId device identifier
17 * @param role requested role 16 * @param role requested role
18 */ 17 */
19 - void setRole(NodeId instance, DeviceId deviceId, MastershipRole role); 18 + void setRole(NodeId instance, DeviceId deviceId, DeviceMastershipRole role);
20 19
21 } 20 }
......
1 -package org.onlab.onos.net; 1 +package org.onlab.onos.net.device;
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 MastershipRole { 7 +public enum DeviceMastershipRole {
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
......
...@@ -4,7 +4,6 @@ import java.util.Set; ...@@ -4,7 +4,6 @@ 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;
8 7
9 /** 8 /**
10 * Service responsible for determining the controller instance mastership of 9 * Service responsible for determining the controller instance mastership of
...@@ -21,7 +20,7 @@ public interface DeviceMastershipService { ...@@ -21,7 +20,7 @@ public interface DeviceMastershipService {
21 * @param deviceId the the identifier of the device 20 * @param deviceId the the identifier of the device
22 * @return role of the current node 21 * @return role of the current node
23 */ 22 */
24 - MastershipRole getLocalRole(DeviceId deviceId); 23 + DeviceMastershipRole getLocalRole(DeviceId deviceId);
25 24
26 /** 25 /**
27 * Returns the mastership status of the local controller for a given 26 * Returns the mastership status of the local controller for a given
...@@ -30,7 +29,7 @@ public interface DeviceMastershipService { ...@@ -30,7 +29,7 @@ public interface DeviceMastershipService {
30 * @param deviceId the the identifier of the device 29 * @param deviceId the the identifier of the device
31 * @return the role of this controller instance 30 * @return the role of this controller instance
32 */ 31 */
33 - MastershipRole requestRoleFor(DeviceId deviceId); 32 + DeviceMastershipRole requestRoleFor(DeviceId deviceId);
34 33
35 /** 34 /**
36 * Abandons mastership of the specified device on the local node thus 35 * Abandons mastership of the specified device on the local node thus
......
...@@ -4,7 +4,6 @@ import java.util.Set; ...@@ -4,7 +4,6 @@ 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;
8 import org.onlab.onos.store.Store; 7 import org.onlab.onos.store.Store;
9 8
10 /** 9 /**
...@@ -21,7 +20,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -21,7 +20,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
21 * @param deviceId device identifier 20 * @param deviceId device identifier
22 * @return established or newly negotiated mastership role 21 * @return established or newly negotiated mastership role
23 */ 22 */
24 - MastershipRole requestRole(DeviceId deviceId); 23 + DeviceMastershipRole requestRole(DeviceId deviceId);
25 24
26 /** 25 /**
27 * Returns the role of a device for a specific controller instance. 26 * Returns the role of a device for a specific controller instance.
...@@ -30,7 +29,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -30,7 +29,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
30 * @param deviceId the device identifiers 29 * @param deviceId the device identifiers
31 * @return the role 30 * @return the role
32 */ 31 */
33 - MastershipRole getRole(NodeId nodeId, DeviceId deviceId); 32 + DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId);
34 33
35 /** 34 /**
36 * Returns the master for a device. 35 * 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;
5 import org.onlab.onos.net.provider.Provider; 4 import org.onlab.onos.net.provider.Provider;
6 5
7 /** 6 /**
...@@ -30,6 +29,6 @@ public interface DeviceProvider extends Provider { ...@@ -30,6 +29,6 @@ public interface DeviceProvider extends Provider {
30 * @param device affected device 29 * @param device affected device
31 * @param newRole newly determined mastership role 30 * @param newRole newly determined mastership role
32 */ 31 */
33 - void roleChanged(Device device, MastershipRole newRole); 32 + void roleChanged(Device device, DeviceMastershipRole newRole);
34 33
35 } 34 }
......
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;
5 import org.onlab.onos.net.provider.ProviderService; 4 import org.onlab.onos.net.provider.ProviderService;
6 5
7 import java.util.List; 6 import java.util.List;
...@@ -53,6 +52,6 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> { ...@@ -53,6 +52,6 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> {
53 * @param deviceId identity of the device 52 * @param deviceId identity of the device
54 * @param role mastership role that was asserted but failed 53 * @param role mastership role that was asserted but failed
55 */ 54 */
56 - void unableToAssertRole(DeviceId deviceId, MastershipRole role); 55 + void unableToAssertRole(DeviceId deviceId, DeviceMastershipRole role);
57 56
58 } 57 }
......
...@@ -2,7 +2,6 @@ package org.onlab.onos.net.device; ...@@ -2,7 +2,6 @@ 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;
6 import org.onlab.onos.net.Port; 5 import org.onlab.onos.net.Port;
7 import org.onlab.onos.net.PortNumber; 6 import org.onlab.onos.net.PortNumber;
8 7
...@@ -43,7 +42,7 @@ public interface DeviceService { ...@@ -43,7 +42,7 @@ public interface DeviceService {
43 * @return designated mastership role 42 * @return designated mastership role
44 */ 43 */
45 //XXX do we want this method here when MastershipService already does? 44 //XXX do we want this method here when MastershipService already does?
46 - MastershipRole getRole(DeviceId deviceId); 45 + DeviceMastershipRole getRole(DeviceId deviceId);
47 46
48 47
49 /** 48 /**
......
1 -package org.onlab.onos.store; 1 +package org.onlab.onos.net.device;
2 2
3 /** 3 /**
4 * Opaque version structure. 4 * Opaque version structure.
......
1 -package org.onlab.onos.store; 1 +package org.onlab.onos.net.device;
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.store; 1 +package org.onlab.onos.net.device;
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;
5 import org.onlab.onos.net.device.DeviceMastershipListener; 4 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 MastershipRole getLocalRole(DeviceId deviceId) { 16 + public DeviceMastershipRole getLocalRole(DeviceId deviceId) {
17 return null; 17 return null;
18 } 18 }
19 19
20 @Override 20 @Override
21 - public MastershipRole requestRoleFor(DeviceId deviceId) { 21 + public DeviceMastershipRole requestRoleFor(DeviceId deviceId) {
22 return null; 22 return null;
23 } 23 }
24 24
......
...@@ -2,7 +2,6 @@ package org.onlab.onos.net.device; ...@@ -2,7 +2,6 @@ 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;
6 import org.onlab.onos.net.Port; 5 import org.onlab.onos.net.Port;
7 import org.onlab.onos.net.PortNumber; 6 import org.onlab.onos.net.PortNumber;
8 7
...@@ -28,7 +27,7 @@ public class DeviceServiceAdapter implements DeviceService { ...@@ -28,7 +27,7 @@ public class DeviceServiceAdapter implements DeviceService {
28 } 27 }
29 28
30 @Override 29 @Override
31 - public MastershipRole getRole(DeviceId deviceId) { 30 + public DeviceMastershipRole getRole(DeviceId deviceId) {
32 return null; 31 return null;
33 } 32 }
34 33
......
...@@ -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;
22 import org.onlab.onos.net.device.DeviceMastershipAdminService; 21 import org.onlab.onos.net.device.DeviceMastershipAdminService;
23 import org.onlab.onos.net.device.DeviceMastershipEvent; 22 import org.onlab.onos.net.device.DeviceMastershipEvent;
24 import org.onlab.onos.net.device.DeviceMastershipListener; 23 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, MastershipRole role) { 76 + public void setRole(NodeId nodeId, DeviceId deviceId, DeviceMastershipRole 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(MastershipRole.MASTER)) { 82 + if (role.equals(DeviceMastershipRole.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 MastershipRole getLocalRole(DeviceId deviceId) { 94 + public DeviceMastershipRole 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 MastershipRole requestRoleFor(DeviceId deviceId) { 111 + public DeviceMastershipRole 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,13 +18,14 @@ import org.onlab.onos.event.AbstractListenerRegistry; ...@@ -18,13 +18,14 @@ 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;
22 import org.onlab.onos.net.Port; 21 import org.onlab.onos.net.Port;
23 import org.onlab.onos.net.PortNumber; 22 import org.onlab.onos.net.PortNumber;
24 import org.onlab.onos.net.device.DeviceAdminService; 23 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;
28 import org.onlab.onos.net.device.DeviceProvider; 29 import org.onlab.onos.net.device.DeviceProvider;
29 import org.onlab.onos.net.device.DeviceProviderRegistry; 30 import org.onlab.onos.net.device.DeviceProviderRegistry;
30 import org.onlab.onos.net.device.DeviceProviderService; 31 import org.onlab.onos.net.device.DeviceProviderService;
...@@ -39,7 +40,6 @@ import org.onlab.onos.net.device.DeviceMastershipTermService; ...@@ -39,7 +40,6 @@ import org.onlab.onos.net.device.DeviceMastershipTermService;
39 import org.onlab.onos.net.device.PortDescription; 40 import org.onlab.onos.net.device.PortDescription;
40 import org.onlab.onos.net.provider.AbstractProviderRegistry; 41 import org.onlab.onos.net.provider.AbstractProviderRegistry;
41 import org.onlab.onos.net.provider.AbstractProviderService; 42 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 ClockProviderService clockProviderService; 84 + protected DeviceClockProviderService 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 MastershipRole getRole(DeviceId deviceId) { 120 + public DeviceMastershipRole 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, MastershipRole newRole) { 145 + private void applyRole(DeviceId deviceId, DeviceMastershipRole newRole) {
146 - if (newRole.equals(MastershipRole.NONE)) { 146 + if (newRole.equals(DeviceMastershipRole.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 - MastershipRole role = mastershipService.requestRoleFor(deviceId); 204 + DeviceMastershipRole role = mastershipService.requestRoleFor(deviceId);
205 205
206 - if (role != MastershipRole.MASTER) { 206 + if (role != DeviceMastershipRole.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.setMastershipTerm(deviceId, term); 219 + clockProviderService.setDeviceMastershipTerm(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(MastershipRole.MASTER)) { 258 + if (!mastershipService.getLocalRole(deviceId).equals(DeviceMastershipRole.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, MastershipRole role) { 305 + public void unableToAssertRole(DeviceId deviceId, DeviceMastershipRole 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 == MastershipRole.MASTER) { 309 + if (role == DeviceMastershipRole.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.setMastershipTerm(did, term); 336 + clockProviderService.setDeviceMastershipTerm(did, term);
337 } 337 }
338 - applyRole(did, MastershipRole.MASTER); 338 + applyRole(did, DeviceMastershipRole.MASTER);
339 } else { 339 } else {
340 - applyRole(did, MastershipRole.STANDBY); 340 + applyRole(did, DeviceMastershipRole.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, MastershipRole.STANDBY); 345 + applyRole(did, DeviceMastershipRole.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.MastershipRole.*; 23 +import static org.onlab.onos.net.device.DeviceMastershipRole.*;
24 24
25 /** 25 /**
26 * Test codifying the mastership service contracts. 26 * Test codifying the mastership service contracts.
......
...@@ -17,15 +17,16 @@ import org.onlab.onos.event.Event; ...@@ -17,15 +17,16 @@ 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;
21 import org.onlab.onos.net.Port; 20 import org.onlab.onos.net.Port;
22 import org.onlab.onos.net.PortNumber; 21 import org.onlab.onos.net.PortNumber;
23 import org.onlab.onos.net.device.DefaultDeviceDescription; 22 import org.onlab.onos.net.device.DefaultDeviceDescription;
24 import org.onlab.onos.net.device.DefaultPortDescription; 23 import org.onlab.onos.net.device.DefaultPortDescription;
25 import org.onlab.onos.net.device.DeviceAdminService; 24 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;
29 import org.onlab.onos.net.device.DeviceProvider; 30 import org.onlab.onos.net.device.DeviceProvider;
30 import org.onlab.onos.net.device.DeviceProviderRegistry; 31 import org.onlab.onos.net.device.DeviceProviderRegistry;
31 import org.onlab.onos.net.device.DeviceProviderService; 32 import org.onlab.onos.net.device.DeviceProviderService;
...@@ -35,7 +36,6 @@ import org.onlab.onos.net.device.DeviceMastershipTermService; ...@@ -35,7 +36,6 @@ import org.onlab.onos.net.device.DeviceMastershipTermService;
35 import org.onlab.onos.net.device.PortDescription; 36 import org.onlab.onos.net.device.PortDescription;
36 import org.onlab.onos.net.provider.AbstractProvider; 37 import org.onlab.onos.net.provider.AbstractProvider;
37 import org.onlab.onos.net.provider.ProviderId; 38 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", MastershipRole.MASTER, service.getRole(DID1)); 164 + assertEquals("incorrect role", DeviceMastershipRole.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", MastershipRole.STANDBY, service.getRole(DID1)); 172 + assertEquals("incorrect role", DeviceMastershipRole.STANDBY, service.getRole(DID1));
173 assertEquals("incorrect device", DID1, provider.deviceReceived.id()); 173 assertEquals("incorrect device", DID1, provider.deviceReceived.id());
174 - assertEquals("incorrect role", MastershipRole.STANDBY, provider.roleReceived); 174 + assertEquals("incorrect role", DeviceMastershipRole.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 MastershipRole roleReceived; 249 + private DeviceMastershipRole 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, MastershipRole newRole) { 260 + public void roleChanged(Device device, DeviceMastershipRole 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 MastershipRole getLocalRole(DeviceId deviceId) { 278 + public DeviceMastershipRole getLocalRole(DeviceId deviceId) {
279 - return MastershipRole.MASTER; 279 + return DeviceMastershipRole.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 MastershipRole requestRoleFor(DeviceId deviceId) { 288 + public DeviceMastershipRole requestRoleFor(DeviceId deviceId) {
289 - return MastershipRole.MASTER; 289 + return DeviceMastershipRole.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 - ClockProviderService { 339 + DeviceClockProviderService {
340 340
341 @Override 341 @Override
342 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 342 + public void setDeviceMastershipTerm(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;
28 import org.onlab.onos.net.Port; 27 import org.onlab.onos.net.Port;
29 import org.onlab.onos.net.PortNumber; 28 import org.onlab.onos.net.PortNumber;
30 import org.onlab.onos.net.device.DeviceListener; 29 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 MastershipRole getRole(DeviceId deviceId) { 367 + public DeviceMastershipRole 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;
23 import org.onlab.onos.net.Port; 22 import org.onlab.onos.net.Port;
24 import org.onlab.onos.net.PortNumber; 23 import org.onlab.onos.net.PortNumber;
25 import org.onlab.onos.net.device.DeviceListener; 24 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 MastershipRole getRole(DeviceId deviceId) { 192 + public DeviceMastershipRole 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 +
4 import org.junit.After; 5 import org.junit.After;
5 import org.junit.Before; 6 import org.junit.Before;
6 import org.junit.Test; 7 import org.junit.Test;
...@@ -9,7 +10,6 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -9,7 +10,6 @@ import org.onlab.onos.net.ConnectPoint;
9 import org.onlab.onos.net.Device; 10 import org.onlab.onos.net.Device;
10 import org.onlab.onos.net.DeviceId; 11 import org.onlab.onos.net.DeviceId;
11 import org.onlab.onos.net.Link; 12 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,6 +22,7 @@ import org.onlab.onos.net.link.LinkService; ...@@ -22,6 +22,7 @@ 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;
25 import org.onlab.onos.net.device.impl.DeviceManager; 26 import org.onlab.onos.net.device.impl.DeviceManager;
26 import org.onlab.onos.store.trivial.impl.SimpleLinkStore; 27 import org.onlab.onos.store.trivial.impl.SimpleLinkStore;
27 28
...@@ -243,7 +244,7 @@ public class LinkManagerTest { ...@@ -243,7 +244,7 @@ public class LinkManagerTest {
243 244
244 private class TestProvider extends AbstractProvider implements LinkProvider { 245 private class TestProvider extends AbstractProvider implements LinkProvider {
245 private Device deviceReceived; 246 private Device deviceReceived;
246 - private MastershipRole roleReceived; 247 + private DeviceMastershipRole roleReceived;
247 248
248 public TestProvider() { 249 public TestProvider() {
249 super(PID); 250 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.DefaultControllerNode; 3 +import org.onlab.onos.cluster.ControllerNode;
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 - DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort); 21 + ControllerNode 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;
7 import com.google.common.collect.ImmutableSet; 3 import com.google.common.collect.ImmutableSet;
8 4
9 import org.apache.felix.scr.annotations.Activate; 5 import org.apache.felix.scr.annotations.Activate;
...@@ -18,8 +14,16 @@ import org.onlab.onos.cluster.DefaultControllerNode; ...@@ -18,8 +14,16 @@ import org.onlab.onos.cluster.DefaultControllerNode;
18 import org.onlab.onos.cluster.NodeId; 14 import org.onlab.onos.cluster.NodeId;
19 import org.onlab.onos.store.AbstractStore; 15 import org.onlab.onos.store.AbstractStore;
20 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService; 16 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService;
21 -import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager; 17 +import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
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;
22 import org.onlab.packet.IpPrefix; 25 import org.onlab.packet.IpPrefix;
26 +import org.onlab.util.KryoPool;
23 import org.slf4j.Logger; 27 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 28 import org.slf4j.LoggerFactory;
25 29
...@@ -27,7 +31,6 @@ import java.io.IOException; ...@@ -27,7 +31,6 @@ import java.io.IOException;
27 import java.util.Map; 31 import java.util.Map;
28 import java.util.Set; 32 import java.util.Set;
29 import java.util.concurrent.ConcurrentHashMap; 33 import java.util.concurrent.ConcurrentHashMap;
30 -import java.util.concurrent.TimeUnit;
31 34
32 import static org.onlab.onos.cluster.ControllerNode.State; 35 import static org.onlab.onos.cluster.ControllerNode.State;
33 import static org.onlab.packet.IpPrefix.valueOf; 36 import static org.onlab.packet.IpPrefix.valueOf;
...@@ -43,17 +46,33 @@ public class DistributedClusterStore ...@@ -43,17 +46,33 @@ public class DistributedClusterStore
43 46
44 private final Logger log = LoggerFactory.getLogger(getClass()); 47 private final Logger log = LoggerFactory.getLogger(getClass());
45 48
46 - private DefaultControllerNode localNode; 49 + private ControllerNode localNode;
47 - private final Map<NodeId, DefaultControllerNode> nodes = new ConcurrentHashMap<>(); 50 + private final Map<NodeId, ControllerNode> nodes = new ConcurrentHashMap<>();
48 private final Map<NodeId, State> states = new ConcurrentHashMap<>(); 51 private final Map<NodeId, State> states = new ConcurrentHashMap<>();
49 - private final Cache<NodeId, ControllerNode> livenessCache = CacheBuilder.newBuilder() 52 +
50 - .maximumSize(1000) 53 + private static final KryoSerializer SERIALIZER = new KryoSerializer() {
51 - .expireAfterWrite(ClusterCommunicationManager.HEART_BEAT_INTERVAL_MILLIS * 3, TimeUnit.MILLISECONDS) 54 + @Override
52 - .removalListener(new LivenessCacheRemovalListener()).build(); 55 + protected void setupKryoPool() {
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 + };
53 66
54 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 67 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
55 private ClusterCommunicationAdminService clusterCommunicationAdminService; 68 private ClusterCommunicationAdminService clusterCommunicationAdminService;
56 69
70 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
71 + private ClusterCommunicationService clusterCommunicator;
72 +
73 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
74 + private ClusterMonitorService clusterMonitor;
75 +
57 private final ClusterNodesDelegate nodesDelegate = new InnerNodesDelegate(); 76 private final ClusterNodesDelegate nodesDelegate = new InnerNodesDelegate();
58 77
59 @Activate 78 @Activate
...@@ -61,10 +80,15 @@ public class DistributedClusterStore ...@@ -61,10 +80,15 @@ public class DistributedClusterStore
61 loadClusterDefinition(); 80 loadClusterDefinition();
62 establishSelfIdentity(); 81 establishSelfIdentity();
63 82
64 - // Start-up the comm service and prime it with the loaded nodes. 83 + clusterCommunicator.addSubscriber(
65 - clusterCommunicationAdminService.initialize(localNode, nodesDelegate); 84 + ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT,
66 - for (DefaultControllerNode node : nodes.values()) { 85 + new ClusterMembershipEventListener());
67 - clusterCommunicationAdminService.addNode(node); 86 +
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);
68 } 92 }
69 log.info("Started"); 93 log.info("Started");
70 } 94 }
...@@ -130,22 +154,78 @@ public class DistributedClusterStore ...@@ -130,22 +154,78 @@ public class DistributedClusterStore
130 @Override 154 @Override
131 public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) { 155 public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) {
132 DefaultControllerNode node = new DefaultControllerNode(nodeId, ip, tcpPort); 156 DefaultControllerNode node = new DefaultControllerNode(nodeId, ip, tcpPort);
133 - nodes.put(nodeId, node); 157 + addNodeInternal(node);
134 - clusterCommunicationAdminService.addNode(node); 158 +
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 +
135 return node; 174 return node;
136 } 175 }
137 176
177 + private void addNodeInternal(ControllerNode node) {
178 + nodes.put(node.id(), node);
179 + }
180 +
138 @Override 181 @Override
139 public void removeNode(NodeId nodeId) { 182 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) {
140 if (nodeId.equals(localNode.id())) { 205 if (nodeId.equals(localNode.id())) {
141 nodes.clear(); 206 nodes.clear();
142 nodes.put(localNode.id(), localNode); 207 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 + }
143 215
144 - } else { 216 + private class ClusterMembershipEventListener implements ClusterMessageHandler {
145 - // Remove the other node. 217 + @Override
146 - DefaultControllerNode node = nodes.remove(nodeId); 218 + public void handle(ClusterMessage message) {
147 - if (node != null) { 219 +
148 - clusterCommunicationAdminService.removeNode(node); 220 + log.info("Received cluster membership event from peer: {}", message.sender());
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());
149 } 229 }
150 } 230 }
151 } 231 }
...@@ -153,13 +233,12 @@ public class DistributedClusterStore ...@@ -153,13 +233,12 @@ public class DistributedClusterStore
153 // Entity to handle back calls from the connection manager. 233 // Entity to handle back calls from the connection manager.
154 private class InnerNodesDelegate implements ClusterNodesDelegate { 234 private class InnerNodesDelegate implements ClusterNodesDelegate {
155 @Override 235 @Override
156 - public DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) { 236 + public ControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
157 - DefaultControllerNode node = nodes.get(nodeId); 237 + ControllerNode node = nodes.get(nodeId);
158 if (node == null) { 238 if (node == null) {
159 node = (DefaultControllerNode) addNode(nodeId, ip, tcpPort); 239 node = (DefaultControllerNode) addNode(nodeId, ip, tcpPort);
160 } 240 }
161 states.put(nodeId, State.ACTIVE); 241 states.put(nodeId, State.ACTIVE);
162 - livenessCache.put(nodeId, node);
163 return node; 242 return node;
164 } 243 }
165 244
...@@ -173,14 +252,4 @@ public class DistributedClusterStore ...@@ -173,14 +252,4 @@ public class DistributedClusterStore
173 removeNode(nodeId); 252 removeNode(nodeId);
174 } 253 }
175 } 254 }
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 - }
186 } 255 }
......
...@@ -4,8 +4,6 @@ import static com.google.common.base.Preconditions.checkArgument; ...@@ -4,8 +4,6 @@ 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;
9 7
10 import org.apache.felix.scr.annotations.Activate; 8 import org.apache.felix.scr.annotations.Activate;
11 import org.apache.felix.scr.annotations.Component; 9 import org.apache.felix.scr.annotations.Component;
...@@ -16,10 +14,6 @@ import org.apache.felix.scr.annotations.Service; ...@@ -16,10 +14,6 @@ import org.apache.felix.scr.annotations.Service;
16 import org.onlab.onos.cluster.ClusterService; 14 import org.onlab.onos.cluster.ClusterService;
17 import org.onlab.onos.cluster.ControllerNode; 15 import org.onlab.onos.cluster.ControllerNode;
18 import org.onlab.onos.cluster.NodeId; 16 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;
23 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 17 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
24 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 18 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
25 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 19 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
...@@ -38,7 +32,7 @@ import org.slf4j.LoggerFactory; ...@@ -38,7 +32,7 @@ import org.slf4j.LoggerFactory;
38 @Component(immediate = true) 32 @Component(immediate = true)
39 @Service 33 @Service
40 public class ClusterCommunicationManager 34 public class ClusterCommunicationManager
41 - implements ClusterCommunicationService, ClusterCommunicationAdminService { 35 + implements ClusterCommunicationService {
42 36
43 private final Logger log = LoggerFactory.getLogger(getClass()); 37 private final Logger log = LoggerFactory.getLogger(getClass());
44 38
...@@ -47,10 +41,6 @@ public class ClusterCommunicationManager ...@@ -47,10 +41,6 @@ public class ClusterCommunicationManager
47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 41 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 private ClusterService clusterService; 42 private ClusterService clusterService;
49 43
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 -
54 // TODO: This probably should not be a OSGi service. 44 // TODO: This probably should not be a OSGi service.
55 private MessagingService messagingService; 45 private MessagingService messagingService;
56 46
...@@ -60,7 +50,6 @@ public class ClusterCommunicationManager ...@@ -60,7 +50,6 @@ public class ClusterCommunicationManager
60 serializerPool = KryoPool.newBuilder() 50 serializerPool = KryoPool.newBuilder()
61 .register(KryoPoolUtil.API) 51 .register(KryoPoolUtil.API)
62 .register(ClusterMessage.class, new ClusterMessageSerializer()) 52 .register(ClusterMessage.class, new ClusterMessageSerializer())
63 - .register(ClusterMembershipEvent.class)
64 .register(byte[].class) 53 .register(byte[].class)
65 .register(MessageSubject.class, new MessageSubjectSerializer()) 54 .register(MessageSubject.class, new MessageSubjectSerializer())
66 .build() 55 .build()
...@@ -134,61 +123,6 @@ public class ClusterCommunicationManager ...@@ -134,61 +123,6 @@ public class ClusterCommunicationManager
134 messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber)); 123 messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber));
135 } 124 }
136 125
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 -
192 private final class InternalClusterMessageHandler implements MessageHandler { 126 private final class InternalClusterMessageHandler implements MessageHandler {
193 127
194 private final ClusterMessageHandler handler; 128 private final ClusterMessageHandler handler;
...@@ -208,4 +142,4 @@ public class ClusterCommunicationManager ...@@ -208,4 +142,4 @@ public class ClusterCommunicationManager
208 } 142 }
209 } 143 }
210 } 144 }
211 -} 145 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -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.store.Timestamp; 6 +import org.onlab.onos.net.device.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.store.VersionedValue; 7 +import org.onlab.onos.net.device.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.store.Timestamp; 7 +import org.onlab.onos.net.device.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.store.Timestamp; 10 +import org.onlab.onos.net.device.Timestamp;
11 -import org.onlab.onos.store.VersionedValue; 11 +import org.onlab.onos.net.device.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.store.Timestamp; 12 +import org.onlab.onos.net.device.Timestamp;
13 -import org.onlab.onos.store.VersionedValue; 13 +import org.onlab.onos.net.device.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;
14 import org.onlab.onos.net.device.DeviceMastershipTerm; 16 import org.onlab.onos.net.device.DeviceMastershipTerm;
15 -import org.onlab.onos.store.ClockProviderService; 17 +import org.onlab.onos.net.device.Timestamp;
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 ClockService, ClockProviderService { 26 +public class DeviceClockManager implements DeviceClockService, DeviceClockProviderService {
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 ClockService, ClockProviderService { ...@@ -51,7 +51,7 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
51 } 51 }
52 52
53 @Override 53 @Override
54 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 54 + public void setDeviceMastershipTerm(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;
29 import org.onlab.onos.net.device.DeviceDescription; 30 import org.onlab.onos.net.device.DeviceDescription;
30 import org.onlab.onos.net.device.DeviceEvent; 31 import org.onlab.onos.net.device.DeviceEvent;
31 import org.onlab.onos.net.device.DeviceStore; 32 import org.onlab.onos.net.device.DeviceStore;
32 import org.onlab.onos.net.device.DeviceStoreDelegate; 33 import org.onlab.onos.net.device.DeviceStoreDelegate;
33 import org.onlab.onos.net.device.PortDescription; 34 import org.onlab.onos.net.device.PortDescription;
35 +import org.onlab.onos.net.device.Timestamp;
36 +import org.onlab.onos.net.device.Timestamped;
34 import org.onlab.onos.net.provider.ProviderId; 37 import org.onlab.onos.net.provider.ProviderId;
35 import org.onlab.onos.store.AbstractStore; 38 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 ClockService clockService; 108 + protected DeviceClockService 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;
5 import org.onlab.onos.net.provider.ProviderId; 6 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;
5 import org.onlab.onos.net.provider.ProviderId; 6 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.store.Timestamp; 4 +import org.onlab.onos.net.device.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.store.Timestamp; 4 +import org.onlab.onos.net.device.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.store.Timestamp; 4 +import org.onlab.onos.net.device.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;
7 import org.onlab.onos.net.provider.ProviderId; 8 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;
7 import org.onlab.onos.net.provider.ProviderId; 8 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;
5 import org.onlab.onos.net.provider.ProviderId; 6 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;
5 import org.onlab.onos.net.provider.ProviderId; 6 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;
26 import org.onlab.onos.net.link.LinkDescription; 29 import org.onlab.onos.net.link.LinkDescription;
27 import org.onlab.onos.net.link.LinkEvent; 30 import org.onlab.onos.net.link.LinkEvent;
28 import org.onlab.onos.net.link.LinkStore; 31 import org.onlab.onos.net.link.LinkStore;
29 import org.onlab.onos.net.link.LinkStoreDelegate; 32 import org.onlab.onos.net.link.LinkStoreDelegate;
30 import org.onlab.onos.net.provider.ProviderId; 33 import org.onlab.onos.net.provider.ProviderId;
31 import org.onlab.onos.store.AbstractStore; 34 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 ClockService clockService; 74 + protected DeviceClockService clockService;
75 75
76 @Activate 76 @Activate
77 public void activate() { 77 public void activate() {
......
...@@ -2,8 +2,6 @@ package org.onlab.onos.store.cluster.impl; ...@@ -2,8 +2,6 @@ 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;
7 import org.onlab.onos.cluster.DefaultControllerNode; 5 import org.onlab.onos.cluster.DefaultControllerNode;
8 import org.onlab.onos.cluster.NodeId; 6 import org.onlab.onos.cluster.NodeId;
9 import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager; 7 import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager;
...@@ -11,12 +9,6 @@ import org.onlab.onos.store.cluster.messaging.impl.MessageSerializer; ...@@ -11,12 +9,6 @@ import org.onlab.onos.store.cluster.messaging.impl.MessageSerializer;
11 import org.onlab.netty.NettyMessagingService; 9 import org.onlab.netty.NettyMessagingService;
12 import org.onlab.packet.IpPrefix; 10 import org.onlab.packet.IpPrefix;
13 11
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 -
20 /** 12 /**
21 * Tests of the cluster communication manager. 13 * Tests of the cluster communication manager.
22 */ 14 */
...@@ -33,9 +25,6 @@ public class ClusterCommunicationManagerTest { ...@@ -33,9 +25,6 @@ public class ClusterCommunicationManagerTest {
33 private ClusterCommunicationManager ccm1; 25 private ClusterCommunicationManager ccm1;
34 private ClusterCommunicationManager ccm2; 26 private ClusterCommunicationManager ccm2;
35 27
36 - private TestDelegate cnd1 = new TestDelegate();
37 - private TestDelegate cnd2 = new TestDelegate();
38 -
39 private DefaultControllerNode node1 = new DefaultControllerNode(N1, IP, P1); 28 private DefaultControllerNode node1 = new DefaultControllerNode(N1, IP, P1);
40 private DefaultControllerNode node2 = new DefaultControllerNode(N2, IP, P2); 29 private DefaultControllerNode node2 = new DefaultControllerNode(N2, IP, P2);
41 30
...@@ -48,15 +37,10 @@ public class ClusterCommunicationManagerTest { ...@@ -48,15 +37,10 @@ public class ClusterCommunicationManagerTest {
48 messagingService.activate(); 37 messagingService.activate();
49 38
50 ccm1 = new ClusterCommunicationManager(); 39 ccm1 = new ClusterCommunicationManager();
51 -// ccm1.serializationService = messageSerializer;
52 ccm1.activate(); 40 ccm1.activate();
53 41
54 ccm2 = new ClusterCommunicationManager(); 42 ccm2 = new ClusterCommunicationManager();
55 -// ccm2.serializationService = messageSerializer;
56 ccm2.activate(); 43 ccm2.activate();
57 -
58 - ccm1.initialize(node1, cnd1);
59 - ccm2.initialize(node2, cnd2);
60 } 44 }
61 45
62 @After 46 @After
...@@ -64,70 +48,4 @@ public class ClusterCommunicationManagerTest { ...@@ -64,70 +48,4 @@ public class ClusterCommunicationManagerTest {
64 ccm1.deactivate(); 48 ccm1.deactivate();
65 ccm2.deactivate(); 49 ccm2.deactivate();
66 } 50 }
67 - 51 +}
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 -}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -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.store.Timestamp; 8 +import org.onlab.onos.net.device.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.store.Timestamp; 8 +import org.onlab.onos.net.device.Timestamp;
9 -import org.onlab.onos.store.Timestamped; 9 +import org.onlab.onos.net.device.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,6 +35,7 @@ import org.onlab.onos.net.PortNumber; ...@@ -35,6 +35,7 @@ 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;
38 import org.onlab.onos.net.device.DeviceDescription; 39 import org.onlab.onos.net.device.DeviceDescription;
39 import org.onlab.onos.net.device.DeviceEvent; 40 import org.onlab.onos.net.device.DeviceEvent;
40 import org.onlab.onos.net.device.DeviceStore; 41 import org.onlab.onos.net.device.DeviceStore;
...@@ -42,7 +43,6 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; ...@@ -42,7 +43,6 @@ import org.onlab.onos.net.device.DeviceStoreDelegate;
42 import org.onlab.onos.net.device.DeviceMastershipTerm; 43 import org.onlab.onos.net.device.DeviceMastershipTerm;
43 import org.onlab.onos.net.device.PortDescription; 44 import org.onlab.onos.net.device.PortDescription;
44 import org.onlab.onos.net.provider.ProviderId; 45 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 ClockService clockService; 99 + private DeviceClockService 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.setMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1)); 116 + deviceClockManager.setDeviceMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1));
117 - deviceClockManager.setMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2)); 117 + deviceClockManager.setDeviceMastershipTerm(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 - ClockService clockService, 559 + DeviceClockService 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;
18 import org.onlab.onos.net.device.DeviceMastershipEvent; 17 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;
...@@ -32,7 +32,7 @@ import com.hazelcast.core.MultiMap; ...@@ -32,7 +32,7 @@ import com.hazelcast.core.MultiMap;
32 */ 32 */
33 @Component(immediate = true) 33 @Component(immediate = true)
34 @Service 34 @Service
35 -public class DistributedMastershipStore 35 +public class DistributedDeviceMastershipStore
36 extends AbstractHazelcastStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate> 36 extends AbstractHazelcastStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate>
37 implements DeviceMastershipStore { 37 implements DeviceMastershipStore {
38 38
...@@ -76,7 +76,7 @@ implements DeviceMastershipStore { ...@@ -76,7 +76,7 @@ implements DeviceMastershipStore {
76 } 76 }
77 77
78 @Override 78 @Override
79 - public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) { 79 + public DeviceMastershipRole 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 MastershipRole.STANDBY; 87 + return DeviceMastershipRole.STANDBY;
88 } else { 88 } else {
89 - return MastershipRole.NONE; 89 + return DeviceMastershipRole.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 MastershipRole.MASTER; 94 + return DeviceMastershipRole.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 MastershipRole.STANDBY; 97 + return DeviceMastershipRole.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 - MastershipRole role = getRole(nodeId, deviceId); 110 + DeviceMastershipRole 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 MastershipRole requestRole(DeviceId deviceId) { 160 + public DeviceMastershipRole 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 - MastershipRole role = getRole(local, deviceId); 168 + DeviceMastershipRole 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 = MastershipRole.MASTER; 182 + role = DeviceMastershipRole.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 - MastershipRole role = getRole(nodeId, deviceId); 213 + DeviceMastershipRole 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 - MastershipRole role = getRole(nodeId, deviceId); 242 + DeviceMastershipRole 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.MastershipRole.*; 6 +import static org.onlab.onos.net.device.DeviceMastershipRole.*;
7 7
8 import java.util.Map; 8 import java.util.Map;
9 import java.util.Set; 9 import java.util.Set;
...@@ -40,7 +40,7 @@ import com.hazelcast.core.Hazelcast; ...@@ -40,7 +40,7 @@ import com.hazelcast.core.Hazelcast;
40 /** 40 /**
41 * Test of the Hazelcast-based distributed MastershipStore implementation. 41 * Test of the Hazelcast-based distributed MastershipStore implementation.
42 */ 42 */
43 -public class DistributedMastershipStoreTest { 43 +public class DistributedDeviceMastershipStoreTest {
44 44
45 private static final DeviceId DID1 = DeviceId.deviceId("of:01"); 45 private static final DeviceId DID1 = DeviceId.deviceId("of:01");
46 private static final DeviceId DID2 = DeviceId.deviceId("of:02"); 46 private static final DeviceId DID2 = DeviceId.deviceId("of:02");
...@@ -54,8 +54,8 @@ public class DistributedMastershipStoreTest { ...@@ -54,8 +54,8 @@ public class DistributedMastershipStoreTest {
54 private static final ControllerNode CN1 = new DefaultControllerNode(N1, IP); 54 private static final ControllerNode CN1 = new DefaultControllerNode(N1, IP);
55 private static final ControllerNode CN2 = new DefaultControllerNode(N2, IP); 55 private static final ControllerNode CN2 = new DefaultControllerNode(N2, IP);
56 56
57 - private DistributedMastershipStore dms; 57 + private DistributedDeviceMastershipStore dms;
58 - private TestDistributedMastershipStore testStore; 58 + private TestDistributedDeviceMastershipStore testStore;
59 private KryoSerializer serializationMgr; 59 private KryoSerializer serializationMgr;
60 private StoreManager storeMgr; 60 private StoreManager storeMgr;
61 61
...@@ -77,11 +77,11 @@ public class DistributedMastershipStoreTest { ...@@ -77,11 +77,11 @@ public class DistributedMastershipStoreTest {
77 77
78 serializationMgr = new KryoSerializer(); 78 serializationMgr = new KryoSerializer();
79 79
80 - dms = new TestDistributedMastershipStore(storeMgr, serializationMgr); 80 + dms = new TestDistributedDeviceMastershipStore(storeMgr, serializationMgr);
81 dms.clusterService = new TestClusterService(); 81 dms.clusterService = new TestClusterService();
82 dms.activate(); 82 dms.activate();
83 83
84 - testStore = (TestDistributedMastershipStore) dms; 84 + testStore = (TestDistributedDeviceMastershipStore) dms;
85 } 85 }
86 86
87 @After 87 @After
...@@ -227,9 +227,9 @@ public class DistributedMastershipStoreTest { ...@@ -227,9 +227,9 @@ public class DistributedMastershipStoreTest {
227 assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); 227 assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
228 } 228 }
229 229
230 - private class TestDistributedMastershipStore extends 230 + private class TestDistributedDeviceMastershipStore extends
231 - DistributedMastershipStore { 231 + DistributedDeviceMastershipStore {
232 - public TestDistributedMastershipStore(StoreService storeService, 232 + public TestDistributedDeviceMastershipStore(StoreService storeService,
233 KryoSerializer kryoSerialization) { 233 KryoSerializer kryoSerialization) {
234 this.storeService = storeService; 234 this.storeService = storeService;
235 this.serializer = kryoSerialization; 235 this.serializer = kryoSerialization;
......
...@@ -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;
6 import org.onlab.onos.net.device.DeviceMastershipTerm; 7 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 ClockProviderService}. 11 + * Dummy implementation of {@link DeviceClockProviderService}.
12 */ 12 */
13 @Component(immediate = true) 13 @Component(immediate = true)
14 @Service 14 @Service
15 -public class NoOpClockProviderService implements ClockProviderService { 15 +public class NoOpClockProviderService implements DeviceClockProviderService {
16 16
17 @Override 17 @Override
18 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 18 + public void setDeviceMastershipTerm(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;
22 import org.onlab.onos.net.Port; 21 import org.onlab.onos.net.Port;
23 import org.onlab.onos.net.PortNumber; 22 import org.onlab.onos.net.PortNumber;
24 import org.onlab.onos.net.device.DefaultDeviceDescription; 23 import org.onlab.onos.net.device.DefaultDeviceDescription;
25 import org.onlab.onos.net.device.DefaultPortDescription; 24 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 - MastershipRole.class, 62 + DeviceMastershipRole.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(MastershipRole.class, new MastershipRoleSerializer()) 78 + .register(DeviceMastershipRole.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.MastershipRole; 3 +import org.onlab.onos.net.device.DeviceMastershipRole;
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.MastershipRole}. 11 + * Kryo Serializer for {@link org.onlab.onos.net.device.DeviceMastershipRole}.
12 */ 12 */
13 -public class MastershipRoleSerializer extends Serializer<MastershipRole> { 13 +public class MastershipRoleSerializer extends Serializer<DeviceMastershipRole> {
14 14
15 /** 15 /**
16 - * Creates {@link MastershipRole} serializer instance. 16 + * Creates {@link DeviceMastershipRole} 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<MastershipRole> { ...@@ -21,13 +21,13 @@ public class MastershipRoleSerializer extends Serializer<MastershipRole> {
21 } 21 }
22 22
23 @Override 23 @Override
24 - public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) { 24 + public DeviceMastershipRole read(Kryo kryo, Input input, Class<DeviceMastershipRole> type) {
25 final String role = kryo.readObject(input, String.class); 25 final String role = kryo.readObject(input, String.class);
26 - return MastershipRole.valueOf(role); 26 + return DeviceMastershipRole.valueOf(role);
27 } 27 }
28 28
29 @Override 29 @Override
30 - public void write(Kryo kryo, Output output, MastershipRole object) { 30 + public void write(Kryo kryo, Output output, DeviceMastershipRole 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;
25 import org.onlab.onos.net.PortNumber; 24 import org.onlab.onos.net.PortNumber;
26 import org.onlab.onos.net.SparseAnnotations; 25 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 (MastershipRole role : MastershipRole.values()) { 118 + for (DeviceMastershipRole role : DeviceMastershipRole.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;
6 import org.onlab.onos.net.device.DeviceMastershipTerm; 7 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 ClockProviderService}. 11 + * Dummy implementation of {@link DeviceClockProviderService}.
12 */ 12 */
13 @Component(immediate = true) 13 @Component(immediate = true)
14 @Service 14 @Service
15 -public class NoOpClockProviderService implements ClockProviderService { 15 +public class NoOpClockProviderService implements DeviceClockProviderService {
16 16
17 @Override 17 @Override
18 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 18 + public void setDeviceMastershipTerm(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;
21 import org.onlab.onos.net.device.DeviceMastershipEvent; 20 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 - MastershipRole role = getRole(nodeId, deviceId); 67 + DeviceMastershipRole 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 MastershipRole requestRole(DeviceId deviceId) { 109 + public DeviceMastershipRole requestRole(DeviceId deviceId) {
110 //query+possible reelection 110 //query+possible reelection
111 NodeId node = instance.id(); 111 NodeId node = instance.id();
112 - MastershipRole role = getRole(node, deviceId); 112 + DeviceMastershipRole 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 = MastershipRole.MASTER; 124 + role = DeviceMastershipRole.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 = MastershipRole.MASTER; 135 + role = DeviceMastershipRole.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 MastershipRole getRole(NodeId nodeId, DeviceId deviceId) { 145 + public DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
146 //just query 146 //just query
147 NodeId current = masterMap.get(deviceId); 147 NodeId current = masterMap.get(deviceId);
148 - MastershipRole role; 148 + DeviceMastershipRole role;
149 149
150 if (current == null) { 150 if (current == null) {
151 if (backups.contains(nodeId)) { 151 if (backups.contains(nodeId)) {
152 - role = MastershipRole.STANDBY; 152 + role = DeviceMastershipRole.STANDBY;
153 } else { 153 } else {
154 - role = MastershipRole.NONE; 154 + role = DeviceMastershipRole.NONE;
155 } 155 }
156 } else { 156 } else {
157 if (current.equals(nodeId)) { 157 if (current.equals(nodeId)) {
158 - role = MastershipRole.MASTER; 158 + role = DeviceMastershipRole.MASTER;
159 } else { 159 } else {
160 - role = MastershipRole.STANDBY; 160 + role = DeviceMastershipRole.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 - MastershipRole role = getRole(nodeId, deviceId); 178 + DeviceMastershipRole 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.*;
19 import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*; 18 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;
11 import org.onlab.onos.net.PortNumber; 10 import org.onlab.onos.net.PortNumber;
12 import org.onlab.onos.net.device.DefaultDeviceDescription; 11 import org.onlab.onos.net.device.DefaultDeviceDescription;
13 import org.onlab.onos.net.device.DefaultPortDescription; 12 import org.onlab.onos.net.device.DefaultPortDescription;
14 import org.onlab.onos.net.device.DeviceDescription; 13 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, MastershipRole newRole) { 94 + public void roleChanged(Device device, DeviceMastershipRole 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 - MastershipRole failed; 147 + DeviceMastershipRole failed;
148 switch (role) { 148 switch (role) {
149 case MASTER: 149 case MASTER:
150 - failed = MastershipRole.MASTER; 150 + failed = DeviceMastershipRole.MASTER;
151 break; 151 break;
152 case EQUAL: 152 case EQUAL:
153 - failed = MastershipRole.STANDBY; 153 + failed = DeviceMastershipRole.STANDBY;
154 break; 154 break;
155 case SLAVE: 155 case SLAVE:
156 - failed = MastershipRole.NONE; 156 + failed = DeviceMastershipRole.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.MastershipRole.*; 8 +import static org.onlab.onos.net.device.DeviceMastershipRole.*;
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;
24 import org.onlab.onos.net.device.DeviceDescription; 23 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<MastershipRole, Dpid> roles = new HashMap<>(); 146 + Map<DeviceMastershipRole, 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, MastershipRole role) { 198 + public void unableToAssertRole(DeviceId deviceId, DeviceMastershipRole role) {
199 roles.put(role, Dpid.dpid(deviceId.uri())); 199 roles.put(role, Dpid.dpid(deviceId.uri()));
200 } 200 }
201 201
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 export ONOS_ROOT=${ONOS_ROOT:-~/onos-next} 6 export ONOS_ROOT=${ONOS_ROOT:-~/onos-next}
7 7
8 # Setup some environmental context for developers 8 # Setup some environmental context for developers
9 -export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) 9 +export JAVA_HOME=${JAVA_HOME:-$(/usr/libexec/java_home -v 1.7)}
10 export MAVEN=${MAVEN:-~/Applications/apache-maven-3.2.2} 10 export MAVEN=${MAVEN:-~/Applications/apache-maven-3.2.2}
11 export KARAF=${KARAF:-~/Applications/apache-karaf-3.0.1} 11 export KARAF=${KARAF:-~/Applications/apache-karaf-3.0.1}
12 export KARAF_LOG=$KARAF/data/log/karaf.log 12 export KARAF_LOG=$KARAF/data/log/karaf.log
......