Ayaka Koshibe
Committed by Gerrit Code Review

optical configs:

o add integral node to serializer
o add linc-oe 'speed' config field

Change-Id: Ifc0ee8959e3589f3c2372f28fc10780a99278572
...@@ -24,6 +24,9 @@ public class OpticalPortConfig extends Config<ConnectPoint> { ...@@ -24,6 +24,9 @@ public class OpticalPortConfig extends Config<ConnectPoint> {
24 public static final String STATIC_PORT = "staticPort"; 24 public static final String STATIC_PORT = "staticPort";
25 public static final String STATIC_LAMBDA = "staticLambda"; 25 public static final String STATIC_LAMBDA = "staticLambda";
26 26
27 + // **Linc-OE : remove if it's not needed after all.**
28 + public static final String SPEED = "speed";
29 +
27 /** 30 /**
28 * Returns the Enum value representing the type of port. 31 * Returns the Enum value representing the type of port.
29 * 32 *
...@@ -75,7 +78,8 @@ public class OpticalPortConfig extends Config<ConnectPoint> { ...@@ -75,7 +78,8 @@ public class OpticalPortConfig extends Config<ConnectPoint> {
75 78
76 /** 79 /**
77 * Returns the output lambda configured for this port. The lambda value is 80 * Returns the output lambda configured for this port. The lambda value is
78 - * expressed as a frequency value. 81 + * expressed as a frequency value. If the port type doesn't have a notion of
82 + * lambdas, this returns an empty Optional.
79 * 83 *
80 * @return an Optional that may contain a frequency value. 84 * @return an Optional that may contain a frequency value.
81 */ 85 */
...@@ -88,6 +92,20 @@ public class OpticalPortConfig extends Config<ConnectPoint> { ...@@ -88,6 +92,20 @@ public class OpticalPortConfig extends Config<ConnectPoint> {
88 } 92 }
89 93
90 /** 94 /**
95 + * Returns the port speed configured for this port. If the port doesn't have
96 + * a notion of speed, this returns an empty Optional.
97 + *
98 + * @return a port speed value whose default is 0.
99 + */
100 + public Optional<Integer> speed() {
101 + JsonNode s = node.path(SPEED);
102 + if (s.isMissingNode()) {
103 + return Optional.empty();
104 + }
105 + return Optional.of(s.asInt());
106 + }
107 +
108 + /**
91 * Sets the port type, or updates it if it's already set. A null argument removes 109 * Sets the port type, or updates it if it's already set. A null argument removes
92 * this field. 110 * this field.
93 * 111 *
...@@ -144,4 +162,14 @@ public class OpticalPortConfig extends Config<ConnectPoint> { ...@@ -144,4 +162,14 @@ public class OpticalPortConfig extends Config<ConnectPoint> {
144 return (OpticalPortConfig) setOrClear(STATIC_LAMBDA, index); 162 return (OpticalPortConfig) setOrClear(STATIC_LAMBDA, index);
145 } 163 }
146 164
165 + /**
166 + * Sets the port speed, or updates it if already set. A null argument
167 + * removes this field.
168 + *
169 + * @param bw the port bandwidth
170 + * @return this OpticalPortConfig instance
171 + */
172 + public OpticalPortConfig speed(Integer bw) {
173 + return (OpticalPortConfig) setOrClear(SPEED, bw);
174 + }
147 } 175 }
......
...@@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
19 import com.fasterxml.jackson.databind.node.ArrayNode; 19 import com.fasterxml.jackson.databind.node.ArrayNode;
20 import com.fasterxml.jackson.databind.node.BooleanNode; 20 import com.fasterxml.jackson.databind.node.BooleanNode;
21 import com.fasterxml.jackson.databind.node.DoubleNode; 21 import com.fasterxml.jackson.databind.node.DoubleNode;
22 +import com.fasterxml.jackson.databind.node.IntNode;
22 import com.fasterxml.jackson.databind.node.JsonNodeFactory; 23 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
23 import com.fasterxml.jackson.databind.node.LongNode; 24 import com.fasterxml.jackson.databind.node.LongNode;
24 import com.fasterxml.jackson.databind.node.ObjectNode; 25 import com.fasterxml.jackson.databind.node.ObjectNode;
...@@ -90,7 +91,7 @@ public class DistributedNetworkConfigStore ...@@ -90,7 +91,7 @@ public class DistributedNetworkConfigStore
90 .register(ConfigKey.class, ObjectNode.class, ArrayNode.class, 91 .register(ConfigKey.class, ObjectNode.class, ArrayNode.class,
91 JsonNodeFactory.class, LinkedHashMap.class, 92 JsonNodeFactory.class, LinkedHashMap.class,
92 TextNode.class, BooleanNode.class, 93 TextNode.class, BooleanNode.class,
93 - LongNode.class, DoubleNode.class, ShortNode.class); 94 + LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class);
94 95
95 configs = storageService.<ConfigKey, ObjectNode>consistentMapBuilder() 96 configs = storageService.<ConfigKey, ObjectNode>consistentMapBuilder()
96 .withSerializer(Serializer.using(kryoBuilder.build())) 97 .withSerializer(Serializer.using(kryoBuilder.build()))
......