Sho SHIMIZU

Make constraint objects serializable by Kryo

Change-Id: I15e5a14b16fc1ab0416570fec176f18b713727a0
...@@ -41,6 +41,12 @@ public class AnnotationConstraint extends BooleanConstraint { ...@@ -41,6 +41,12 @@ public class AnnotationConstraint extends BooleanConstraint {
41 this.threshold = threshold; 41 this.threshold = threshold;
42 } 42 }
43 43
44 + // Constructor for serialization
45 + private AnnotationConstraint() {
46 + this.key = "";
47 + this.threshold = 0;
48 + }
49 +
44 /** 50 /**
45 * Returns the key of link annotation this constraint designates. 51 * Returns the key of link annotation this constraint designates.
46 * @return key of link annotation 52 * @return key of link annotation
......
...@@ -42,6 +42,11 @@ public class LatencyConstraint implements Constraint { ...@@ -42,6 +42,11 @@ public class LatencyConstraint implements Constraint {
42 this.latency = latency; 42 this.latency = latency;
43 } 43 }
44 44
45 + // Constructor for serialization
46 + private LatencyConstraint() {
47 + this.latency = Duration.ZERO;
48 + }
49 +
45 public Duration latency() { 50 public Duration latency() {
46 return latency; 51 return latency;
47 } 52 }
......
...@@ -21,6 +21,7 @@ import org.onlab.onos.net.DeviceId; ...@@ -21,6 +21,7 @@ import org.onlab.onos.net.DeviceId;
21 import org.onlab.onos.net.Link; 21 import org.onlab.onos.net.Link;
22 import org.onlab.onos.net.resource.LinkResourceService; 22 import org.onlab.onos.net.resource.LinkResourceService;
23 23
24 +import java.util.Collections;
24 import java.util.Objects; 25 import java.util.Objects;
25 import java.util.Set; 26 import java.util.Set;
26 27
...@@ -39,6 +40,11 @@ public class ObstacleConstraint extends BooleanConstraint { ...@@ -39,6 +40,11 @@ public class ObstacleConstraint extends BooleanConstraint {
39 this.obstacles = ImmutableSet.copyOf(obstacles); 40 this.obstacles = ImmutableSet.copyOf(obstacles);
40 } 41 }
41 42
43 + // Constructor for serialization
44 + private ObstacleConstraint() {
45 + this.obstacles = Collections.emptySet();
46 + }
47 +
42 @Override 48 @Override
43 public boolean isValid(Link link, LinkResourceService resourceService) { 49 public boolean isValid(Link link, LinkResourceService resourceService) {
44 DeviceId src = link.src().deviceId(); 50 DeviceId src = link.src().deviceId();
......
...@@ -23,6 +23,7 @@ import org.onlab.onos.net.Path; ...@@ -23,6 +23,7 @@ import org.onlab.onos.net.Path;
23 import org.onlab.onos.net.intent.Constraint; 23 import org.onlab.onos.net.intent.Constraint;
24 import org.onlab.onos.net.resource.LinkResourceService; 24 import org.onlab.onos.net.resource.LinkResourceService;
25 25
26 +import java.util.Collections;
26 import java.util.LinkedList; 27 import java.util.LinkedList;
27 import java.util.List; 28 import java.util.List;
28 import java.util.Objects; 29 import java.util.Objects;
...@@ -48,6 +49,11 @@ public class WaypointConstraint implements Constraint { ...@@ -48,6 +49,11 @@ public class WaypointConstraint implements Constraint {
48 this.waypoints = ImmutableList.copyOf(waypoints); 49 this.waypoints = ImmutableList.copyOf(waypoints);
49 } 50 }
50 51
52 + // Constructor for serialization
53 + private WaypointConstraint() {
54 + this.waypoints = Collections.emptyList();
55 + }
56 +
51 public List<DeviceId> waypoints() { 57 public List<DeviceId> waypoints() {
52 return waypoints; 58 return waypoints;
53 } 59 }
......
...@@ -75,10 +75,14 @@ import org.onlab.onos.net.intent.OpticalConnectivityIntent; ...@@ -75,10 +75,14 @@ import org.onlab.onos.net.intent.OpticalConnectivityIntent;
75 import org.onlab.onos.net.intent.OpticalPathIntent; 75 import org.onlab.onos.net.intent.OpticalPathIntent;
76 import org.onlab.onos.net.intent.PathIntent; 76 import org.onlab.onos.net.intent.PathIntent;
77 import org.onlab.onos.net.intent.PointToPointIntent; 77 import org.onlab.onos.net.intent.PointToPointIntent;
78 +import org.onlab.onos.net.intent.constraint.AnnotationConstraint;
78 import org.onlab.onos.net.intent.constraint.BandwidthConstraint; 79 import org.onlab.onos.net.intent.constraint.BandwidthConstraint;
79 import org.onlab.onos.net.intent.constraint.BooleanConstraint; 80 import org.onlab.onos.net.intent.constraint.BooleanConstraint;
80 import org.onlab.onos.net.intent.constraint.LambdaConstraint; 81 import org.onlab.onos.net.intent.constraint.LambdaConstraint;
82 +import org.onlab.onos.net.intent.constraint.LatencyConstraint;
81 import org.onlab.onos.net.intent.constraint.LinkTypeConstraint; 83 import org.onlab.onos.net.intent.constraint.LinkTypeConstraint;
84 +import org.onlab.onos.net.intent.constraint.ObstacleConstraint;
85 +import org.onlab.onos.net.intent.constraint.WaypointConstraint;
82 import org.onlab.onos.net.link.DefaultLinkDescription; 86 import org.onlab.onos.net.link.DefaultLinkDescription;
83 import org.onlab.onos.net.packet.DefaultOutboundPacket; 87 import org.onlab.onos.net.packet.DefaultOutboundPacket;
84 import org.onlab.onos.net.provider.ProviderId; 88 import org.onlab.onos.net.provider.ProviderId;
...@@ -208,9 +212,14 @@ public final class KryoNamespaces { ...@@ -208,9 +212,14 @@ public final class KryoNamespaces {
208 LinkResourceRequest.class, 212 LinkResourceRequest.class,
209 Lambda.class, 213 Lambda.class,
210 Bandwidth.class, 214 Bandwidth.class,
215 + // Constraints
211 LambdaConstraint.class, 216 LambdaConstraint.class,
212 BandwidthConstraint.class, 217 BandwidthConstraint.class,
213 LinkTypeConstraint.class, 218 LinkTypeConstraint.class,
219 + LatencyConstraint.class,
220 + WaypointConstraint.class,
221 + ObstacleConstraint.class,
222 + AnnotationConstraint.class,
214 BooleanConstraint.class 223 BooleanConstraint.class
215 ) 224 )
216 .register(DefaultApplicationId.class, new DefaultApplicationIdSerializer()) 225 .register(DefaultApplicationId.class, new DefaultApplicationIdSerializer())
......