Thomas Vachuska
Committed by Gerrit Code Review

Merge "Make constraint objects serializable by Kryo"

......@@ -43,6 +43,12 @@ public class AnnotationConstraint extends BooleanConstraint {
this.threshold = threshold;
}
// Constructor for serialization
private AnnotationConstraint() {
this.key = "";
this.threshold = 0;
}
/**
* Returns the key of link annotation this constraint designates.
* @return key of link annotation
......
......@@ -43,6 +43,11 @@ public class LatencyConstraint implements Constraint {
this.latency = latency;
}
// Constructor for serialization
private LatencyConstraint() {
this.latency = Duration.ZERO;
}
public Duration latency() {
return latency;
}
......
......@@ -21,6 +21,7 @@ import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.resource.LinkResourceService;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
......@@ -39,6 +40,11 @@ public class ObstacleConstraint extends BooleanConstraint {
this.obstacles = ImmutableSet.copyOf(obstacles);
}
// Constructor for serialization
private ObstacleConstraint() {
this.obstacles = Collections.emptySet();
}
@Override
public boolean isValid(Link link, LinkResourceService resourceService) {
DeviceId src = link.src().deviceId();
......
......@@ -23,6 +23,7 @@ import org.onlab.onos.net.Path;
import org.onlab.onos.net.intent.Constraint;
import org.onlab.onos.net.resource.LinkResourceService;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
......@@ -48,6 +49,11 @@ public class WaypointConstraint implements Constraint {
this.waypoints = ImmutableList.copyOf(waypoints);
}
// Constructor for serialization
private WaypointConstraint() {
this.waypoints = Collections.emptyList();
}
public List<DeviceId> waypoints() {
return waypoints;
}
......
......@@ -75,10 +75,14 @@ import org.onlab.onos.net.intent.OpticalConnectivityIntent;
import org.onlab.onos.net.intent.OpticalPathIntent;
import org.onlab.onos.net.intent.PathIntent;
import org.onlab.onos.net.intent.PointToPointIntent;
import org.onlab.onos.net.intent.constraint.AnnotationConstraint;
import org.onlab.onos.net.intent.constraint.BandwidthConstraint;
import org.onlab.onos.net.intent.constraint.BooleanConstraint;
import org.onlab.onos.net.intent.constraint.LambdaConstraint;
import org.onlab.onos.net.intent.constraint.LatencyConstraint;
import org.onlab.onos.net.intent.constraint.LinkTypeConstraint;
import org.onlab.onos.net.intent.constraint.ObstacleConstraint;
import org.onlab.onos.net.intent.constraint.WaypointConstraint;
import org.onlab.onos.net.link.DefaultLinkDescription;
import org.onlab.onos.net.packet.DefaultOutboundPacket;
import org.onlab.onos.net.provider.ProviderId;
......@@ -208,9 +212,14 @@ public final class KryoNamespaces {
LinkResourceRequest.class,
Lambda.class,
Bandwidth.class,
// Constraints
LambdaConstraint.class,
BandwidthConstraint.class,
LinkTypeConstraint.class,
LatencyConstraint.class,
WaypointConstraint.class,
ObstacleConstraint.class,
AnnotationConstraint.class,
BooleanConstraint.class
)
.register(DefaultApplicationId.class, new DefaultApplicationIdSerializer())
......