Committed by
Gerrit Code Review
Merge "Make constraint objects serializable by Kryo"
Showing
5 changed files
with
32 additions
and
0 deletions
... | @@ -43,6 +43,12 @@ public class AnnotationConstraint extends BooleanConstraint { | ... | @@ -43,6 +43,12 @@ public class AnnotationConstraint extends BooleanConstraint { |
43 | this.threshold = threshold; | 43 | this.threshold = threshold; |
44 | } | 44 | } |
45 | 45 | ||
46 | + // Constructor for serialization | ||
47 | + private AnnotationConstraint() { | ||
48 | + this.key = ""; | ||
49 | + this.threshold = 0; | ||
50 | + } | ||
51 | + | ||
46 | /** | 52 | /** |
47 | * Returns the key of link annotation this constraint designates. | 53 | * Returns the key of link annotation this constraint designates. |
48 | * @return key of link annotation | 54 | * @return key of link annotation | ... | ... |
... | @@ -43,6 +43,11 @@ public class LatencyConstraint implements Constraint { | ... | @@ -43,6 +43,11 @@ public class LatencyConstraint implements Constraint { |
43 | this.latency = latency; | 43 | this.latency = latency; |
44 | } | 44 | } |
45 | 45 | ||
46 | + // Constructor for serialization | ||
47 | + private LatencyConstraint() { | ||
48 | + this.latency = Duration.ZERO; | ||
49 | + } | ||
50 | + | ||
46 | public Duration latency() { | 51 | public Duration latency() { |
47 | return latency; | 52 | return latency; |
48 | } | 53 | } | ... | ... |
... | @@ -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()) | ... | ... |
-
Please register or login to post a comment