Ayaka Koshibe

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

1 package org.onlab.onos.cli.net; 1 package org.onlab.onos.cli.net;
2 2
3 -import com.google.common.collect.Maps; 3 +import static com.google.common.collect.Lists.newArrayList;
4 +
5 +import java.util.Collections;
6 +import java.util.List;
7 +import java.util.Map;
8 +
9 +import org.apache.karaf.shell.commands.Argument;
4 import org.apache.karaf.shell.commands.Command; 10 import org.apache.karaf.shell.commands.Command;
5 import org.onlab.onos.cli.AbstractShellCommand; 11 import org.onlab.onos.cli.AbstractShellCommand;
6 import org.onlab.onos.net.Device; 12 import org.onlab.onos.net.Device;
13 +import org.onlab.onos.net.DeviceId;
7 import org.onlab.onos.net.device.DeviceService; 14 import org.onlab.onos.net.device.DeviceService;
8 import org.onlab.onos.net.flow.FlowRule; 15 import org.onlab.onos.net.flow.FlowRule;
9 import org.onlab.onos.net.flow.FlowRuleService; 16 import org.onlab.onos.net.flow.FlowRuleService;
10 17
11 -import java.util.Collections; 18 +import com.google.common.collect.Maps;
12 -import java.util.List;
13 -import java.util.Map;
14 -
15 -import static com.google.common.collect.Lists.newArrayList;
16 19
17 /** 20 /**
18 * Lists all currently-known hosts. 21 * Lists all currently-known hosts.
...@@ -22,14 +25,20 @@ description = "Lists all currently-known flows.") ...@@ -22,14 +25,20 @@ description = "Lists all currently-known flows.")
22 public class FlowsListCommand extends AbstractShellCommand { 25 public class FlowsListCommand extends AbstractShellCommand {
23 26
24 private static final String FMT = 27 private static final String FMT =
25 - " id=%s, selector=%s, treatment=%s, state=%s"; 28 + " id=%s, state=%s, bytes=%s, packets=%s, duration=%s, priority=%s";
29 + private static final String TFMT = " treatment=%s";
30 + private static final String SFMT = " selector=%s";
31 +
32 + @Argument(index = 0, name = "uri", description = "Device ID",
33 + required = false, multiValued = false)
34 + String uri = null;
26 35
27 @Override 36 @Override
28 protected void execute() { 37 protected void execute() {
29 DeviceService deviceService = get(DeviceService.class); 38 DeviceService deviceService = get(DeviceService.class);
30 FlowRuleService service = get(FlowRuleService.class); 39 FlowRuleService service = get(FlowRuleService.class);
31 Map<Device, List<FlowRule>> flows = getSortedFlows(deviceService, service); 40 Map<Device, List<FlowRule>> flows = getSortedFlows(deviceService, service);
32 - for (Device d : deviceService.getDevices()) { 41 + for (Device d : flows.keySet()) {
33 printFlows(d, flows.get(d)); 42 printFlows(d, flows.get(d));
34 } 43 }
35 } 44 }
...@@ -42,8 +51,10 @@ public class FlowsListCommand extends AbstractShellCommand { ...@@ -42,8 +51,10 @@ public class FlowsListCommand extends AbstractShellCommand {
42 */ 51 */
43 protected Map<Device, List<FlowRule>> getSortedFlows(DeviceService deviceService, FlowRuleService service) { 52 protected Map<Device, List<FlowRule>> getSortedFlows(DeviceService deviceService, FlowRuleService service) {
44 Map<Device, List<FlowRule>> flows = Maps.newHashMap(); 53 Map<Device, List<FlowRule>> flows = Maps.newHashMap();
45 - List<FlowRule> rules; 54 + List<FlowRule> rules = newArrayList();
46 - for (Device d : deviceService.getDevices()) { 55 + Iterable<Device> devices = uri == null ? deviceService.getDevices() :
56 + Collections.singletonList(deviceService.getDevice(DeviceId.deviceId(uri)));
57 + for (Device d : devices) {
47 rules = newArrayList(service.getFlowEntries(d.id())); 58 rules = newArrayList(service.getFlowEntries(d.id()));
48 Collections.sort(rules, Comparators.FLOW_RULE_COMPARATOR); 59 Collections.sort(rules, Comparators.FLOW_RULE_COMPARATOR);
49 flows.put(d, rules); 60 flows.put(d, rules);
...@@ -58,8 +69,15 @@ public class FlowsListCommand extends AbstractShellCommand { ...@@ -58,8 +69,15 @@ public class FlowsListCommand extends AbstractShellCommand {
58 */ 69 */
59 protected void printFlows(Device d, List<FlowRule> flows) { 70 protected void printFlows(Device d, List<FlowRule> flows) {
60 print("Device: " + d.id()); 71 print("Device: " + d.id());
72 + if (flows == null | flows.isEmpty()) {
73 + print(" %s", "No flows installed.");
74 + return;
75 + }
61 for (FlowRule f : flows) { 76 for (FlowRule f : flows) {
62 - print(FMT, f.id().value(), f.selector(), f.treatment(), f.state()); 77 + print(FMT, Long.toHexString(f.id().value()), f.state(), f.bytes(),
78 + f.packets(), f.lifeMillis(), f.priority());
79 + print(SFMT, f.selector().criteria());
80 + print(TFMT, f.treatment().instructions());
63 } 81 }
64 82
65 } 83 }
......
1 package org.onlab.onos.cli.net; 1 package org.onlab.onos.cli.net;
2 2
3 +import java.util.Iterator;
4 +import java.util.List;
5 +import java.util.SortedSet;
6 +
3 import org.apache.karaf.shell.console.Completer; 7 import org.apache.karaf.shell.console.Completer;
4 import org.apache.karaf.shell.console.completer.StringsCompleter; 8 import org.apache.karaf.shell.console.completer.StringsCompleter;
5 import org.onlab.onos.cli.AbstractShellCommand; 9 import org.onlab.onos.cli.AbstractShellCommand;
6 import org.onlab.onos.net.Host; 10 import org.onlab.onos.net.Host;
7 import org.onlab.onos.net.host.HostService; 11 import org.onlab.onos.net.host.HostService;
8 12
9 -import java.util.Iterator;
10 -import java.util.List;
11 -import java.util.SortedSet;
12 -
13 public class HostIdCompleter implements Completer { 13 public class HostIdCompleter implements Completer {
14 14
15 @Override 15 @Override
......
...@@ -72,6 +72,9 @@ ...@@ -72,6 +72,9 @@
72 72
73 <command> 73 <command>
74 <action class="org.onlab.onos.cli.net.FlowsListCommand"/> 74 <action class="org.onlab.onos.cli.net.FlowsListCommand"/>
75 + <completers>
76 + <ref component-id="deviceIdCompleter"/>
77 + </completers>
75 </command> 78 </command>
76 79
77 <command> 80 <command>
......
1 package org.onlab.onos.net.flow.criteria; 1 package org.onlab.onos.net.flow.criteria;
2 2
3 +import static com.google.common.base.MoreObjects.toStringHelper;
4 +
3 import org.onlab.onos.net.PortNumber; 5 import org.onlab.onos.net.PortNumber;
4 import org.onlab.onos.net.flow.criteria.Criterion.Type; 6 import org.onlab.onos.net.flow.criteria.Criterion.Type;
5 import org.onlab.packet.IpPrefix; 7 import org.onlab.packet.IpPrefix;
...@@ -129,6 +131,12 @@ public final class Criteria { ...@@ -129,6 +131,12 @@ public final class Criteria {
129 public PortNumber port() { 131 public PortNumber port() {
130 return this.port; 132 return this.port;
131 } 133 }
134 +
135 + @Override
136 + public String toString() {
137 + return toStringHelper(type().toString())
138 + .add("port", port).toString();
139 + }
132 } 140 }
133 141
134 142
...@@ -149,6 +157,13 @@ public final class Criteria { ...@@ -149,6 +157,13 @@ public final class Criteria {
149 public MacAddress mac() { 157 public MacAddress mac() {
150 return this.mac; 158 return this.mac;
151 } 159 }
160 +
161 + @Override
162 + public String toString() {
163 + return toStringHelper(type().toString())
164 + .add("mac", mac).toString();
165 + }
166 +
152 } 167 }
153 168
154 public static final class EthTypeCriterion implements Criterion { 169 public static final class EthTypeCriterion implements Criterion {
...@@ -168,6 +183,12 @@ public final class Criteria { ...@@ -168,6 +183,12 @@ public final class Criteria {
168 return ethType; 183 return ethType;
169 } 184 }
170 185
186 + @Override
187 + public String toString() {
188 + return toStringHelper(type().toString())
189 + .add("ethType", Long.toHexString(ethType)).toString();
190 + }
191 +
171 } 192 }
172 193
173 194
...@@ -190,6 +211,11 @@ public final class Criteria { ...@@ -190,6 +211,11 @@ public final class Criteria {
190 return this.ip; 211 return this.ip;
191 } 212 }
192 213
214 + @Override
215 + public String toString() {
216 + return toStringHelper(type().toString())
217 + .add("ip", ip).toString();
218 + }
193 219
194 } 220 }
195 221
...@@ -211,6 +237,12 @@ public final class Criteria { ...@@ -211,6 +237,12 @@ public final class Criteria {
211 return proto; 237 return proto;
212 } 238 }
213 239
240 + @Override
241 + public String toString() {
242 + return toStringHelper(type().toString())
243 + .add("protocol", Long.toHexString(proto)).toString();
244 + }
245 +
214 } 246 }
215 247
216 248
...@@ -231,6 +263,12 @@ public final class Criteria { ...@@ -231,6 +263,12 @@ public final class Criteria {
231 return vlanPcp; 263 return vlanPcp;
232 } 264 }
233 265
266 + @Override
267 + public String toString() {
268 + return toStringHelper(type().toString())
269 + .add("pcp", Long.toHexString(vlanPcp)).toString();
270 + }
271 +
234 } 272 }
235 273
236 274
...@@ -252,6 +290,12 @@ public final class Criteria { ...@@ -252,6 +290,12 @@ public final class Criteria {
252 return vlanId; 290 return vlanId;
253 } 291 }
254 292
293 + @Override
294 + public String toString() {
295 + return toStringHelper(type().toString())
296 + .add("id", vlanId).toString();
297 + }
298 +
255 } 299 }
256 300
257 301
......
1 package org.onlab.onos.net.flow.instructions; 1 package org.onlab.onos.net.flow.instructions;
2 2
3 +import static com.google.common.base.MoreObjects.toStringHelper;
3 import static com.google.common.base.Preconditions.checkNotNull; 4 import static com.google.common.base.Preconditions.checkNotNull;
4 5
5 import org.onlab.onos.net.PortNumber; 6 import org.onlab.onos.net.PortNumber;
...@@ -47,7 +48,7 @@ public final class Instructions { ...@@ -47,7 +48,7 @@ public final class Instructions {
47 */ 48 */
48 public static L2ModificationInstruction modL2Src(MacAddress addr) { 49 public static L2ModificationInstruction modL2Src(MacAddress addr) {
49 checkNotNull(addr, "Src l2 address cannot be null"); 50 checkNotNull(addr, "Src l2 address cannot be null");
50 - return new ModEtherInstruction(L2SubType.L2_SRC, addr); 51 + return new ModEtherInstruction(L2SubType.ETH_SRC, addr);
51 } 52 }
52 53
53 /** 54 /**
...@@ -57,7 +58,7 @@ public final class Instructions { ...@@ -57,7 +58,7 @@ public final class Instructions {
57 */ 58 */
58 public static L2ModificationInstruction modL2Dst(MacAddress addr) { 59 public static L2ModificationInstruction modL2Dst(MacAddress addr) {
59 checkNotNull(addr, "Dst l2 address cannot be null"); 60 checkNotNull(addr, "Dst l2 address cannot be null");
60 - return new L2ModificationInstruction.ModEtherInstruction(L2SubType.L2_DST, addr); 61 + return new L2ModificationInstruction.ModEtherInstruction(L2SubType.ETH_DST, addr);
61 } 62 }
62 63
63 /** 64 /**
...@@ -87,7 +88,7 @@ public final class Instructions { ...@@ -87,7 +88,7 @@ public final class Instructions {
87 */ 88 */
88 public static L3ModificationInstruction modL3Src(IpPrefix addr) { 89 public static L3ModificationInstruction modL3Src(IpPrefix addr) {
89 checkNotNull(addr, "Src l3 address cannot be null"); 90 checkNotNull(addr, "Src l3 address cannot be null");
90 - return new ModIPInstruction(L3SubType.L3_SRC, addr); 91 + return new ModIPInstruction(L3SubType.IP_SRC, addr);
91 } 92 }
92 93
93 /** 94 /**
...@@ -97,7 +98,7 @@ public final class Instructions { ...@@ -97,7 +98,7 @@ public final class Instructions {
97 */ 98 */
98 public static L3ModificationInstruction modL3Dst(IpPrefix addr) { 99 public static L3ModificationInstruction modL3Dst(IpPrefix addr) {
99 checkNotNull(addr, "Dst l3 address cannot be null"); 100 checkNotNull(addr, "Dst l3 address cannot be null");
100 - return new ModIPInstruction(L3SubType.L3_DST, addr); 101 + return new ModIPInstruction(L3SubType.IP_DST, addr);
101 } 102 }
102 103
103 104
...@@ -110,6 +111,12 @@ public final class Instructions { ...@@ -110,6 +111,12 @@ public final class Instructions {
110 public Type type() { 111 public Type type() {
111 return Type.DROP; 112 return Type.DROP;
112 } 113 }
114 +
115 + @Override
116 + public String toString() {
117 + return toStringHelper(type()).toString();
118 +
119 + }
113 } 120 }
114 121
115 122
...@@ -128,6 +135,11 @@ public final class Instructions { ...@@ -128,6 +135,11 @@ public final class Instructions {
128 public Type type() { 135 public Type type() {
129 return Type.OUTPUT; 136 return Type.OUTPUT;
130 } 137 }
138 + @Override
139 + public String toString() {
140 + return toStringHelper(type().toString())
141 + .add("port", port).toString();
142 + }
131 } 143 }
132 144
133 } 145 }
......
1 package org.onlab.onos.net.flow.instructions; 1 package org.onlab.onos.net.flow.instructions;
2 2
3 +import static com.google.common.base.MoreObjects.toStringHelper;
4 +
3 import org.onlab.packet.MacAddress; 5 import org.onlab.packet.MacAddress;
4 import org.onlab.packet.VlanId; 6 import org.onlab.packet.VlanId;
5 7
...@@ -15,12 +17,12 @@ public abstract class L2ModificationInstruction implements Instruction { ...@@ -15,12 +17,12 @@ public abstract class L2ModificationInstruction implements Instruction {
15 /** 17 /**
16 * Ether src modification. 18 * Ether src modification.
17 */ 19 */
18 - L2_SRC, 20 + ETH_SRC,
19 21
20 /** 22 /**
21 * Ether dst modification. 23 * Ether dst modification.
22 */ 24 */
23 - L2_DST, 25 + ETH_DST,
24 26
25 /** 27 /**
26 * VLAN id modification. 28 * VLAN id modification.
...@@ -66,6 +68,13 @@ public abstract class L2ModificationInstruction implements Instruction { ...@@ -66,6 +68,13 @@ public abstract class L2ModificationInstruction implements Instruction {
66 return this.mac; 68 return this.mac;
67 } 69 }
68 70
71 + @Override
72 + public String toString() {
73 + return toStringHelper(subtype().toString())
74 + .add("mac", mac).toString();
75 + }
76 +
77 +
69 } 78 }
70 79
71 /** 80 /**
...@@ -88,6 +97,12 @@ public abstract class L2ModificationInstruction implements Instruction { ...@@ -88,6 +97,12 @@ public abstract class L2ModificationInstruction implements Instruction {
88 return this.vlanId; 97 return this.vlanId;
89 } 98 }
90 99
100 + @Override
101 + public String toString() {
102 + return toStringHelper(subtype().toString())
103 + .add("id", vlanId).toString();
104 + }
105 +
91 } 106 }
92 107
93 /** 108 /**
...@@ -110,6 +125,12 @@ public abstract class L2ModificationInstruction implements Instruction { ...@@ -110,6 +125,12 @@ public abstract class L2ModificationInstruction implements Instruction {
110 return this.vlanPcp; 125 return this.vlanPcp;
111 } 126 }
112 127
128 + @Override
129 + public String toString() {
130 + return toStringHelper(subtype().toString())
131 + .add("pcp", Long.toHexString(vlanPcp)).toString();
132 + }
133 +
113 } 134 }
114 135
115 136
......
1 package org.onlab.onos.net.flow.instructions; 1 package org.onlab.onos.net.flow.instructions;
2 2
3 +import static com.google.common.base.MoreObjects.toStringHelper;
4 +
3 import org.onlab.packet.IpPrefix; 5 import org.onlab.packet.IpPrefix;
4 6
5 /** 7 /**
...@@ -14,12 +16,12 @@ public abstract class L3ModificationInstruction implements Instruction { ...@@ -14,12 +16,12 @@ public abstract class L3ModificationInstruction implements Instruction {
14 /** 16 /**
15 * Ether src modification. 17 * Ether src modification.
16 */ 18 */
17 - L3_SRC, 19 + IP_SRC,
18 20
19 /** 21 /**
20 * Ether dst modification. 22 * Ether dst modification.
21 */ 23 */
22 - L3_DST 24 + IP_DST
23 25
24 //TODO: remaining types 26 //TODO: remaining types
25 } 27 }
...@@ -58,5 +60,11 @@ public abstract class L3ModificationInstruction implements Instruction { ...@@ -58,5 +60,11 @@ public abstract class L3ModificationInstruction implements Instruction {
58 return this.ip; 60 return this.ip;
59 } 61 }
60 62
63 + @Override
64 + public String toString() {
65 + return toStringHelper(subtype().toString())
66 + .add("ip", ip).toString();
67 + }
68 +
61 } 69 }
62 } 70 }
......
1 +package org.onlab.onos.store;
2 +
3 +/**
4 + * Opaque version structure.
5 + */
6 +public interface Timestamp extends Comparable<Timestamp> {
7 +
8 +}
...@@ -252,7 +252,6 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -252,7 +252,6 @@ implements FlowRuleService, FlowRuleProviderRegistry {
252 } 252 }
253 } 253 }
254 for (FlowRule rule : storedRules) { 254 for (FlowRule rule : storedRules) {
255 - log.info("missing rule is {}", rule);
256 // there are rules in the store that aren't on the switch 255 // there are rules in the store that aren't on the switch
257 flowMissing(rule); 256 flowMissing(rule);
258 257
......
1 +package org.onlab.onos.store.impl;
2 +
3 +import static com.google.common.base.Preconditions.checkNotNull;
4 +import static com.google.common.base.Preconditions.checkArgument;
5 +
6 +import java.util.Objects;
7 +
8 +import org.onlab.onos.net.ElementId;
9 +import org.onlab.onos.store.Timestamp;
10 +
11 +import com.google.common.base.MoreObjects;
12 +import com.google.common.collect.ComparisonChain;
13 +
14 +// If it is store specific, implement serializable interfaces?
15 +/**
16 + * Default implementation of Timestamp.
17 + */
18 +public final class OnosTimestamp implements Timestamp {
19 +
20 + private final ElementId id;
21 + private final int termNumber;
22 + private final int sequenceNumber;
23 +
24 + /**
25 + * Default version tuple.
26 + *
27 + * @param id identifier of the element
28 + * @param termNumber the mastership termNumber
29 + * @param sequenceNumber the sequenceNumber number within the termNumber
30 + */
31 + public OnosTimestamp(ElementId id, int termNumber, int sequenceNumber) {
32 + this.id = checkNotNull(id);
33 + this.termNumber = termNumber;
34 + this.sequenceNumber = sequenceNumber;
35 + }
36 +
37 + @Override
38 + public int compareTo(Timestamp o) {
39 + checkArgument(o instanceof OnosTimestamp, "Must be OnosTimestamp", o);
40 + OnosTimestamp that = (OnosTimestamp) o;
41 + checkArgument(this.id.equals(that.id),
42 + "Cannot compare version for different element this:%s, that:%s",
43 + this, that);
44 +
45 + return ComparisonChain.start()
46 + .compare(this.termNumber, that.termNumber)
47 + .compare(this.sequenceNumber, that.sequenceNumber)
48 + .result();
49 + }
50 +
51 + @Override
52 + public int hashCode() {
53 + return Objects.hash(id, termNumber, sequenceNumber);
54 + }
55 +
56 + @Override
57 + public boolean equals(Object obj) {
58 + if (this == obj) {
59 + return true;
60 + }
61 + if (!(obj instanceof OnosTimestamp)) {
62 + return false;
63 + }
64 + OnosTimestamp that = (OnosTimestamp) obj;
65 + return Objects.equals(this.id, that.id) &&
66 + Objects.equals(this.termNumber, that.termNumber) &&
67 + Objects.equals(this.sequenceNumber, that.sequenceNumber);
68 + }
69 +
70 + @Override
71 + public String toString() {
72 + return MoreObjects.toStringHelper(getClass())
73 + .add("id", id)
74 + .add("termNumber", termNumber)
75 + .add("sequenceNumber", sequenceNumber)
76 + .toString();
77 + }
78 +
79 + /**
80 + * Returns the element.
81 + *
82 + * @return element identifier
83 + */
84 + public ElementId id() {
85 + return id;
86 + }
87 +
88 + /**
89 + * Returns the termNumber.
90 + *
91 + * @return termNumber
92 + */
93 + public int termNumber() {
94 + return termNumber;
95 + }
96 +
97 + /**
98 + * Returns the sequenceNumber number.
99 + *
100 + * @return sequenceNumber
101 + */
102 + public int sequenceNumber() {
103 + return sequenceNumber;
104 + }
105 +}
...@@ -4,7 +4,9 @@ import com.hazelcast.config.Config; ...@@ -4,7 +4,9 @@ import com.hazelcast.config.Config;
4 import com.hazelcast.config.FileSystemXmlConfig; 4 import com.hazelcast.config.FileSystemXmlConfig;
5 import com.hazelcast.core.Hazelcast; 5 import com.hazelcast.core.Hazelcast;
6 import com.hazelcast.core.HazelcastInstance; 6 import com.hazelcast.core.HazelcastInstance;
7 +
7 import de.javakaffee.kryoserializers.URISerializer; 8 import de.javakaffee.kryoserializers.URISerializer;
9 +
8 import org.apache.felix.scr.annotations.Activate; 10 import org.apache.felix.scr.annotations.Activate;
9 import org.apache.felix.scr.annotations.Component; 11 import org.apache.felix.scr.annotations.Component;
10 import org.apache.felix.scr.annotations.Deactivate; 12 import org.apache.felix.scr.annotations.Deactivate;
...@@ -26,6 +28,7 @@ import org.onlab.onos.store.serializers.DefaultPortSerializer; ...@@ -26,6 +28,7 @@ import org.onlab.onos.store.serializers.DefaultPortSerializer;
26 import org.onlab.onos.store.serializers.DeviceIdSerializer; 28 import org.onlab.onos.store.serializers.DeviceIdSerializer;
27 import org.onlab.onos.store.serializers.IpPrefixSerializer; 29 import org.onlab.onos.store.serializers.IpPrefixSerializer;
28 import org.onlab.onos.store.serializers.NodeIdSerializer; 30 import org.onlab.onos.store.serializers.NodeIdSerializer;
31 +import org.onlab.onos.store.serializers.OnosTimestampSerializer;
29 import org.onlab.onos.store.serializers.PortNumberSerializer; 32 import org.onlab.onos.store.serializers.PortNumberSerializer;
30 import org.onlab.onos.store.serializers.ProviderIdSerializer; 33 import org.onlab.onos.store.serializers.ProviderIdSerializer;
31 import org.onlab.packet.IpPrefix; 34 import org.onlab.packet.IpPrefix;
...@@ -90,6 +93,7 @@ public class StoreManager implements StoreService { ...@@ -90,6 +93,7 @@ public class StoreManager implements StoreService {
90 .register(DeviceId.class, new DeviceIdSerializer()) 93 .register(DeviceId.class, new DeviceIdSerializer())
91 .register(PortNumber.class, new PortNumberSerializer()) 94 .register(PortNumber.class, new PortNumberSerializer())
92 .register(DefaultPort.class, new DefaultPortSerializer()) 95 .register(DefaultPort.class, new DefaultPortSerializer())
96 + .register(OnosTimestamp.class, new OnosTimestampSerializer())
93 .build() 97 .build()
94 .populate(10); 98 .populate(10);
95 } 99 }
......
...@@ -9,7 +9,6 @@ import com.esotericsoftware.kryo.Serializer; ...@@ -9,7 +9,6 @@ import com.esotericsoftware.kryo.Serializer;
9 import com.esotericsoftware.kryo.io.Input; 9 import com.esotericsoftware.kryo.io.Input;
10 import com.esotericsoftware.kryo.io.Output; 10 import com.esotericsoftware.kryo.io.Output;
11 11
12 -// TODO move to util, etc.
13 /** 12 /**
14 * Kryo Serializer for {@link DefaultPort}. 13 * Kryo Serializer for {@link DefaultPort}.
15 */ 14 */
......
...@@ -9,7 +9,6 @@ import com.esotericsoftware.kryo.Serializer; ...@@ -9,7 +9,6 @@ import com.esotericsoftware.kryo.Serializer;
9 import com.esotericsoftware.kryo.io.Input; 9 import com.esotericsoftware.kryo.io.Input;
10 import com.esotericsoftware.kryo.io.Output; 10 import com.esotericsoftware.kryo.io.Output;
11 11
12 -//TODO move to util, etc.
13 /** 12 /**
14 * Kryo Serializer for {@link DeviceId}. 13 * Kryo Serializer for {@link DeviceId}.
15 */ 14 */
......
...@@ -7,7 +7,6 @@ import com.esotericsoftware.kryo.Serializer; ...@@ -7,7 +7,6 @@ import com.esotericsoftware.kryo.Serializer;
7 import com.esotericsoftware.kryo.io.Input; 7 import com.esotericsoftware.kryo.io.Input;
8 import com.esotericsoftware.kryo.io.Output; 8 import com.esotericsoftware.kryo.io.Output;
9 9
10 -// TODO move to util, etc.
11 /** 10 /**
12 * Kryo Serializer for {@link IpPrefix}. 11 * Kryo Serializer for {@link IpPrefix}.
13 */ 12 */
......
1 +package org.onlab.onos.store.serializers;
2 +
3 +import org.onlab.onos.net.ElementId;
4 +import org.onlab.onos.store.impl.OnosTimestamp;
5 +
6 +import com.esotericsoftware.kryo.Kryo;
7 +import com.esotericsoftware.kryo.Serializer;
8 +import com.esotericsoftware.kryo.io.Input;
9 +import com.esotericsoftware.kryo.io.Output;
10 +
11 +/**
12 + * Kryo Serializer for {@link OnosTimestamp}.
13 + */
14 +public class OnosTimestampSerializer extends Serializer<OnosTimestamp> {
15 +
16 + /**
17 + * Default constructor.
18 + */
19 + public OnosTimestampSerializer() {
20 + // non-null, immutable
21 + super(false, true);
22 + }
23 + @Override
24 + public void write(Kryo kryo, Output output, OnosTimestamp object) {
25 + kryo.writeClassAndObject(output, object.id());
26 + output.writeInt(object.termNumber());
27 + output.writeInt(object.sequenceNumber());
28 + }
29 +
30 + @Override
31 + public OnosTimestamp read(Kryo kryo, Input input, Class<OnosTimestamp> type) {
32 + ElementId id = (ElementId) kryo.readClassAndObject(input);
33 + final int term = input.readInt();
34 + final int sequence = input.readInt();
35 + return new OnosTimestamp(id, term, sequence);
36 + }
37 +}
...@@ -7,7 +7,6 @@ import com.esotericsoftware.kryo.Serializer; ...@@ -7,7 +7,6 @@ import com.esotericsoftware.kryo.Serializer;
7 import com.esotericsoftware.kryo.io.Input; 7 import com.esotericsoftware.kryo.io.Input;
8 import com.esotericsoftware.kryo.io.Output; 8 import com.esotericsoftware.kryo.io.Output;
9 9
10 -// TODO move to util, etc.
11 /** 10 /**
12 * Serializer for {@link PortNumber}. 11 * Serializer for {@link PortNumber}.
13 */ 12 */
......
...@@ -7,7 +7,6 @@ import com.esotericsoftware.kryo.Serializer; ...@@ -7,7 +7,6 @@ import com.esotericsoftware.kryo.Serializer;
7 import com.esotericsoftware.kryo.io.Input; 7 import com.esotericsoftware.kryo.io.Input;
8 import com.esotericsoftware.kryo.io.Output; 8 import com.esotericsoftware.kryo.io.Output;
9 9
10 -//TODO move to util, etc.
11 /** 10 /**
12 * Serializer for {@link ProviderId}. 11 * Serializer for {@link ProviderId}.
13 */ 12 */
......
...@@ -133,10 +133,10 @@ public class FlowModBuilder { ...@@ -133,10 +133,10 @@ public class FlowModBuilder {
133 L3ModificationInstruction l3m = (L3ModificationInstruction) i; 133 L3ModificationInstruction l3m = (L3ModificationInstruction) i;
134 ModIPInstruction ip; 134 ModIPInstruction ip;
135 switch (l3m.subtype()) { 135 switch (l3m.subtype()) {
136 - case L3_DST: 136 + case IP_DST:
137 ip = (ModIPInstruction) i; 137 ip = (ModIPInstruction) i;
138 return factory.actions().setNwDst(IPv4Address.of(ip.ip().toInt())); 138 return factory.actions().setNwDst(IPv4Address.of(ip.ip().toInt()));
139 - case L3_SRC: 139 + case IP_SRC:
140 ip = (ModIPInstruction) i; 140 ip = (ModIPInstruction) i;
141 return factory.actions().setNwSrc(IPv4Address.of(ip.ip().toInt())); 141 return factory.actions().setNwSrc(IPv4Address.of(ip.ip().toInt()));
142 default: 142 default:
...@@ -150,10 +150,10 @@ public class FlowModBuilder { ...@@ -150,10 +150,10 @@ public class FlowModBuilder {
150 L2ModificationInstruction l2m = (L2ModificationInstruction) i; 150 L2ModificationInstruction l2m = (L2ModificationInstruction) i;
151 ModEtherInstruction eth; 151 ModEtherInstruction eth;
152 switch (l2m.subtype()) { 152 switch (l2m.subtype()) {
153 - case L2_DST: 153 + case ETH_DST:
154 eth = (ModEtherInstruction) l2m; 154 eth = (ModEtherInstruction) l2m;
155 return factory.actions().setDlDst(MacAddress.of(eth.mac().toLong())); 155 return factory.actions().setDlDst(MacAddress.of(eth.mac().toLong()));
156 - case L2_SRC: 156 + case ETH_SRC:
157 eth = (ModEtherInstruction) l2m; 157 eth = (ModEtherInstruction) l2m;
158 return factory.actions().setDlSrc(MacAddress.of(eth.mac().toLong())); 158 return factory.actions().setDlSrc(MacAddress.of(eth.mac().toLong()));
159 case VLAN_ID: 159 case VLAN_ID:
......