Thomas Vachuska

Added constructors for serialization of the new constraint types and registered …

…the types with the serializer pool.
......@@ -43,6 +43,11 @@ public class BandwidthConstraint extends BooleanConstraint {
this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null");
}
// Constructor for serialization
private BandwidthConstraint() {
this.bandwidth = null;
}
@Override
public boolean isValid(Link link, LinkResourceService resourceService) {
for (ResourceRequest request : resourceService.getAvailableResources(link)) {
......
......@@ -41,6 +41,11 @@ public class LambdaConstraint extends BooleanConstraint {
this.lambda = lambda;
}
// Constructor for serialization
private LambdaConstraint() {
this.lambda = null;
}
@Override
public boolean isValid(Link link, LinkResourceService resourceService) {
for (ResourceRequest request : resourceService.getAvailableResources(link)) {
......
......@@ -49,6 +49,12 @@ public class LinkTypeConstraint extends BooleanConstraint {
this.isInclusive = inclusive;
}
// Constructor for serialization
private LinkTypeConstraint() {
this.types = null;
this.isInclusive = false;
}
@Override
public boolean isValid(Link link, LinkResourceService resourceService) {
boolean contains = types.contains(link.type());
......
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Definitions of constraints used to refine intent specifications.
*/
package org.onlab.onos.net.intent.constraint;
......@@ -33,6 +33,11 @@ public final class Bandwidth extends LinkResource {
this.bandwidth = bandwidth;
}
// Constructor for serialization
private Bandwidth() {
this.bandwidth = 0;
}
/**
* Creates a new instance with given bandwidth.
*
......
......@@ -33,6 +33,11 @@ public final class Lambda extends LinkResource {
this.lambda = lambda;
}
// Constructor for serialization
private Lambda() {
this.lambda = 0;
}
/**
* Creates a new instance with given lambda.
*
......
......@@ -75,9 +75,15 @@ 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.BandwidthConstraint;
import org.onlab.onos.net.intent.constraint.BooleanConstraint;
import org.onlab.onos.net.intent.constraint.LambdaConstraint;
import org.onlab.onos.net.intent.constraint.LinkTypeConstraint;
import org.onlab.onos.net.link.DefaultLinkDescription;
import org.onlab.onos.net.packet.DefaultOutboundPacket;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.net.resource.Bandwidth;
import org.onlab.onos.net.resource.Lambda;
import org.onlab.onos.net.resource.LinkResourceRequest;
import org.onlab.onos.store.Timestamp;
import org.onlab.packet.ChassisId;
......@@ -188,7 +194,13 @@ public final class KryoNamespaces {
LinkCollectionIntent.class,
OpticalConnectivityIntent.class,
OpticalPathIntent.class,
LinkResourceRequest.class
LinkResourceRequest.class,
Lambda.class,
Bandwidth.class,
LambdaConstraint.class,
BandwidthConstraint.class,
LinkTypeConstraint.class,
BooleanConstraint.class
)
.register(DefaultApplicationId.class, new DefaultApplicationIdSerializer())
.register(URI.class, new URISerializer())
......