Committed by
Naoki Shiota
Made ResourceManager to accept arbitrary ResourceConsumer implementation. (ONOS-4406)
Change-Id: If41564824770c2a8b78237a206c036df94141117
Showing
15 changed files
with
276 additions
and
56 deletions
| ... | @@ -40,6 +40,7 @@ import org.onosproject.net.PortNumber; | ... | @@ -40,6 +40,7 @@ import org.onosproject.net.PortNumber; |
| 40 | import org.onosproject.net.TributarySlot; | 40 | import org.onosproject.net.TributarySlot; |
| 41 | import org.onosproject.net.device.DeviceService; | 41 | import org.onosproject.net.device.DeviceService; |
| 42 | import org.onosproject.net.intent.IntentId; | 42 | import org.onosproject.net.intent.IntentId; |
| 43 | +import org.onosproject.net.resource.ResourceConsumerId; | ||
| 43 | import org.onosproject.net.resource.Resources; | 44 | import org.onosproject.net.resource.Resources; |
| 44 | import org.onosproject.net.resource.DiscreteResourceId; | 45 | import org.onosproject.net.resource.DiscreteResourceId; |
| 45 | import org.onosproject.net.resource.ResourceAllocation; | 46 | import org.onosproject.net.resource.ResourceAllocation; |
| ... | @@ -145,15 +146,15 @@ public class AllocationsCommand extends AbstractShellCommand { | ... | @@ -145,15 +146,15 @@ public class AllocationsCommand extends AbstractShellCommand { |
| 145 | resourceService.getResourceAllocations(resourceId, t).stream() | 146 | resourceService.getResourceAllocations(resourceId, t).stream() |
| 146 | .filter(a -> isSubjectToPrint(a)) | 147 | .filter(a -> isSubjectToPrint(a)) |
| 147 | .forEach(a -> print("%s%s allocated by %s", Strings.repeat(" ", level + 1), | 148 | .forEach(a -> print("%s%s allocated by %s", Strings.repeat(" ", level + 1), |
| 148 | - a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumer()))); | 149 | + a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumerId()))); |
| 149 | 150 | ||
| 150 | } | 151 | } |
| 151 | } | 152 | } |
| 152 | 153 | ||
| 153 | private boolean isSubjectToPrint(ResourceAllocation allocation) { | 154 | private boolean isSubjectToPrint(ResourceAllocation allocation) { |
| 154 | if (!intentsToPrint.isEmpty() | 155 | if (!intentsToPrint.isEmpty() |
| 155 | - && allocation.consumer() instanceof IntentId | 156 | + && allocation.consumerId().isClassOf(IntentId.class) |
| 156 | - && !intentsToPrint.contains(allocation.consumer().toString())) { | 157 | + && !intentsToPrint.contains(allocation.consumerId().toString())) { |
| 157 | return false; | 158 | return false; |
| 158 | } | 159 | } |
| 159 | 160 | ||
| ... | @@ -184,4 +185,8 @@ public class AllocationsCommand extends AbstractShellCommand { | ... | @@ -184,4 +185,8 @@ public class AllocationsCommand extends AbstractShellCommand { |
| 184 | } | 185 | } |
| 185 | } | 186 | } |
| 186 | 187 | ||
| 188 | + private static String asVerboseString(ResourceConsumerId consumerId) { | ||
| 189 | + return String.format("%s:%s", consumerId.consumerClass(), consumerId.value()); | ||
| 190 | + } | ||
| 191 | + | ||
| 187 | } | 192 | } | ... | ... |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.net.intent; | ... | @@ -18,6 +18,7 @@ package org.onosproject.net.intent; |
| 18 | import com.google.common.annotations.Beta; | 18 | import com.google.common.annotations.Beta; |
| 19 | import org.onlab.util.Identifier; | 19 | import org.onlab.util.Identifier; |
| 20 | import org.onosproject.net.resource.ResourceConsumer; | 20 | import org.onosproject.net.resource.ResourceConsumer; |
| 21 | +import org.onosproject.net.resource.ResourceConsumerId; | ||
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| 23 | * Intent identifier suitable as an external key. | 24 | * Intent identifier suitable as an external key. |
| ... | @@ -66,4 +67,8 @@ public final class IntentId extends Identifier<Long> implements ResourceConsumer | ... | @@ -66,4 +67,8 @@ public final class IntentId extends Identifier<Long> implements ResourceConsumer |
| 66 | return "0x" + Long.toHexString(identifier); | 67 | return "0x" + Long.toHexString(identifier); |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 70 | + @Override | ||
| 71 | + public ResourceConsumerId consumerId() { | ||
| 72 | + return ResourceConsumerId.of(this); | ||
| 73 | + } | ||
| 69 | } | 74 | } | ... | ... |
| ... | @@ -29,7 +29,18 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -29,7 +29,18 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 29 | public class ResourceAllocation { | 29 | public class ResourceAllocation { |
| 30 | 30 | ||
| 31 | private final Resource resource; | 31 | private final Resource resource; |
| 32 | - private final ResourceConsumer consumer; | 32 | + private final ResourceConsumerId consumerId; |
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Creates an instance with the specified subject, resource and consumerId. | ||
| 36 | + * | ||
| 37 | + * @param resource resource of the subject | ||
| 38 | + * @param consumerId consumer ID of this resource | ||
| 39 | + */ | ||
| 40 | + public ResourceAllocation(Resource resource, ResourceConsumerId consumerId) { | ||
| 41 | + this.resource = checkNotNull(resource); | ||
| 42 | + this.consumerId = checkNotNull(consumerId); | ||
| 43 | + } | ||
| 33 | 44 | ||
| 34 | /** | 45 | /** |
| 35 | * Creates an instance with the specified subject, resource and consumer. | 46 | * Creates an instance with the specified subject, resource and consumer. |
| ... | @@ -38,14 +49,13 @@ public class ResourceAllocation { | ... | @@ -38,14 +49,13 @@ public class ResourceAllocation { |
| 38 | * @param consumer consumer of this resource | 49 | * @param consumer consumer of this resource |
| 39 | */ | 50 | */ |
| 40 | public ResourceAllocation(Resource resource, ResourceConsumer consumer) { | 51 | public ResourceAllocation(Resource resource, ResourceConsumer consumer) { |
| 41 | - this.resource = checkNotNull(resource); | 52 | + this(resource, checkNotNull(consumer).consumerId()); |
| 42 | - this.consumer = consumer; | ||
| 43 | } | 53 | } |
| 44 | 54 | ||
| 45 | // for serialization | 55 | // for serialization |
| 46 | private ResourceAllocation() { | 56 | private ResourceAllocation() { |
| 47 | this.resource = null; | 57 | this.resource = null; |
| 48 | - this.consumer = null; | 58 | + this.consumerId = null; |
| 49 | } | 59 | } |
| 50 | 60 | ||
| 51 | /** | 61 | /** |
| ... | @@ -58,17 +68,17 @@ public class ResourceAllocation { | ... | @@ -58,17 +68,17 @@ public class ResourceAllocation { |
| 58 | } | 68 | } |
| 59 | 69 | ||
| 60 | /** | 70 | /** |
| 61 | - * Returns the consumer of this resource. | 71 | + * Returns ID of the consumer of this resource. |
| 62 | * | 72 | * |
| 63 | - * @return the consumer of this resource | 73 | + * @return ID of the consumer of this resource |
| 64 | */ | 74 | */ |
| 65 | - public ResourceConsumer consumer() { | 75 | + public ResourceConsumerId consumerId() { |
| 66 | - return consumer; | 76 | + return consumerId; |
| 67 | } | 77 | } |
| 68 | 78 | ||
| 69 | @Override | 79 | @Override |
| 70 | public int hashCode() { | 80 | public int hashCode() { |
| 71 | - return Objects.hash(resource, consumer); | 81 | + return Objects.hash(resource, consumerId); |
| 72 | } | 82 | } |
| 73 | 83 | ||
| 74 | @Override | 84 | @Override |
| ... | @@ -81,14 +91,14 @@ public class ResourceAllocation { | ... | @@ -81,14 +91,14 @@ public class ResourceAllocation { |
| 81 | } | 91 | } |
| 82 | final ResourceAllocation that = (ResourceAllocation) obj; | 92 | final ResourceAllocation that = (ResourceAllocation) obj; |
| 83 | return Objects.equals(this.resource, that.resource) | 93 | return Objects.equals(this.resource, that.resource) |
| 84 | - && Objects.equals(this.consumer, that.consumer); | 94 | + && Objects.equals(this.consumerId, that.consumerId); |
| 85 | } | 95 | } |
| 86 | 96 | ||
| 87 | @Override | 97 | @Override |
| 88 | public String toString() { | 98 | public String toString() { |
| 89 | return MoreObjects.toStringHelper(this) | 99 | return MoreObjects.toStringHelper(this) |
| 90 | .add("resource", resource) | 100 | .add("resource", resource) |
| 91 | - .add("consumer", consumer) | 101 | + .add("consumerId", consumerId) |
| 92 | .toString(); | 102 | .toString(); |
| 93 | } | 103 | } |
| 94 | } | 104 | } | ... | ... |
| ... | @@ -22,4 +22,10 @@ import com.google.common.annotations.Beta; | ... | @@ -22,4 +22,10 @@ import com.google.common.annotations.Beta; |
| 22 | */ | 22 | */ |
| 23 | @Beta | 23 | @Beta |
| 24 | public interface ResourceConsumer { | 24 | public interface ResourceConsumer { |
| 25 | + /** | ||
| 26 | + * Returns ID of this consumer. | ||
| 27 | + * | ||
| 28 | + * @return ID of this consumer | ||
| 29 | + */ | ||
| 30 | + ResourceConsumerId consumerId(); | ||
| 25 | } | 31 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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 | +package org.onosproject.net.resource; | ||
| 18 | + | ||
| 19 | +import com.google.common.base.Objects; | ||
| 20 | +import org.onlab.util.Identifier; | ||
| 21 | + | ||
| 22 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Representation of global unique ID for ResourceConsumer object. | ||
| 26 | + */ | ||
| 27 | +public class ResourceConsumerId { | ||
| 28 | + private final String className; | ||
| 29 | + private final long value; | ||
| 30 | + | ||
| 31 | + // Constructor for serializer. | ||
| 32 | + protected ResourceConsumerId() { | ||
| 33 | + this.className = null; | ||
| 34 | + this.value = 0L; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Constructor with specifying every fields. | ||
| 39 | + * | ||
| 40 | + * @param value ID value unique within the given class | ||
| 41 | + * @param cls class of ResourceConsumer implementation | ||
| 42 | + */ | ||
| 43 | + ResourceConsumerId(long value, Class<?> cls) { | ||
| 44 | + this.className = checkNotNull(cls.getName()); | ||
| 45 | + this.value = value; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Checks if the consumer is an instance of given class. | ||
| 50 | + * | ||
| 51 | + * @param cls class object | ||
| 52 | + * @return result of check | ||
| 53 | + */ | ||
| 54 | + public boolean isClassOf(Class<?> cls) { | ||
| 55 | + return checkNotNull(cls).getName().equals(className); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Returns class name of the consumer. | ||
| 60 | + * | ||
| 61 | + * @return class name of the consumer in String | ||
| 62 | + */ | ||
| 63 | + public String consumerClass() { | ||
| 64 | + return className; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * Returns ID value. | ||
| 69 | + * | ||
| 70 | + * @return ID value | ||
| 71 | + */ | ||
| 72 | + public long value() { | ||
| 73 | + return value; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public boolean equals(Object o) { | ||
| 78 | + if (this == o) { | ||
| 79 | + return true; | ||
| 80 | + } | ||
| 81 | + if (o == null || getClass() != o.getClass()) { | ||
| 82 | + return false; | ||
| 83 | + } | ||
| 84 | + ResourceConsumerId that = (ResourceConsumerId) o; | ||
| 85 | + return Objects.equal(className, that.className) && | ||
| 86 | + Objects.equal(value, that.value); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public int hashCode() { | ||
| 91 | + return Objects.hashCode(className, value); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * Creates ResourceConsumerId from given value and class. | ||
| 96 | + * | ||
| 97 | + * @param value ID value unique within the given class | ||
| 98 | + * @param cls class of ResourceConsumer implementation | ||
| 99 | + * @return created ResourceConsumerId object | ||
| 100 | + */ | ||
| 101 | + public static <T extends ResourceConsumer> ResourceConsumerId of(long value, Class<T> cls) { | ||
| 102 | + return new ResourceConsumerId(value, cls); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Creates ResourceConsumerId instance from Identifier object. | ||
| 107 | + * | ||
| 108 | + * @param id identifier object backed by Long value | ||
| 109 | + * @return created ResourceConsumerId object | ||
| 110 | + */ | ||
| 111 | + public static <T extends Identifier<Long> & ResourceConsumer> ResourceConsumerId of(T id) { | ||
| 112 | + return new ResourceConsumerId(id.id(), id.getClass()); | ||
| 113 | + } | ||
| 114 | +} |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.net.resource; | ... | @@ -18,6 +18,7 @@ package org.onosproject.net.resource; |
| 18 | import com.google.common.testing.EqualsTester; | 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.junit.Test; | 19 | import org.junit.Test; |
| 20 | import org.onlab.packet.VlanId; | 20 | import org.onlab.packet.VlanId; |
| 21 | +import org.onlab.util.Identifier; | ||
| 21 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.PortNumber; | 23 | import org.onosproject.net.PortNumber; |
| 23 | import org.onosproject.net.intent.IntentId; | 24 | import org.onosproject.net.intent.IntentId; |
| ... | @@ -27,18 +28,38 @@ public class ResourceAllocationTest { | ... | @@ -27,18 +28,38 @@ public class ResourceAllocationTest { |
| 27 | private static final DeviceId D1 = DeviceId.deviceId("of:001"); | 28 | private static final DeviceId D1 = DeviceId.deviceId("of:001"); |
| 28 | private static final DeviceId D2 = DeviceId.deviceId("of:002"); | 29 | private static final DeviceId D2 = DeviceId.deviceId("of:002"); |
| 29 | private static final PortNumber P1 = PortNumber.portNumber(1); | 30 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 31 | + private static final PortNumber P2 = PortNumber.portNumber(2); | ||
| 30 | private static final VlanId VLAN1 = VlanId.vlanId((short) 100); | 32 | private static final VlanId VLAN1 = VlanId.vlanId((short) 100); |
| 31 | - private static final IntentId IID1 = IntentId.valueOf(30); | 33 | + private static final VlanId VLAN2 = VlanId.vlanId((short) 200); |
| 34 | + private static final TestResourceConsumer RC2 = new TestResourceConsumer(2L); | ||
| 35 | + | ||
| 36 | + // ResourceConsumerId generated by specifying ID and class name | ||
| 37 | + private static final ResourceConsumerId RCID1 = ResourceConsumerId.of(30L, IntentId.class); | ||
| 38 | + | ||
| 39 | + // ResourceConsumerId generated from Identifier<Long> class | ||
| 40 | + private static final ResourceConsumerId RCID2 = ResourceConsumerId.of(RC2); | ||
| 32 | 41 | ||
| 33 | @Test | 42 | @Test |
| 34 | public void testEquals() { | 43 | public void testEquals() { |
| 35 | - ResourceAllocation alloc1 = new ResourceAllocation(Resources.discrete(D1, P1, VLAN1).resource(), IID1); | 44 | + ResourceAllocation alloc1 = new ResourceAllocation(Resources.discrete(D1, P1, VLAN1).resource(), RCID1); |
| 36 | - ResourceAllocation sameAsAlloc1 = new ResourceAllocation(Resources.discrete(D1, P1, VLAN1).resource(), IID1); | 45 | + ResourceAllocation sameAsAlloc1 = new ResourceAllocation(Resources.discrete(D1, P1, VLAN1).resource(), RCID1); |
| 37 | - ResourceAllocation alloc2 = new ResourceAllocation(Resources.discrete(D2, P1, VLAN1).resource(), IID1); | 46 | + ResourceAllocation alloc2 = new ResourceAllocation(Resources.discrete(D2, P2, VLAN2).resource(), RCID2); |
| 47 | + ResourceAllocation sameAsAlloc2 = new ResourceAllocation(Resources.discrete(D2, P2, VLAN2).resource(), RCID2); | ||
| 38 | 48 | ||
| 39 | new EqualsTester() | 49 | new EqualsTester() |
| 40 | .addEqualityGroup(alloc1, sameAsAlloc1) | 50 | .addEqualityGroup(alloc1, sameAsAlloc1) |
| 41 | - .addEqualityGroup(alloc2) | 51 | + .addEqualityGroup(alloc2, sameAsAlloc2) |
| 42 | .testEquals(); | 52 | .testEquals(); |
| 43 | } | 53 | } |
| 54 | + | ||
| 55 | + private static class TestResourceConsumer extends Identifier<Long> implements ResourceConsumer { | ||
| 56 | + public TestResourceConsumer(long idValue) { | ||
| 57 | + super(idValue); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public ResourceConsumerId consumerId() { | ||
| 62 | + return ResourceConsumerId.of(this); | ||
| 63 | + } | ||
| 64 | + } | ||
| 44 | } | 65 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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 | +package org.onosproject.net.intent.impl; | ||
| 18 | + | ||
| 19 | +import com.google.common.annotations.Beta; | ||
| 20 | +import org.onosproject.net.intent.IntentId; | ||
| 21 | +import org.onosproject.net.resource.ResourceConsumerId; | ||
| 22 | + | ||
| 23 | +import java.util.Optional; | ||
| 24 | + | ||
| 25 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Helper class for ResourceService related processes. | ||
| 29 | + */ | ||
| 30 | +@Beta | ||
| 31 | +public final class ResourceHelper { | ||
| 32 | + | ||
| 33 | + // To avoid instantiation | ||
| 34 | + private ResourceHelper() { | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Creates IntentId object from given consumer ID. | ||
| 39 | + * | ||
| 40 | + * @param consumerId ConsumerId object | ||
| 41 | + * @return Created IntentId object. null if failed to create or given consumer is not instance of IntentId. | ||
| 42 | + */ | ||
| 43 | + public static Optional<IntentId> getIntentId(ResourceConsumerId consumerId) { | ||
| 44 | + checkNotNull(consumerId); | ||
| 45 | + | ||
| 46 | + if (!consumerId.isClassOf(IntentId.class)) { | ||
| 47 | + return Optional.empty(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + return Optional.of(IntentId.valueOf(consumerId.value())); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | +} |
| ... | @@ -61,6 +61,7 @@ import org.onosproject.net.intent.impl.IntentCompilationException; | ... | @@ -61,6 +61,7 @@ import org.onosproject.net.intent.impl.IntentCompilationException; |
| 61 | import org.onosproject.net.optical.OchPort; | 61 | import org.onosproject.net.optical.OchPort; |
| 62 | import org.onosproject.net.optical.OduCltPort; | 62 | import org.onosproject.net.optical.OduCltPort; |
| 63 | import org.onosproject.net.intent.IntentSetMultimap; | 63 | import org.onosproject.net.intent.IntentSetMultimap; |
| 64 | +import org.onosproject.net.intent.impl.ResourceHelper; | ||
| 64 | import org.onosproject.net.resource.ResourceAllocation; | 65 | import org.onosproject.net.resource.ResourceAllocation; |
| 65 | import org.onosproject.net.resource.Resource; | 66 | import org.onosproject.net.resource.Resource; |
| 66 | import org.onosproject.net.resource.ResourceService; | 67 | import org.onosproject.net.resource.ResourceService; |
| ... | @@ -446,9 +447,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -446,9 +447,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 446 | Optional<IntentId> intentId = | 447 | Optional<IntentId> intentId = |
| 447 | resourceService.getResourceAllocations(Resources.discrete(ochCP.deviceId(), ochCP.port()).id()) | 448 | resourceService.getResourceAllocations(Resources.discrete(ochCP.deviceId(), ochCP.port()).id()) |
| 448 | .stream() | 449 | .stream() |
| 449 | - .map(ResourceAllocation::consumer) | 450 | + .map(ResourceAllocation::consumerId) |
| 450 | - .filter(x -> x instanceof IntentId) | 451 | + .map(ResourceHelper::getIntentId) |
| 451 | - .map(x -> (IntentId) x) | 452 | + .flatMap(Tools::stream) |
| 452 | .findAny(); | 453 | .findAny(); |
| 453 | 454 | ||
| 454 | if (isAvailable(intentId.orElse(null))) { | 455 | if (isAvailable(intentId.orElse(null))) { |
| ... | @@ -476,9 +477,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -476,9 +477,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 476 | Optional<IntentId> intentId = | 477 | Optional<IntentId> intentId = |
| 477 | resourceService.getResourceAllocations(Resources.discrete(oduPort.deviceId(), port.number()).id()) | 478 | resourceService.getResourceAllocations(Resources.discrete(oduPort.deviceId(), port.number()).id()) |
| 478 | .stream() | 479 | .stream() |
| 479 | - .map(ResourceAllocation::consumer) | 480 | + .map(ResourceAllocation::consumerId) |
| 480 | - .filter(x -> x instanceof IntentId) | 481 | + .map(ResourceHelper::getIntentId) |
| 481 | - .map(x -> (IntentId) x) | 482 | + .flatMap(Tools::stream) |
| 482 | .findAny(); | 483 | .findAny(); |
| 483 | 484 | ||
| 484 | if (isAvailable(intentId.orElse(null))) { | 485 | if (isAvailable(intentId.orElse(null))) { | ... | ... |
| ... | @@ -24,7 +24,7 @@ import org.onosproject.net.resource.ContinuousResourceId; | ... | @@ -24,7 +24,7 @@ import org.onosproject.net.resource.ContinuousResourceId; |
| 24 | import org.onosproject.net.resource.DiscreteResourceId; | 24 | import org.onosproject.net.resource.DiscreteResourceId; |
| 25 | import org.onosproject.net.resource.Resource; | 25 | import org.onosproject.net.resource.Resource; |
| 26 | import org.onosproject.net.resource.ResourceAllocation; | 26 | import org.onosproject.net.resource.ResourceAllocation; |
| 27 | -import org.onosproject.net.resource.ResourceConsumer; | 27 | +import org.onosproject.net.resource.ResourceConsumerId; |
| 28 | import org.onosproject.store.service.ConsistentMap; | 28 | import org.onosproject.store.service.ConsistentMap; |
| 29 | import org.onosproject.store.service.ConsistentMapException; | 29 | import org.onosproject.store.service.ConsistentMapException; |
| 30 | import org.onosproject.store.service.StorageService; | 30 | import org.onosproject.store.service.StorageService; |
| ... | @@ -132,10 +132,10 @@ class ConsistentContinuousResourceStore { | ... | @@ -132,10 +132,10 @@ class ConsistentContinuousResourceStore { |
| 132 | }); | 132 | }); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | - Stream<ContinuousResource> getResources(ResourceConsumer consumer) { | 135 | + Stream<ContinuousResource> getResources(ResourceConsumerId consumerId) { |
| 136 | return consumers.values().stream() | 136 | return consumers.values().stream() |
| 137 | .flatMap(x -> x.value().allocations().stream()) | 137 | .flatMap(x -> x.value().allocations().stream()) |
| 138 | - .filter(x -> x.consumer().equals(consumer)) | 138 | + .filter(x -> x.consumerId().equals(consumerId)) |
| 139 | // this cast is safe because this class stores | 139 | // this cast is safe because this class stores |
| 140 | // continuous resource allocations only | 140 | // continuous resource allocations only |
| 141 | .map(x -> (ContinuousResource) x.resource()); | 141 | .map(x -> (ContinuousResource) x.resource()); | ... | ... |
| ... | @@ -22,7 +22,7 @@ import org.onosproject.net.resource.DiscreteResource; | ... | @@ -22,7 +22,7 @@ import org.onosproject.net.resource.DiscreteResource; |
| 22 | import org.onosproject.net.resource.DiscreteResourceId; | 22 | import org.onosproject.net.resource.DiscreteResourceId; |
| 23 | import org.onosproject.net.resource.Resource; | 23 | import org.onosproject.net.resource.Resource; |
| 24 | import org.onosproject.net.resource.ResourceAllocation; | 24 | import org.onosproject.net.resource.ResourceAllocation; |
| 25 | -import org.onosproject.net.resource.ResourceConsumer; | 25 | +import org.onosproject.net.resource.ResourceConsumerId; |
| 26 | import org.onosproject.net.resource.Resources; | 26 | import org.onosproject.net.resource.Resources; |
| 27 | import org.onosproject.store.service.ConsistentMap; | 27 | import org.onosproject.store.service.ConsistentMap; |
| 28 | import org.onosproject.store.service.ConsistentMapException; | 28 | import org.onosproject.store.service.ConsistentMapException; |
| ... | @@ -41,11 +41,11 @@ import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_ | ... | @@ -41,11 +41,11 @@ import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_ |
| 41 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER; | 41 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER; |
| 42 | 42 | ||
| 43 | class ConsistentDiscreteResourceStore { | 43 | class ConsistentDiscreteResourceStore { |
| 44 | - private ConsistentMap<DiscreteResourceId, ResourceConsumer> consumers; | 44 | + private ConsistentMap<DiscreteResourceId, ResourceConsumerId> consumers; |
| 45 | private ConsistentMap<DiscreteResourceId, Set<DiscreteResource>> childMap; | 45 | private ConsistentMap<DiscreteResourceId, Set<DiscreteResource>> childMap; |
| 46 | 46 | ||
| 47 | ConsistentDiscreteResourceStore(StorageService service) { | 47 | ConsistentDiscreteResourceStore(StorageService service) { |
| 48 | - this.consumers = service.<DiscreteResourceId, ResourceConsumer>consistentMapBuilder() | 48 | + this.consumers = service.<DiscreteResourceId, ResourceConsumerId>consistentMapBuilder() |
| 49 | .withName(MapNames.DISCRETE_CONSUMER_MAP) | 49 | .withName(MapNames.DISCRETE_CONSUMER_MAP) |
| 50 | .withSerializer(SERIALIZER) | 50 | .withSerializer(SERIALIZER) |
| 51 | .build(); | 51 | .build(); |
| ... | @@ -64,12 +64,12 @@ class ConsistentDiscreteResourceStore { | ... | @@ -64,12 +64,12 @@ class ConsistentDiscreteResourceStore { |
| 64 | 64 | ||
| 65 | // computational complexity: O(1) | 65 | // computational complexity: O(1) |
| 66 | List<ResourceAllocation> getResourceAllocations(DiscreteResourceId resource) { | 66 | List<ResourceAllocation> getResourceAllocations(DiscreteResourceId resource) { |
| 67 | - Versioned<ResourceConsumer> consumer = consumers.get(resource); | 67 | + Versioned<ResourceConsumerId> consumerId = consumers.get(resource); |
| 68 | - if (consumer == null) { | 68 | + if (consumerId == null) { |
| 69 | return ImmutableList.of(); | 69 | return ImmutableList.of(); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | - return ImmutableList.of(new ResourceAllocation(Resources.discrete(resource).resource(), consumer.value())); | 72 | + return ImmutableList.of(new ResourceAllocation(Resources.discrete(resource).resource(), consumerId.value())); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | Set<DiscreteResource> getChildResources(DiscreteResourceId parent) { | 75 | Set<DiscreteResource> getChildResources(DiscreteResourceId parent) { |
| ... | @@ -97,9 +97,9 @@ class ConsistentDiscreteResourceStore { | ... | @@ -97,9 +97,9 @@ class ConsistentDiscreteResourceStore { |
| 97 | .filter(x -> consumers.containsKey(x.id())); | 97 | .filter(x -> consumers.containsKey(x.id())); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - Stream<DiscreteResource> getResources(ResourceConsumer consumer) { | 100 | + Stream<DiscreteResource> getResources(ResourceConsumerId consumerId) { |
| 101 | return consumers.entrySet().stream() | 101 | return consumers.entrySet().stream() |
| 102 | - .filter(x -> x.getValue().value().equals(consumer)) | 102 | + .filter(x -> x.getValue().value().equals(consumerId)) |
| 103 | .map(Map.Entry::getKey) | 103 | .map(Map.Entry::getKey) |
| 104 | .map(x -> Resources.discrete(x).resource()); | 104 | .map(x -> Resources.discrete(x).resource()); |
| 105 | } | 105 | } | ... | ... |
| ... | @@ -29,6 +29,7 @@ import org.onosproject.net.resource.DiscreteResourceId; | ... | @@ -29,6 +29,7 @@ import org.onosproject.net.resource.DiscreteResourceId; |
| 29 | import org.onosproject.net.resource.Resource; | 29 | import org.onosproject.net.resource.Resource; |
| 30 | import org.onosproject.net.resource.ResourceAllocation; | 30 | import org.onosproject.net.resource.ResourceAllocation; |
| 31 | import org.onosproject.net.resource.ResourceConsumer; | 31 | import org.onosproject.net.resource.ResourceConsumer; |
| 32 | +import org.onosproject.net.resource.ResourceConsumerId; | ||
| 32 | import org.onosproject.net.resource.ResourceEvent; | 33 | import org.onosproject.net.resource.ResourceEvent; |
| 33 | import org.onosproject.net.resource.ResourceId; | 34 | import org.onosproject.net.resource.ResourceId; |
| 34 | import org.onosproject.net.resource.ResourceStore; | 35 | import org.onosproject.net.resource.ResourceStore; |
| ... | @@ -208,11 +209,11 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -208,11 +209,11 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
| 208 | TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx); | 209 | TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx); |
| 209 | for (Resource resource : resources) { | 210 | for (Resource resource : resources) { |
| 210 | if (resource instanceof DiscreteResource) { | 211 | if (resource instanceof DiscreteResource) { |
| 211 | - if (!discreteTxStore.allocate(consumer, (DiscreteResource) resource)) { | 212 | + if (!discreteTxStore.allocate(consumer.consumerId(), (DiscreteResource) resource)) { |
| 212 | return abortTransaction(tx); | 213 | return abortTransaction(tx); |
| 213 | } | 214 | } |
| 214 | } else if (resource instanceof ContinuousResource) { | 215 | } else if (resource instanceof ContinuousResource) { |
| 215 | - if (!continuousTxStore.allocate(consumer, (ContinuousResource) resource)) { | 216 | + if (!continuousTxStore.allocate(consumer.consumerId(), (ContinuousResource) resource)) { |
| 216 | return abortTransaction(tx); | 217 | return abortTransaction(tx); |
| 217 | } | 218 | } |
| 218 | } | 219 | } |
| ... | @@ -232,14 +233,14 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -232,14 +233,14 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
| 232 | TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx); | 233 | TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx); |
| 233 | for (ResourceAllocation allocation : allocations) { | 234 | for (ResourceAllocation allocation : allocations) { |
| 234 | Resource resource = allocation.resource(); | 235 | Resource resource = allocation.resource(); |
| 235 | - ResourceConsumer consumer = allocation.consumer(); | 236 | + ResourceConsumerId consumerId = allocation.consumerId(); |
| 236 | 237 | ||
| 237 | if (resource instanceof DiscreteResource) { | 238 | if (resource instanceof DiscreteResource) { |
| 238 | - if (!discreteTxStore.release((DiscreteResource) resource, consumer)) { | 239 | + if (!discreteTxStore.release((DiscreteResource) resource, consumerId)) { |
| 239 | return abortTransaction(tx); | 240 | return abortTransaction(tx); |
| 240 | } | 241 | } |
| 241 | } else if (resource instanceof ContinuousResource) { | 242 | } else if (resource instanceof ContinuousResource) { |
| 242 | - if (!continuousTxStore.release((ContinuousResource) resource, consumer)) { | 243 | + if (!continuousTxStore.release((ContinuousResource) resource, consumerId)) { |
| 243 | return abortTransaction(tx); | 244 | return abortTransaction(tx); |
| 244 | } | 245 | } |
| 245 | } | 246 | } |
| ... | @@ -269,11 +270,12 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -269,11 +270,12 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
| 269 | @Override | 270 | @Override |
| 270 | public Collection<Resource> getResources(ResourceConsumer consumer) { | 271 | public Collection<Resource> getResources(ResourceConsumer consumer) { |
| 271 | checkNotNull(consumer); | 272 | checkNotNull(consumer); |
| 273 | + ResourceConsumerId consumerId = consumer.consumerId(); | ||
| 272 | 274 | ||
| 273 | // NOTE: getting all entries may become performance bottleneck | 275 | // NOTE: getting all entries may become performance bottleneck |
| 274 | // TODO: revisit for better backend data structure | 276 | // TODO: revisit for better backend data structure |
| 275 | - Stream<DiscreteResource> discrete = discreteStore.getResources(consumer); | 277 | + Stream<DiscreteResource> discrete = discreteStore.getResources(consumer.consumerId()); |
| 276 | - Stream<ContinuousResource> continuous = continuousStore.getResources(consumer); | 278 | + Stream<ContinuousResource> continuous = continuousStore.getResources(consumer.consumerId()); |
| 277 | 279 | ||
| 278 | return Stream.concat(discrete, continuous).collect(Collectors.toList()); | 280 | return Stream.concat(discrete, continuous).collect(Collectors.toList()); |
| 279 | } | 281 | } | ... | ... |
| ... | @@ -22,7 +22,7 @@ import org.onosproject.net.resource.ContinuousResource; | ... | @@ -22,7 +22,7 @@ import org.onosproject.net.resource.ContinuousResource; |
| 22 | import org.onosproject.net.resource.ContinuousResourceId; | 22 | import org.onosproject.net.resource.ContinuousResourceId; |
| 23 | import org.onosproject.net.resource.DiscreteResourceId; | 23 | import org.onosproject.net.resource.DiscreteResourceId; |
| 24 | import org.onosproject.net.resource.ResourceAllocation; | 24 | import org.onosproject.net.resource.ResourceAllocation; |
| 25 | -import org.onosproject.net.resource.ResourceConsumer; | 25 | +import org.onosproject.net.resource.ResourceConsumerId; |
| 26 | import org.onosproject.store.service.TransactionContext; | 26 | import org.onosproject.store.service.TransactionContext; |
| 27 | import org.onosproject.store.service.TransactionalMap; | 27 | import org.onosproject.store.service.TransactionalMap; |
| 28 | import org.slf4j.Logger; | 28 | import org.slf4j.Logger; |
| ... | @@ -133,7 +133,7 @@ class TransactionalContinuousResourceStore { | ... | @@ -133,7 +133,7 @@ class TransactionalContinuousResourceStore { |
| 133 | return allocations != null && !allocations.allocations().isEmpty(); | 133 | return allocations != null && !allocations.allocations().isEmpty(); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | - boolean allocate(ResourceConsumer consumer, ContinuousResource request) { | 136 | + boolean allocate(ResourceConsumerId consumerId, ContinuousResource request) { |
| 137 | // if the resource is not registered, then abort | 137 | // if the resource is not registered, then abort |
| 138 | Optional<ContinuousResource> lookedUp = lookup(request.id()); | 138 | Optional<ContinuousResource> lookedUp = lookup(request.id()); |
| 139 | if (!lookedUp.isPresent()) { | 139 | if (!lookedUp.isPresent()) { |
| ... | @@ -146,7 +146,7 @@ class TransactionalContinuousResourceStore { | ... | @@ -146,7 +146,7 @@ class TransactionalContinuousResourceStore { |
| 146 | return false; | 146 | return false; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | - return appendValue(original, new ResourceAllocation(request, consumer)); | 149 | + return appendValue(original, new ResourceAllocation(request, consumerId)); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | // Appends the specified ResourceAllocation to the existing values stored in the map | 152 | // Appends the specified ResourceAllocation to the existing values stored in the map |
| ... | @@ -166,16 +166,16 @@ class TransactionalContinuousResourceStore { | ... | @@ -166,16 +166,16 @@ class TransactionalContinuousResourceStore { |
| 166 | return consumers.replace(original.id(), oldValue, newValue); | 166 | return consumers.replace(original.id(), oldValue, newValue); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | - boolean release(ContinuousResource resource, ResourceConsumer consumer) { | 169 | + boolean release(ContinuousResource resource, ResourceConsumerId consumerId) { |
| 170 | ContinuousResourceAllocation oldAllocation = consumers.get(resource.id()); | 170 | ContinuousResourceAllocation oldAllocation = consumers.get(resource.id()); |
| 171 | 171 | ||
| 172 | List<ResourceAllocation> nonMatched = oldAllocation.allocations().stream() | 172 | List<ResourceAllocation> nonMatched = oldAllocation.allocations().stream() |
| 173 | - .filter(x -> !(x.consumer().equals(consumer) && | 173 | + .filter(x -> !(x.consumerId().equals(consumerId) && |
| 174 | ((ContinuousResource) x.resource()).value() == resource.value())) | 174 | ((ContinuousResource) x.resource()).value() == resource.value())) |
| 175 | .collect(Collectors.toList()); | 175 | .collect(Collectors.toList()); |
| 176 | 176 | ||
| 177 | List<ResourceAllocation> matched = oldAllocation.allocations().stream() | 177 | List<ResourceAllocation> matched = oldAllocation.allocations().stream() |
| 178 | - .filter(x -> (x.consumer().equals(consumer) && | 178 | + .filter(x -> (x.consumerId().equals(consumerId) && |
| 179 | ((ContinuousResource) x.resource()).value() == resource.value())) | 179 | ((ContinuousResource) x.resource()).value() == resource.value())) |
| 180 | .collect(Collectors.toList()); | 180 | .collect(Collectors.toList()); |
| 181 | 181 | ... | ... |
| ... | @@ -19,7 +19,7 @@ import com.google.common.collect.Sets; | ... | @@ -19,7 +19,7 @@ import com.google.common.collect.Sets; |
| 19 | import org.onosproject.net.resource.DiscreteResource; | 19 | import org.onosproject.net.resource.DiscreteResource; |
| 20 | import org.onosproject.net.resource.DiscreteResourceId; | 20 | import org.onosproject.net.resource.DiscreteResourceId; |
| 21 | import org.onosproject.net.resource.Resource; | 21 | import org.onosproject.net.resource.Resource; |
| 22 | -import org.onosproject.net.resource.ResourceConsumer; | 22 | +import org.onosproject.net.resource.ResourceConsumerId; |
| 23 | import org.onosproject.net.resource.Resources; | 23 | import org.onosproject.net.resource.Resources; |
| 24 | import org.onosproject.store.service.TransactionContext; | 24 | import org.onosproject.store.service.TransactionContext; |
| 25 | import org.onosproject.store.service.TransactionalMap; | 25 | import org.onosproject.store.service.TransactionalMap; |
| ... | @@ -36,7 +36,7 @@ import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIAL | ... | @@ -36,7 +36,7 @@ import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIAL |
| 36 | class TransactionalDiscreteResourceStore { | 36 | class TransactionalDiscreteResourceStore { |
| 37 | private final Logger log = LoggerFactory.getLogger(getClass()); | 37 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 38 | private final TransactionalMap<DiscreteResourceId, Set<DiscreteResource>> childMap; | 38 | private final TransactionalMap<DiscreteResourceId, Set<DiscreteResource>> childMap; |
| 39 | - private final TransactionalMap<DiscreteResourceId, ResourceConsumer> consumers; | 39 | + private final TransactionalMap<DiscreteResourceId, ResourceConsumerId> consumers; |
| 40 | 40 | ||
| 41 | TransactionalDiscreteResourceStore(TransactionContext tx) { | 41 | TransactionalDiscreteResourceStore(TransactionContext tx) { |
| 42 | this.childMap = tx.getTransactionalMap(MapNames.DISCRETE_CHILD_MAP, SERIALIZER); | 42 | this.childMap = tx.getTransactionalMap(MapNames.DISCRETE_CHILD_MAP, SERIALIZER); |
| ... | @@ -121,21 +121,21 @@ class TransactionalDiscreteResourceStore { | ... | @@ -121,21 +121,21 @@ class TransactionalDiscreteResourceStore { |
| 121 | return consumers.get(id) != null; | 121 | return consumers.get(id) != null; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | - boolean allocate(ResourceConsumer consumer, DiscreteResource resource) { | 124 | + boolean allocate(ResourceConsumerId consumerId, DiscreteResource resource) { |
| 125 | // if the resource is not registered, then abort | 125 | // if the resource is not registered, then abort |
| 126 | Optional<DiscreteResource> lookedUp = lookup(resource.id()); | 126 | Optional<DiscreteResource> lookedUp = lookup(resource.id()); |
| 127 | if (!lookedUp.isPresent()) { | 127 | if (!lookedUp.isPresent()) { |
| 128 | return false; | 128 | return false; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | - ResourceConsumer oldValue = consumers.put(resource.id(), consumer); | 131 | + ResourceConsumerId oldValue = consumers.put(resource.id(), consumerId); |
| 132 | return oldValue == null; | 132 | return oldValue == null; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | - boolean release(DiscreteResource resource, ResourceConsumer consumer) { | 135 | + boolean release(DiscreteResource resource, ResourceConsumerId consumerId) { |
| 136 | // if this single release fails (because the resource is allocated to another consumer) | 136 | // if this single release fails (because the resource is allocated to another consumer) |
| 137 | // the whole release fails | 137 | // the whole release fails |
| 138 | - if (!consumers.remove(resource.id(), consumer)) { | 138 | + if (!consumers.remove(resource.id(), consumerId)) { |
| 139 | return false; | 139 | return false; |
| 140 | } | 140 | } |
| 141 | 141 | ... | ... |
| ... | @@ -199,6 +199,7 @@ import org.onosproject.net.resource.DiscreteResourceSetSerializer; | ... | @@ -199,6 +199,7 @@ import org.onosproject.net.resource.DiscreteResourceSetSerializer; |
| 199 | import org.onosproject.net.resource.MplsCodec; | 199 | import org.onosproject.net.resource.MplsCodec; |
| 200 | import org.onosproject.net.resource.NoOpCodec; | 200 | import org.onosproject.net.resource.NoOpCodec; |
| 201 | import org.onosproject.net.resource.ResourceAllocation; | 201 | import org.onosproject.net.resource.ResourceAllocation; |
| 202 | +import org.onosproject.net.resource.ResourceConsumerId; | ||
| 202 | import org.onosproject.net.packet.DefaultOutboundPacket; | 203 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 203 | import org.onosproject.net.packet.DefaultPacketRequest; | 204 | import org.onosproject.net.packet.DefaultPacketRequest; |
| 204 | import org.onosproject.net.packet.PacketPriority; | 205 | import org.onosproject.net.packet.PacketPriority; |
| ... | @@ -454,6 +455,7 @@ public final class KryoNamespaces { | ... | @@ -454,6 +455,7 @@ public final class KryoNamespaces { |
| 454 | DiscreteResourceId.class, | 455 | DiscreteResourceId.class, |
| 455 | ContinuousResourceId.class, | 456 | ContinuousResourceId.class, |
| 456 | ResourceAllocation.class, | 457 | ResourceAllocation.class, |
| 458 | + ResourceConsumerId.class, | ||
| 457 | // Constraints | 459 | // Constraints |
| 458 | BandwidthConstraint.class, | 460 | BandwidthConstraint.class, |
| 459 | LinkTypeConstraint.class, | 461 | LinkTypeConstraint.class, | ... | ... |
| ... | @@ -67,6 +67,7 @@ import org.onosproject.net.resource.DiscreteResource; | ... | @@ -67,6 +67,7 @@ import org.onosproject.net.resource.DiscreteResource; |
| 67 | import org.onosproject.net.resource.DiscreteResourceSet; | 67 | import org.onosproject.net.resource.DiscreteResourceSet; |
| 68 | import org.onosproject.net.resource.MplsCodec; | 68 | import org.onosproject.net.resource.MplsCodec; |
| 69 | import org.onosproject.net.resource.ResourceAllocation; | 69 | import org.onosproject.net.resource.ResourceAllocation; |
| 70 | +import org.onosproject.net.resource.ResourceConsumerId; | ||
| 70 | import org.onosproject.net.resource.Resources; | 71 | import org.onosproject.net.resource.Resources; |
| 71 | import org.onosproject.net.provider.ProviderId; | 72 | import org.onosproject.net.provider.ProviderId; |
| 72 | import org.onosproject.net.intent.constraint.AnnotationConstraint; | 73 | import org.onosproject.net.intent.constraint.AnnotationConstraint; |
| ... | @@ -404,7 +405,7 @@ public class KryoSerializerTest { | ... | @@ -404,7 +405,7 @@ public class KryoSerializerTest { |
| 404 | public void testResourceAllocation() { | 405 | public void testResourceAllocation() { |
| 405 | testSerializedEquals(new ResourceAllocation( | 406 | testSerializedEquals(new ResourceAllocation( |
| 406 | Resources.discrete(DID1, P1, VLAN1).resource(), | 407 | Resources.discrete(DID1, P1, VLAN1).resource(), |
| 407 | - IntentId.valueOf(30))); | 408 | + ResourceConsumerId.of(30L, IntentId.class))); |
| 408 | } | 409 | } |
| 409 | 410 | ||
| 410 | @Test | 411 | @Test | ... | ... |
-
Please register or login to post a comment