Added constructors for serialization of the new constraint types and registered …
…the types with the serializer pool.
Showing
7 changed files
with
59 additions
and
1 deletions
... | @@ -43,6 +43,11 @@ public class BandwidthConstraint extends BooleanConstraint { | ... | @@ -43,6 +43,11 @@ public class BandwidthConstraint extends BooleanConstraint { |
43 | this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null"); | 43 | this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null"); |
44 | } | 44 | } |
45 | 45 | ||
46 | + // Constructor for serialization | ||
47 | + private BandwidthConstraint() { | ||
48 | + this.bandwidth = null; | ||
49 | + } | ||
50 | + | ||
46 | @Override | 51 | @Override |
47 | public boolean isValid(Link link, LinkResourceService resourceService) { | 52 | public boolean isValid(Link link, LinkResourceService resourceService) { |
48 | for (ResourceRequest request : resourceService.getAvailableResources(link)) { | 53 | for (ResourceRequest request : resourceService.getAvailableResources(link)) { | ... | ... |
... | @@ -41,6 +41,11 @@ public class LambdaConstraint extends BooleanConstraint { | ... | @@ -41,6 +41,11 @@ public class LambdaConstraint extends BooleanConstraint { |
41 | this.lambda = lambda; | 41 | this.lambda = lambda; |
42 | } | 42 | } |
43 | 43 | ||
44 | + // Constructor for serialization | ||
45 | + private LambdaConstraint() { | ||
46 | + this.lambda = null; | ||
47 | + } | ||
48 | + | ||
44 | @Override | 49 | @Override |
45 | public boolean isValid(Link link, LinkResourceService resourceService) { | 50 | public boolean isValid(Link link, LinkResourceService resourceService) { |
46 | for (ResourceRequest request : resourceService.getAvailableResources(link)) { | 51 | for (ResourceRequest request : resourceService.getAvailableResources(link)) { | ... | ... |
... | @@ -49,6 +49,12 @@ public class LinkTypeConstraint extends BooleanConstraint { | ... | @@ -49,6 +49,12 @@ public class LinkTypeConstraint extends BooleanConstraint { |
49 | this.isInclusive = inclusive; | 49 | this.isInclusive = inclusive; |
50 | } | 50 | } |
51 | 51 | ||
52 | + // Constructor for serialization | ||
53 | + private LinkTypeConstraint() { | ||
54 | + this.types = null; | ||
55 | + this.isInclusive = false; | ||
56 | + } | ||
57 | + | ||
52 | @Override | 58 | @Override |
53 | public boolean isValid(Link link, LinkResourceService resourceService) { | 59 | public boolean isValid(Link link, LinkResourceService resourceService) { |
54 | boolean contains = types.contains(link.type()); | 60 | boolean contains = types.contains(link.type()); | ... | ... |
1 | +/* | ||
2 | + * Copyright 2014 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Definitions of constraints used to refine intent specifications. | ||
19 | + */ | ||
20 | +package org.onlab.onos.net.intent.constraint; |
... | @@ -33,6 +33,11 @@ public final class Bandwidth extends LinkResource { | ... | @@ -33,6 +33,11 @@ public final class Bandwidth extends LinkResource { |
33 | this.bandwidth = bandwidth; | 33 | this.bandwidth = bandwidth; |
34 | } | 34 | } |
35 | 35 | ||
36 | + // Constructor for serialization | ||
37 | + private Bandwidth() { | ||
38 | + this.bandwidth = 0; | ||
39 | + } | ||
40 | + | ||
36 | /** | 41 | /** |
37 | * Creates a new instance with given bandwidth. | 42 | * Creates a new instance with given bandwidth. |
38 | * | 43 | * | ... | ... |
... | @@ -33,6 +33,11 @@ public final class Lambda extends LinkResource { | ... | @@ -33,6 +33,11 @@ public final class Lambda extends LinkResource { |
33 | this.lambda = lambda; | 33 | this.lambda = lambda; |
34 | } | 34 | } |
35 | 35 | ||
36 | + // Constructor for serialization | ||
37 | + private Lambda() { | ||
38 | + this.lambda = 0; | ||
39 | + } | ||
40 | + | ||
36 | /** | 41 | /** |
37 | * Creates a new instance with given lambda. | 42 | * Creates a new instance with given lambda. |
38 | * | 43 | * | ... | ... |
... | @@ -75,9 +75,15 @@ import org.onlab.onos.net.intent.OpticalConnectivityIntent; | ... | @@ -75,9 +75,15 @@ 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.BandwidthConstraint; | ||
79 | +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.LinkTypeConstraint; | ||
78 | import org.onlab.onos.net.link.DefaultLinkDescription; | 82 | import org.onlab.onos.net.link.DefaultLinkDescription; |
79 | import org.onlab.onos.net.packet.DefaultOutboundPacket; | 83 | import org.onlab.onos.net.packet.DefaultOutboundPacket; |
80 | import org.onlab.onos.net.provider.ProviderId; | 84 | import org.onlab.onos.net.provider.ProviderId; |
85 | +import org.onlab.onos.net.resource.Bandwidth; | ||
86 | +import org.onlab.onos.net.resource.Lambda; | ||
81 | import org.onlab.onos.net.resource.LinkResourceRequest; | 87 | import org.onlab.onos.net.resource.LinkResourceRequest; |
82 | import org.onlab.onos.store.Timestamp; | 88 | import org.onlab.onos.store.Timestamp; |
83 | import org.onlab.packet.ChassisId; | 89 | import org.onlab.packet.ChassisId; |
... | @@ -188,7 +194,13 @@ public final class KryoNamespaces { | ... | @@ -188,7 +194,13 @@ public final class KryoNamespaces { |
188 | LinkCollectionIntent.class, | 194 | LinkCollectionIntent.class, |
189 | OpticalConnectivityIntent.class, | 195 | OpticalConnectivityIntent.class, |
190 | OpticalPathIntent.class, | 196 | OpticalPathIntent.class, |
191 | - LinkResourceRequest.class | 197 | + LinkResourceRequest.class, |
198 | + Lambda.class, | ||
199 | + Bandwidth.class, | ||
200 | + LambdaConstraint.class, | ||
201 | + BandwidthConstraint.class, | ||
202 | + LinkTypeConstraint.class, | ||
203 | + BooleanConstraint.class | ||
192 | ) | 204 | ) |
193 | .register(DefaultApplicationId.class, new DefaultApplicationIdSerializer()) | 205 | .register(DefaultApplicationId.class, new DefaultApplicationIdSerializer()) |
194 | .register(URI.class, new URISerializer()) | 206 | .register(URI.class, new URISerializer()) | ... | ... |
-
Please register or login to post a comment