Yuta HIGUCHI

Revert "Refactoring to move code to right locations. Attempt at breaking dependency cycles."

This reverts commit 58819b4d.
Showing 48 changed files with 226 additions and 233 deletions
1 package org.onlab.onos.cli; 1 package org.onlab.onos.cli;
2 2
3 import com.google.common.collect.Lists; 3 import com.google.common.collect.Lists;
4 -
5 import org.apache.karaf.shell.commands.Command; 4 import org.apache.karaf.shell.commands.Command;
6 import org.onlab.onos.cluster.ClusterService; 5 import org.onlab.onos.cluster.ClusterService;
7 import org.onlab.onos.cluster.ControllerNode; 6 import org.onlab.onos.cluster.ControllerNode;
7 +import org.onlab.onos.cluster.MastershipService;
8 import org.onlab.onos.net.DeviceId; 8 import org.onlab.onos.net.DeviceId;
9 -import org.onlab.onos.net.device.DeviceMastershipService;
10 9
11 import java.util.Collections; 10 import java.util.Collections;
12 import java.util.List; 11 import java.util.List;
...@@ -23,7 +22,7 @@ public class MastersListCommand extends AbstractShellCommand { ...@@ -23,7 +22,7 @@ public class MastersListCommand extends AbstractShellCommand {
23 @Override 22 @Override
24 protected void execute() { 23 protected void execute() {
25 ClusterService service = get(ClusterService.class); 24 ClusterService service = get(ClusterService.class);
26 - DeviceMastershipService mastershipService = get(DeviceMastershipService.class); 25 + MastershipService mastershipService = get(MastershipService.class);
27 List<ControllerNode> nodes = newArrayList(service.getNodes()); 26 List<ControllerNode> nodes = newArrayList(service.getNodes());
28 Collections.sort(nodes, Comparators.NODE_COMPARATOR); 27 Collections.sort(nodes, Comparators.NODE_COMPARATOR);
29 ControllerNode self = service.getLocalNode(); 28 ControllerNode self = service.getLocalNode();
......
...@@ -3,9 +3,9 @@ package org.onlab.onos.cli.net; ...@@ -3,9 +3,9 @@ package org.onlab.onos.cli.net;
3 import org.apache.karaf.shell.commands.Argument; 3 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.MastershipAdminService;
6 import org.onlab.onos.cluster.NodeId; 7 import org.onlab.onos.cluster.NodeId;
7 import org.onlab.onos.net.MastershipRole; 8 import org.onlab.onos.net.MastershipRole;
8 -import org.onlab.onos.net.device.DeviceMastershipAdminService;
9 9
10 import static org.onlab.onos.net.DeviceId.deviceId; 10 import static org.onlab.onos.net.DeviceId.deviceId;
11 11
...@@ -30,7 +30,7 @@ public class DeviceRoleCommand extends AbstractShellCommand { ...@@ -30,7 +30,7 @@ public class DeviceRoleCommand extends AbstractShellCommand {
30 30
31 @Override 31 @Override
32 protected void execute() { 32 protected void execute() {
33 - DeviceMastershipAdminService service = get(DeviceMastershipAdminService.class); 33 + MastershipAdminService service = get(MastershipAdminService.class);
34 MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase()); 34 MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase());
35 service.setRole(new NodeId(node), deviceId(uri), mastershipRole); 35 service.setRole(new NodeId(node), deviceId(uri), mastershipRole);
36 } 36 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 -import org.onlab.onos.cluster.NodeId;
4 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
5 import org.onlab.onos.net.MastershipRole; 4 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.
9 */ 8 */
10 -public interface DeviceMastershipAdminService { 9 +public interface MastershipAdminService {
11 10
12 /** 11 /**
13 * Applies the current mastership role for the specified device. 12 * Applies the current mastership role for the specified device.
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 -import org.onlab.onos.cluster.NodeId;
4 import org.onlab.onos.event.AbstractEvent; 3 import org.onlab.onos.event.AbstractEvent;
5 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
6 5
7 /** 6 /**
8 * Describes a device mastership event. 7 * Describes a device mastership event.
9 */ 8 */
10 -public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.Type, DeviceId> { 9 +public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
11 10
12 //do we worry about explicitly setting slaves/equals? probably not, 11 //do we worry about explicitly setting slaves/equals? probably not,
13 //to keep it simple 12 //to keep it simple
...@@ -31,7 +30,7 @@ public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.T ...@@ -31,7 +30,7 @@ public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.T
31 * @param device event device subject 30 * @param device event device subject
32 * @param master master ID subject 31 * @param master master ID subject
33 */ 32 */
34 - public DeviceMastershipEvent(Type type, DeviceId device, NodeId master) { 33 + public MastershipEvent(Type type, DeviceId device, NodeId master) {
35 super(type, device); 34 super(type, device);
36 this.master = master; 35 this.master = master;
37 } 36 }
...@@ -45,7 +44,7 @@ public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.T ...@@ -45,7 +44,7 @@ public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.T
45 * @param master master ID subject 44 * @param master master ID subject
46 * @param time occurrence time 45 * @param time occurrence time
47 */ 46 */
48 - public DeviceMastershipEvent(Type type, DeviceId device, NodeId master, long time) { 47 + public MastershipEvent(Type type, DeviceId device, NodeId master, long time) {
49 super(type, device, time); 48 super(type, device, time);
50 this.master = master; 49 this.master = master;
51 } 50 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 import org.onlab.onos.event.EventListener; 3 import org.onlab.onos.event.EventListener;
4 4
5 /** 5 /**
6 * Entity capable of receiving device mastership-related events. 6 * Entity capable of receiving device mastership-related events.
7 */ 7 */
8 -public interface DeviceMastershipListener extends EventListener<DeviceMastershipEvent> { 8 +public interface MastershipListener extends EventListener<MastershipEvent> {
9 } 9 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 import java.util.Set; 3 import java.util.Set;
4 4
5 -import org.onlab.onos.cluster.NodeId;
6 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
7 import org.onlab.onos.net.MastershipRole; 6 import org.onlab.onos.net.MastershipRole;
8 7
...@@ -12,7 +11,7 @@ import org.onlab.onos.net.MastershipRole; ...@@ -12,7 +11,7 @@ import org.onlab.onos.net.MastershipRole;
12 * determining mastership, but is not responsible for actually applying it 11 * determining mastership, but is not responsible for actually applying it
13 * to the devices; this falls on the device service. 12 * to the devices; this falls on the device service.
14 */ 13 */
15 -public interface DeviceMastershipService { 14 +public interface MastershipService {
16 15
17 /** 16 /**
18 * Returns the role of the local node for the specified device, without 17 * Returns the role of the local node for the specified device, without
...@@ -63,20 +62,20 @@ public interface DeviceMastershipService { ...@@ -63,20 +62,20 @@ public interface DeviceMastershipService {
63 * 62 *
64 * @return the MastershipTermService for this mastership manager 63 * @return the MastershipTermService for this mastership manager
65 */ 64 */
66 - DeviceMastershipTermService requestTermService(); 65 + MastershipTermService requestTermService();
67 66
68 /** 67 /**
69 * Adds the specified mastership change listener. 68 * Adds the specified mastership change listener.
70 * 69 *
71 * @param listener the mastership listener 70 * @param listener the mastership listener
72 */ 71 */
73 - void addListener(DeviceMastershipListener listener); 72 + void addListener(MastershipListener listener);
74 73
75 /** 74 /**
76 * Removes the specified mastership change listener. 75 * Removes the specified mastership change listener.
77 * 76 *
78 * @param listener the mastership listener 77 * @param listener the mastership listener
79 */ 78 */
80 - void removeListener(DeviceMastershipListener listener); 79 + void removeListener(MastershipListener listener);
81 80
82 } 81 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 import java.util.Set; 3 import java.util.Set;
4 4
5 -import org.onlab.onos.cluster.NodeId;
6 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
7 import org.onlab.onos.net.MastershipRole; 6 import org.onlab.onos.net.MastershipRole;
8 import org.onlab.onos.store.Store; 7 import org.onlab.onos.store.Store;
...@@ -11,7 +10,7 @@ import org.onlab.onos.store.Store; ...@@ -11,7 +10,7 @@ import org.onlab.onos.store.Store;
11 * Manages inventory of mastership roles for devices, across controller 10 * Manages inventory of mastership roles for devices, across controller
12 * instances; not intended for direct use. 11 * instances; not intended for direct use.
13 */ 12 */
14 -public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, DeviceMastershipStoreDelegate> { 13 +public interface MastershipStore extends Store<MastershipEvent, MastershipStoreDelegate> {
15 14
16 // three things to map: NodeId, DeviceId, MastershipRole 15 // three things to map: NodeId, DeviceId, MastershipRole
17 16
...@@ -55,7 +54,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -55,7 +54,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
55 * @param deviceId device identifier 54 * @param deviceId device identifier
56 * @return a mastership event 55 * @return a mastership event
57 */ 56 */
58 - DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId); 57 + MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId);
59 58
60 /** 59 /**
61 * Returns the current master and number of past mastership hand-offs 60 * Returns the current master and number of past mastership hand-offs
...@@ -64,7 +63,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -64,7 +63,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
64 * @param deviceId the device identifier 63 * @param deviceId the device identifier
65 * @return the current master's ID and the term value for device, or null 64 * @return the current master's ID and the term value for device, or null
66 */ 65 */
67 - DeviceMastershipTerm getTermFor(DeviceId deviceId); 66 + MastershipTerm getTermFor(DeviceId deviceId);
68 67
69 /** 68 /**
70 * Sets a controller instance's mastership role to STANDBY for a device. 69 * Sets a controller instance's mastership role to STANDBY for a device.
...@@ -75,7 +74,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -75,7 +74,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
75 * @param deviceId device to revoke mastership role for 74 * @param deviceId device to revoke mastership role for
76 * @return a mastership event 75 * @return a mastership event
77 */ 76 */
78 - DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId); 77 + MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId);
79 78
80 /** 79 /**
81 * Allows a controller instance to give up its current role for a device. 80 * Allows a controller instance to give up its current role for a device.
...@@ -86,6 +85,6 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi ...@@ -86,6 +85,6 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
86 * @param deviceId device to revoke mastership role for 85 * @param deviceId device to revoke mastership role for
87 * @return a mastership event 86 * @return a mastership event
88 */ 87 */
89 - DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId); 88 + MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId);
90 89
91 } 90 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 import org.onlab.onos.store.StoreDelegate; 3 import org.onlab.onos.store.StoreDelegate;
4 4
5 /** 5 /**
6 - * DeviceMastership store delegate abstraction. 6 + * Mastership store delegate abstraction.
7 */ 7 */
8 -public interface DeviceMastershipStoreDelegate extends StoreDelegate<DeviceMastershipEvent> { 8 +public interface MastershipStoreDelegate extends StoreDelegate<MastershipEvent> {
9 } 9 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
2 2
3 import java.util.Objects; 3 import java.util.Objects;
4 4
5 -import org.onlab.onos.cluster.NodeId; 5 +public final class MastershipTerm {
6 -
7 -public final class DeviceMastershipTerm {
8 6
9 private final NodeId master; 7 private final NodeId master;
10 private final int termNumber; 8 private final int termNumber;
11 9
12 - private DeviceMastershipTerm(NodeId master, int term) { 10 + private MastershipTerm(NodeId master, int term) {
13 this.master = master; 11 this.master = master;
14 this.termNumber = term; 12 this.termNumber = term;
15 } 13 }
16 14
17 - public static DeviceMastershipTerm of(NodeId master, int term) { 15 + public static MastershipTerm of(NodeId master, int term) {
18 - return new DeviceMastershipTerm(master, term); 16 + return new MastershipTerm(master, term);
19 } 17 }
20 18
21 public NodeId master() { 19 public NodeId master() {
...@@ -36,8 +34,8 @@ public final class DeviceMastershipTerm { ...@@ -36,8 +34,8 @@ public final class DeviceMastershipTerm {
36 if (this == other) { 34 if (this == other) {
37 return true; 35 return true;
38 } 36 }
39 - if (other instanceof DeviceMastershipTerm) { 37 + if (other instanceof MastershipTerm) {
40 - DeviceMastershipTerm that = (DeviceMastershipTerm) other; 38 + MastershipTerm that = (MastershipTerm) other;
41 if (!this.master.equals(that.master)) { 39 if (!this.master.equals(that.master)) {
42 return false; 40 return false;
43 } 41 }
......
1 -package org.onlab.onos.net.device; 1 +package org.onlab.onos.cluster;
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 * Service to obtain mastership term information. 7 * Service to obtain mastership term information.
8 */ 8 */
9 -public interface DeviceMastershipTermService { 9 +public interface MastershipTermService {
10 10
11 // TBD: manage/increment per device mastership change 11 // TBD: manage/increment per device mastership change
12 // or increment on any change 12 // or increment on any change
...@@ -16,5 +16,5 @@ public interface DeviceMastershipTermService { ...@@ -16,5 +16,5 @@ public interface DeviceMastershipTermService {
16 * @param deviceId the identifier of the device 16 * @param deviceId the identifier of the device
17 * @return current master's term. 17 * @return current master's term.
18 */ 18 */
19 - DeviceMastershipTerm getMastershipTerm(DeviceId deviceId); 19 + MastershipTerm getMastershipTerm(DeviceId deviceId);
20 } 20 }
......
1 package org.onlab.onos.store; 1 package org.onlab.onos.store;
2 2
3 +import org.onlab.onos.cluster.MastershipTerm;
3 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
4 -import org.onlab.onos.net.device.DeviceMastershipTerm;
5 5
6 //TODO: Consider renaming to DeviceClockProviderService? 6 //TODO: Consider renaming to DeviceClockProviderService?
7 /** 7 /**
...@@ -16,5 +16,5 @@ public interface ClockProviderService { ...@@ -16,5 +16,5 @@ public interface ClockProviderService {
16 * @param deviceId device identifier. 16 * @param deviceId device identifier.
17 * @param term mastership term. 17 * @param term mastership term.
18 */ 18 */
19 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term); 19 + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term);
20 } 20 }
......
...@@ -2,16 +2,13 @@ package org.onlab.onos.cluster; ...@@ -2,16 +2,13 @@ package org.onlab.onos.cluster;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.MastershipRole; 4 import org.onlab.onos.net.MastershipRole;
5 -import org.onlab.onos.net.device.DeviceMastershipListener;
6 -import org.onlab.onos.net.device.DeviceMastershipService;
7 -import org.onlab.onos.net.device.DeviceMastershipTermService;
8 5
9 import java.util.Set; 6 import java.util.Set;
10 7
11 /** 8 /**
12 * Test adapter for mastership service. 9 * Test adapter for mastership service.
13 */ 10 */
14 -public class MastershipServiceAdapter implements DeviceMastershipService { 11 +public class MastershipServiceAdapter implements MastershipService {
15 @Override 12 @Override
16 public MastershipRole getLocalRole(DeviceId deviceId) { 13 public MastershipRole getLocalRole(DeviceId deviceId) {
17 return null; 14 return null;
...@@ -37,15 +34,15 @@ public class MastershipServiceAdapter implements DeviceMastershipService { ...@@ -37,15 +34,15 @@ public class MastershipServiceAdapter implements DeviceMastershipService {
37 } 34 }
38 35
39 @Override 36 @Override
40 - public void addListener(DeviceMastershipListener listener) { 37 + public void addListener(MastershipListener listener) {
41 } 38 }
42 39
43 @Override 40 @Override
44 - public void removeListener(DeviceMastershipListener listener) { 41 + public void removeListener(MastershipListener listener) {
45 } 42 }
46 43
47 @Override 44 @Override
48 - public DeviceMastershipTermService requestTermService() { 45 + public MastershipTermService requestTermService() {
49 return null; 46 return null;
50 } 47 }
51 } 48 }
......
...@@ -3,7 +3,6 @@ package org.onlab.onos.cluster; ...@@ -3,7 +3,6 @@ package org.onlab.onos.cluster;
3 import static org.junit.Assert.assertEquals; 3 import static org.junit.Assert.assertEquals;
4 4
5 import org.junit.Test; 5 import org.junit.Test;
6 -import org.onlab.onos.net.device.DeviceMastershipTerm;
7 6
8 import com.google.common.testing.EqualsTester; 7 import com.google.common.testing.EqualsTester;
9 8
...@@ -12,10 +11,10 @@ public class MastershipTermTest { ...@@ -12,10 +11,10 @@ public class MastershipTermTest {
12 private static final NodeId N1 = new NodeId("foo"); 11 private static final NodeId N1 = new NodeId("foo");
13 private static final NodeId N2 = new NodeId("bar"); 12 private static final NodeId N2 = new NodeId("bar");
14 13
15 - private static final DeviceMastershipTerm TERM1 = DeviceMastershipTerm.of(N1, 0); 14 + private static final MastershipTerm TERM1 = MastershipTerm.of(N1, 0);
16 - private static final DeviceMastershipTerm TERM2 = DeviceMastershipTerm.of(N2, 1); 15 + private static final MastershipTerm TERM2 = MastershipTerm.of(N2, 1);
17 - private static final DeviceMastershipTerm TERM3 = DeviceMastershipTerm.of(N2, 1); 16 + private static final MastershipTerm TERM3 = MastershipTerm.of(N2, 1);
18 - private static final DeviceMastershipTerm TERM4 = DeviceMastershipTerm.of(N1, 1); 17 + private static final MastershipTerm TERM4 = MastershipTerm.of(N1, 1);
19 18
20 @Test 19 @Test
21 public void basics() { 20 public void basics() {
...@@ -25,7 +24,7 @@ public class MastershipTermTest { ...@@ -25,7 +24,7 @@ public class MastershipTermTest {
25 24
26 @Test 25 @Test
27 public void testEquality() { 26 public void testEquality() {
28 - new EqualsTester().addEqualityGroup(DeviceMastershipTerm.of(N1, 0), TERM1) 27 + new EqualsTester().addEqualityGroup(MastershipTerm.of(N1, 0), TERM1)
29 .addEqualityGroup(TERM2, TERM3) 28 .addEqualityGroup(TERM2, TERM3)
30 .addEqualityGroup(TERM4); 29 .addEqualityGroup(TERM4);
31 } 30 }
......
...@@ -14,25 +14,25 @@ import org.apache.felix.scr.annotations.Service; ...@@ -14,25 +14,25 @@ import org.apache.felix.scr.annotations.Service;
14 import org.onlab.onos.cluster.ClusterEvent; 14 import org.onlab.onos.cluster.ClusterEvent;
15 import org.onlab.onos.cluster.ClusterEventListener; 15 import org.onlab.onos.cluster.ClusterEventListener;
16 import org.onlab.onos.cluster.ClusterService; 16 import org.onlab.onos.cluster.ClusterService;
17 +import org.onlab.onos.cluster.MastershipAdminService;
18 +import org.onlab.onos.cluster.MastershipEvent;
19 +import org.onlab.onos.cluster.MastershipListener;
20 +import org.onlab.onos.cluster.MastershipService;
21 +import org.onlab.onos.cluster.MastershipStore;
22 +import org.onlab.onos.cluster.MastershipStoreDelegate;
23 +import org.onlab.onos.cluster.MastershipTerm;
24 +import org.onlab.onos.cluster.MastershipTermService;
17 import org.onlab.onos.cluster.NodeId; 25 import org.onlab.onos.cluster.NodeId;
18 import org.onlab.onos.event.AbstractListenerRegistry; 26 import org.onlab.onos.event.AbstractListenerRegistry;
19 import org.onlab.onos.event.EventDeliveryService; 27 import org.onlab.onos.event.EventDeliveryService;
20 import org.onlab.onos.net.DeviceId; 28 import org.onlab.onos.net.DeviceId;
21 import org.onlab.onos.net.MastershipRole; 29 import org.onlab.onos.net.MastershipRole;
22 -import org.onlab.onos.net.device.DeviceMastershipAdminService;
23 -import org.onlab.onos.net.device.DeviceMastershipEvent;
24 -import org.onlab.onos.net.device.DeviceMastershipListener;
25 -import org.onlab.onos.net.device.DeviceMastershipService;
26 -import org.onlab.onos.net.device.DeviceMastershipStore;
27 -import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
28 -import org.onlab.onos.net.device.DeviceMastershipTerm;
29 -import org.onlab.onos.net.device.DeviceMastershipTermService;
30 import org.slf4j.Logger; 30 import org.slf4j.Logger;
31 31
32 @Component(immediate = true) 32 @Component(immediate = true)
33 @Service 33 @Service
34 public class MastershipManager 34 public class MastershipManager
35 -implements DeviceMastershipService, DeviceMastershipAdminService { 35 +implements MastershipService, MastershipAdminService {
36 36
37 private static final String NODE_ID_NULL = "Node ID cannot be null"; 37 private static final String NODE_ID_NULL = "Node ID cannot be null";
38 private static final String DEVICE_ID_NULL = "Device ID cannot be null"; 38 private static final String DEVICE_ID_NULL = "Device ID cannot be null";
...@@ -40,13 +40,13 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -40,13 +40,13 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
40 40
41 private final Logger log = getLogger(getClass()); 41 private final Logger log = getLogger(getClass());
42 42
43 - protected final AbstractListenerRegistry<DeviceMastershipEvent, DeviceMastershipListener> 43 + protected final AbstractListenerRegistry<MastershipEvent, MastershipListener>
44 listenerRegistry = new AbstractListenerRegistry<>(); 44 listenerRegistry = new AbstractListenerRegistry<>();
45 45
46 - private final DeviceMastershipStoreDelegate delegate = new InternalDelegate(); 46 + private final MastershipStoreDelegate delegate = new InternalDelegate();
47 47
48 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 48 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
49 - protected DeviceMastershipStore store; 49 + protected MastershipStore store;
50 50
51 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 51 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
52 protected EventDeliveryService eventDispatcher; 52 protected EventDeliveryService eventDispatcher;
...@@ -58,7 +58,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -58,7 +58,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
58 58
59 @Activate 59 @Activate
60 public void activate() { 60 public void activate() {
61 - eventDispatcher.addSink(DeviceMastershipEvent.class, listenerRegistry); 61 + eventDispatcher.addSink(MastershipEvent.class, listenerRegistry);
62 clusterService.addListener(clusterListener); 62 clusterService.addListener(clusterListener);
63 store.setDelegate(delegate); 63 store.setDelegate(delegate);
64 log.info("Started"); 64 log.info("Started");
...@@ -66,7 +66,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -66,7 +66,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
66 66
67 @Deactivate 67 @Deactivate
68 public void deactivate() { 68 public void deactivate() {
69 - eventDispatcher.removeSink(DeviceMastershipEvent.class); 69 + eventDispatcher.removeSink(MastershipEvent.class);
70 clusterService.removeListener(clusterListener); 70 clusterService.removeListener(clusterListener);
71 store.unsetDelegate(delegate); 71 store.unsetDelegate(delegate);
72 log.info("Stopped"); 72 log.info("Stopped");
...@@ -78,7 +78,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -78,7 +78,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
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 + MastershipEvent event = null;
82 if (role.equals(MastershipRole.MASTER)) { 82 if (role.equals(MastershipRole.MASTER)) {
83 event = store.setMaster(nodeId, deviceId); 83 event = store.setMaster(nodeId, deviceId);
84 } else { 84 } else {
...@@ -98,7 +98,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -98,7 +98,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
98 98
99 @Override 99 @Override
100 public void relinquishMastership(DeviceId deviceId) { 100 public void relinquishMastership(DeviceId deviceId) {
101 - DeviceMastershipEvent event = null; 101 + MastershipEvent event = null;
102 event = store.relinquishRole( 102 event = store.relinquishRole(
103 clusterService.getLocalNode().id(), deviceId); 103 clusterService.getLocalNode().id(), deviceId);
104 104
...@@ -127,18 +127,18 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -127,18 +127,18 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
127 127
128 128
129 @Override 129 @Override
130 - public DeviceMastershipTermService requestTermService() { 130 + public MastershipTermService requestTermService() {
131 return new InternalMastershipTermService(); 131 return new InternalMastershipTermService();
132 } 132 }
133 133
134 @Override 134 @Override
135 - public void addListener(DeviceMastershipListener listener) { 135 + public void addListener(MastershipListener listener) {
136 checkNotNull(listener); 136 checkNotNull(listener);
137 listenerRegistry.addListener(listener); 137 listenerRegistry.addListener(listener);
138 } 138 }
139 139
140 @Override 140 @Override
141 - public void removeListener(DeviceMastershipListener listener) { 141 + public void removeListener(MastershipListener listener) {
142 checkNotNull(listener); 142 checkNotNull(listener);
143 listenerRegistry.removeListener(listener); 143 listenerRegistry.removeListener(listener);
144 } 144 }
...@@ -146,16 +146,16 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -146,16 +146,16 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
146 // FIXME: provide wiring to allow events to be triggered by changes within the store 146 // FIXME: provide wiring to allow events to be triggered by changes within the store
147 147
148 // Posts the specified event to the local event dispatcher. 148 // Posts the specified event to the local event dispatcher.
149 - private void post(DeviceMastershipEvent event) { 149 + private void post(MastershipEvent event) {
150 if (event != null && eventDispatcher != null) { 150 if (event != null && eventDispatcher != null) {
151 eventDispatcher.post(event); 151 eventDispatcher.post(event);
152 } 152 }
153 } 153 }
154 154
155 - private class InternalMastershipTermService implements DeviceMastershipTermService { 155 + private class InternalMastershipTermService implements MastershipTermService {
156 156
157 @Override 157 @Override
158 - public DeviceMastershipTerm getMastershipTerm(DeviceId deviceId) { 158 + public MastershipTerm getMastershipTerm(DeviceId deviceId) {
159 return store.getTermFor(deviceId); 159 return store.getTermFor(deviceId);
160 } 160 }
161 161
...@@ -181,10 +181,10 @@ implements DeviceMastershipService, DeviceMastershipAdminService { ...@@ -181,10 +181,10 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
181 181
182 } 182 }
183 183
184 - public class InternalDelegate implements DeviceMastershipStoreDelegate { 184 + public class InternalDelegate implements MastershipStoreDelegate {
185 185
186 @Override 186 @Override
187 - public void notify(DeviceMastershipEvent event) { 187 + public void notify(MastershipEvent event) {
188 log.info("dispatching mastership event {}", event); 188 log.info("dispatching mastership event {}", event);
189 eventDispatcher.post(event); 189 eventDispatcher.post(event);
190 } 190 }
......
...@@ -13,6 +13,11 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -13,6 +13,11 @@ import org.apache.felix.scr.annotations.Reference;
13 import org.apache.felix.scr.annotations.ReferenceCardinality; 13 import org.apache.felix.scr.annotations.ReferenceCardinality;
14 import org.apache.felix.scr.annotations.Service; 14 import org.apache.felix.scr.annotations.Service;
15 import org.onlab.onos.cluster.ClusterService; 15 import org.onlab.onos.cluster.ClusterService;
16 +import org.onlab.onos.cluster.MastershipEvent;
17 +import org.onlab.onos.cluster.MastershipListener;
18 +import org.onlab.onos.cluster.MastershipService;
19 +import org.onlab.onos.cluster.MastershipTermService;
20 +import org.onlab.onos.cluster.MastershipTerm;
16 import org.onlab.onos.cluster.NodeId; 21 import org.onlab.onos.cluster.NodeId;
17 import org.onlab.onos.event.AbstractListenerRegistry; 22 import org.onlab.onos.event.AbstractListenerRegistry;
18 import org.onlab.onos.event.EventDeliveryService; 23 import org.onlab.onos.event.EventDeliveryService;
...@@ -31,11 +36,6 @@ import org.onlab.onos.net.device.DeviceProviderService; ...@@ -31,11 +36,6 @@ import org.onlab.onos.net.device.DeviceProviderService;
31 import org.onlab.onos.net.device.DeviceService; 36 import org.onlab.onos.net.device.DeviceService;
32 import org.onlab.onos.net.device.DeviceStore; 37 import org.onlab.onos.net.device.DeviceStore;
33 import org.onlab.onos.net.device.DeviceStoreDelegate; 38 import org.onlab.onos.net.device.DeviceStoreDelegate;
34 -import org.onlab.onos.net.device.DeviceMastershipEvent;
35 -import org.onlab.onos.net.device.DeviceMastershipListener;
36 -import org.onlab.onos.net.device.DeviceMastershipService;
37 -import org.onlab.onos.net.device.DeviceMastershipTerm;
38 -import org.onlab.onos.net.device.DeviceMastershipTermService;
39 import org.onlab.onos.net.device.PortDescription; 39 import org.onlab.onos.net.device.PortDescription;
40 import org.onlab.onos.net.provider.AbstractProviderRegistry; 40 import org.onlab.onos.net.provider.AbstractProviderRegistry;
41 import org.onlab.onos.net.provider.AbstractProviderService; 41 import org.onlab.onos.net.provider.AbstractProviderService;
...@@ -64,7 +64,7 @@ public class DeviceManager ...@@ -64,7 +64,7 @@ public class DeviceManager
64 64
65 private final DeviceStoreDelegate delegate = new InternalStoreDelegate(); 65 private final DeviceStoreDelegate delegate = new InternalStoreDelegate();
66 66
67 - private final DeviceMastershipListener mastershipListener = new InternalMastershipListener(); 67 + private final MastershipListener mastershipListener = new InternalMastershipListener();
68 68
69 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 69 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
70 protected DeviceStore store; 70 protected DeviceStore store;
...@@ -76,9 +76,9 @@ public class DeviceManager ...@@ -76,9 +76,9 @@ public class DeviceManager
76 protected ClusterService clusterService; 76 protected ClusterService clusterService;
77 77
78 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 78 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
79 - protected DeviceMastershipService mastershipService; 79 + protected MastershipService mastershipService;
80 80
81 - protected DeviceMastershipTermService termService; 81 + protected MastershipTermService termService;
82 82
83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 protected ClockProviderService clockProviderService; 84 protected ClockProviderService clockProviderService;
...@@ -209,7 +209,7 @@ public class DeviceManager ...@@ -209,7 +209,7 @@ public class DeviceManager
209 return; 209 return;
210 } 210 }
211 211
212 - DeviceMastershipTerm term = mastershipService.requestTermService() 212 + MastershipTerm term = mastershipService.requestTermService()
213 .getMastershipTerm(deviceId); 213 .getMastershipTerm(deviceId);
214 if (!term.master().equals(clusterService.getLocalNode().id())) { 214 if (!term.master().equals(clusterService.getLocalNode().id())) {
215 // lost mastership after requestRole told this instance was MASTER. 215 // lost mastership after requestRole told this instance was MASTER.
...@@ -320,16 +320,16 @@ public class DeviceManager ...@@ -320,16 +320,16 @@ public class DeviceManager
320 } 320 }
321 321
322 // Intercepts mastership events 322 // Intercepts mastership events
323 - private class InternalMastershipListener implements DeviceMastershipListener { 323 + private class InternalMastershipListener implements MastershipListener {
324 324
325 @Override 325 @Override
326 - public void event(DeviceMastershipEvent event) { 326 + public void event(MastershipEvent event) {
327 final DeviceId did = event.subject(); 327 final DeviceId did = event.subject();
328 if (isAvailable(did)) { 328 if (isAvailable(did)) {
329 final NodeId myNodeId = clusterService.getLocalNode().id(); 329 final NodeId myNodeId = clusterService.getLocalNode().id();
330 330
331 if (myNodeId.equals(event.master())) { 331 if (myNodeId.equals(event.master())) {
332 - DeviceMastershipTerm term = termService.getMastershipTerm(did); 332 + MastershipTerm term = termService.getMastershipTerm(did);
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
......
...@@ -10,11 +10,11 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -10,11 +10,11 @@ import org.onlab.onos.cluster.ClusterService;
10 import org.onlab.onos.cluster.ControllerNode; 10 import org.onlab.onos.cluster.ControllerNode;
11 import org.onlab.onos.cluster.ControllerNode.State; 11 import org.onlab.onos.cluster.ControllerNode.State;
12 import org.onlab.onos.cluster.DefaultControllerNode; 12 import org.onlab.onos.cluster.DefaultControllerNode;
13 +import org.onlab.onos.cluster.MastershipService;
14 +import org.onlab.onos.cluster.MastershipTermService;
13 import org.onlab.onos.cluster.NodeId; 15 import org.onlab.onos.cluster.NodeId;
14 import org.onlab.onos.event.impl.TestEventDispatcher; 16 import org.onlab.onos.event.impl.TestEventDispatcher;
15 import org.onlab.onos.net.DeviceId; 17 import org.onlab.onos.net.DeviceId;
16 -import org.onlab.onos.net.device.DeviceMastershipService;
17 -import org.onlab.onos.net.device.DeviceMastershipTermService;
18 import org.onlab.onos.store.trivial.impl.SimpleMastershipStore; 18 import org.onlab.onos.store.trivial.impl.SimpleMastershipStore;
19 import org.onlab.packet.IpPrefix; 19 import org.onlab.packet.IpPrefix;
20 20
...@@ -34,7 +34,7 @@ public class MastershipManagerTest { ...@@ -34,7 +34,7 @@ public class MastershipManagerTest {
34 private static final DeviceId DEV_OTHER = DeviceId.deviceId("of:2"); 34 private static final DeviceId DEV_OTHER = DeviceId.deviceId("of:2");
35 35
36 private MastershipManager mgr; 36 private MastershipManager mgr;
37 - protected DeviceMastershipService service; 37 + protected MastershipService service;
38 38
39 @Before 39 @Before
40 public void setUp() { 40 public void setUp() {
...@@ -120,7 +120,7 @@ public class MastershipManagerTest { ...@@ -120,7 +120,7 @@ public class MastershipManagerTest {
120 120
121 @Test 121 @Test
122 public void termService() { 122 public void termService() {
123 - DeviceMastershipTermService ts = mgr.requestTermService(); 123 + MastershipTermService ts = mgr.requestTermService();
124 124
125 //term = 0 for both 125 //term = 0 for both
126 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER); 126 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
......
...@@ -11,6 +11,8 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -11,6 +11,8 @@ import org.onlab.onos.cluster.ClusterService;
11 import org.onlab.onos.cluster.ControllerNode; 11 import org.onlab.onos.cluster.ControllerNode;
12 import org.onlab.onos.cluster.DefaultControllerNode; 12 import org.onlab.onos.cluster.DefaultControllerNode;
13 import org.onlab.onos.cluster.MastershipServiceAdapter; 13 import org.onlab.onos.cluster.MastershipServiceAdapter;
14 +import org.onlab.onos.cluster.MastershipTerm;
15 +import org.onlab.onos.cluster.MastershipTermService;
14 import org.onlab.onos.cluster.NodeId; 16 import org.onlab.onos.cluster.NodeId;
15 import org.onlab.onos.cluster.ControllerNode.State; 17 import org.onlab.onos.cluster.ControllerNode.State;
16 import org.onlab.onos.event.Event; 18 import org.onlab.onos.event.Event;
...@@ -30,8 +32,6 @@ import org.onlab.onos.net.device.DeviceProvider; ...@@ -30,8 +32,6 @@ import org.onlab.onos.net.device.DeviceProvider;
30 import org.onlab.onos.net.device.DeviceProviderRegistry; 32 import org.onlab.onos.net.device.DeviceProviderRegistry;
31 import org.onlab.onos.net.device.DeviceProviderService; 33 import org.onlab.onos.net.device.DeviceProviderService;
32 import org.onlab.onos.net.device.DeviceService; 34 import org.onlab.onos.net.device.DeviceService;
33 -import org.onlab.onos.net.device.DeviceMastershipTerm;
34 -import org.onlab.onos.net.device.DeviceMastershipTermService;
35 import org.onlab.onos.net.device.PortDescription; 35 import org.onlab.onos.net.device.PortDescription;
36 import org.onlab.onos.net.provider.AbstractProvider; 36 import org.onlab.onos.net.provider.AbstractProvider;
37 import org.onlab.onos.net.provider.ProviderId; 37 import org.onlab.onos.net.provider.ProviderId;
...@@ -290,12 +290,12 @@ public class DeviceManagerTest { ...@@ -290,12 +290,12 @@ public class DeviceManagerTest {
290 } 290 }
291 291
292 @Override 292 @Override
293 - public DeviceMastershipTermService requestTermService() { 293 + public MastershipTermService requestTermService() {
294 - return new DeviceMastershipTermService() { 294 + return new MastershipTermService() {
295 @Override 295 @Override
296 - public DeviceMastershipTerm getMastershipTerm(DeviceId deviceId) { 296 + public MastershipTerm getMastershipTerm(DeviceId deviceId) {
297 // FIXME: just returning something not null 297 // FIXME: just returning something not null
298 - return DeviceMastershipTerm.of(NID_LOCAL, 1); 298 + return MastershipTerm.of(NID_LOCAL, 1);
299 } 299 }
300 }; 300 };
301 } 301 }
...@@ -339,7 +339,7 @@ public class DeviceManagerTest { ...@@ -339,7 +339,7 @@ public class DeviceManagerTest {
339 ClockProviderService { 339 ClockProviderService {
340 340
341 @Override 341 @Override
342 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 342 + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
343 // TODO Auto-generated method stub 343 // TODO Auto-generated method stub
344 } 344 }
345 } 345 }
......
...@@ -6,7 +6,6 @@ import java.io.IOException; ...@@ -6,7 +6,6 @@ import java.io.IOException;
6 import java.util.Set; 6 import java.util.Set;
7 import java.util.Timer; 7 import java.util.Timer;
8 import java.util.TimerTask; 8 import java.util.TimerTask;
9 -
10 import org.apache.felix.scr.annotations.Activate; 9 import org.apache.felix.scr.annotations.Activate;
11 import org.apache.felix.scr.annotations.Component; 10 import org.apache.felix.scr.annotations.Component;
12 import org.apache.felix.scr.annotations.Deactivate; 11 import org.apache.felix.scr.annotations.Deactivate;
...@@ -24,8 +23,10 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; ...@@ -24,8 +23,10 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
24 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 23 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
25 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 24 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
26 import org.onlab.onos.store.cluster.messaging.MessageSubject; 25 import org.onlab.onos.store.cluster.messaging.MessageSubject;
26 +import org.onlab.onos.store.serializers.ClusterMessageSerializer;
27 import org.onlab.onos.store.serializers.KryoPoolUtil; 27 import org.onlab.onos.store.serializers.KryoPoolUtil;
28 import org.onlab.onos.store.serializers.KryoSerializer; 28 import org.onlab.onos.store.serializers.KryoSerializer;
29 +import org.onlab.onos.store.serializers.MessageSubjectSerializer;
29 import org.onlab.util.KryoPool; 30 import org.onlab.util.KryoPool;
30 import org.onlab.netty.Endpoint; 31 import org.onlab.netty.Endpoint;
31 import org.onlab.netty.Message; 32 import org.onlab.netty.Message;
......
...@@ -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.store.device.impl.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;
......
...@@ -13,7 +13,7 @@ import com.google.common.collect.ComparisonChain; ...@@ -13,7 +13,7 @@ import com.google.common.collect.ComparisonChain;
13 * Default implementation of Timestamp. 13 * Default implementation of Timestamp.
14 * TODO: Better documentation. 14 * TODO: Better documentation.
15 */ 15 */
16 -public final class DeviceMastershipBasedTimestamp implements Timestamp { 16 +public final class MastershipBasedTimestamp implements Timestamp {
17 17
18 private final int termNumber; 18 private final int termNumber;
19 private final int sequenceNumber; 19 private final int sequenceNumber;
...@@ -24,16 +24,16 @@ public final class DeviceMastershipBasedTimestamp implements Timestamp { ...@@ -24,16 +24,16 @@ public final class DeviceMastershipBasedTimestamp implements Timestamp {
24 * @param termNumber the mastership termNumber 24 * @param termNumber the mastership termNumber
25 * @param sequenceNumber the sequenceNumber number within the termNumber 25 * @param sequenceNumber the sequenceNumber number within the termNumber
26 */ 26 */
27 - public DeviceMastershipBasedTimestamp(int termNumber, int sequenceNumber) { 27 + public MastershipBasedTimestamp(int termNumber, int sequenceNumber) {
28 this.termNumber = termNumber; 28 this.termNumber = termNumber;
29 this.sequenceNumber = sequenceNumber; 29 this.sequenceNumber = sequenceNumber;
30 } 30 }
31 31
32 @Override 32 @Override
33 public int compareTo(Timestamp o) { 33 public int compareTo(Timestamp o) {
34 - checkArgument(o instanceof DeviceMastershipBasedTimestamp, 34 + checkArgument(o instanceof MastershipBasedTimestamp,
35 "Must be MastershipBasedTimestamp", o); 35 "Must be MastershipBasedTimestamp", o);
36 - DeviceMastershipBasedTimestamp that = (DeviceMastershipBasedTimestamp) o; 36 + MastershipBasedTimestamp that = (MastershipBasedTimestamp) o;
37 37
38 return ComparisonChain.start() 38 return ComparisonChain.start()
39 .compare(this.termNumber, that.termNumber) 39 .compare(this.termNumber, that.termNumber)
...@@ -51,10 +51,10 @@ public final class DeviceMastershipBasedTimestamp implements Timestamp { ...@@ -51,10 +51,10 @@ public final class DeviceMastershipBasedTimestamp implements Timestamp {
51 if (this == obj) { 51 if (this == obj) {
52 return true; 52 return true;
53 } 53 }
54 - if (!(obj instanceof DeviceMastershipBasedTimestamp)) { 54 + if (!(obj instanceof MastershipBasedTimestamp)) {
55 return false; 55 return false;
56 } 56 }
57 - DeviceMastershipBasedTimestamp that = (DeviceMastershipBasedTimestamp) obj; 57 + MastershipBasedTimestamp that = (MastershipBasedTimestamp) obj;
58 return Objects.equals(this.termNumber, that.termNumber) && 58 return Objects.equals(this.termNumber, that.termNumber) &&
59 Objects.equals(this.sequenceNumber, that.sequenceNumber); 59 Objects.equals(this.sequenceNumber, that.sequenceNumber);
60 } 60 }
...@@ -87,7 +87,7 @@ public final class DeviceMastershipBasedTimestamp implements Timestamp { ...@@ -87,7 +87,7 @@ public final class DeviceMastershipBasedTimestamp implements Timestamp {
87 87
88 // Default constructor for serialization 88 // Default constructor for serialization
89 @Deprecated 89 @Deprecated
90 - protected DeviceMastershipBasedTimestamp() { 90 + protected MastershipBasedTimestamp() {
91 this.termNumber = -1; 91 this.termNumber = -1;
92 this.sequenceNumber = -1; 92 this.sequenceNumber = -1;
93 } 93 }
......
1 -package org.onlab.onos.store; 1 +package org.onlab.onos.store.common.impl;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 4
5 import java.util.Objects; 5 import java.util.Objects;
6 6
7 +import org.onlab.onos.store.Timestamp;
8 +
7 import com.google.common.base.MoreObjects; 9 import com.google.common.base.MoreObjects;
8 10
9 /** 11 /**
......
...@@ -8,7 +8,6 @@ import org.onlab.onos.cluster.NodeId; ...@@ -8,7 +8,6 @@ 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.store.Timestamp;
11 -import org.onlab.onos.store.VersionedValue;
12 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement; 11 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement;
13 12
14 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID) 13 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID)
......
...@@ -10,7 +10,6 @@ import org.onlab.onos.cluster.NodeId; ...@@ -10,7 +10,6 @@ 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.store.Timestamp;
13 -import org.onlab.onos.store.VersionedValue;
14 import org.onlab.onos.store.common.impl.AntiEntropyReply; 13 import org.onlab.onos.store.common.impl.AntiEntropyReply;
15 14
16 import com.google.common.collect.ImmutableMap; 15 import com.google.common.collect.ImmutableMap;
......
...@@ -10,12 +10,12 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -10,12 +10,12 @@ import org.apache.felix.scr.annotations.Activate;
10 import org.apache.felix.scr.annotations.Component; 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.cluster.MastershipTerm;
13 import org.onlab.onos.net.DeviceId; 14 import org.onlab.onos.net.DeviceId;
14 -import org.onlab.onos.net.device.DeviceMastershipTerm;
15 import org.onlab.onos.store.ClockProviderService; 15 import org.onlab.onos.store.ClockProviderService;
16 import org.onlab.onos.store.ClockService; 16 import org.onlab.onos.store.ClockService;
17 import org.onlab.onos.store.Timestamp; 17 import org.onlab.onos.store.Timestamp;
18 -import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp; 18 +import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
19 import org.slf4j.Logger; 19 import org.slf4j.Logger;
20 20
21 /** 21 /**
...@@ -29,7 +29,7 @@ public class DeviceClockManager implements ClockService, ClockProviderService { ...@@ -29,7 +29,7 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
29 29
30 // TODO: Implement per device ticker that is reset to 0 at the beginning of a new term. 30 // TODO: Implement per device ticker that is reset to 0 at the beginning of a new term.
31 private final AtomicInteger ticker = new AtomicInteger(0); 31 private final AtomicInteger ticker = new AtomicInteger(0);
32 - private ConcurrentMap<DeviceId, DeviceMastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>(); 32 + private ConcurrentMap<DeviceId, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>();
33 33
34 @Activate 34 @Activate
35 public void activate() { 35 public void activate() {
...@@ -43,15 +43,15 @@ public class DeviceClockManager implements ClockService, ClockProviderService { ...@@ -43,15 +43,15 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
43 43
44 @Override 44 @Override
45 public Timestamp getTimestamp(DeviceId deviceId) { 45 public Timestamp getTimestamp(DeviceId deviceId) {
46 - DeviceMastershipTerm term = deviceMastershipTerms.get(deviceId); 46 + MastershipTerm term = deviceMastershipTerms.get(deviceId);
47 if (term == null) { 47 if (term == null) {
48 throw new IllegalStateException("Requesting timestamp for a deviceId without mastership"); 48 throw new IllegalStateException("Requesting timestamp for a deviceId without mastership");
49 } 49 }
50 - return new DeviceMastershipBasedTimestamp(term.termNumber(), ticker.incrementAndGet()); 50 + return new MastershipBasedTimestamp(term.termNumber(), ticker.incrementAndGet());
51 } 51 }
52 52
53 @Override 53 @Override
54 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 54 + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
55 deviceMastershipTerms.put(deviceId, term); 55 deviceMastershipTerms.put(deviceId, term);
56 } 56 }
57 } 57 }
......
...@@ -35,14 +35,14 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -35,14 +35,14 @@ import org.onlab.onos.net.provider.ProviderId;
35 import org.onlab.onos.store.AbstractStore; 35 import org.onlab.onos.store.AbstractStore;
36 import org.onlab.onos.store.ClockService; 36 import org.onlab.onos.store.ClockService;
37 import org.onlab.onos.store.Timestamp; 37 import org.onlab.onos.store.Timestamp;
38 -import org.onlab.onos.store.Timestamped;
39 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 38 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
40 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 39 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
41 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 40 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
42 -import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp; 41 +import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
43 -import org.onlab.onos.store.common.impl.MastershipBasedTimestampSerializer; 42 +import org.onlab.onos.store.common.impl.Timestamped;
44 import org.onlab.onos.store.serializers.KryoPoolUtil; 43 import org.onlab.onos.store.serializers.KryoPoolUtil;
45 import org.onlab.onos.store.serializers.KryoSerializer; 44 import org.onlab.onos.store.serializers.KryoSerializer;
45 +import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer;
46 import org.onlab.util.KryoPool; 46 import org.onlab.util.KryoPool;
47 import org.onlab.util.NewConcurrentHashMap; 47 import org.onlab.util.NewConcurrentHashMap;
48 import org.slf4j.Logger; 48 import org.slf4j.Logger;
...@@ -125,7 +125,7 @@ public class GossipDeviceStore ...@@ -125,7 +125,7 @@ public class GossipDeviceStore
125 .register(InternalPortStatusEvent.class, new InternalPortStatusEventSerializer()) 125 .register(InternalPortStatusEvent.class, new InternalPortStatusEventSerializer())
126 .register(Timestamp.class) 126 .register(Timestamp.class)
127 .register(Timestamped.class) 127 .register(Timestamped.class)
128 - .register(DeviceMastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer()) 128 + .register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
129 .build() 129 .build()
130 .populate(1); 130 .populate(1);
131 } 131 }
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl; ...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
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.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 -import org.onlab.onos.store.Timestamped; 6 +import org.onlab.onos.store.common.impl.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
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl; ...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
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.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 -import org.onlab.onos.store.Timestamped; 6 +import org.onlab.onos.store.common.impl.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;
......
...@@ -5,7 +5,7 @@ import java.util.List; ...@@ -5,7 +5,7 @@ import java.util.List;
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.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 -import org.onlab.onos.store.Timestamped; 8 +import org.onlab.onos.store.common.impl.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
......
...@@ -5,7 +5,7 @@ import java.util.List; ...@@ -5,7 +5,7 @@ import java.util.List;
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.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 -import org.onlab.onos.store.Timestamped; 8 +import org.onlab.onos.store.common.impl.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;
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl; ...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
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.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 -import org.onlab.onos.store.Timestamped; 6 +import org.onlab.onos.store.common.impl.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
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl; ...@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
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.provider.ProviderId; 5 import org.onlab.onos.net.provider.ProviderId;
6 -import org.onlab.onos.store.Timestamped; 6 +import org.onlab.onos.store.common.impl.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; 1 +package org.onlab.onos.store.device.impl;
2 2
3 import java.util.Objects; 3 import java.util.Objects;
4 4
5 +import org.onlab.onos.store.Timestamp;
6 +
5 /** 7 /**
6 * Wrapper class for a entity that is versioned 8 * Wrapper class for a entity that is versioned
7 * and can either be up or down. 9 * and can either be up or down.
......
...@@ -31,7 +31,7 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -31,7 +31,7 @@ import org.onlab.onos.net.provider.ProviderId;
31 import org.onlab.onos.store.AbstractStore; 31 import org.onlab.onos.store.AbstractStore;
32 import org.onlab.onos.store.ClockService; 32 import org.onlab.onos.store.ClockService;
33 import org.onlab.onos.store.Timestamp; 33 import org.onlab.onos.store.Timestamp;
34 -import org.onlab.onos.store.VersionedValue; 34 +import org.onlab.onos.store.device.impl.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;
......
1 -package org.onlab.onos.store.cluster.messaging.impl; 1 +package org.onlab.onos.store.serializers;
2 2
3 import org.onlab.onos.cluster.NodeId; 3 import org.onlab.onos.cluster.NodeId;
4 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 4 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
......
1 -package org.onlab.onos.store.common.impl; 1 +package org.onlab.onos.store.serializers;
2 +
3 +import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
2 4
3 import com.esotericsoftware.kryo.Kryo; 5 import com.esotericsoftware.kryo.Kryo;
4 import com.esotericsoftware.kryo.Serializer; 6 import com.esotericsoftware.kryo.Serializer;
...@@ -7,12 +9,12 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -7,12 +9,12 @@ import com.esotericsoftware.kryo.io.Output;
7 9
8 // To be used if Timestamp ever needs to cross bundle boundary. 10 // To be used if Timestamp ever needs to cross bundle boundary.
9 /** 11 /**
10 - * Kryo Serializer for {@link DeviceMastershipBasedTimestamp}. 12 + * Kryo Serializer for {@link MastershipBasedTimestamp}.
11 */ 13 */
12 -public class MastershipBasedTimestampSerializer extends Serializer<DeviceMastershipBasedTimestamp> { 14 +public class MastershipBasedTimestampSerializer extends Serializer<MastershipBasedTimestamp> {
13 15
14 /** 16 /**
15 - * Creates a serializer for {@link DeviceMastershipBasedTimestamp}. 17 + * Creates a serializer for {@link MastershipBasedTimestamp}.
16 */ 18 */
17 public MastershipBasedTimestampSerializer() { 19 public MastershipBasedTimestampSerializer() {
18 // non-null, immutable 20 // non-null, immutable
...@@ -20,15 +22,15 @@ public class MastershipBasedTimestampSerializer extends Serializer<DeviceMasters ...@@ -20,15 +22,15 @@ public class MastershipBasedTimestampSerializer extends Serializer<DeviceMasters
20 } 22 }
21 23
22 @Override 24 @Override
23 - public void write(Kryo kryo, Output output, DeviceMastershipBasedTimestamp object) { 25 + public void write(Kryo kryo, Output output, MastershipBasedTimestamp object) {
24 output.writeInt(object.termNumber()); 26 output.writeInt(object.termNumber());
25 output.writeInt(object.sequenceNumber()); 27 output.writeInt(object.sequenceNumber());
26 } 28 }
27 29
28 @Override 30 @Override
29 - public DeviceMastershipBasedTimestamp read(Kryo kryo, Input input, Class<DeviceMastershipBasedTimestamp> type) { 31 + public MastershipBasedTimestamp read(Kryo kryo, Input input, Class<MastershipBasedTimestamp> type) {
30 final int term = input.readInt(); 32 final int term = input.readInt();
31 final int sequence = input.readInt(); 33 final int sequence = input.readInt();
32 - return new DeviceMastershipBasedTimestamp(term, sequence); 34 + return new MastershipBasedTimestamp(term, sequence);
33 } 35 }
34 } 36 }
......
1 -package org.onlab.onos.store.cluster.messaging.impl; 1 +package org.onlab.onos.store.serializers;
2 2
3 import org.onlab.onos.store.cluster.messaging.MessageSubject; 3 import org.onlab.onos.store.cluster.messaging.MessageSubject;
4 4
......
...@@ -6,25 +6,26 @@ import java.nio.ByteBuffer; ...@@ -6,25 +6,26 @@ 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.store.Timestamp;
9 +import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer;
9 import org.onlab.util.KryoPool; 10 import org.onlab.util.KryoPool;
10 11
11 import com.google.common.testing.EqualsTester; 12 import com.google.common.testing.EqualsTester;
12 13
13 /** 14 /**
14 - * Test of {@link DeviceMastershipBasedTimestamp}. 15 + * Test of {@link MastershipBasedTimestamp}.
15 */ 16 */
16 public class MastershipBasedTimestampTest { 17 public class MastershipBasedTimestampTest {
17 18
18 - private static final Timestamp TS_1_1 = new DeviceMastershipBasedTimestamp(1, 1); 19 + private static final Timestamp TS_1_1 = new MastershipBasedTimestamp(1, 1);
19 - private static final Timestamp TS_1_2 = new DeviceMastershipBasedTimestamp(1, 2); 20 + private static final Timestamp TS_1_2 = new MastershipBasedTimestamp(1, 2);
20 - private static final Timestamp TS_2_1 = new DeviceMastershipBasedTimestamp(2, 1); 21 + private static final Timestamp TS_2_1 = new MastershipBasedTimestamp(2, 1);
21 - private static final Timestamp TS_2_2 = new DeviceMastershipBasedTimestamp(2, 2); 22 + private static final Timestamp TS_2_2 = new MastershipBasedTimestamp(2, 2);
22 23
23 @Test 24 @Test
24 public final void testBasic() { 25 public final void testBasic() {
25 final int termNumber = 5; 26 final int termNumber = 5;
26 final int sequenceNumber = 6; 27 final int sequenceNumber = 6;
27 - DeviceMastershipBasedTimestamp ts = new DeviceMastershipBasedTimestamp(termNumber, 28 + MastershipBasedTimestamp ts = new MastershipBasedTimestamp(termNumber,
28 sequenceNumber); 29 sequenceNumber);
29 30
30 assertEquals(termNumber, ts.termNumber()); 31 assertEquals(termNumber, ts.termNumber());
...@@ -34,7 +35,7 @@ public class MastershipBasedTimestampTest { ...@@ -34,7 +35,7 @@ public class MastershipBasedTimestampTest {
34 @Test 35 @Test
35 public final void testCompareTo() { 36 public final void testCompareTo() {
36 assertTrue(TS_1_1.compareTo(TS_1_1) == 0); 37 assertTrue(TS_1_1.compareTo(TS_1_1) == 0);
37 - assertTrue(TS_1_1.compareTo(new DeviceMastershipBasedTimestamp(1, 1)) == 0); 38 + assertTrue(TS_1_1.compareTo(new MastershipBasedTimestamp(1, 1)) == 0);
38 39
39 assertTrue(TS_1_1.compareTo(TS_1_2) < 0); 40 assertTrue(TS_1_1.compareTo(TS_1_2) < 0);
40 assertTrue(TS_1_2.compareTo(TS_1_1) > 0); 41 assertTrue(TS_1_2.compareTo(TS_1_1) > 0);
...@@ -48,14 +49,14 @@ public class MastershipBasedTimestampTest { ...@@ -48,14 +49,14 @@ public class MastershipBasedTimestampTest {
48 @Test 49 @Test
49 public final void testEqualsObject() { 50 public final void testEqualsObject() {
50 new EqualsTester() 51 new EqualsTester()
51 - .addEqualityGroup(new DeviceMastershipBasedTimestamp(1, 1), 52 + .addEqualityGroup(new MastershipBasedTimestamp(1, 1),
52 - new DeviceMastershipBasedTimestamp(1, 1), TS_1_1) 53 + new MastershipBasedTimestamp(1, 1), TS_1_1)
53 - .addEqualityGroup(new DeviceMastershipBasedTimestamp(1, 2), 54 + .addEqualityGroup(new MastershipBasedTimestamp(1, 2),
54 - new DeviceMastershipBasedTimestamp(1, 2), TS_1_2) 55 + new MastershipBasedTimestamp(1, 2), TS_1_2)
55 - .addEqualityGroup(new DeviceMastershipBasedTimestamp(2, 1), 56 + .addEqualityGroup(new MastershipBasedTimestamp(2, 1),
56 - new DeviceMastershipBasedTimestamp(2, 1), TS_2_1) 57 + new MastershipBasedTimestamp(2, 1), TS_2_1)
57 - .addEqualityGroup(new DeviceMastershipBasedTimestamp(2, 2), 58 + .addEqualityGroup(new MastershipBasedTimestamp(2, 2),
58 - new DeviceMastershipBasedTimestamp(2, 2), TS_2_2) 59 + new MastershipBasedTimestamp(2, 2), TS_2_2)
59 .testEquals(); 60 .testEquals();
60 } 61 }
61 62
...@@ -63,7 +64,7 @@ public class MastershipBasedTimestampTest { ...@@ -63,7 +64,7 @@ public class MastershipBasedTimestampTest {
63 public final void testKryoSerializable() { 64 public final void testKryoSerializable() {
64 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); 65 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
65 final KryoPool kryos = KryoPool.newBuilder() 66 final KryoPool kryos = KryoPool.newBuilder()
66 - .register(DeviceMastershipBasedTimestamp.class) 67 + .register(MastershipBasedTimestamp.class)
67 .build(); 68 .build();
68 69
69 kryos.serialize(TS_2_1, buffer); 70 kryos.serialize(TS_2_1, buffer);
...@@ -79,7 +80,7 @@ public class MastershipBasedTimestampTest { ...@@ -79,7 +80,7 @@ public class MastershipBasedTimestampTest {
79 public final void testKryoSerializableWithHandcraftedSerializer() { 80 public final void testKryoSerializableWithHandcraftedSerializer() {
80 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); 81 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
81 final KryoPool kryos = KryoPool.newBuilder() 82 final KryoPool kryos = KryoPool.newBuilder()
82 - .register(DeviceMastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer()) 83 + .register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
83 .build(); 84 .build();
84 85
85 kryos.serialize(TS_1_2, buffer); 86 kryos.serialize(TS_1_2, buffer);
......
...@@ -6,7 +6,6 @@ import java.nio.ByteBuffer; ...@@ -6,7 +6,6 @@ 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.store.Timestamp;
9 -import org.onlab.onos.store.Timestamped;
10 import org.onlab.util.KryoPool; 9 import org.onlab.util.KryoPool;
11 10
12 import com.google.common.testing.EqualsTester; 11 import com.google.common.testing.EqualsTester;
...@@ -16,9 +15,9 @@ import com.google.common.testing.EqualsTester; ...@@ -16,9 +15,9 @@ import com.google.common.testing.EqualsTester;
16 */ 15 */
17 public class TimestampedTest { 16 public class TimestampedTest {
18 17
19 - private static final Timestamp TS_1_1 = new DeviceMastershipBasedTimestamp(1, 1); 18 + private static final Timestamp TS_1_1 = new MastershipBasedTimestamp(1, 1);
20 - private static final Timestamp TS_1_2 = new DeviceMastershipBasedTimestamp(1, 2); 19 + private static final Timestamp TS_1_2 = new MastershipBasedTimestamp(1, 2);
21 - private static final Timestamp TS_2_1 = new DeviceMastershipBasedTimestamp(2, 1); 20 + private static final Timestamp TS_2_1 = new MastershipBasedTimestamp(2, 1);
22 21
23 @Test 22 @Test
24 public final void testHashCode() { 23 public final void testHashCode() {
...@@ -80,7 +79,7 @@ public class TimestampedTest { ...@@ -80,7 +79,7 @@ public class TimestampedTest {
80 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); 79 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
81 final KryoPool kryos = KryoPool.newBuilder() 80 final KryoPool kryos = KryoPool.newBuilder()
82 .register(Timestamped.class, 81 .register(Timestamped.class,
83 - DeviceMastershipBasedTimestamp.class) 82 + MastershipBasedTimestamp.class)
84 .build(); 83 .build();
85 84
86 Timestamped<String> original = new Timestamped<>("foobar", TS_1_1); 85 Timestamped<String> original = new Timestamped<>("foobar", TS_1_1);
......
...@@ -25,6 +25,7 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -25,6 +25,7 @@ import org.onlab.onos.cluster.ClusterService;
25 import org.onlab.onos.cluster.ControllerNode; 25 import org.onlab.onos.cluster.ControllerNode;
26 import org.onlab.onos.cluster.ControllerNode.State; 26 import org.onlab.onos.cluster.ControllerNode.State;
27 import org.onlab.onos.cluster.DefaultControllerNode; 27 import org.onlab.onos.cluster.DefaultControllerNode;
28 +import org.onlab.onos.cluster.MastershipTerm;
28 import org.onlab.onos.cluster.NodeId; 29 import org.onlab.onos.cluster.NodeId;
29 import org.onlab.onos.net.Annotations; 30 import org.onlab.onos.net.Annotations;
30 import org.onlab.onos.net.DefaultAnnotations; 31 import org.onlab.onos.net.DefaultAnnotations;
...@@ -39,7 +40,6 @@ import org.onlab.onos.net.device.DeviceDescription; ...@@ -39,7 +40,6 @@ 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;
41 import org.onlab.onos.net.device.DeviceStoreDelegate; 42 import org.onlab.onos.net.device.DeviceStoreDelegate;
42 -import org.onlab.onos.net.device.DeviceMastershipTerm;
43 import org.onlab.onos.net.device.PortDescription; 43 import org.onlab.onos.net.device.PortDescription;
44 import org.onlab.onos.net.provider.ProviderId; 44 import org.onlab.onos.net.provider.ProviderId;
45 import org.onlab.onos.store.ClockService; 45 import org.onlab.onos.store.ClockService;
...@@ -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.setMastershipTerm(DID1, MastershipTerm.of(MYSELF, 1));
117 - deviceClockManager.setMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2)); 117 + deviceClockManager.setMastershipTerm(DID2, MastershipTerm.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();
......
1 package org.onlab.onos.store.cluster.impl; 1 package org.onlab.onos.store.cluster.impl;
2 2
3 -import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.MASTER_CHANGED; 3 +import static org.onlab.onos.cluster.MastershipEvent.Type.MASTER_CHANGED;
4 4
5 import java.util.Map; 5 import java.util.Map;
6 import java.util.Set; 6 import java.util.Set;
...@@ -12,13 +12,13 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -12,13 +12,13 @@ import org.apache.felix.scr.annotations.Reference;
12 import org.apache.felix.scr.annotations.ReferenceCardinality; 12 import org.apache.felix.scr.annotations.ReferenceCardinality;
13 import org.apache.felix.scr.annotations.Service; 13 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.MastershipEvent;
16 +import org.onlab.onos.cluster.MastershipStore;
17 +import org.onlab.onos.cluster.MastershipStoreDelegate;
18 +import org.onlab.onos.cluster.MastershipTerm;
15 import org.onlab.onos.cluster.NodeId; 19 import org.onlab.onos.cluster.NodeId;
16 import org.onlab.onos.net.DeviceId; 20 import org.onlab.onos.net.DeviceId;
17 import org.onlab.onos.net.MastershipRole; 21 import org.onlab.onos.net.MastershipRole;
18 -import org.onlab.onos.net.device.DeviceMastershipEvent;
19 -import org.onlab.onos.net.device.DeviceMastershipStore;
20 -import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
21 -import org.onlab.onos.net.device.DeviceMastershipTerm;
22 import org.onlab.onos.store.common.AbstractHazelcastStore; 22 import org.onlab.onos.store.common.AbstractHazelcastStore;
23 23
24 import com.google.common.collect.ImmutableSet; 24 import com.google.common.collect.ImmutableSet;
...@@ -33,8 +33,8 @@ import com.hazelcast.core.MultiMap; ...@@ -33,8 +33,8 @@ import com.hazelcast.core.MultiMap;
33 @Component(immediate = true) 33 @Component(immediate = true)
34 @Service 34 @Service
35 public class DistributedMastershipStore 35 public class DistributedMastershipStore
36 -extends AbstractHazelcastStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate> 36 +extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate>
37 -implements DeviceMastershipStore { 37 +implements MastershipStore {
38 38
39 //arbitrary lock name 39 //arbitrary lock name
40 private static final String LOCK = "lock"; 40 private static final String LOCK = "lock";
...@@ -100,7 +100,7 @@ implements DeviceMastershipStore { ...@@ -100,7 +100,7 @@ implements DeviceMastershipStore {
100 } 100 }
101 101
102 @Override 102 @Override
103 - public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) { 103 + public MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
104 byte [] did = serialize(deviceId); 104 byte [] did = serialize(deviceId);
105 byte [] nid = serialize(nodeId); 105 byte [] nid = serialize(nodeId);
106 106
...@@ -123,12 +123,12 @@ implements DeviceMastershipStore { ...@@ -123,12 +123,12 @@ implements DeviceMastershipStore {
123 masters.put(did, nid); 123 masters.put(did, nid);
124 evict(nid, did); 124 evict(nid, did);
125 updateTerm(did); 125 updateTerm(did);
126 - return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId); 126 + return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
127 case NONE: 127 case NONE:
128 masters.put(did, nid); 128 masters.put(did, nid);
129 evict(nid, did); 129 evict(nid, did);
130 updateTerm(did); 130 updateTerm(did);
131 - return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId); 131 + return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
132 default: 132 default:
133 log.warn("unknown Mastership Role {}", role); 133 log.warn("unknown Mastership Role {}", role);
134 return null; 134 return null;
...@@ -191,21 +191,21 @@ implements DeviceMastershipStore { ...@@ -191,21 +191,21 @@ implements DeviceMastershipStore {
191 } 191 }
192 192
193 @Override 193 @Override
194 - public DeviceMastershipTerm getTermFor(DeviceId deviceId) { 194 + public MastershipTerm getTermFor(DeviceId deviceId) {
195 byte[] did = serialize(deviceId); 195 byte[] did = serialize(deviceId);
196 if ((masters.get(did) == null) || 196 if ((masters.get(did) == null) ||
197 (terms.get(did) == null)) { 197 (terms.get(did) == null)) {
198 return null; 198 return null;
199 } 199 }
200 - return DeviceMastershipTerm.of( 200 + return MastershipTerm.of(
201 (NodeId) deserialize(masters.get(did)), terms.get(did)); 201 (NodeId) deserialize(masters.get(did)), terms.get(did));
202 } 202 }
203 203
204 @Override 204 @Override
205 - public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) { 205 + public MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
206 byte [] did = serialize(deviceId); 206 byte [] did = serialize(deviceId);
207 byte [] nid = serialize(nodeId); 207 byte [] nid = serialize(nodeId);
208 - DeviceMastershipEvent event = null; 208 + MastershipEvent event = null;
209 209
210 ILock lock = theInstance.getLock(LOCK); 210 ILock lock = theInstance.getLock(LOCK);
211 lock.lock(); 211 lock.lock();
...@@ -231,10 +231,10 @@ implements DeviceMastershipStore { ...@@ -231,10 +231,10 @@ implements DeviceMastershipStore {
231 } 231 }
232 232
233 @Override 233 @Override
234 - public DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) { 234 + public MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
235 byte [] did = serialize(deviceId); 235 byte [] did = serialize(deviceId);
236 byte [] nid = serialize(nodeId); 236 byte [] nid = serialize(nodeId);
237 - DeviceMastershipEvent event = null; 237 + MastershipEvent event = null;
238 238
239 ILock lock = theInstance.getLock(LOCK); 239 ILock lock = theInstance.getLock(LOCK);
240 lock.lock(); 240 lock.lock();
...@@ -260,7 +260,7 @@ implements DeviceMastershipStore { ...@@ -260,7 +260,7 @@ implements DeviceMastershipStore {
260 } 260 }
261 261
262 //helper to fetch a new master candidate for a given device. 262 //helper to fetch a new master candidate for a given device.
263 - private DeviceMastershipEvent reelect(NodeId current, DeviceId deviceId) { 263 + private MastershipEvent reelect(NodeId current, DeviceId deviceId) {
264 byte [] did = serialize(deviceId); 264 byte [] did = serialize(deviceId);
265 byte [] nid = serialize(current); 265 byte [] nid = serialize(current);
266 266
...@@ -281,7 +281,7 @@ implements DeviceMastershipStore { ...@@ -281,7 +281,7 @@ implements DeviceMastershipStore {
281 evict(backup, did); 281 evict(backup, did);
282 Integer term = terms.get(did); 282 Integer term = terms.get(did);
283 terms.put(did, ++term); 283 terms.put(did, ++term);
284 - return new DeviceMastershipEvent( 284 + return new MastershipEvent(
285 MASTER_CHANGED, deviceId, (NodeId) deserialize(backup)); 285 MASTER_CHANGED, deviceId, (NodeId) deserialize(backup));
286 } 286 }
287 } 287 }
...@@ -320,7 +320,7 @@ implements DeviceMastershipStore { ...@@ -320,7 +320,7 @@ implements DeviceMastershipStore {
320 320
321 @Override 321 @Override
322 protected void onAdd(DeviceId deviceId, NodeId nodeId) { 322 protected void onAdd(DeviceId deviceId, NodeId nodeId) {
323 - notifyDelegate(new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId)); 323 + notifyDelegate(new MastershipEvent(MASTER_CHANGED, deviceId, nodeId));
324 } 324 }
325 325
326 @Override 326 @Override
......
...@@ -21,12 +21,12 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -21,12 +21,12 @@ import org.onlab.onos.cluster.ClusterService;
21 import org.onlab.onos.cluster.ControllerNode; 21 import org.onlab.onos.cluster.ControllerNode;
22 import org.onlab.onos.cluster.ControllerNode.State; 22 import org.onlab.onos.cluster.ControllerNode.State;
23 import org.onlab.onos.cluster.DefaultControllerNode; 23 import org.onlab.onos.cluster.DefaultControllerNode;
24 +import org.onlab.onos.cluster.MastershipEvent;
25 +import org.onlab.onos.cluster.MastershipEvent.Type;
26 +import org.onlab.onos.cluster.MastershipStoreDelegate;
27 +import org.onlab.onos.cluster.MastershipTerm;
24 import org.onlab.onos.cluster.NodeId; 28 import org.onlab.onos.cluster.NodeId;
25 import org.onlab.onos.net.DeviceId; 29 import org.onlab.onos.net.DeviceId;
26 -import org.onlab.onos.net.device.DeviceMastershipEvent;
27 -import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
28 -import org.onlab.onos.net.device.DeviceMastershipTerm;
29 -import org.onlab.onos.net.device.DeviceMastershipEvent.Type;
30 import org.onlab.onos.store.common.StoreManager; 30 import org.onlab.onos.store.common.StoreManager;
31 import org.onlab.onos.store.common.StoreService; 31 import org.onlab.onos.store.common.StoreService;
32 import org.onlab.onos.store.common.TestStoreManager; 32 import org.onlab.onos.store.common.TestStoreManager;
...@@ -133,7 +133,7 @@ public class DistributedMastershipStoreTest { ...@@ -133,7 +133,7 @@ public class DistributedMastershipStoreTest {
133 assertEquals("wrong role for NONE:", MASTER, dms.requestRole(DID1)); 133 assertEquals("wrong role for NONE:", MASTER, dms.requestRole(DID1));
134 assertTrue("wrong state for store:", !dms.terms.isEmpty()); 134 assertTrue("wrong state for store:", !dms.terms.isEmpty());
135 assertEquals("wrong term", 135 assertEquals("wrong term",
136 - DeviceMastershipTerm.of(N1, 0), dms.getTermFor(DID1)); 136 + MastershipTerm.of(N1, 0), dms.getTermFor(DID1));
137 137
138 //CN2 now local. DID2 has N1 as MASTER so N2 is STANDBY 138 //CN2 now local. DID2 has N1 as MASTER so N2 is STANDBY
139 testStore.setCurrent(CN2); 139 testStore.setCurrent(CN2);
...@@ -143,7 +143,7 @@ public class DistributedMastershipStoreTest { ...@@ -143,7 +143,7 @@ public class DistributedMastershipStoreTest {
143 //change term and requestRole() again; should persist 143 //change term and requestRole() again; should persist
144 testStore.increment(DID2); 144 testStore.increment(DID2);
145 assertEquals("wrong role for STANDBY:", STANDBY, dms.requestRole(DID2)); 145 assertEquals("wrong role for STANDBY:", STANDBY, dms.requestRole(DID2));
146 - assertEquals("wrong term", DeviceMastershipTerm.of(N1, 1), dms.getTermFor(DID2)); 146 + assertEquals("wrong term", MastershipTerm.of(N1, 1), dms.getTermFor(DID2));
147 } 147 }
148 148
149 @Test 149 @Test
...@@ -155,15 +155,15 @@ public class DistributedMastershipStoreTest { ...@@ -155,15 +155,15 @@ public class DistributedMastershipStoreTest {
155 155
156 //switch over to N2 156 //switch over to N2
157 assertEquals("wrong event:", Type.MASTER_CHANGED, dms.setMaster(N2, DID1).type()); 157 assertEquals("wrong event:", Type.MASTER_CHANGED, dms.setMaster(N2, DID1).type());
158 - assertEquals("wrong term", DeviceMastershipTerm.of(N2, 1), dms.getTermFor(DID1)); 158 + assertEquals("wrong term", MastershipTerm.of(N2, 1), dms.getTermFor(DID1));
159 159
160 //orphan switch - should be rare case 160 //orphan switch - should be rare case
161 assertEquals("wrong event:", Type.MASTER_CHANGED, dms.setMaster(N2, DID2).type()); 161 assertEquals("wrong event:", Type.MASTER_CHANGED, dms.setMaster(N2, DID2).type());
162 - assertEquals("wrong term", DeviceMastershipTerm.of(N2, 0), dms.getTermFor(DID2)); 162 + assertEquals("wrong term", MastershipTerm.of(N2, 0), dms.getTermFor(DID2));
163 //disconnect and reconnect - sign of failing re-election or single-instance channel 163 //disconnect and reconnect - sign of failing re-election or single-instance channel
164 testStore.reset(true, false, false); 164 testStore.reset(true, false, false);
165 dms.setMaster(N2, DID2); 165 dms.setMaster(N2, DID2);
166 - assertEquals("wrong term", DeviceMastershipTerm.of(N2, 1), dms.getTermFor(DID2)); 166 + assertEquals("wrong term", MastershipTerm.of(N2, 1), dms.getTermFor(DID2));
167 } 167 }
168 168
169 @Test 169 @Test
...@@ -211,9 +211,9 @@ public class DistributedMastershipStoreTest { ...@@ -211,9 +211,9 @@ public class DistributedMastershipStoreTest {
211 //shamelessly copy other distributed store tests 211 //shamelessly copy other distributed store tests
212 final CountDownLatch addLatch = new CountDownLatch(1); 212 final CountDownLatch addLatch = new CountDownLatch(1);
213 213
214 - DeviceMastershipStoreDelegate checkAdd = new DeviceMastershipStoreDelegate() { 214 + MastershipStoreDelegate checkAdd = new MastershipStoreDelegate() {
215 @Override 215 @Override
216 - public void notify(DeviceMastershipEvent event) { 216 + public void notify(MastershipEvent event) {
217 assertEquals("wrong event:", Type.MASTER_CHANGED, event.type()); 217 assertEquals("wrong event:", Type.MASTER_CHANGED, event.type());
218 assertEquals("wrong subject", DID1, event.subject()); 218 assertEquals("wrong subject", DID1, event.subject());
219 assertEquals("wrong subject", N1, event.master()); 219 assertEquals("wrong subject", N1, event.master());
......
...@@ -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.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.cluster.MastershipTerm;
5 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
6 -import org.onlab.onos.net.device.DeviceMastershipTerm;
7 import org.onlab.onos.store.ClockProviderService; 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
...@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService; ...@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService;
15 public class NoOpClockProviderService implements ClockProviderService { 15 public class NoOpClockProviderService implements ClockProviderService {
16 16
17 @Override 17 @Override
18 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 18 + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
19 } 19 }
20 } 20 }
......
...@@ -7,6 +7,7 @@ import java.util.HashMap; ...@@ -7,6 +7,7 @@ import java.util.HashMap;
7 7
8 import org.onlab.onos.cluster.ControllerNode; 8 import org.onlab.onos.cluster.ControllerNode;
9 import org.onlab.onos.cluster.DefaultControllerNode; 9 import org.onlab.onos.cluster.DefaultControllerNode;
10 +import org.onlab.onos.cluster.MastershipTerm;
10 import org.onlab.onos.cluster.NodeId; 11 import org.onlab.onos.cluster.NodeId;
11 import org.onlab.onos.net.ConnectPoint; 12 import org.onlab.onos.net.ConnectPoint;
12 import org.onlab.onos.net.DefaultAnnotations; 13 import org.onlab.onos.net.DefaultAnnotations;
...@@ -23,7 +24,6 @@ import org.onlab.onos.net.Port; ...@@ -23,7 +24,6 @@ import org.onlab.onos.net.Port;
23 import org.onlab.onos.net.PortNumber; 24 import org.onlab.onos.net.PortNumber;
24 import org.onlab.onos.net.device.DefaultDeviceDescription; 25 import org.onlab.onos.net.device.DefaultDeviceDescription;
25 import org.onlab.onos.net.device.DefaultPortDescription; 26 import org.onlab.onos.net.device.DefaultPortDescription;
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;
29 import org.onlab.packet.IpPrefix; 29 import org.onlab.packet.IpPrefix;
...@@ -74,7 +74,7 @@ public final class KryoPoolUtil { ...@@ -74,7 +74,7 @@ public final class KryoPoolUtil {
74 .register(LinkKey.class, new LinkKeySerializer()) 74 .register(LinkKey.class, new LinkKeySerializer())
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(MastershipTerm.class, new MastershipTermSerializer())
78 .register(MastershipRole.class, new MastershipRoleSerializer()) 78 .register(MastershipRole.class, new MastershipRoleSerializer())
79 79
80 .build(); 80 .build();
......
1 package org.onlab.onos.store.serializers; 1 package org.onlab.onos.store.serializers;
2 2
3 +import org.onlab.onos.cluster.MastershipTerm;
3 import org.onlab.onos.cluster.NodeId; 4 import org.onlab.onos.cluster.NodeId;
4 -import org.onlab.onos.net.device.DeviceMastershipTerm;
5 -
6 import com.esotericsoftware.kryo.Kryo; 5 import com.esotericsoftware.kryo.Kryo;
7 import com.esotericsoftware.kryo.Serializer; 6 import com.esotericsoftware.kryo.Serializer;
8 import com.esotericsoftware.kryo.io.Input; 7 import com.esotericsoftware.kryo.io.Input;
9 import com.esotericsoftware.kryo.io.Output; 8 import com.esotericsoftware.kryo.io.Output;
10 9
11 /** 10 /**
12 - * Kryo Serializer for {@link org.onlab.onos.net.device.DeviceMastershipTerm}. 11 + * Kryo Serializer for {@link org.onlab.onos.cluster.MastershipTerm}.
13 */ 12 */
14 -public class MastershipTermSerializer extends Serializer<DeviceMastershipTerm> { 13 +public class MastershipTermSerializer extends Serializer<MastershipTerm> {
15 14
16 /** 15 /**
17 - * Creates {@link DeviceMastershipTerm} serializer instance. 16 + * Creates {@link MastershipTerm} serializer instance.
18 */ 17 */
19 public MastershipTermSerializer() { 18 public MastershipTermSerializer() {
20 // non-null, immutable 19 // non-null, immutable
...@@ -22,14 +21,14 @@ public class MastershipTermSerializer extends Serializer<DeviceMastershipTerm> { ...@@ -22,14 +21,14 @@ public class MastershipTermSerializer extends Serializer<DeviceMastershipTerm> {
22 } 21 }
23 22
24 @Override 23 @Override
25 - public DeviceMastershipTerm read(Kryo kryo, Input input, Class<DeviceMastershipTerm> type) { 24 + public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) {
26 final NodeId node = new NodeId(input.readString()); 25 final NodeId node = new NodeId(input.readString());
27 final int term = input.readInt(); 26 final int term = input.readInt();
28 - return DeviceMastershipTerm.of(node, term); 27 + return MastershipTerm.of(node, term);
29 } 28 }
30 29
31 @Override 30 @Override
32 - public void write(Kryo kryo, Output output, DeviceMastershipTerm object) { 31 + public void write(Kryo kryo, Output output, MastershipTerm object) {
33 output.writeString(object.master().toString()); 32 output.writeString(object.master().toString());
34 output.writeInt(object.termNumber()); 33 output.writeInt(object.termNumber());
35 } 34 }
......
...@@ -10,6 +10,7 @@ import org.junit.After; ...@@ -10,6 +10,7 @@ import org.junit.After;
10 import org.junit.Before; 10 import org.junit.Before;
11 import org.junit.BeforeClass; 11 import org.junit.BeforeClass;
12 import org.junit.Test; 12 import org.junit.Test;
13 +import org.onlab.onos.cluster.MastershipTerm;
13 import org.onlab.onos.cluster.NodeId; 14 import org.onlab.onos.cluster.NodeId;
14 import org.onlab.onos.net.Annotations; 15 import org.onlab.onos.net.Annotations;
15 import org.onlab.onos.net.ConnectPoint; 16 import org.onlab.onos.net.ConnectPoint;
...@@ -24,7 +25,6 @@ import org.onlab.onos.net.LinkKey; ...@@ -24,7 +25,6 @@ import org.onlab.onos.net.LinkKey;
24 import org.onlab.onos.net.MastershipRole; 25 import org.onlab.onos.net.MastershipRole;
25 import org.onlab.onos.net.PortNumber; 26 import org.onlab.onos.net.PortNumber;
26 import org.onlab.onos.net.SparseAnnotations; 27 import org.onlab.onos.net.SparseAnnotations;
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;
30 import org.onlab.packet.IpPrefix; 30 import org.onlab.packet.IpPrefix;
...@@ -114,7 +114,7 @@ public class KryoSerializerTest { ...@@ -114,7 +114,7 @@ public class KryoSerializerTest {
114 testSerialized(PID); 114 testSerialized(PID);
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(MastershipTerm.of(new NodeId("foo"), 2));
118 for (MastershipRole role : MastershipRole.values()) { 118 for (MastershipRole role : MastershipRole.values()) {
119 testSerialized(role); 119 testSerialized(role);
120 } 120 }
......
...@@ -2,8 +2,8 @@ package org.onlab.onos.store.trivial.impl; ...@@ -2,8 +2,8 @@ package org.onlab.onos.store.trivial.impl;
2 2
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.cluster.MastershipTerm;
5 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
6 -import org.onlab.onos.net.device.DeviceMastershipTerm;
7 import org.onlab.onos.store.ClockProviderService; 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
...@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService; ...@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService;
15 public class NoOpClockProviderService implements ClockProviderService { 15 public class NoOpClockProviderService implements ClockProviderService {
16 16
17 @Override 17 @Override
18 - public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) { 18 + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
19 } 19 }
20 } 20 }
......
...@@ -15,18 +15,18 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -15,18 +15,18 @@ import org.apache.felix.scr.annotations.Deactivate;
15 import org.apache.felix.scr.annotations.Service; 15 import org.apache.felix.scr.annotations.Service;
16 import org.onlab.onos.cluster.ControllerNode; 16 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.MastershipEvent;
19 +import org.onlab.onos.cluster.MastershipStore;
20 +import org.onlab.onos.cluster.MastershipStoreDelegate;
21 +import org.onlab.onos.cluster.MastershipTerm;
18 import org.onlab.onos.cluster.NodeId; 22 import org.onlab.onos.cluster.NodeId;
19 import org.onlab.onos.net.DeviceId; 23 import org.onlab.onos.net.DeviceId;
20 import org.onlab.onos.net.MastershipRole; 24 import org.onlab.onos.net.MastershipRole;
21 -import org.onlab.onos.net.device.DeviceMastershipEvent;
22 -import org.onlab.onos.net.device.DeviceMastershipStore;
23 -import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
24 -import org.onlab.onos.net.device.DeviceMastershipTerm;
25 import org.onlab.onos.store.AbstractStore; 25 import org.onlab.onos.store.AbstractStore;
26 import org.onlab.packet.IpPrefix; 26 import org.onlab.packet.IpPrefix;
27 import org.slf4j.Logger; 27 import org.slf4j.Logger;
28 28
29 -import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*; 29 +import static org.onlab.onos.cluster.MastershipEvent.Type.*;
30 30
31 /** 31 /**
32 * Manages inventory of controller mastership over devices using 32 * Manages inventory of controller mastership over devices using
...@@ -35,8 +35,8 @@ import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*; ...@@ -35,8 +35,8 @@ import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*;
35 @Component(immediate = true) 35 @Component(immediate = true)
36 @Service 36 @Service
37 public class SimpleMastershipStore 37 public class SimpleMastershipStore
38 - extends AbstractStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate> 38 + extends AbstractStore<MastershipEvent, MastershipStoreDelegate>
39 - implements DeviceMastershipStore { 39 + implements MastershipStore {
40 40
41 private final Logger log = getLogger(getClass()); 41 private final Logger log = getLogger(getClass());
42 42
...@@ -63,7 +63,7 @@ public class SimpleMastershipStore ...@@ -63,7 +63,7 @@ public class SimpleMastershipStore
63 } 63 }
64 64
65 @Override 65 @Override
66 - public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) { 66 + public MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
67 MastershipRole role = getRole(nodeId, deviceId); 67 MastershipRole role = getRole(nodeId, deviceId);
68 68
69 synchronized (this) { 69 synchronized (this) {
...@@ -86,7 +86,7 @@ public class SimpleMastershipStore ...@@ -86,7 +86,7 @@ public class SimpleMastershipStore
86 } 86 }
87 } 87 }
88 88
89 - return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId); 89 + return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
90 } 90 }
91 91
92 @Override 92 @Override
...@@ -164,17 +164,17 @@ public class SimpleMastershipStore ...@@ -164,17 +164,17 @@ public class SimpleMastershipStore
164 } 164 }
165 165
166 @Override 166 @Override
167 - public DeviceMastershipTerm getTermFor(DeviceId deviceId) { 167 + public MastershipTerm getTermFor(DeviceId deviceId) {
168 if ((masterMap.get(deviceId) == null) || 168 if ((masterMap.get(deviceId) == null) ||
169 (termMap.get(deviceId) == null)) { 169 (termMap.get(deviceId) == null)) {
170 return null; 170 return null;
171 } 171 }
172 - return DeviceMastershipTerm.of( 172 + return MastershipTerm.of(
173 masterMap.get(deviceId), termMap.get(deviceId).get()); 173 masterMap.get(deviceId), termMap.get(deviceId).get());
174 } 174 }
175 175
176 @Override 176 @Override
177 - public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) { 177 + public MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
178 MastershipRole role = getRole(nodeId, deviceId); 178 MastershipRole role = getRole(nodeId, deviceId);
179 synchronized (this) { 179 synchronized (this) {
180 switch (role) { 180 switch (role) {
...@@ -185,7 +185,7 @@ public class SimpleMastershipStore ...@@ -185,7 +185,7 @@ public class SimpleMastershipStore
185 } else { 185 } else {
186 masterMap.put(deviceId, backup); 186 masterMap.put(deviceId, backup);
187 termMap.get(deviceId).incrementAndGet(); 187 termMap.get(deviceId).incrementAndGet();
188 - return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, backup); 188 + return new MastershipEvent(MASTER_CHANGED, deviceId, backup);
189 } 189 }
190 case STANDBY: 190 case STANDBY:
191 case NONE: 191 case NONE:
...@@ -215,7 +215,7 @@ public class SimpleMastershipStore ...@@ -215,7 +215,7 @@ public class SimpleMastershipStore
215 } 215 }
216 216
217 @Override 217 @Override
218 - public DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) { 218 + public MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
219 return setStandby(nodeId, deviceId); 219 return setStandby(nodeId, deviceId);
220 } 220 }
221 221
......
...@@ -6,9 +6,9 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -6,9 +6,9 @@ import java.util.concurrent.atomic.AtomicInteger;
6 import org.junit.After; 6 import org.junit.After;
7 import org.junit.Before; 7 import org.junit.Before;
8 import org.junit.Test; 8 import org.junit.Test;
9 +import org.onlab.onos.cluster.MastershipTerm;
9 import org.onlab.onos.cluster.NodeId; 10 import org.onlab.onos.cluster.NodeId;
10 import org.onlab.onos.net.DeviceId; 11 import org.onlab.onos.net.DeviceId;
11 -import org.onlab.onos.net.device.DeviceMastershipTerm;
12 12
13 import com.google.common.collect.Sets; 13 import com.google.common.collect.Sets;
14 14
...@@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals; ...@@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNull; 16 import static org.junit.Assert.assertNull;
17 import static org.junit.Assert.assertTrue; 17 import static org.junit.Assert.assertTrue;
18 import static org.onlab.onos.net.MastershipRole.*; 18 import static org.onlab.onos.net.MastershipRole.*;
19 -import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*; 19 +import static org.onlab.onos.cluster.MastershipEvent.Type.*;
20 20
21 /** 21 /**
22 * Test for the simple MastershipStore implementation. 22 * Test for the simple MastershipStore implementation.
...@@ -98,12 +98,12 @@ public class SimpleMastershipStoreTest { ...@@ -98,12 +98,12 @@ public class SimpleMastershipStoreTest {
98 @Test 98 @Test
99 public void getTermFor() { 99 public void getTermFor() {
100 put(DID1, N1, true, true); 100 put(DID1, N1, true, true);
101 - assertEquals("wrong term", DeviceMastershipTerm.of(N1, 0), sms.getTermFor(DID1)); 101 + assertEquals("wrong term", MastershipTerm.of(N1, 0), sms.getTermFor(DID1));
102 102
103 //switch to N2 and back - 2 term switches 103 //switch to N2 and back - 2 term switches
104 sms.setMaster(N2, DID1); 104 sms.setMaster(N2, DID1);
105 sms.setMaster(N1, DID1); 105 sms.setMaster(N1, DID1);
106 - assertEquals("wrong term", DeviceMastershipTerm.of(N1, 2), sms.getTermFor(DID1)); 106 + assertEquals("wrong term", MastershipTerm.of(N1, 2), sms.getTermFor(DID1));
107 } 107 }
108 108
109 @Test 109 @Test
......