Committed by
Gerrit Code Review
Avoid double wrap of IndexedLambda
Change-Id: I2acaa255529949e8443542904df465e6b0fbb72a
Showing
10 changed files
with
23 additions
and
24 deletions
... | @@ -16,8 +16,8 @@ | ... | @@ -16,8 +16,8 @@ |
16 | package org.onosproject.net.intent.constraint; | 16 | package org.onosproject.net.intent.constraint; |
17 | 17 | ||
18 | import com.google.common.annotations.Beta; | 18 | import com.google.common.annotations.Beta; |
19 | +import org.onosproject.net.IndexedLambda; | ||
19 | import org.onosproject.net.Link; | 20 | import org.onosproject.net.Link; |
20 | -import org.onosproject.net.resource.link.LambdaResource; | ||
21 | import org.onosproject.net.resource.link.LinkResourceService; | 21 | import org.onosproject.net.resource.link.LinkResourceService; |
22 | import org.onosproject.net.resource.ResourceRequest; | 22 | import org.onosproject.net.resource.ResourceRequest; |
23 | import org.onosproject.net.resource.ResourceType; | 23 | import org.onosproject.net.resource.ResourceType; |
... | @@ -32,14 +32,14 @@ import static com.google.common.base.MoreObjects.toStringHelper; | ... | @@ -32,14 +32,14 @@ import static com.google.common.base.MoreObjects.toStringHelper; |
32 | @Beta | 32 | @Beta |
33 | public class LambdaConstraint extends BooleanConstraint { | 33 | public class LambdaConstraint extends BooleanConstraint { |
34 | 34 | ||
35 | - private final LambdaResource lambda; | 35 | + private final IndexedLambda lambda; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Creates a new optical lambda constraint. | 38 | * Creates a new optical lambda constraint. |
39 | * | 39 | * |
40 | * @param lambda optional lambda to indicate a specific lambda | 40 | * @param lambda optional lambda to indicate a specific lambda |
41 | */ | 41 | */ |
42 | - public LambdaConstraint(LambdaResource lambda) { | 42 | + public LambdaConstraint(IndexedLambda lambda) { |
43 | this.lambda = lambda; | 43 | this.lambda = lambda; |
44 | } | 44 | } |
45 | 45 | ||
... | @@ -63,7 +63,7 @@ public class LambdaConstraint extends BooleanConstraint { | ... | @@ -63,7 +63,7 @@ public class LambdaConstraint extends BooleanConstraint { |
63 | * | 63 | * |
64 | * @return required lambda | 64 | * @return required lambda |
65 | */ | 65 | */ |
66 | - public LambdaResource lambda() { | 66 | + public IndexedLambda lambda() { |
67 | return lambda; | 67 | return lambda; |
68 | } | 68 | } |
69 | 69 | ... | ... |
... | @@ -22,11 +22,11 @@ import java.util.Set; | ... | @@ -22,11 +22,11 @@ import java.util.Set; |
22 | 22 | ||
23 | import org.junit.Test; | 23 | import org.junit.Test; |
24 | import org.onosproject.net.ConnectPoint; | 24 | import org.onosproject.net.ConnectPoint; |
25 | +import org.onosproject.net.IndexedLambda; | ||
25 | import org.onosproject.net.Link; | 26 | import org.onosproject.net.Link; |
26 | import org.onosproject.net.NetTestTools; | 27 | import org.onosproject.net.NetTestTools; |
27 | import org.onosproject.net.flow.TrafficSelector; | 28 | import org.onosproject.net.flow.TrafficSelector; |
28 | import org.onosproject.net.intent.constraint.LambdaConstraint; | 29 | import org.onosproject.net.intent.constraint.LambdaConstraint; |
29 | -import org.onosproject.net.resource.link.LambdaResource; | ||
30 | 30 | ||
31 | import com.google.common.collect.ImmutableSet; | 31 | import com.google.common.collect.ImmutableSet; |
32 | import com.google.common.testing.EqualsTester; | 32 | import com.google.common.testing.EqualsTester; |
... | @@ -132,7 +132,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -132,7 +132,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
132 | final LinkedList<Constraint> constraints = new LinkedList<>(); | 132 | final LinkedList<Constraint> constraints = new LinkedList<>(); |
133 | 133 | ||
134 | links1.add(link("src", 1, "dst", 2)); | 134 | links1.add(link("src", 1, "dst", 2)); |
135 | - constraints.add(new LambdaConstraint(LambdaResource.valueOf(23))); | 135 | + constraints.add(new LambdaConstraint(new IndexedLambda(23))); |
136 | final LinkCollectionIntent collectionIntent = | 136 | final LinkCollectionIntent collectionIntent = |
137 | LinkCollectionIntent.builder() | 137 | LinkCollectionIntent.builder() |
138 | .appId(APP_ID) | 138 | .appId(APP_ID) | ... | ... |
... | @@ -17,8 +17,8 @@ package org.onosproject.net.intent.constraint; | ... | @@ -17,8 +17,8 @@ package org.onosproject.net.intent.constraint; |
17 | 17 | ||
18 | import org.junit.Test; | 18 | import org.junit.Test; |
19 | import org.onlab.util.Bandwidth; | 19 | import org.onlab.util.Bandwidth; |
20 | +import org.onosproject.net.IndexedLambda; | ||
20 | import org.onosproject.net.Link; | 21 | import org.onosproject.net.Link; |
21 | -import org.onosproject.net.resource.link.LambdaResource; | ||
22 | 22 | ||
23 | import com.google.common.testing.EqualsTester; | 23 | import com.google.common.testing.EqualsTester; |
24 | 24 | ||
... | @@ -66,20 +66,20 @@ public class ConstraintObjectsTest { | ... | @@ -66,20 +66,20 @@ public class ConstraintObjectsTest { |
66 | // Lambda Constraint | 66 | // Lambda Constraint |
67 | 67 | ||
68 | final LambdaConstraint lambdaConstraint1 = | 68 | final LambdaConstraint lambdaConstraint1 = |
69 | - new LambdaConstraint(LambdaResource.valueOf(100)); | 69 | + new LambdaConstraint(new IndexedLambda(100)); |
70 | final LambdaConstraint lambdaConstraintSameAs1 = | 70 | final LambdaConstraint lambdaConstraintSameAs1 = |
71 | - new LambdaConstraint(LambdaResource.valueOf(100)); | 71 | + new LambdaConstraint(new IndexedLambda(100)); |
72 | final LambdaConstraint lambdaConstraint2 = | 72 | final LambdaConstraint lambdaConstraint2 = |
73 | - new LambdaConstraint(LambdaResource.valueOf(200)); | 73 | + new LambdaConstraint(new IndexedLambda(200)); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Checks that the objects were created properly. | 76 | * Checks that the objects were created properly. |
77 | */ | 77 | */ |
78 | @Test | 78 | @Test |
79 | public void testLambdaConstraintCreation() { | 79 | public void testLambdaConstraintCreation() { |
80 | - assertThat(lambdaConstraint1.lambda().toInt(), is(equalTo(100))); | 80 | + assertThat(lambdaConstraint1.lambda().index(), is(equalTo(100L))); |
81 | - assertThat(lambdaConstraintSameAs1.lambda().toInt(), is(equalTo(100))); | 81 | + assertThat(lambdaConstraintSameAs1.lambda().index(), is(equalTo(100L))); |
82 | - assertThat(lambdaConstraint2.lambda().toInt(), is(equalTo(200))); | 82 | + assertThat(lambdaConstraint2.lambda().index(), is(equalTo(200L))); |
83 | } | 83 | } |
84 | 84 | ||
85 | /** | 85 | /** | ... | ... |
... | @@ -32,7 +32,6 @@ import org.onosproject.net.intent.constraint.LatencyConstraint; | ... | @@ -32,7 +32,6 @@ import org.onosproject.net.intent.constraint.LatencyConstraint; |
32 | import org.onosproject.net.intent.constraint.LinkTypeConstraint; | 32 | import org.onosproject.net.intent.constraint.LinkTypeConstraint; |
33 | import org.onosproject.net.intent.constraint.ObstacleConstraint; | 33 | import org.onosproject.net.intent.constraint.ObstacleConstraint; |
34 | import org.onosproject.net.intent.constraint.WaypointConstraint; | 34 | import org.onosproject.net.intent.constraint.WaypointConstraint; |
35 | -import org.onosproject.net.resource.link.LambdaResource; | ||
36 | 35 | ||
37 | import com.fasterxml.jackson.databind.JsonNode; | 36 | import com.fasterxml.jackson.databind.JsonNode; |
38 | import com.fasterxml.jackson.databind.node.ObjectNode; | 37 | import com.fasterxml.jackson.databind.node.ObjectNode; |
... | @@ -105,7 +104,7 @@ public final class DecodeConstraintCodecHelper { | ... | @@ -105,7 +104,7 @@ public final class DecodeConstraintCodecHelper { |
105 | ConstraintCodec.LAMBDA + ConstraintCodec.MISSING_MEMBER_MESSAGE) | 104 | ConstraintCodec.LAMBDA + ConstraintCodec.MISSING_MEMBER_MESSAGE) |
106 | .asLong(); | 105 | .asLong(); |
107 | 106 | ||
108 | - return new LambdaConstraint(LambdaResource.valueOf(new IndexedLambda(lambda))); | 107 | + return new LambdaConstraint(new IndexedLambda(lambda)); |
109 | } | 108 | } |
110 | 109 | ||
111 | /** | 110 | /** | ... | ... |
... | @@ -142,7 +142,7 @@ public final class EncodeConstraintCodecHelper { | ... | @@ -142,7 +142,7 @@ public final class EncodeConstraintCodecHelper { |
142 | (LambdaConstraint) constraint; | 142 | (LambdaConstraint) constraint; |
143 | 143 | ||
144 | return context.mapper().createObjectNode() | 144 | return context.mapper().createObjectNode() |
145 | - .put("lambda", lambdaConstraint.lambda().toInt()); | 145 | + .put("lambda", lambdaConstraint.lambda().index()); |
146 | } | 146 | } |
147 | 147 | ||
148 | /** | 148 | /** | ... | ... |
... | @@ -146,7 +146,7 @@ public class ConstraintCodecTest { | ... | @@ -146,7 +146,7 @@ public class ConstraintCodecTest { |
146 | assertThat(constraint, instanceOf(LambdaConstraint.class)); | 146 | assertThat(constraint, instanceOf(LambdaConstraint.class)); |
147 | 147 | ||
148 | LambdaConstraint lambdaConstraint = (LambdaConstraint) constraint; | 148 | LambdaConstraint lambdaConstraint = (LambdaConstraint) constraint; |
149 | - assertThat(lambdaConstraint.lambda().toInt(), is(444)); | 149 | + assertThat(lambdaConstraint.lambda().index(), is(444L)); |
150 | } | 150 | } |
151 | 151 | ||
152 | /** | 152 | /** | ... | ... |
... | @@ -63,7 +63,6 @@ import org.onosproject.net.intent.constraint.LambdaConstraint; | ... | @@ -63,7 +63,6 @@ import org.onosproject.net.intent.constraint.LambdaConstraint; |
63 | import org.onosproject.net.intent.constraint.LatencyConstraint; | 63 | import org.onosproject.net.intent.constraint.LatencyConstraint; |
64 | import org.onosproject.net.intent.constraint.ObstacleConstraint; | 64 | import org.onosproject.net.intent.constraint.ObstacleConstraint; |
65 | import org.onosproject.net.intent.constraint.WaypointConstraint; | 65 | import org.onosproject.net.intent.constraint.WaypointConstraint; |
66 | -import org.onosproject.net.resource.link.LambdaResource; | ||
67 | 66 | ||
68 | import com.fasterxml.jackson.databind.JsonNode; | 67 | import com.fasterxml.jackson.databind.JsonNode; |
69 | import com.fasterxml.jackson.databind.node.ObjectNode; | 68 | import com.fasterxml.jackson.databind.node.ObjectNode; |
... | @@ -181,7 +180,7 @@ public class IntentCodecTest extends AbstractIntentTest { | ... | @@ -181,7 +180,7 @@ public class IntentCodecTest extends AbstractIntentTest { |
181 | final List<Constraint> constraints = | 180 | final List<Constraint> constraints = |
182 | ImmutableList.of( | 181 | ImmutableList.of( |
183 | new BandwidthConstraint(Bandwidth.bps(1.0)), | 182 | new BandwidthConstraint(Bandwidth.bps(1.0)), |
184 | - new LambdaConstraint(LambdaResource.valueOf(3)), | 183 | + new LambdaConstraint(new IndexedLambda(3)), |
185 | new AnnotationConstraint("key", 33.0), | 184 | new AnnotationConstraint("key", 33.0), |
186 | new AsymmetricPathConstraint(), | 185 | new AsymmetricPathConstraint(), |
187 | new LatencyConstraint(Duration.ofSeconds(2)), | 186 | new LatencyConstraint(Duration.ofSeconds(2)), | ... | ... |
... | @@ -157,7 +157,7 @@ public final class IntentJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> | ... | @@ -157,7 +157,7 @@ public final class IntentJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> |
157 | final JsonNode lambdaJson = constraintJson.get("lambda"); | 157 | final JsonNode lambdaJson = constraintJson.get("lambda"); |
158 | return lambdaJson != null | 158 | return lambdaJson != null |
159 | && constraintJson.get("lambda").asInt() | 159 | && constraintJson.get("lambda").asInt() |
160 | - == lambdaConstraint.lambda().toInt(); | 160 | + == lambdaConstraint.lambda().index(); |
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** | ... | ... |
... | @@ -21,6 +21,7 @@ import org.onlab.util.Bandwidth; | ... | @@ -21,6 +21,7 @@ import org.onlab.util.Bandwidth; |
21 | import org.onosproject.TestApplicationId; | 21 | import org.onosproject.TestApplicationId; |
22 | import org.onosproject.core.ApplicationId; | 22 | import org.onosproject.core.ApplicationId; |
23 | import org.onosproject.net.ConnectPoint; | 23 | import org.onosproject.net.ConnectPoint; |
24 | +import org.onosproject.net.IndexedLambda; | ||
24 | import org.onosproject.net.Link; | 25 | import org.onosproject.net.Link; |
25 | import org.onosproject.net.Path; | 26 | import org.onosproject.net.Path; |
26 | import org.onosproject.net.flow.TrafficSelector; | 27 | import org.onosproject.net.flow.TrafficSelector; |
... | @@ -34,7 +35,6 @@ import org.onosproject.net.intent.PointToPointIntent; | ... | @@ -34,7 +35,6 @@ import org.onosproject.net.intent.PointToPointIntent; |
34 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 35 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
35 | import org.onosproject.net.intent.constraint.LambdaConstraint; | 36 | import org.onosproject.net.intent.constraint.LambdaConstraint; |
36 | import org.onosproject.net.intent.impl.PathNotFoundException; | 37 | import org.onosproject.net.intent.impl.PathNotFoundException; |
37 | -import org.onosproject.net.resource.link.LambdaResource; | ||
38 | import org.onosproject.net.resource.link.LinkResourceService; | 38 | import org.onosproject.net.resource.link.LinkResourceService; |
39 | 39 | ||
40 | import java.util.Collections; | 40 | import java.util.Collections; |
... | @@ -274,7 +274,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { | ... | @@ -274,7 +274,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { |
274 | public void testLambdaConstrainedIntentSuccess() { | 274 | public void testLambdaConstrainedIntentSuccess() { |
275 | 275 | ||
276 | final List<Constraint> constraints = | 276 | final List<Constraint> constraints = |
277 | - Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); | 277 | + Collections.singletonList(new LambdaConstraint(new IndexedLambda(1))); |
278 | final LinkResourceService resourceService = | 278 | final LinkResourceService resourceService = |
279 | IntentTestsMocks.MockResourceService.makeLambdaResourceService(1); | 279 | IntentTestsMocks.MockResourceService.makeLambdaResourceService(1); |
280 | 280 | ||
... | @@ -298,7 +298,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { | ... | @@ -298,7 +298,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { |
298 | public void testLambdaConstrainedIntentFailure() { | 298 | public void testLambdaConstrainedIntentFailure() { |
299 | 299 | ||
300 | final List<Constraint> constraints = | 300 | final List<Constraint> constraints = |
301 | - Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); | 301 | + Collections.singletonList(new LambdaConstraint(new IndexedLambda(1))); |
302 | final LinkResourceService resourceService = | 302 | final LinkResourceService resourceService = |
303 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); | 303 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); |
304 | try { | 304 | try { | ... | ... |
... | @@ -43,6 +43,7 @@ import org.onosproject.net.Device; | ... | @@ -43,6 +43,7 @@ import org.onosproject.net.Device; |
43 | import org.onosproject.net.DeviceId; | 43 | import org.onosproject.net.DeviceId; |
44 | import org.onosproject.net.GridType; | 44 | import org.onosproject.net.GridType; |
45 | import org.onosproject.net.HostLocation; | 45 | import org.onosproject.net.HostLocation; |
46 | +import org.onosproject.net.IndexedLambda; | ||
46 | import org.onosproject.net.Link; | 47 | import org.onosproject.net.Link; |
47 | import org.onosproject.net.Link.Type; | 48 | import org.onosproject.net.Link.Type; |
48 | import org.onosproject.net.LinkKey; | 49 | import org.onosproject.net.LinkKey; |
... | @@ -395,7 +396,7 @@ public class KryoSerializerTest { | ... | @@ -395,7 +396,7 @@ public class KryoSerializerTest { |
395 | 396 | ||
396 | @Test | 397 | @Test |
397 | public void testLambdaConstraint() { | 398 | public void testLambdaConstraint() { |
398 | - testSerializable(new LambdaConstraint(LambdaResource.valueOf(1))); | 399 | + testSerializable(new LambdaConstraint(new IndexedLambda(1))); |
399 | } | 400 | } |
400 | 401 | ||
401 | @Test | 402 | @Test | ... | ... |
-
Please register or login to post a comment