pankaj

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

Showing 56 changed files with 275 additions and 280 deletions
...@@ -170,7 +170,9 @@ public class ReactiveForwarding { ...@@ -170,7 +170,9 @@ public class ReactiveForwarding {
170 // We don't yet support bufferids in the flowservice so packet out first. 170 // We don't yet support bufferids in the flowservice so packet out first.
171 packetOut(context, portNumber); 171 packetOut(context, portNumber);
172 172
173 - 173 + if (true) {
174 + return;
175 + }
174 176
175 // Install the flow rule to handle this type of message from now on. 177 // Install the flow rule to handle this type of message from now on.
176 Ethernet inPkt = context.inPacket().parsed(); 178 Ethernet inPkt = context.inPacket().parsed();
......
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 +
4 import org.apache.karaf.shell.commands.Command; 5 import org.apache.karaf.shell.commands.Command;
5 import org.onlab.onos.cluster.ClusterService; 6 import org.onlab.onos.cluster.ClusterService;
6 import org.onlab.onos.cluster.ControllerNode; 7 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;
9 10
10 import java.util.Collections; 11 import java.util.Collections;
11 import java.util.List; 12 import java.util.List;
...@@ -22,7 +23,7 @@ public class MastersListCommand extends AbstractShellCommand { ...@@ -22,7 +23,7 @@ public class MastersListCommand extends AbstractShellCommand {
22 @Override 23 @Override
23 protected void execute() { 24 protected void execute() {
24 ClusterService service = get(ClusterService.class); 25 ClusterService service = get(ClusterService.class);
25 - MastershipService mastershipService = get(MastershipService.class); 26 + DeviceMastershipService mastershipService = get(DeviceMastershipService.class);
26 List<ControllerNode> nodes = newArrayList(service.getNodes()); 27 List<ControllerNode> nodes = newArrayList(service.getNodes());
27 Collections.sort(nodes, Comparators.NODE_COMPARATOR); 28 Collections.sort(nodes, Comparators.NODE_COMPARATOR);
28 ControllerNode self = service.getLocalNode(); 29 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;
7 import org.onlab.onos.cluster.NodeId; 6 import org.onlab.onos.cluster.NodeId;
8 import org.onlab.onos.net.MastershipRole; 7 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 - MastershipAdminService service = get(MastershipAdminService.class); 33 + DeviceMastershipAdminService service = get(DeviceMastershipAdminService.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 }
......
...@@ -19,17 +19,16 @@ import org.onlab.onos.net.intent.IntentState; ...@@ -19,17 +19,16 @@ import org.onlab.onos.net.intent.IntentState;
19 description = "Wipes-out the entire network information base, i.e. devices, links, hosts") 19 description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
20 public class WipeOutCommand extends ClustersListCommand { 20 public class WipeOutCommand extends ClustersListCommand {
21 21
22 - private static final String DISCLAIMER = "Delete everything please."; 22 + private static final String PLEASE = "please";
23 23
24 - @Argument(index = 0, name = "disclaimer", description = "Device ID", 24 + @Argument(index = 0, name = "please", description = "Confirmation phrase",
25 required = false, multiValued = false) 25 required = false, multiValued = false)
26 - String disclaimer = null; 26 + String please = null;
27 27
28 @Override 28 @Override
29 protected void execute() { 29 protected void execute() {
30 - if (disclaimer == null || !disclaimer.equals(DISCLAIMER)) { 30 + if (please == null || !please.equals(PLEASE)) {
31 - print("I'm afraid I can't do that!\nPlease acknowledge with phrase: '%s'", 31 + print("I'm afraid I can't do that!\nSay: %s", PLEASE);
32 - DISCLAIMER);
33 return; 32 return;
34 } 33 }
35 34
......
...@@ -9,10 +9,12 @@ import java.util.Objects; ...@@ -9,10 +9,12 @@ import java.util.Objects;
9 public abstract class ElementId { 9 public abstract class ElementId {
10 10
11 private final URI uri; 11 private final URI uri;
12 + private final String str;
12 13
13 // Default constructor for serialization 14 // Default constructor for serialization
14 protected ElementId() { 15 protected ElementId() {
15 this.uri = null; 16 this.uri = null;
17 + this.str = null;
16 } 18 }
17 19
18 /** 20 /**
...@@ -22,6 +24,7 @@ public abstract class ElementId { ...@@ -22,6 +24,7 @@ public abstract class ElementId {
22 */ 24 */
23 protected ElementId(URI uri) { 25 protected ElementId(URI uri) {
24 this.uri = uri; 26 this.uri = uri;
27 + this.str = uri.toString();
25 } 28 }
26 29
27 /** 30 /**
...@@ -35,7 +38,7 @@ public abstract class ElementId { ...@@ -35,7 +38,7 @@ public abstract class ElementId {
35 38
36 @Override 39 @Override
37 public int hashCode() { 40 public int hashCode() {
38 - return Objects.hash(uri); 41 + return Objects.hash(str);
39 } 42 }
40 43
41 @Override 44 @Override
...@@ -46,14 +49,14 @@ public abstract class ElementId { ...@@ -46,14 +49,14 @@ public abstract class ElementId {
46 if (obj instanceof ElementId) { 49 if (obj instanceof ElementId) {
47 final ElementId that = (ElementId) obj; 50 final ElementId that = (ElementId) obj;
48 return this.getClass() == that.getClass() && 51 return this.getClass() == that.getClass() &&
49 - Objects.equals(this.uri, that.uri); 52 + Objects.equals(this.str, that.str);
50 } 53 }
51 return false; 54 return false;
52 } 55 }
53 56
54 @Override 57 @Override
55 public String toString() { 58 public String toString() {
56 - return uri.toString(); 59 + return str;
57 } 60 }
58 61
59 } 62 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 +import org.onlab.onos.cluster.NodeId;
3 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.MastershipRole; 5 import org.onlab.onos.net.MastershipRole;
5 6
6 /** 7 /**
7 * Service for administering the inventory of device masterships. 8 * Service for administering the inventory of device masterships.
8 */ 9 */
9 -public interface MastershipAdminService { 10 +public interface DeviceMastershipAdminService {
10 11
11 /** 12 /**
12 * Applies the current mastership role for the specified device. 13 * Applies the current mastership role for the specified device.
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 +import org.onlab.onos.cluster.NodeId;
3 import org.onlab.onos.event.AbstractEvent; 4 import org.onlab.onos.event.AbstractEvent;
4 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
5 6
6 /** 7 /**
7 * Describes a device mastership event. 8 * Describes a device mastership event.
8 */ 9 */
9 -public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> { 10 +public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.Type, DeviceId> {
10 11
11 //do we worry about explicitly setting slaves/equals? probably not, 12 //do we worry about explicitly setting slaves/equals? probably not,
12 //to keep it simple 13 //to keep it simple
...@@ -30,7 +31,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -30,7 +31,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
30 * @param device event device subject 31 * @param device event device subject
31 * @param master master ID subject 32 * @param master master ID subject
32 */ 33 */
33 - public MastershipEvent(Type type, DeviceId device, NodeId master) { 34 + public DeviceMastershipEvent(Type type, DeviceId device, NodeId master) {
34 super(type, device); 35 super(type, device);
35 this.master = master; 36 this.master = master;
36 } 37 }
...@@ -44,7 +45,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -44,7 +45,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
44 * @param master master ID subject 45 * @param master master ID subject
45 * @param time occurrence time 46 * @param time occurrence time
46 */ 47 */
47 - public MastershipEvent(Type type, DeviceId device, NodeId master, long time) { 48 + public DeviceMastershipEvent(Type type, DeviceId device, NodeId master, long time) {
48 super(type, device, time); 49 super(type, device, time);
49 this.master = master; 50 this.master = master;
50 } 51 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
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 MastershipListener extends EventListener<MastershipEvent> { 8 +public interface DeviceMastershipListener extends EventListener<DeviceMastershipEvent> {
9 } 9 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 import java.util.Set; 3 import java.util.Set;
4 4
5 +import org.onlab.onos.cluster.NodeId;
5 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.MastershipRole; 7 import org.onlab.onos.net.MastershipRole;
7 8
...@@ -11,7 +12,7 @@ import org.onlab.onos.net.MastershipRole; ...@@ -11,7 +12,7 @@ import org.onlab.onos.net.MastershipRole;
11 * determining mastership, but is not responsible for actually applying it 12 * determining mastership, but is not responsible for actually applying it
12 * to the devices; this falls on the device service. 13 * to the devices; this falls on the device service.
13 */ 14 */
14 -public interface MastershipService { 15 +public interface DeviceMastershipService {
15 16
16 /** 17 /**
17 * Returns the role of the local node for the specified device, without 18 * Returns the role of the local node for the specified device, without
...@@ -62,20 +63,20 @@ public interface MastershipService { ...@@ -62,20 +63,20 @@ public interface MastershipService {
62 * 63 *
63 * @return the MastershipTermService for this mastership manager 64 * @return the MastershipTermService for this mastership manager
64 */ 65 */
65 - MastershipTermService requestTermService(); 66 + DeviceMastershipTermService requestTermService();
66 67
67 /** 68 /**
68 * Adds the specified mastership change listener. 69 * Adds the specified mastership change listener.
69 * 70 *
70 * @param listener the mastership listener 71 * @param listener the mastership listener
71 */ 72 */
72 - void addListener(MastershipListener listener); 73 + void addListener(DeviceMastershipListener listener);
73 74
74 /** 75 /**
75 * Removes the specified mastership change listener. 76 * Removes the specified mastership change listener.
76 * 77 *
77 * @param listener the mastership listener 78 * @param listener the mastership listener
78 */ 79 */
79 - void removeListener(MastershipListener listener); 80 + void removeListener(DeviceMastershipListener listener);
80 81
81 } 82 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 import java.util.Set; 3 import java.util.Set;
4 4
5 +import org.onlab.onos.cluster.NodeId;
5 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.MastershipRole; 7 import org.onlab.onos.net.MastershipRole;
7 import org.onlab.onos.store.Store; 8 import org.onlab.onos.store.Store;
...@@ -10,7 +11,7 @@ import org.onlab.onos.store.Store; ...@@ -10,7 +11,7 @@ import org.onlab.onos.store.Store;
10 * Manages inventory of mastership roles for devices, across controller 11 * Manages inventory of mastership roles for devices, across controller
11 * instances; not intended for direct use. 12 * instances; not intended for direct use.
12 */ 13 */
13 -public interface MastershipStore extends Store<MastershipEvent, MastershipStoreDelegate> { 14 +public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, DeviceMastershipStoreDelegate> {
14 15
15 // three things to map: NodeId, DeviceId, MastershipRole 16 // three things to map: NodeId, DeviceId, MastershipRole
16 17
...@@ -54,7 +55,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD ...@@ -54,7 +55,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
54 * @param deviceId device identifier 55 * @param deviceId device identifier
55 * @return a mastership event 56 * @return a mastership event
56 */ 57 */
57 - MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId); 58 + DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId);
58 59
59 /** 60 /**
60 * Returns the current master and number of past mastership hand-offs 61 * Returns the current master and number of past mastership hand-offs
...@@ -63,7 +64,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD ...@@ -63,7 +64,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
63 * @param deviceId the device identifier 64 * @param deviceId the device identifier
64 * @return the current master's ID and the term value for device, or null 65 * @return the current master's ID and the term value for device, or null
65 */ 66 */
66 - MastershipTerm getTermFor(DeviceId deviceId); 67 + DeviceMastershipTerm getTermFor(DeviceId deviceId);
67 68
68 /** 69 /**
69 * Sets a controller instance's mastership role to STANDBY for a device. 70 * Sets a controller instance's mastership role to STANDBY for a device.
...@@ -74,7 +75,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD ...@@ -74,7 +75,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
74 * @param deviceId device to revoke mastership role for 75 * @param deviceId device to revoke mastership role for
75 * @return a mastership event 76 * @return a mastership event
76 */ 77 */
77 - MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId); 78 + DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId);
78 79
79 /** 80 /**
80 * Allows a controller instance to give up its current role for a device. 81 * Allows a controller instance to give up its current role for a device.
...@@ -85,6 +86,6 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD ...@@ -85,6 +86,6 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
85 * @param deviceId device to revoke mastership role for 86 * @param deviceId device to revoke mastership role for
86 * @return a mastership event 87 * @return a mastership event
87 */ 88 */
88 - MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId); 89 + DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId);
89 90
90 } 91 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.store.StoreDelegate; 3 import org.onlab.onos.store.StoreDelegate;
4 4
5 /** 5 /**
6 - * Mastership store delegate abstraction. 6 + * DeviceMastership store delegate abstraction.
7 */ 7 */
8 -public interface MastershipStoreDelegate extends StoreDelegate<MastershipEvent> { 8 +public interface DeviceMastershipStoreDelegate extends StoreDelegate<DeviceMastershipEvent> {
9 } 9 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 import java.util.Objects; 3 import java.util.Objects;
4 4
5 -public final class MastershipTerm { 5 +import org.onlab.onos.cluster.NodeId;
6 +
7 +public final class DeviceMastershipTerm {
6 8
7 private final NodeId master; 9 private final NodeId master;
8 private final int termNumber; 10 private final int termNumber;
9 11
10 - private MastershipTerm(NodeId master, int term) { 12 + private DeviceMastershipTerm(NodeId master, int term) {
11 this.master = master; 13 this.master = master;
12 this.termNumber = term; 14 this.termNumber = term;
13 } 15 }
14 16
15 - public static MastershipTerm of(NodeId master, int term) { 17 + public static DeviceMastershipTerm of(NodeId master, int term) {
16 - return new MastershipTerm(master, term); 18 + return new DeviceMastershipTerm(master, term);
17 } 19 }
18 20
19 public NodeId master() { 21 public NodeId master() {
...@@ -34,8 +36,8 @@ public final class MastershipTerm { ...@@ -34,8 +36,8 @@ public final class MastershipTerm {
34 if (this == other) { 36 if (this == other) {
35 return true; 37 return true;
36 } 38 }
37 - if (other instanceof MastershipTerm) { 39 + if (other instanceof DeviceMastershipTerm) {
38 - MastershipTerm that = (MastershipTerm) other; 40 + DeviceMastershipTerm that = (DeviceMastershipTerm) other;
39 if (!this.master.equals(that.master)) { 41 if (!this.master.equals(that.master)) {
40 return false; 42 return false;
41 } 43 }
......
1 -package org.onlab.onos.cluster; 1 +package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 4
...@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId; ...@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId;
6 /** 6 /**
7 * Service to obtain mastership term information. 7 * Service to obtain mastership term information.
8 */ 8 */
9 -public interface MastershipTermService { 9 +public interface DeviceMastershipTermService {
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 MastershipTermService { ...@@ -16,5 +16,5 @@ public interface MastershipTermService {
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 - MastershipTerm getMastershipTerm(DeviceId deviceId); 19 + DeviceMastershipTerm getMastershipTerm(DeviceId deviceId);
20 } 20 }
......
1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 -import static org.slf4j.LoggerFactory.getLogger;
4 -
5 -import java.util.Collections;
6 -import java.util.LinkedList;
7 -import java.util.List;
8 -import java.util.Objects;
9 -
10 import org.onlab.onos.net.PortNumber; 3 import org.onlab.onos.net.PortNumber;
11 import org.onlab.onos.net.flow.instructions.Instruction; 4 import org.onlab.onos.net.flow.instructions.Instruction;
12 import org.onlab.onos.net.flow.instructions.Instructions; 5 import org.onlab.onos.net.flow.instructions.Instructions;
13 import org.onlab.packet.IpPrefix; 6 import org.onlab.packet.IpPrefix;
14 import org.onlab.packet.MacAddress; 7 import org.onlab.packet.MacAddress;
15 import org.onlab.packet.VlanId; 8 import org.onlab.packet.VlanId;
16 -import org.slf4j.Logger; 9 +
10 +import java.util.Collections;
11 +import java.util.LinkedList;
12 +import java.util.List;
13 +import java.util.Objects;
17 14
18 /** 15 /**
19 * Default traffic treatment implementation. 16 * Default traffic treatment implementation.
...@@ -58,7 +55,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -58,7 +55,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
58 } 55 }
59 if (obj instanceof DefaultTrafficTreatment) { 56 if (obj instanceof DefaultTrafficTreatment) {
60 DefaultTrafficTreatment that = (DefaultTrafficTreatment) obj; 57 DefaultTrafficTreatment that = (DefaultTrafficTreatment) obj;
61 - return Objects.equals(instructions, that.instructions); 58 + return Objects.equals(instructions, that.instructions);
62 59
63 } 60 }
64 return false; 61 return false;
...@@ -70,8 +67,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -70,8 +67,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
70 */ 67 */
71 public static final class Builder implements TrafficTreatment.Builder { 68 public static final class Builder implements TrafficTreatment.Builder {
72 69
73 - private final Logger log = getLogger(getClass());
74 -
75 boolean drop = false; 70 boolean drop = false;
76 71
77 List<Instruction> outputs = new LinkedList<>(); 72 List<Instruction> outputs = new LinkedList<>();
...@@ -107,7 +102,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -107,7 +102,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
107 groups.add(instruction); 102 groups.add(instruction);
108 break; 103 break;
109 default: 104 default:
110 - log.warn("Unknown instruction type {}", instruction.type()); 105 + throw new IllegalArgumentException("Unknown instruction type: " +
106 + instruction.type());
111 } 107 }
112 return this; 108 return this;
113 } 109 }
......
1 package org.onlab.onos.store; 1 package org.onlab.onos.store;
2 2
3 -import org.onlab.onos.cluster.MastershipTerm;
4 import org.onlab.onos.net.DeviceId; 3 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, MastershipTerm term); 19 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term);
20 } 20 }
......
1 -package org.onlab.onos.store.common.impl; 1 +package org.onlab.onos.store;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 4
5 import java.util.Objects; 5 import java.util.Objects;
6 6
7 -import org.onlab.onos.store.Timestamp;
8 -
9 import com.google.common.base.MoreObjects; 7 import com.google.common.base.MoreObjects;
10 8
11 /** 9 /**
......
1 -package org.onlab.onos.store.device.impl; 1 +package org.onlab.onos.store;
2 2
3 import java.util.Objects; 3 import java.util.Objects;
4 4
5 -import org.onlab.onos.store.Timestamp;
6 -
7 /** 5 /**
8 * Wrapper class for a entity that is versioned 6 * Wrapper class for a entity that is versioned
9 * and can either be up or down. 7 * and can either be up or down.
......
...@@ -2,13 +2,16 @@ package org.onlab.onos.cluster; ...@@ -2,13 +2,16 @@ 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;
5 8
6 import java.util.Set; 9 import java.util.Set;
7 10
8 /** 11 /**
9 * Test adapter for mastership service. 12 * Test adapter for mastership service.
10 */ 13 */
11 -public class MastershipServiceAdapter implements MastershipService { 14 +public class MastershipServiceAdapter implements DeviceMastershipService {
12 @Override 15 @Override
13 public MastershipRole getLocalRole(DeviceId deviceId) { 16 public MastershipRole getLocalRole(DeviceId deviceId) {
14 return null; 17 return null;
...@@ -34,15 +37,15 @@ public class MastershipServiceAdapter implements MastershipService { ...@@ -34,15 +37,15 @@ public class MastershipServiceAdapter implements MastershipService {
34 } 37 }
35 38
36 @Override 39 @Override
37 - public void addListener(MastershipListener listener) { 40 + public void addListener(DeviceMastershipListener listener) {
38 } 41 }
39 42
40 @Override 43 @Override
41 - public void removeListener(MastershipListener listener) { 44 + public void removeListener(DeviceMastershipListener listener) {
42 } 45 }
43 46
44 @Override 47 @Override
45 - public MastershipTermService requestTermService() { 48 + public DeviceMastershipTermService requestTermService() {
46 return null; 49 return null;
47 } 50 }
48 } 51 }
......
...@@ -3,6 +3,7 @@ package org.onlab.onos.cluster; ...@@ -3,6 +3,7 @@ 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;
6 7
7 import com.google.common.testing.EqualsTester; 8 import com.google.common.testing.EqualsTester;
8 9
...@@ -11,10 +12,10 @@ public class MastershipTermTest { ...@@ -11,10 +12,10 @@ public class MastershipTermTest {
11 private static final NodeId N1 = new NodeId("foo"); 12 private static final NodeId N1 = new NodeId("foo");
12 private static final NodeId N2 = new NodeId("bar"); 13 private static final NodeId N2 = new NodeId("bar");
13 14
14 - private static final MastershipTerm TERM1 = MastershipTerm.of(N1, 0); 15 + private static final DeviceMastershipTerm TERM1 = DeviceMastershipTerm.of(N1, 0);
15 - private static final MastershipTerm TERM2 = MastershipTerm.of(N2, 1); 16 + private static final DeviceMastershipTerm TERM2 = DeviceMastershipTerm.of(N2, 1);
16 - private static final MastershipTerm TERM3 = MastershipTerm.of(N2, 1); 17 + private static final DeviceMastershipTerm TERM3 = DeviceMastershipTerm.of(N2, 1);
17 - private static final MastershipTerm TERM4 = MastershipTerm.of(N1, 1); 18 + private static final DeviceMastershipTerm TERM4 = DeviceMastershipTerm.of(N1, 1);
18 19
19 @Test 20 @Test
20 public void basics() { 21 public void basics() {
...@@ -24,7 +25,7 @@ public class MastershipTermTest { ...@@ -24,7 +25,7 @@ public class MastershipTermTest {
24 25
25 @Test 26 @Test
26 public void testEquality() { 27 public void testEquality() {
27 - new EqualsTester().addEqualityGroup(MastershipTerm.of(N1, 0), TERM1) 28 + new EqualsTester().addEqualityGroup(DeviceMastershipTerm.of(N1, 0), TERM1)
28 .addEqualityGroup(TERM2, TERM3) 29 .addEqualityGroup(TERM2, TERM3)
29 .addEqualityGroup(TERM4); 30 .addEqualityGroup(TERM4);
30 } 31 }
......
...@@ -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;
25 import org.onlab.onos.cluster.NodeId; 17 import org.onlab.onos.cluster.NodeId;
26 import org.onlab.onos.event.AbstractListenerRegistry; 18 import org.onlab.onos.event.AbstractListenerRegistry;
27 import org.onlab.onos.event.EventDeliveryService; 19 import org.onlab.onos.event.EventDeliveryService;
28 import org.onlab.onos.net.DeviceId; 20 import org.onlab.onos.net.DeviceId;
29 import org.onlab.onos.net.MastershipRole; 21 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 MastershipService, MastershipAdminService { 35 +implements DeviceMastershipService, DeviceMastershipAdminService {
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 MastershipService, MastershipAdminService { ...@@ -40,13 +40,13 @@ implements MastershipService, MastershipAdminService {
40 40
41 private final Logger log = getLogger(getClass()); 41 private final Logger log = getLogger(getClass());
42 42
43 - protected final AbstractListenerRegistry<MastershipEvent, MastershipListener> 43 + protected final AbstractListenerRegistry<DeviceMastershipEvent, DeviceMastershipListener>
44 listenerRegistry = new AbstractListenerRegistry<>(); 44 listenerRegistry = new AbstractListenerRegistry<>();
45 45
46 - private final MastershipStoreDelegate delegate = new InternalDelegate(); 46 + private final DeviceMastershipStoreDelegate delegate = new InternalDelegate();
47 47
48 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 48 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
49 - protected MastershipStore store; 49 + protected DeviceMastershipStore 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 MastershipService, MastershipAdminService { ...@@ -58,7 +58,7 @@ implements MastershipService, MastershipAdminService {
58 58
59 @Activate 59 @Activate
60 public void activate() { 60 public void activate() {
61 - eventDispatcher.addSink(MastershipEvent.class, listenerRegistry); 61 + eventDispatcher.addSink(DeviceMastershipEvent.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 MastershipService, MastershipAdminService { ...@@ -66,7 +66,7 @@ implements MastershipService, MastershipAdminService {
66 66
67 @Deactivate 67 @Deactivate
68 public void deactivate() { 68 public void deactivate() {
69 - eventDispatcher.removeSink(MastershipEvent.class); 69 + eventDispatcher.removeSink(DeviceMastershipEvent.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 MastershipService, MastershipAdminService { ...@@ -78,7 +78,7 @@ implements MastershipService, MastershipAdminService {
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 - MastershipEvent event = null; 81 + DeviceMastershipEvent 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 MastershipService, MastershipAdminService { ...@@ -98,7 +98,7 @@ implements MastershipService, MastershipAdminService {
98 98
99 @Override 99 @Override
100 public void relinquishMastership(DeviceId deviceId) { 100 public void relinquishMastership(DeviceId deviceId) {
101 - MastershipEvent event = null; 101 + DeviceMastershipEvent 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 MastershipService, MastershipAdminService { ...@@ -127,18 +127,18 @@ implements MastershipService, MastershipAdminService {
127 127
128 128
129 @Override 129 @Override
130 - public MastershipTermService requestTermService() { 130 + public DeviceMastershipTermService requestTermService() {
131 return new InternalMastershipTermService(); 131 return new InternalMastershipTermService();
132 } 132 }
133 133
134 @Override 134 @Override
135 - public void addListener(MastershipListener listener) { 135 + public void addListener(DeviceMastershipListener 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(MastershipListener listener) { 141 + public void removeListener(DeviceMastershipListener listener) {
142 checkNotNull(listener); 142 checkNotNull(listener);
143 listenerRegistry.removeListener(listener); 143 listenerRegistry.removeListener(listener);
144 } 144 }
...@@ -146,16 +146,16 @@ implements MastershipService, MastershipAdminService { ...@@ -146,16 +146,16 @@ implements MastershipService, MastershipAdminService {
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(MastershipEvent event) { 149 + private void post(DeviceMastershipEvent 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 MastershipTermService { 155 + private class InternalMastershipTermService implements DeviceMastershipTermService {
156 156
157 @Override 157 @Override
158 - public MastershipTerm getMastershipTerm(DeviceId deviceId) { 158 + public DeviceMastershipTerm getMastershipTerm(DeviceId deviceId) {
159 return store.getTermFor(deviceId); 159 return store.getTermFor(deviceId);
160 } 160 }
161 161
...@@ -181,10 +181,10 @@ implements MastershipService, MastershipAdminService { ...@@ -181,10 +181,10 @@ implements MastershipService, MastershipAdminService {
181 181
182 } 182 }
183 183
184 - public class InternalDelegate implements MastershipStoreDelegate { 184 + public class InternalDelegate implements DeviceMastershipStoreDelegate {
185 185
186 @Override 186 @Override
187 - public void notify(MastershipEvent event) { 187 + public void notify(DeviceMastershipEvent 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,11 +13,6 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -13,11 +13,6 @@ 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;
21 import org.onlab.onos.cluster.NodeId; 16 import org.onlab.onos.cluster.NodeId;
22 import org.onlab.onos.event.AbstractListenerRegistry; 17 import org.onlab.onos.event.AbstractListenerRegistry;
23 import org.onlab.onos.event.EventDeliveryService; 18 import org.onlab.onos.event.EventDeliveryService;
...@@ -36,6 +31,11 @@ import org.onlab.onos.net.device.DeviceProviderService; ...@@ -36,6 +31,11 @@ import org.onlab.onos.net.device.DeviceProviderService;
36 import org.onlab.onos.net.device.DeviceService; 31 import org.onlab.onos.net.device.DeviceService;
37 import org.onlab.onos.net.device.DeviceStore; 32 import org.onlab.onos.net.device.DeviceStore;
38 import org.onlab.onos.net.device.DeviceStoreDelegate; 33 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 MastershipListener mastershipListener = new InternalMastershipListener(); 67 + private final DeviceMastershipListener 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 MastershipService mastershipService; 79 + protected DeviceMastershipService mastershipService;
80 80
81 - protected MastershipTermService termService; 81 + protected DeviceMastershipTermService termService;
82 82
83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 protected ClockProviderService clockProviderService; 84 protected 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 - MastershipTerm term = mastershipService.requestTermService() 212 + DeviceMastershipTerm 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 MastershipListener { 323 + private class InternalMastershipListener implements DeviceMastershipListener {
324 324
325 @Override 325 @Override
326 - public void event(MastershipEvent event) { 326 + public void event(DeviceMastershipEvent 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 - MastershipTerm term = termService.getMastershipTerm(did); 332 + DeviceMastershipTerm 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;
15 import org.onlab.onos.cluster.NodeId; 13 import org.onlab.onos.cluster.NodeId;
16 import org.onlab.onos.event.impl.TestEventDispatcher; 14 import org.onlab.onos.event.impl.TestEventDispatcher;
17 import org.onlab.onos.net.DeviceId; 15 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 MastershipService service; 37 + protected DeviceMastershipService 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 - MastershipTermService ts = mgr.requestTermService(); 123 + DeviceMastershipTermService 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,8 +11,6 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -11,8 +11,6 @@ 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;
16 import org.onlab.onos.cluster.NodeId; 14 import org.onlab.onos.cluster.NodeId;
17 import org.onlab.onos.cluster.ControllerNode.State; 15 import org.onlab.onos.cluster.ControllerNode.State;
18 import org.onlab.onos.event.Event; 16 import org.onlab.onos.event.Event;
...@@ -32,6 +30,8 @@ import org.onlab.onos.net.device.DeviceProvider; ...@@ -32,6 +30,8 @@ import org.onlab.onos.net.device.DeviceProvider;
32 import org.onlab.onos.net.device.DeviceProviderRegistry; 30 import org.onlab.onos.net.device.DeviceProviderRegistry;
33 import org.onlab.onos.net.device.DeviceProviderService; 31 import org.onlab.onos.net.device.DeviceProviderService;
34 import org.onlab.onos.net.device.DeviceService; 32 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 MastershipTermService requestTermService() { 293 + public DeviceMastershipTermService requestTermService() {
294 - return new MastershipTermService() { 294 + return new DeviceMastershipTermService() {
295 @Override 295 @Override
296 - public MastershipTerm getMastershipTerm(DeviceId deviceId) { 296 + public DeviceMastershipTerm getMastershipTerm(DeviceId deviceId) {
297 // FIXME: just returning something not null 297 // FIXME: just returning something not null
298 - return MastershipTerm.of(NID_LOCAL, 1); 298 + return DeviceMastershipTerm.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, MastershipTerm term) { 342 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
343 // TODO Auto-generated method stub 343 // TODO Auto-generated method stub
344 } 344 }
345 } 345 }
......
...@@ -6,6 +6,7 @@ import java.io.IOException; ...@@ -6,6 +6,7 @@ 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 +
9 import org.apache.felix.scr.annotations.Activate; 10 import org.apache.felix.scr.annotations.Activate;
10 import org.apache.felix.scr.annotations.Component; 11 import org.apache.felix.scr.annotations.Component;
11 import org.apache.felix.scr.annotations.Deactivate; 12 import org.apache.felix.scr.annotations.Deactivate;
...@@ -23,10 +24,8 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; ...@@ -23,10 +24,8 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
23 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 24 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
24 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 25 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
25 import org.onlab.onos.store.cluster.messaging.MessageSubject; 26 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;
30 import org.onlab.util.KryoPool; 29 import org.onlab.util.KryoPool;
31 import org.onlab.netty.Endpoint; 30 import org.onlab.netty.Endpoint;
32 import org.onlab.netty.Message; 31 import org.onlab.netty.Message;
......
1 -package org.onlab.onos.store.serializers; 1 +package org.onlab.onos.store.cluster.messaging.impl;
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.serializers; 1 +package org.onlab.onos.store.cluster.messaging.impl;
2 2
3 import org.onlab.onos.store.cluster.messaging.MessageSubject; 3 import org.onlab.onos.store.cluster.messaging.MessageSubject;
4 4
......
...@@ -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.device.impl.VersionedValue; 7 +import org.onlab.onos.store.VersionedValue;
8 8
9 import com.google.common.collect.ImmutableMap; 9 import com.google.common.collect.ImmutableMap;
10 import com.google.common.collect.ImmutableSet; 10 import com.google.common.collect.ImmutableSet;
......
...@@ -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 MastershipBasedTimestamp implements Timestamp { 16 +public final class DeviceMastershipBasedTimestamp 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 MastershipBasedTimestamp implements Timestamp { ...@@ -24,16 +24,16 @@ public final class MastershipBasedTimestamp 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 MastershipBasedTimestamp(int termNumber, int sequenceNumber) { 27 + public DeviceMastershipBasedTimestamp(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 MastershipBasedTimestamp, 34 + checkArgument(o instanceof DeviceMastershipBasedTimestamp,
35 "Must be MastershipBasedTimestamp", o); 35 "Must be MastershipBasedTimestamp", o);
36 - MastershipBasedTimestamp that = (MastershipBasedTimestamp) o; 36 + DeviceMastershipBasedTimestamp that = (DeviceMastershipBasedTimestamp) 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 MastershipBasedTimestamp implements Timestamp { ...@@ -51,10 +51,10 @@ public final class MastershipBasedTimestamp implements Timestamp {
51 if (this == obj) { 51 if (this == obj) {
52 return true; 52 return true;
53 } 53 }
54 - if (!(obj instanceof MastershipBasedTimestamp)) { 54 + if (!(obj instanceof DeviceMastershipBasedTimestamp)) {
55 return false; 55 return false;
56 } 56 }
57 - MastershipBasedTimestamp that = (MastershipBasedTimestamp) obj; 57 + DeviceMastershipBasedTimestamp that = (DeviceMastershipBasedTimestamp) 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 MastershipBasedTimestamp implements Timestamp { ...@@ -87,7 +87,7 @@ public final class MastershipBasedTimestamp implements Timestamp {
87 87
88 // Default constructor for serialization 88 // Default constructor for serialization
89 @Deprecated 89 @Deprecated
90 - protected MastershipBasedTimestamp() { 90 + protected DeviceMastershipBasedTimestamp() {
91 this.termNumber = -1; 91 this.termNumber = -1;
92 this.sequenceNumber = -1; 92 this.sequenceNumber = -1;
93 } 93 }
......
1 -package org.onlab.onos.store.serializers; 1 +package org.onlab.onos.store.common.impl;
2 -
3 -import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
4 2
5 import com.esotericsoftware.kryo.Kryo; 3 import com.esotericsoftware.kryo.Kryo;
6 import com.esotericsoftware.kryo.Serializer; 4 import com.esotericsoftware.kryo.Serializer;
...@@ -9,12 +7,12 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -9,12 +7,12 @@ import com.esotericsoftware.kryo.io.Output;
9 7
10 // To be used if Timestamp ever needs to cross bundle boundary. 8 // To be used if Timestamp ever needs to cross bundle boundary.
11 /** 9 /**
12 - * Kryo Serializer for {@link MastershipBasedTimestamp}. 10 + * Kryo Serializer for {@link DeviceMastershipBasedTimestamp}.
13 */ 11 */
14 -public class MastershipBasedTimestampSerializer extends Serializer<MastershipBasedTimestamp> { 12 +public class MastershipBasedTimestampSerializer extends Serializer<DeviceMastershipBasedTimestamp> {
15 13
16 /** 14 /**
17 - * Creates a serializer for {@link MastershipBasedTimestamp}. 15 + * Creates a serializer for {@link DeviceMastershipBasedTimestamp}.
18 */ 16 */
19 public MastershipBasedTimestampSerializer() { 17 public MastershipBasedTimestampSerializer() {
20 // non-null, immutable 18 // non-null, immutable
...@@ -22,15 +20,15 @@ public class MastershipBasedTimestampSerializer extends Serializer<MastershipBas ...@@ -22,15 +20,15 @@ public class MastershipBasedTimestampSerializer extends Serializer<MastershipBas
22 } 20 }
23 21
24 @Override 22 @Override
25 - public void write(Kryo kryo, Output output, MastershipBasedTimestamp object) { 23 + public void write(Kryo kryo, Output output, DeviceMastershipBasedTimestamp object) {
26 output.writeInt(object.termNumber()); 24 output.writeInt(object.termNumber());
27 output.writeInt(object.sequenceNumber()); 25 output.writeInt(object.sequenceNumber());
28 } 26 }
29 27
30 @Override 28 @Override
31 - public MastershipBasedTimestamp read(Kryo kryo, Input input, Class<MastershipBasedTimestamp> type) { 29 + public DeviceMastershipBasedTimestamp read(Kryo kryo, Input input, Class<DeviceMastershipBasedTimestamp> type) {
32 final int term = input.readInt(); 30 final int term = input.readInt();
33 final int sequence = input.readInt(); 31 final int sequence = input.readInt();
34 - return new MastershipBasedTimestamp(term, sequence); 32 + return new DeviceMastershipBasedTimestamp(term, sequence);
35 } 33 }
36 } 34 }
......
...@@ -8,6 +8,7 @@ import org.onlab.onos.cluster.NodeId; ...@@ -8,6 +8,7 @@ import org.onlab.onos.cluster.NodeId;
8 import org.onlab.onos.net.Device; 8 import org.onlab.onos.net.Device;
9 import org.onlab.onos.net.DeviceId; 9 import org.onlab.onos.net.DeviceId;
10 import org.onlab.onos.store.Timestamp; 10 import org.onlab.onos.store.Timestamp;
11 +import org.onlab.onos.store.VersionedValue;
11 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement; 12 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement;
12 13
13 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID) 14 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID)
......
...@@ -10,6 +10,7 @@ import org.onlab.onos.cluster.NodeId; ...@@ -10,6 +10,7 @@ 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;
13 import org.onlab.onos.store.common.impl.AntiEntropyReply; 14 import org.onlab.onos.store.common.impl.AntiEntropyReply;
14 15
15 import com.google.common.collect.ImmutableMap; 16 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;
14 import org.onlab.onos.net.DeviceId; 13 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.MastershipBasedTimestamp; 18 +import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp;
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, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>(); 32 + private ConcurrentMap<DeviceId, DeviceMastershipTerm> 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 - MastershipTerm term = deviceMastershipTerms.get(deviceId); 46 + DeviceMastershipTerm 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 MastershipBasedTimestamp(term.termNumber(), ticker.incrementAndGet()); 50 + return new DeviceMastershipBasedTimestamp(term.termNumber(), ticker.incrementAndGet());
51 } 51 }
52 52
53 @Override 53 @Override
54 - public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { 54 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm 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;
38 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; 39 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
39 import org.onlab.onos.store.cluster.messaging.ClusterMessage; 40 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
40 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; 41 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
41 -import org.onlab.onos.store.common.impl.MastershipBasedTimestamp; 42 +import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp;
42 -import org.onlab.onos.store.common.impl.Timestamped; 43 +import org.onlab.onos.store.common.impl.MastershipBasedTimestampSerializer;
43 import org.onlab.onos.store.serializers.KryoPoolUtil; 44 import org.onlab.onos.store.serializers.KryoPoolUtil;
44 import org.onlab.onos.store.serializers.KryoSerializer; 45 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(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer()) 128 + .register(DeviceMastershipBasedTimestamp.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.common.impl.Timestamped; 6 +import org.onlab.onos.store.Timestamped;
7 7
8 /** 8 /**
9 * Information published by GossipDeviceStore to notify peers of a device 9 * Information published by GossipDeviceStore to notify peers of a device
......
...@@ -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.common.impl.Timestamped; 6 +import org.onlab.onos.store.Timestamped;
7 7
8 import com.esotericsoftware.kryo.Kryo; 8 import com.esotericsoftware.kryo.Kryo;
9 import com.esotericsoftware.kryo.Serializer; 9 import com.esotericsoftware.kryo.Serializer;
......
...@@ -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.common.impl.Timestamped; 8 +import org.onlab.onos.store.Timestamped;
9 9
10 /** 10 /**
11 * Information published by GossipDeviceStore to notify peers of a port 11 * Information published by GossipDeviceStore to notify peers of a port
......
...@@ -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.common.impl.Timestamped; 8 +import org.onlab.onos.store.Timestamped;
9 9
10 import com.esotericsoftware.kryo.Kryo; 10 import com.esotericsoftware.kryo.Kryo;
11 import com.esotericsoftware.kryo.Serializer; 11 import com.esotericsoftware.kryo.Serializer;
......
...@@ -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.common.impl.Timestamped; 6 +import org.onlab.onos.store.Timestamped;
7 7
8 /** 8 /**
9 * Information published by GossipDeviceStore to notify peers of a port 9 * Information published by GossipDeviceStore to notify peers of a port
......
...@@ -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.common.impl.Timestamped; 6 +import org.onlab.onos.store.Timestamped;
7 7
8 import com.esotericsoftware.kryo.Kryo; 8 import com.esotericsoftware.kryo.Kryo;
9 import com.esotericsoftware.kryo.Serializer; 9 import com.esotericsoftware.kryo.Serializer;
......
...@@ -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.device.impl.VersionedValue; 34 +import org.onlab.onos.store.VersionedValue;
35 import org.slf4j.Logger; 35 import org.slf4j.Logger;
36 36
37 import com.google.common.collect.HashMultimap; 37 import com.google.common.collect.HashMultimap;
......
...@@ -6,26 +6,25 @@ import java.nio.ByteBuffer; ...@@ -6,26 +6,25 @@ 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;
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;
13 12
14 /** 13 /**
15 - * Test of {@link MastershipBasedTimestamp}. 14 + * Test of {@link DeviceMastershipBasedTimestamp}.
16 */ 15 */
17 public class MastershipBasedTimestampTest { 16 public class MastershipBasedTimestampTest {
18 17
19 - private static final Timestamp TS_1_1 = new MastershipBasedTimestamp(1, 1); 18 + private static final Timestamp TS_1_1 = new DeviceMastershipBasedTimestamp(1, 1);
20 - private static final Timestamp TS_1_2 = new MastershipBasedTimestamp(1, 2); 19 + private static final Timestamp TS_1_2 = new DeviceMastershipBasedTimestamp(1, 2);
21 - private static final Timestamp TS_2_1 = new MastershipBasedTimestamp(2, 1); 20 + private static final Timestamp TS_2_1 = new DeviceMastershipBasedTimestamp(2, 1);
22 - private static final Timestamp TS_2_2 = new MastershipBasedTimestamp(2, 2); 21 + private static final Timestamp TS_2_2 = new DeviceMastershipBasedTimestamp(2, 2);
23 22
24 @Test 23 @Test
25 public final void testBasic() { 24 public final void testBasic() {
26 final int termNumber = 5; 25 final int termNumber = 5;
27 final int sequenceNumber = 6; 26 final int sequenceNumber = 6;
28 - MastershipBasedTimestamp ts = new MastershipBasedTimestamp(termNumber, 27 + DeviceMastershipBasedTimestamp ts = new DeviceMastershipBasedTimestamp(termNumber,
29 sequenceNumber); 28 sequenceNumber);
30 29
31 assertEquals(termNumber, ts.termNumber()); 30 assertEquals(termNumber, ts.termNumber());
...@@ -35,7 +34,7 @@ public class MastershipBasedTimestampTest { ...@@ -35,7 +34,7 @@ public class MastershipBasedTimestampTest {
35 @Test 34 @Test
36 public final void testCompareTo() { 35 public final void testCompareTo() {
37 assertTrue(TS_1_1.compareTo(TS_1_1) == 0); 36 assertTrue(TS_1_1.compareTo(TS_1_1) == 0);
38 - assertTrue(TS_1_1.compareTo(new MastershipBasedTimestamp(1, 1)) == 0); 37 + assertTrue(TS_1_1.compareTo(new DeviceMastershipBasedTimestamp(1, 1)) == 0);
39 38
40 assertTrue(TS_1_1.compareTo(TS_1_2) < 0); 39 assertTrue(TS_1_1.compareTo(TS_1_2) < 0);
41 assertTrue(TS_1_2.compareTo(TS_1_1) > 0); 40 assertTrue(TS_1_2.compareTo(TS_1_1) > 0);
...@@ -49,14 +48,14 @@ public class MastershipBasedTimestampTest { ...@@ -49,14 +48,14 @@ public class MastershipBasedTimestampTest {
49 @Test 48 @Test
50 public final void testEqualsObject() { 49 public final void testEqualsObject() {
51 new EqualsTester() 50 new EqualsTester()
52 - .addEqualityGroup(new MastershipBasedTimestamp(1, 1), 51 + .addEqualityGroup(new DeviceMastershipBasedTimestamp(1, 1),
53 - new MastershipBasedTimestamp(1, 1), TS_1_1) 52 + new DeviceMastershipBasedTimestamp(1, 1), TS_1_1)
54 - .addEqualityGroup(new MastershipBasedTimestamp(1, 2), 53 + .addEqualityGroup(new DeviceMastershipBasedTimestamp(1, 2),
55 - new MastershipBasedTimestamp(1, 2), TS_1_2) 54 + new DeviceMastershipBasedTimestamp(1, 2), TS_1_2)
56 - .addEqualityGroup(new MastershipBasedTimestamp(2, 1), 55 + .addEqualityGroup(new DeviceMastershipBasedTimestamp(2, 1),
57 - new MastershipBasedTimestamp(2, 1), TS_2_1) 56 + new DeviceMastershipBasedTimestamp(2, 1), TS_2_1)
58 - .addEqualityGroup(new MastershipBasedTimestamp(2, 2), 57 + .addEqualityGroup(new DeviceMastershipBasedTimestamp(2, 2),
59 - new MastershipBasedTimestamp(2, 2), TS_2_2) 58 + new DeviceMastershipBasedTimestamp(2, 2), TS_2_2)
60 .testEquals(); 59 .testEquals();
61 } 60 }
62 61
...@@ -64,7 +63,7 @@ public class MastershipBasedTimestampTest { ...@@ -64,7 +63,7 @@ public class MastershipBasedTimestampTest {
64 public final void testKryoSerializable() { 63 public final void testKryoSerializable() {
65 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); 64 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
66 final KryoPool kryos = KryoPool.newBuilder() 65 final KryoPool kryos = KryoPool.newBuilder()
67 - .register(MastershipBasedTimestamp.class) 66 + .register(DeviceMastershipBasedTimestamp.class)
68 .build(); 67 .build();
69 68
70 kryos.serialize(TS_2_1, buffer); 69 kryos.serialize(TS_2_1, buffer);
...@@ -80,7 +79,7 @@ public class MastershipBasedTimestampTest { ...@@ -80,7 +79,7 @@ public class MastershipBasedTimestampTest {
80 public final void testKryoSerializableWithHandcraftedSerializer() { 79 public final void testKryoSerializableWithHandcraftedSerializer() {
81 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); 80 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
82 final KryoPool kryos = KryoPool.newBuilder() 81 final KryoPool kryos = KryoPool.newBuilder()
83 - .register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer()) 82 + .register(DeviceMastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
84 .build(); 83 .build();
85 84
86 kryos.serialize(TS_1_2, buffer); 85 kryos.serialize(TS_1_2, buffer);
......
...@@ -6,6 +6,7 @@ import java.nio.ByteBuffer; ...@@ -6,6 +6,7 @@ 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;
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;
...@@ -15,9 +16,9 @@ import com.google.common.testing.EqualsTester; ...@@ -15,9 +16,9 @@ import com.google.common.testing.EqualsTester;
15 */ 16 */
16 public class TimestampedTest { 17 public class TimestampedTest {
17 18
18 - private static final Timestamp TS_1_1 = new MastershipBasedTimestamp(1, 1); 19 + private static final Timestamp TS_1_1 = new DeviceMastershipBasedTimestamp(1, 1);
19 - private static final Timestamp TS_1_2 = new MastershipBasedTimestamp(1, 2); 20 + private static final Timestamp TS_1_2 = new DeviceMastershipBasedTimestamp(1, 2);
20 - private static final Timestamp TS_2_1 = new MastershipBasedTimestamp(2, 1); 21 + private static final Timestamp TS_2_1 = new DeviceMastershipBasedTimestamp(2, 1);
21 22
22 @Test 23 @Test
23 public final void testHashCode() { 24 public final void testHashCode() {
...@@ -79,7 +80,7 @@ public class TimestampedTest { ...@@ -79,7 +80,7 @@ public class TimestampedTest {
79 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); 80 final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
80 final KryoPool kryos = KryoPool.newBuilder() 81 final KryoPool kryos = KryoPool.newBuilder()
81 .register(Timestamped.class, 82 .register(Timestamped.class,
82 - MastershipBasedTimestamp.class) 83 + DeviceMastershipBasedTimestamp.class)
83 .build(); 84 .build();
84 85
85 Timestamped<String> original = new Timestamped<>("foobar", TS_1_1); 86 Timestamped<String> original = new Timestamped<>("foobar", TS_1_1);
......
...@@ -25,7 +25,6 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -25,7 +25,6 @@ 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;
29 import org.onlab.onos.cluster.NodeId; 28 import org.onlab.onos.cluster.NodeId;
30 import org.onlab.onos.net.Annotations; 29 import org.onlab.onos.net.Annotations;
31 import org.onlab.onos.net.DefaultAnnotations; 30 import org.onlab.onos.net.DefaultAnnotations;
...@@ -40,6 +39,7 @@ import org.onlab.onos.net.device.DeviceDescription; ...@@ -40,6 +39,7 @@ import org.onlab.onos.net.device.DeviceDescription;
40 import org.onlab.onos.net.device.DeviceEvent; 39 import org.onlab.onos.net.device.DeviceEvent;
41 import org.onlab.onos.net.device.DeviceStore; 40 import org.onlab.onos.net.device.DeviceStore;
42 import org.onlab.onos.net.device.DeviceStoreDelegate; 41 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, MastershipTerm.of(MYSELF, 1)); 116 + deviceClockManager.setMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1));
117 - deviceClockManager.setMastershipTerm(DID2, MastershipTerm.of(MYSELF, 2)); 117 + deviceClockManager.setMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2));
118 118
119 ClusterCommunicationService clusterCommunicator = new TestClusterCommunicationService(); 119 ClusterCommunicationService clusterCommunicator = new TestClusterCommunicationService();
120 ClusterService clusterService = new TestClusterService(); 120 ClusterService clusterService = new TestClusterService();
......
1 package org.onlab.onos.store.cluster.impl; 1 package org.onlab.onos.store.cluster.impl;
2 2
3 -import static org.onlab.onos.cluster.MastershipEvent.Type.MASTER_CHANGED; 3 +import static org.onlab.onos.net.device.DeviceMastershipEvent.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;
19 import org.onlab.onos.cluster.NodeId; 15 import org.onlab.onos.cluster.NodeId;
20 import org.onlab.onos.net.DeviceId; 16 import org.onlab.onos.net.DeviceId;
21 import org.onlab.onos.net.MastershipRole; 17 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;
...@@ -32,9 +32,9 @@ import com.hazelcast.core.MultiMap; ...@@ -32,9 +32,9 @@ import com.hazelcast.core.MultiMap;
32 */ 32 */
33 @Component(immediate = true) 33 @Component(immediate = true)
34 @Service 34 @Service
35 -public class DistributedMastershipStore 35 +public class DistributedDeviceMastershipStore
36 -extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate> 36 +extends AbstractHazelcastStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate>
37 -implements MastershipStore { 37 +implements DeviceMastershipStore {
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 MastershipStore { ...@@ -100,7 +100,7 @@ implements MastershipStore {
100 } 100 }
101 101
102 @Override 102 @Override
103 - public MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) { 103 + public DeviceMastershipEvent 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 MastershipStore { ...@@ -123,12 +123,12 @@ implements MastershipStore {
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 MastershipEvent(MASTER_CHANGED, deviceId, nodeId); 126 + return new DeviceMastershipEvent(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 MastershipEvent(MASTER_CHANGED, deviceId, nodeId); 131 + return new DeviceMastershipEvent(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 MastershipStore { ...@@ -191,21 +191,21 @@ implements MastershipStore {
191 } 191 }
192 192
193 @Override 193 @Override
194 - public MastershipTerm getTermFor(DeviceId deviceId) { 194 + public DeviceMastershipTerm 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 MastershipTerm.of( 200 + return DeviceMastershipTerm.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 MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) { 205 + public DeviceMastershipEvent 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 - MastershipEvent event = null; 208 + DeviceMastershipEvent 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 MastershipStore { ...@@ -231,10 +231,10 @@ implements MastershipStore {
231 } 231 }
232 232
233 @Override 233 @Override
234 - public MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) { 234 + public DeviceMastershipEvent 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 - MastershipEvent event = null; 237 + DeviceMastershipEvent 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 MastershipStore { ...@@ -260,7 +260,7 @@ implements MastershipStore {
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 MastershipEvent reelect(NodeId current, DeviceId deviceId) { 263 + private DeviceMastershipEvent 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 MastershipStore { ...@@ -281,7 +281,7 @@ implements MastershipStore {
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 MastershipEvent( 284 + return new DeviceMastershipEvent(
285 MASTER_CHANGED, deviceId, (NodeId) deserialize(backup)); 285 MASTER_CHANGED, deviceId, (NodeId) deserialize(backup));
286 } 286 }
287 } 287 }
...@@ -320,7 +320,7 @@ implements MastershipStore { ...@@ -320,7 +320,7 @@ implements MastershipStore {
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 MastershipEvent(MASTER_CHANGED, deviceId, nodeId)); 323 + notifyDelegate(new DeviceMastershipEvent(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;
28 import org.onlab.onos.cluster.NodeId; 24 import org.onlab.onos.cluster.NodeId;
29 import org.onlab.onos.net.DeviceId; 25 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;
...@@ -40,7 +40,7 @@ import com.hazelcast.core.Hazelcast; ...@@ -40,7 +40,7 @@ import com.hazelcast.core.Hazelcast;
40 /** 40 /**
41 * Test of the Hazelcast-based distributed MastershipStore implementation. 41 * Test of the Hazelcast-based distributed MastershipStore implementation.
42 */ 42 */
43 -public class DistributedMastershipStoreTest { 43 +public class DistributedDeviceMastershipStoreTest {
44 44
45 private static final DeviceId DID1 = DeviceId.deviceId("of:01"); 45 private static final DeviceId DID1 = DeviceId.deviceId("of:01");
46 private static final DeviceId DID2 = DeviceId.deviceId("of:02"); 46 private static final DeviceId DID2 = DeviceId.deviceId("of:02");
...@@ -54,8 +54,8 @@ public class DistributedMastershipStoreTest { ...@@ -54,8 +54,8 @@ public class DistributedMastershipStoreTest {
54 private static final ControllerNode CN1 = new DefaultControllerNode(N1, IP); 54 private static final ControllerNode CN1 = new DefaultControllerNode(N1, IP);
55 private static final ControllerNode CN2 = new DefaultControllerNode(N2, IP); 55 private static final ControllerNode CN2 = new DefaultControllerNode(N2, IP);
56 56
57 - private DistributedMastershipStore dms; 57 + private DistributedDeviceMastershipStore dms;
58 - private TestDistributedMastershipStore testStore; 58 + private TestDistributedDeviceMastershipStore testStore;
59 private KryoSerializer serializationMgr; 59 private KryoSerializer serializationMgr;
60 private StoreManager storeMgr; 60 private StoreManager storeMgr;
61 61
...@@ -77,11 +77,11 @@ public class DistributedMastershipStoreTest { ...@@ -77,11 +77,11 @@ public class DistributedMastershipStoreTest {
77 77
78 serializationMgr = new KryoSerializer(); 78 serializationMgr = new KryoSerializer();
79 79
80 - dms = new TestDistributedMastershipStore(storeMgr, serializationMgr); 80 + dms = new TestDistributedDeviceMastershipStore(storeMgr, serializationMgr);
81 dms.clusterService = new TestClusterService(); 81 dms.clusterService = new TestClusterService();
82 dms.activate(); 82 dms.activate();
83 83
84 - testStore = (TestDistributedMastershipStore) dms; 84 + testStore = (TestDistributedDeviceMastershipStore) dms;
85 } 85 }
86 86
87 @After 87 @After
...@@ -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 - MastershipTerm.of(N1, 0), dms.getTermFor(DID1)); 136 + DeviceMastershipTerm.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", MastershipTerm.of(N1, 1), dms.getTermFor(DID2)); 146 + assertEquals("wrong term", DeviceMastershipTerm.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", MastershipTerm.of(N2, 1), dms.getTermFor(DID1)); 158 + assertEquals("wrong term", DeviceMastershipTerm.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", MastershipTerm.of(N2, 0), dms.getTermFor(DID2)); 162 + assertEquals("wrong term", DeviceMastershipTerm.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", MastershipTerm.of(N2, 1), dms.getTermFor(DID2)); 166 + assertEquals("wrong term", DeviceMastershipTerm.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 - MastershipStoreDelegate checkAdd = new MastershipStoreDelegate() { 214 + DeviceMastershipStoreDelegate checkAdd = new DeviceMastershipStoreDelegate() {
215 @Override 215 @Override
216 - public void notify(MastershipEvent event) { 216 + public void notify(DeviceMastershipEvent 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());
...@@ -227,9 +227,9 @@ public class DistributedMastershipStoreTest { ...@@ -227,9 +227,9 @@ public class DistributedMastershipStoreTest {
227 assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); 227 assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
228 } 228 }
229 229
230 - private class TestDistributedMastershipStore extends 230 + private class TestDistributedDeviceMastershipStore extends
231 - DistributedMastershipStore { 231 + DistributedDeviceMastershipStore {
232 - public TestDistributedMastershipStore(StoreService storeService, 232 + public TestDistributedDeviceMastershipStore(StoreService storeService,
233 KryoSerializer kryoSerialization) { 233 KryoSerializer kryoSerialization) {
234 this.storeService = storeService; 234 this.storeService = storeService;
235 this.serializer = kryoSerialization; 235 this.serializer = kryoSerialization;
......
...@@ -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;
6 import org.onlab.onos.net.DeviceId; 5 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, MastershipTerm term) { 18 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
19 } 19 }
20 } 20 }
......
...@@ -7,7 +7,6 @@ import java.util.HashMap; ...@@ -7,7 +7,6 @@ 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;
11 import org.onlab.onos.cluster.NodeId; 10 import org.onlab.onos.cluster.NodeId;
12 import org.onlab.onos.net.ConnectPoint; 11 import org.onlab.onos.net.ConnectPoint;
13 import org.onlab.onos.net.DefaultAnnotations; 12 import org.onlab.onos.net.DefaultAnnotations;
...@@ -24,6 +23,7 @@ import org.onlab.onos.net.Port; ...@@ -24,6 +23,7 @@ import org.onlab.onos.net.Port;
24 import org.onlab.onos.net.PortNumber; 23 import org.onlab.onos.net.PortNumber;
25 import org.onlab.onos.net.device.DefaultDeviceDescription; 24 import org.onlab.onos.net.device.DefaultDeviceDescription;
26 import org.onlab.onos.net.device.DefaultPortDescription; 25 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(MastershipTerm.class, new MastershipTermSerializer()) 77 + .register(DeviceMastershipTerm.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;
4 import org.onlab.onos.cluster.NodeId; 3 import org.onlab.onos.cluster.NodeId;
4 +import org.onlab.onos.net.device.DeviceMastershipTerm;
5 +
5 import com.esotericsoftware.kryo.Kryo; 6 import com.esotericsoftware.kryo.Kryo;
6 import com.esotericsoftware.kryo.Serializer; 7 import com.esotericsoftware.kryo.Serializer;
7 import com.esotericsoftware.kryo.io.Input; 8 import com.esotericsoftware.kryo.io.Input;
8 import com.esotericsoftware.kryo.io.Output; 9 import com.esotericsoftware.kryo.io.Output;
9 10
10 /** 11 /**
11 - * Kryo Serializer for {@link org.onlab.onos.cluster.MastershipTerm}. 12 + * Kryo Serializer for {@link org.onlab.onos.net.device.DeviceMastershipTerm}.
12 */ 13 */
13 -public class MastershipTermSerializer extends Serializer<MastershipTerm> { 14 +public class MastershipTermSerializer extends Serializer<DeviceMastershipTerm> {
14 15
15 /** 16 /**
16 - * Creates {@link MastershipTerm} serializer instance. 17 + * Creates {@link DeviceMastershipTerm} serializer instance.
17 */ 18 */
18 public MastershipTermSerializer() { 19 public MastershipTermSerializer() {
19 // non-null, immutable 20 // non-null, immutable
...@@ -21,14 +22,14 @@ public class MastershipTermSerializer extends Serializer<MastershipTerm> { ...@@ -21,14 +22,14 @@ public class MastershipTermSerializer extends Serializer<MastershipTerm> {
21 } 22 }
22 23
23 @Override 24 @Override
24 - public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) { 25 + public DeviceMastershipTerm read(Kryo kryo, Input input, Class<DeviceMastershipTerm> type) {
25 final NodeId node = new NodeId(input.readString()); 26 final NodeId node = new NodeId(input.readString());
26 final int term = input.readInt(); 27 final int term = input.readInt();
27 - return MastershipTerm.of(node, term); 28 + return DeviceMastershipTerm.of(node, term);
28 } 29 }
29 30
30 @Override 31 @Override
31 - public void write(Kryo kryo, Output output, MastershipTerm object) { 32 + public void write(Kryo kryo, Output output, DeviceMastershipTerm object) {
32 output.writeString(object.master().toString()); 33 output.writeString(object.master().toString());
33 output.writeInt(object.termNumber()); 34 output.writeInt(object.termNumber());
34 } 35 }
......
...@@ -10,7 +10,6 @@ import org.junit.After; ...@@ -10,7 +10,6 @@ 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;
14 import org.onlab.onos.cluster.NodeId; 13 import org.onlab.onos.cluster.NodeId;
15 import org.onlab.onos.net.Annotations; 14 import org.onlab.onos.net.Annotations;
16 import org.onlab.onos.net.ConnectPoint; 15 import org.onlab.onos.net.ConnectPoint;
...@@ -25,6 +24,7 @@ import org.onlab.onos.net.LinkKey; ...@@ -25,6 +24,7 @@ import org.onlab.onos.net.LinkKey;
25 import org.onlab.onos.net.MastershipRole; 24 import org.onlab.onos.net.MastershipRole;
26 import org.onlab.onos.net.PortNumber; 25 import org.onlab.onos.net.PortNumber;
27 import org.onlab.onos.net.SparseAnnotations; 26 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(MastershipTerm.of(new NodeId("foo"), 2)); 117 + testSerialized(DeviceMastershipTerm.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;
6 import org.onlab.onos.net.DeviceId; 5 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, MastershipTerm term) { 18 + public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm 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;
22 import org.onlab.onos.cluster.NodeId; 18 import org.onlab.onos.cluster.NodeId;
23 import org.onlab.onos.net.DeviceId; 19 import org.onlab.onos.net.DeviceId;
24 import org.onlab.onos.net.MastershipRole; 20 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.cluster.MastershipEvent.Type.*; 29 +import static org.onlab.onos.net.device.DeviceMastershipEvent.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.cluster.MastershipEvent.Type.*; ...@@ -35,8 +35,8 @@ import static org.onlab.onos.cluster.MastershipEvent.Type.*;
35 @Component(immediate = true) 35 @Component(immediate = true)
36 @Service 36 @Service
37 public class SimpleMastershipStore 37 public class SimpleMastershipStore
38 - extends AbstractStore<MastershipEvent, MastershipStoreDelegate> 38 + extends AbstractStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate>
39 - implements MastershipStore { 39 + implements DeviceMastershipStore {
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 MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) { 66 + public DeviceMastershipEvent 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 MastershipEvent(MASTER_CHANGED, deviceId, nodeId); 89 + return new DeviceMastershipEvent(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 MastershipTerm getTermFor(DeviceId deviceId) { 167 + public DeviceMastershipTerm 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 MastershipTerm.of( 172 + return DeviceMastershipTerm.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 MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) { 177 + public DeviceMastershipEvent 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 MastershipEvent(MASTER_CHANGED, deviceId, backup); 188 + return new DeviceMastershipEvent(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 MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) { 218 + public DeviceMastershipEvent 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;
10 import org.onlab.onos.cluster.NodeId; 9 import org.onlab.onos.cluster.NodeId;
11 import org.onlab.onos.net.DeviceId; 10 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.cluster.MastershipEvent.Type.*; 19 +import static org.onlab.onos.net.device.DeviceMastershipEvent.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", MastershipTerm.of(N1, 0), sms.getTermFor(DID1)); 101 + assertEquals("wrong term", DeviceMastershipTerm.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", MastershipTerm.of(N1, 2), sms.getTermFor(DID1)); 106 + assertEquals("wrong term", DeviceMastershipTerm.of(N1, 2), sms.getTermFor(DID1));
107 } 107 }
108 108
109 @Test 109 @Test
......
1 package org.onlab.onos.openflow.controller; 1 package org.onlab.onos.openflow.controller;
2 2
3 -import static org.slf4j.LoggerFactory.getLogger;
4 -
5 -import java.util.Collections;
6 -import java.util.concurrent.atomic.AtomicBoolean;
7 -
8 import org.onlab.packet.Ethernet; 3 import org.onlab.packet.Ethernet;
9 import org.projectfloodlight.openflow.protocol.OFPacketIn; 4 import org.projectfloodlight.openflow.protocol.OFPacketIn;
10 import org.projectfloodlight.openflow.protocol.OFPacketOut; 5 import org.projectfloodlight.openflow.protocol.OFPacketOut;
...@@ -13,11 +8,11 @@ import org.projectfloodlight.openflow.protocol.action.OFActionOutput; ...@@ -13,11 +8,11 @@ import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
13 import org.projectfloodlight.openflow.protocol.match.MatchField; 8 import org.projectfloodlight.openflow.protocol.match.MatchField;
14 import org.projectfloodlight.openflow.types.OFBufferId; 9 import org.projectfloodlight.openflow.types.OFBufferId;
15 import org.projectfloodlight.openflow.types.OFPort; 10 import org.projectfloodlight.openflow.types.OFPort;
16 -import org.slf4j.Logger;
17 11
18 -public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext { 12 +import java.util.Collections;
13 +import java.util.concurrent.atomic.AtomicBoolean;
19 14
20 - private final Logger log = getLogger(getClass()); 15 +public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext {
21 16
22 private final AtomicBoolean free = new AtomicBoolean(true); 17 private final AtomicBoolean free = new AtomicBoolean(true);
23 private final AtomicBoolean isBuilt = new AtomicBoolean(false); 18 private final AtomicBoolean isBuilt = new AtomicBoolean(false);
...@@ -82,7 +77,7 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext ...@@ -82,7 +77,7 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
82 } 77 }
83 78
84 public static OpenFlowPacketContext packetContextFromPacketIn(OpenFlowSwitch s, 79 public static OpenFlowPacketContext packetContextFromPacketIn(OpenFlowSwitch s,
85 - OFPacketIn pkt) { 80 + OFPacketIn pkt) {
86 return new DefaultOpenFlowPacketContext(s, pkt); 81 return new DefaultOpenFlowPacketContext(s, pkt);
87 } 82 }
88 83
......
...@@ -157,9 +157,7 @@ public class Controller { ...@@ -157,9 +157,7 @@ public class Controller {
157 } 157 }
158 log.debug("OpenFlow port set to {}", this.openFlowPort); 158 log.debug("OpenFlow port set to {}", this.openFlowPort);
159 String threads = configParams.get("workerthreads"); 159 String threads = configParams.get("workerthreads");
160 - if (threads != null) { 160 + this.workerThreads = threads != null ? Integer.parseInt(threads) : 16;
161 - this.workerThreads = Integer.parseInt(threads);
162 - }
163 log.debug("Number of worker threads set to {}", this.workerThreads); 161 log.debug("Number of worker threads set to {}", this.workerThreads);
164 } 162 }
165 163
......
...@@ -44,7 +44,6 @@ public class OpenFlowControllerImpl implements OpenFlowController { ...@@ -44,7 +44,6 @@ public class OpenFlowControllerImpl implements OpenFlowController {
44 private final ExecutorService executor = Executors.newFixedThreadPool(16, 44 private final ExecutorService executor = Executors.newFixedThreadPool(16,
45 namedThreads("of-event-%d")); 45 namedThreads("of-event-%d"));
46 46
47 -
48 protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches = 47 protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches =
49 new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); 48 new ConcurrentHashMap<Dpid, OpenFlowSwitch>();
50 protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches = 49 protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches =
......
1 package org.onlab.onos.provider.of.packet.impl; 1 package org.onlab.onos.provider.of.packet.impl;
2 2
3 -import static org.slf4j.LoggerFactory.getLogger;
4 -
5 -import java.util.List;
6 -
7 import org.onlab.onos.net.PortNumber; 3 import org.onlab.onos.net.PortNumber;
8 import org.onlab.onos.net.flow.instructions.Instruction; 4 import org.onlab.onos.net.flow.instructions.Instruction;
9 import org.onlab.onos.net.flow.instructions.Instruction.Type; 5 import org.onlab.onos.net.flow.instructions.Instruction.Type;
...@@ -14,16 +10,16 @@ import org.onlab.onos.net.packet.OutboundPacket; ...@@ -14,16 +10,16 @@ import org.onlab.onos.net.packet.OutboundPacket;
14 import org.onlab.onos.openflow.controller.OpenFlowPacketContext; 10 import org.onlab.onos.openflow.controller.OpenFlowPacketContext;
15 import org.onlab.packet.Ethernet; 11 import org.onlab.packet.Ethernet;
16 import org.projectfloodlight.openflow.types.OFPort; 12 import org.projectfloodlight.openflow.types.OFPort;
17 -import org.slf4j.Logger;
18 13
19 -public class OpenFlowCorePacketContext extends DefaultPacketContext { 14 +import java.util.List;
20 15
21 - private final Logger log = getLogger(getClass()); 16 +public class OpenFlowCorePacketContext extends DefaultPacketContext {
22 17
23 private final OpenFlowPacketContext ofPktCtx; 18 private final OpenFlowPacketContext ofPktCtx;
24 19
25 protected OpenFlowCorePacketContext(long time, InboundPacket inPkt, 20 protected OpenFlowCorePacketContext(long time, InboundPacket inPkt,
26 - OutboundPacket outPkt, boolean block, OpenFlowPacketContext ofPktCtx) { 21 + OutboundPacket outPkt, boolean block,
22 + OpenFlowPacketContext ofPktCtx) {
27 super(time, inPkt, outPkt, block); 23 super(time, inPkt, outPkt, block);
28 this.ofPktCtx = ofPktCtx; 24 this.ofPktCtx = ofPktCtx;
29 } 25 }
...@@ -36,9 +32,8 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext { ...@@ -36,9 +32,8 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
36 } else { 32 } else {
37 Ethernet eth = new Ethernet(); 33 Ethernet eth = new Ethernet();
38 eth.deserialize(outPacket().data().array(), 0, 34 eth.deserialize(outPacket().data().array(), 0,
39 - outPacket().data().array().length); 35 + outPacket().data().array().length);
40 sendPacket(eth); 36 sendPacket(eth);
41 -
42 } 37 }
43 38
44 } 39 }
...@@ -61,6 +56,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext { ...@@ -61,6 +56,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
61 } 56 }
62 ofPktCtx.send(); 57 ofPktCtx.send();
63 } 58 }
59 +
64 private OFPort buildPort(PortNumber port) { 60 private OFPort buildPort(PortNumber port) {
65 return OFPort.of((int) port.toLong()); 61 return OFPort.of((int) port.toLong());
66 } 62 }
......