Committed by
Gerrit Code Review
Refactor: Rename ResourcePath to Resource for a better name
Also the followings - Rename variables from path to resource - Update Javadoc Change-Id: I07da7e7d13882f2134a3687c66ed91a9de5b0849
Showing
22 changed files
with
147 additions
and
147 deletions
| ... | @@ -31,7 +31,7 @@ import org.onosproject.net.Port; | ... | @@ -31,7 +31,7 @@ import org.onosproject.net.Port; |
| 31 | import org.onosproject.net.PortNumber; | 31 | import org.onosproject.net.PortNumber; |
| 32 | import org.onosproject.net.device.DeviceService; | 32 | import org.onosproject.net.device.DeviceService; |
| 33 | import org.onosproject.net.newresource.ResourceAllocation; | 33 | import org.onosproject.net.newresource.ResourceAllocation; |
| 34 | -import org.onosproject.net.newresource.ResourcePath; | 34 | +import org.onosproject.net.newresource.Resource; |
| 35 | import org.onosproject.net.newresource.ResourceService; | 35 | import org.onosproject.net.newresource.ResourceService; |
| 36 | 36 | ||
| 37 | import com.google.common.base.Strings; | 37 | import com.google.common.base.Strings; |
| ... | @@ -106,11 +106,11 @@ public class AllocationsCommand extends AbstractShellCommand { | ... | @@ -106,11 +106,11 @@ public class AllocationsCommand extends AbstractShellCommand { |
| 106 | // TODO: Current design cannot deal with sub-resources | 106 | // TODO: Current design cannot deal with sub-resources |
| 107 | // (e.g., TX/RX under Port) | 107 | // (e.g., TX/RX under Port) |
| 108 | 108 | ||
| 109 | - ResourcePath path = ResourcePath.discrete(did, num); | 109 | + Resource resource = Resource.discrete(did, num); |
| 110 | if (lambda) { | 110 | if (lambda) { |
| 111 | //print("Lambda resources:"); | 111 | //print("Lambda resources:"); |
| 112 | Collection<ResourceAllocation> allocations | 112 | Collection<ResourceAllocation> allocations |
| 113 | - = resourceService.getResourceAllocations(path, OchSignal.class); | 113 | + = resourceService.getResourceAllocations(resource, OchSignal.class); |
| 114 | 114 | ||
| 115 | for (ResourceAllocation a : allocations) { | 115 | for (ResourceAllocation a : allocations) { |
| 116 | print("%s%s allocated by %s", Strings.repeat(" ", level + 1), | 116 | print("%s%s allocated by %s", Strings.repeat(" ", level + 1), | ... | ... |
| ... | @@ -29,7 +29,7 @@ import org.apache.karaf.shell.commands.Option; | ... | @@ -29,7 +29,7 @@ import org.apache.karaf.shell.commands.Option; |
| 29 | import org.onosproject.cli.AbstractShellCommand; | 29 | import org.onosproject.cli.AbstractShellCommand; |
| 30 | import org.onosproject.net.DeviceId; | 30 | import org.onosproject.net.DeviceId; |
| 31 | import org.onosproject.net.PortNumber; | 31 | import org.onosproject.net.PortNumber; |
| 32 | -import org.onosproject.net.newresource.ResourcePath; | 32 | +import org.onosproject.net.newresource.Resource; |
| 33 | import org.onosproject.net.newresource.ResourceService; | 33 | import org.onosproject.net.newresource.ResourceService; |
| 34 | 34 | ||
| 35 | import com.google.common.base.Strings; | 35 | import com.google.common.base.Strings; |
| ... | @@ -76,20 +76,20 @@ public class ResourcesCommand extends AbstractShellCommand { | ... | @@ -76,20 +76,20 @@ public class ResourcesCommand extends AbstractShellCommand { |
| 76 | DeviceId deviceId = deviceId(deviceIdStr); | 76 | DeviceId deviceId = deviceId(deviceIdStr); |
| 77 | PortNumber portNumber = PortNumber.fromString(portNumberStr); | 77 | PortNumber portNumber = PortNumber.fromString(portNumberStr); |
| 78 | 78 | ||
| 79 | - printResource(ResourcePath.discrete(deviceId, portNumber), 0); | 79 | + printResource(Resource.discrete(deviceId, portNumber), 0); |
| 80 | } else if (deviceIdStr != null) { | 80 | } else if (deviceIdStr != null) { |
| 81 | DeviceId deviceId = deviceId(deviceIdStr); | 81 | DeviceId deviceId = deviceId(deviceIdStr); |
| 82 | 82 | ||
| 83 | - printResource(ResourcePath.discrete(deviceId), 0); | 83 | + printResource(Resource.discrete(deviceId), 0); |
| 84 | } else { | 84 | } else { |
| 85 | - printResource(ResourcePath.ROOT, 0); | 85 | + printResource(Resource.ROOT, 0); |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | - private void printResource(ResourcePath resource, int level) { | 89 | + private void printResource(Resource resource, int level) { |
| 90 | - Collection<ResourcePath> children = resourceService.getAvailableResources(resource); | 90 | + Collection<Resource> children = resourceService.getAvailableResources(resource); |
| 91 | 91 | ||
| 92 | - if (resource.equals(ResourcePath.ROOT)) { | 92 | + if (resource.equals(Resource.ROOT)) { |
| 93 | print("ROOT"); | 93 | print("ROOT"); |
| 94 | } else { | 94 | } else { |
| 95 | String resourceName = resource.last().getClass().getSimpleName(); | 95 | String resourceName = resource.last().getClass().getSimpleName(); | ... | ... |
| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
| 17 | 17 | ||
| 18 | -import static org.onosproject.net.newresource.ResourcePath.discrete; | 18 | +import static org.onosproject.net.newresource.Resource.discrete; |
| 19 | 19 | ||
| 20 | import java.util.Optional; | 20 | import java.util.Optional; |
| 21 | 21 | ||
| ... | @@ -31,7 +31,7 @@ import org.onosproject.net.PortNumber; | ... | @@ -31,7 +31,7 @@ import org.onosproject.net.PortNumber; |
| 31 | import org.onosproject.net.intent.IntentId; | 31 | import org.onosproject.net.intent.IntentId; |
| 32 | import org.onosproject.net.newresource.ResourceAllocation; | 32 | import org.onosproject.net.newresource.ResourceAllocation; |
| 33 | import org.onosproject.net.newresource.ResourceConsumer; | 33 | import org.onosproject.net.newresource.ResourceConsumer; |
| 34 | -import org.onosproject.net.newresource.ResourcePath; | 34 | +import org.onosproject.net.newresource.Resource; |
| 35 | import org.onosproject.net.newresource.ResourceService; | 35 | import org.onosproject.net.newresource.ResourceService; |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| ... | @@ -73,7 +73,7 @@ public class TestAllocateResource extends AbstractShellCommand { | ... | @@ -73,7 +73,7 @@ public class TestAllocateResource extends AbstractShellCommand { |
| 73 | 73 | ||
| 74 | ResourceConsumer consumer = IntentId.valueOf(nIntendId); | 74 | ResourceConsumer consumer = IntentId.valueOf(nIntendId); |
| 75 | 75 | ||
| 76 | - ResourcePath resource = discrete(did, portNum, | 76 | + Resource resource = discrete(did, portNum, |
| 77 | createLambda(Integer.parseInt(lambda))); | 77 | createLambda(Integer.parseInt(lambda))); |
| 78 | 78 | ||
| 79 | Optional<ResourceAllocation> allocate = resourceService.allocate(consumer, resource); | 79 | Optional<ResourceAllocation> allocate = resourceService.allocate(consumer, resource); | ... | ... |
| ... | @@ -29,10 +29,10 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -29,10 +29,10 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 29 | import static com.google.common.base.Preconditions.checkState; | 29 | import static com.google.common.base.Preconditions.checkState; |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | - * An object that is used to locate a resource in a network. | 32 | + * An object that represent a resource in a network. |
| 33 | - * A ResourcePath represents a path that is hierarchical and composed of a sequence | 33 | + * A Resource can represents path-like hierarchical structure with its ID. An ID of resource is |
| 34 | - * of elementary resources that are not globally identifiable. A ResourcePath can be a globally | 34 | + * composed of a sequence of elementary resources that are not globally identifiable. A Resource |
| 35 | - * unique resource identifier. | 35 | + * can be globally identifiable by its ID. |
| 36 | * | 36 | * |
| 37 | * Two types of resource are considered. One is discrete type and the other is continuous type. | 37 | * Two types of resource are considered. One is discrete type and the other is continuous type. |
| 38 | * Discrete type resource is a resource whose amount is measured as a discrete unit. VLAN ID and | 38 | * Discrete type resource is a resource whose amount is measured as a discrete unit. VLAN ID and |
| ... | @@ -41,18 +41,18 @@ import static com.google.common.base.Preconditions.checkState; | ... | @@ -41,18 +41,18 @@ import static com.google.common.base.Preconditions.checkState; |
| 41 | * A double value is associated with a continuous type value. | 41 | * A double value is associated with a continuous type value. |
| 42 | * | 42 | * |
| 43 | * Users of this class must keep the semantics of resources regarding the hierarchical structure. | 43 | * Users of this class must keep the semantics of resources regarding the hierarchical structure. |
| 44 | - * For example, resource path, Device:1/Port:1/VLAN ID:100, is valid, but resource path, | 44 | + * For example, resource, Device:1/Port:1/VLAN ID:100, is valid, but resource, |
| 45 | * VLAN ID:100/Device:1/Port:1 is not valid because a link is not a sub-component of a VLAN ID. | 45 | * VLAN ID:100/Device:1/Port:1 is not valid because a link is not a sub-component of a VLAN ID. |
| 46 | */ | 46 | */ |
| 47 | @Beta | 47 | @Beta |
| 48 | -public abstract class ResourcePath { | 48 | +public abstract class Resource { |
| 49 | 49 | ||
| 50 | private final Discrete parent; | 50 | private final Discrete parent; |
| 51 | private final ResourceId id; | 51 | private final ResourceId id; |
| 52 | 52 | ||
| 53 | public static final Discrete ROOT = new Discrete(); | 53 | public static final Discrete ROOT = new Discrete(); |
| 54 | 54 | ||
| 55 | - public static ResourcePath discrete(DeviceId device) { | 55 | + public static Resource discrete(DeviceId device) { |
| 56 | return new Discrete(ResourceId.of(device)); | 56 | return new Discrete(ResourceId.of(device)); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| ... | @@ -63,7 +63,7 @@ public abstract class ResourcePath { | ... | @@ -63,7 +63,7 @@ public abstract class ResourcePath { |
| 63 | * @param components following components of the path. The order represents hierarchical structure of the resource. | 63 | * @param components following components of the path. The order represents hierarchical structure of the resource. |
| 64 | * @return resource path instance | 64 | * @return resource path instance |
| 65 | */ | 65 | */ |
| 66 | - public static ResourcePath discrete(DeviceId device, Object... components) { | 66 | + public static Resource discrete(DeviceId device, Object... components) { |
| 67 | return new Discrete(ResourceId.of(device, components)); | 67 | return new Discrete(ResourceId.of(device, components)); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| ... | @@ -75,7 +75,7 @@ public abstract class ResourcePath { | ... | @@ -75,7 +75,7 @@ public abstract class ResourcePath { |
| 75 | * @param components following components of the path. The order represents hierarchical structure of the resource. | 75 | * @param components following components of the path. The order represents hierarchical structure of the resource. |
| 76 | * @return resource path instance | 76 | * @return resource path instance |
| 77 | */ | 77 | */ |
| 78 | - public static ResourcePath discrete(DeviceId device, PortNumber port, Object... components) { | 78 | + public static Resource discrete(DeviceId device, PortNumber port, Object... components) { |
| 79 | return new Discrete(ResourceId.of(device, port, components)); | 79 | return new Discrete(ResourceId.of(device, port, components)); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| ... | @@ -87,7 +87,7 @@ public abstract class ResourcePath { | ... | @@ -87,7 +87,7 @@ public abstract class ResourcePath { |
| 87 | * @param components following components of the path. The order represents hierarchical structure of the resource. | 87 | * @param components following components of the path. The order represents hierarchical structure of the resource. |
| 88 | * @return resource path instance | 88 | * @return resource path instance |
| 89 | */ | 89 | */ |
| 90 | - public static ResourcePath continuous(double value, DeviceId device, Object... components) { | 90 | + public static Resource continuous(double value, DeviceId device, Object... components) { |
| 91 | checkArgument(components.length > 0, | 91 | checkArgument(components.length > 0, |
| 92 | "Length of components must be greater thant 0, but " + components.length); | 92 | "Length of components must be greater thant 0, but " + components.length); |
| 93 | 93 | ||
| ... | @@ -103,7 +103,7 @@ public abstract class ResourcePath { | ... | @@ -103,7 +103,7 @@ public abstract class ResourcePath { |
| 103 | * @param components following components of the path. The order represents hierarchical structure of the resource. | 103 | * @param components following components of the path. The order represents hierarchical structure of the resource. |
| 104 | * @return resource path instance | 104 | * @return resource path instance |
| 105 | */ | 105 | */ |
| 106 | - public static ResourcePath continuous(double value, DeviceId device, PortNumber port, Object... components) { | 106 | + public static Resource continuous(double value, DeviceId device, PortNumber port, Object... components) { |
| 107 | return new Continuous(ResourceId.of(device, port, components), value); | 107 | return new Continuous(ResourceId.of(device, port, components), value); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| ... | @@ -112,7 +112,7 @@ public abstract class ResourcePath { | ... | @@ -112,7 +112,7 @@ public abstract class ResourcePath { |
| 112 | * | 112 | * |
| 113 | * @param id id of the path | 113 | * @param id id of the path |
| 114 | */ | 114 | */ |
| 115 | - protected ResourcePath(ResourceId id) { | 115 | + protected Resource(ResourceId id) { |
| 116 | checkNotNull(id); | 116 | checkNotNull(id); |
| 117 | 117 | ||
| 118 | this.id = id; | 118 | this.id = id; |
| ... | @@ -124,7 +124,7 @@ public abstract class ResourcePath { | ... | @@ -124,7 +124,7 @@ public abstract class ResourcePath { |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | // for serialization | 126 | // for serialization |
| 127 | - private ResourcePath() { | 127 | + private Resource() { |
| 128 | this.parent = null; | 128 | this.parent = null; |
| 129 | this.id = ResourceId.ROOT; | 129 | this.id = ResourceId.ROOT; |
| 130 | } | 130 | } |
| ... | @@ -156,7 +156,7 @@ public abstract class ResourcePath { | ... | @@ -156,7 +156,7 @@ public abstract class ResourcePath { |
| 156 | * @param child child object | 156 | * @param child child object |
| 157 | * @return a child resource path | 157 | * @return a child resource path |
| 158 | */ | 158 | */ |
| 159 | - public ResourcePath child(Object child) { | 159 | + public Resource child(Object child) { |
| 160 | checkState(this instanceof Discrete); | 160 | checkState(this instanceof Discrete); |
| 161 | 161 | ||
| 162 | return new Discrete(id().child(child)); | 162 | return new Discrete(id().child(child)); |
| ... | @@ -170,7 +170,7 @@ public abstract class ResourcePath { | ... | @@ -170,7 +170,7 @@ public abstract class ResourcePath { |
| 170 | * @param value value | 170 | * @param value value |
| 171 | * @return a child resource path | 171 | * @return a child resource path |
| 172 | */ | 172 | */ |
| 173 | - public ResourcePath child(Object child, double value) { | 173 | + public Resource child(Object child, double value) { |
| 174 | checkState(this instanceof Discrete); | 174 | checkState(this instanceof Discrete); |
| 175 | 175 | ||
| 176 | return new Continuous(id.child(child), value); | 176 | return new Continuous(id.child(child), value); |
| ... | @@ -208,10 +208,10 @@ public abstract class ResourcePath { | ... | @@ -208,10 +208,10 @@ public abstract class ResourcePath { |
| 208 | if (this == obj) { | 208 | if (this == obj) { |
| 209 | return true; | 209 | return true; |
| 210 | } | 210 | } |
| 211 | - if (!(obj instanceof ResourcePath)) { | 211 | + if (!(obj instanceof Resource)) { |
| 212 | return false; | 212 | return false; |
| 213 | } | 213 | } |
| 214 | - final ResourcePath that = (ResourcePath) obj; | 214 | + final Resource that = (Resource) obj; |
| 215 | return Objects.equals(this.id, that.id); | 215 | return Objects.equals(this.id, that.id); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| ... | @@ -231,7 +231,7 @@ public abstract class ResourcePath { | ... | @@ -231,7 +231,7 @@ public abstract class ResourcePath { |
| 231 | * </p> | 231 | * </p> |
| 232 | */ | 232 | */ |
| 233 | @Beta | 233 | @Beta |
| 234 | - public static final class Discrete extends ResourcePath { | 234 | + public static final class Discrete extends Resource { |
| 235 | private Discrete() { | 235 | private Discrete() { |
| 236 | super(); | 236 | super(); |
| 237 | } | 237 | } |
| ... | @@ -249,7 +249,7 @@ public abstract class ResourcePath { | ... | @@ -249,7 +249,7 @@ public abstract class ResourcePath { |
| 249 | * implementation only. It is not for resource API user. | 249 | * implementation only. It is not for resource API user. |
| 250 | */ | 250 | */ |
| 251 | @Beta | 251 | @Beta |
| 252 | - public static final class Continuous extends ResourcePath { | 252 | + public static final class Continuous extends Resource { |
| 253 | private final double value; | 253 | private final double value; |
| 254 | 254 | ||
| 255 | private Continuous(ResourceId id, double value) { | 255 | private Continuous(ResourceId id, double value) { | ... | ... |
| ... | @@ -32,7 +32,7 @@ public interface ResourceAdminService { | ... | @@ -32,7 +32,7 @@ public interface ResourceAdminService { |
| 32 | * @return true if registration is successfully done, false otherwise. Registration | 32 | * @return true if registration is successfully done, false otherwise. Registration |
| 33 | * succeeds when each resource is not registered or unallocated. | 33 | * succeeds when each resource is not registered or unallocated. |
| 34 | */ | 34 | */ |
| 35 | - default boolean registerResources(ResourcePath... resources) { | 35 | + default boolean registerResources(Resource... resources) { |
| 36 | return registerResources(ImmutableList.copyOf(resources)); | 36 | return registerResources(ImmutableList.copyOf(resources)); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| ... | @@ -43,7 +43,7 @@ public interface ResourceAdminService { | ... | @@ -43,7 +43,7 @@ public interface ResourceAdminService { |
| 43 | * @return true if registration is successfully done, false otherwise. Registration | 43 | * @return true if registration is successfully done, false otherwise. Registration |
| 44 | * succeeds when each resource is not registered or unallocated. | 44 | * succeeds when each resource is not registered or unallocated. |
| 45 | */ | 45 | */ |
| 46 | - boolean registerResources(List<ResourcePath> resources); | 46 | + boolean registerResources(List<Resource> resources); |
| 47 | 47 | ||
| 48 | /** | 48 | /** |
| 49 | * Unregisters the specified resources. | 49 | * Unregisters the specified resources. |
| ... | @@ -52,7 +52,7 @@ public interface ResourceAdminService { | ... | @@ -52,7 +52,7 @@ public interface ResourceAdminService { |
| 52 | * @return true if unregistration is successfully done, false otherwise. Unregistration | 52 | * @return true if unregistration is successfully done, false otherwise. Unregistration |
| 53 | * succeeds when each resource is not registered or unallocated. | 53 | * succeeds when each resource is not registered or unallocated. |
| 54 | */ | 54 | */ |
| 55 | - default boolean unregisterResources(ResourcePath... resources) { | 55 | + default boolean unregisterResources(Resource... resources) { |
| 56 | return unregisterResources(ImmutableList.copyOf(resources)); | 56 | return unregisterResources(ImmutableList.copyOf(resources)); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| ... | @@ -63,5 +63,5 @@ public interface ResourceAdminService { | ... | @@ -63,5 +63,5 @@ public interface ResourceAdminService { |
| 63 | * @return true if unregistration is successfully done, false otherwise. Unregistration | 63 | * @return true if unregistration is successfully done, false otherwise. Unregistration |
| 64 | * succeeds when each resource is not registered or unallocated. | 64 | * succeeds when each resource is not registered or unallocated. |
| 65 | */ | 65 | */ |
| 66 | - boolean unregisterResources(List<ResourcePath> resources); | 66 | + boolean unregisterResources(List<Resource> resources); |
| 67 | } | 67 | } | ... | ... |
| ... | @@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | @Beta | 28 | @Beta |
| 29 | public class ResourceAllocation { | 29 | public class ResourceAllocation { |
| 30 | 30 | ||
| 31 | - private final ResourcePath resource; | 31 | + private final Resource resource; |
| 32 | private final ResourceConsumer consumer; | 32 | private final ResourceConsumer consumer; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| ... | @@ -37,7 +37,7 @@ public class ResourceAllocation { | ... | @@ -37,7 +37,7 @@ public class ResourceAllocation { |
| 37 | * @param resource resource of the subject | 37 | * @param resource resource of the subject |
| 38 | * @param consumer consumer of this resource | 38 | * @param consumer consumer of this resource |
| 39 | */ | 39 | */ |
| 40 | - public ResourceAllocation(ResourcePath resource, ResourceConsumer consumer) { | 40 | + public ResourceAllocation(Resource resource, ResourceConsumer consumer) { |
| 41 | this.resource = checkNotNull(resource); | 41 | this.resource = checkNotNull(resource); |
| 42 | this.consumer = consumer; | 42 | this.consumer = consumer; |
| 43 | } | 43 | } |
| ... | @@ -53,7 +53,7 @@ public class ResourceAllocation { | ... | @@ -53,7 +53,7 @@ public class ResourceAllocation { |
| 53 | * | 53 | * |
| 54 | * @return the specifier of the resource this allocation uses | 54 | * @return the specifier of the resource this allocation uses |
| 55 | */ | 55 | */ |
| 56 | - public ResourcePath resource() { | 56 | + public Resource resource() { |
| 57 | return resource; | 57 | return resource; |
| 58 | } | 58 | } |
| 59 | 59 | ... | ... |
| ... | @@ -24,7 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -24,7 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 24 | * Describes an event related to a resource. | 24 | * Describes an event related to a resource. |
| 25 | */ | 25 | */ |
| 26 | @Beta | 26 | @Beta |
| 27 | -public final class ResourceEvent extends AbstractEvent<ResourceEvent.Type, ResourcePath> { | 27 | +public final class ResourceEvent extends AbstractEvent<ResourceEvent.Type, Resource> { |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * Type of resource events. | 30 | * Type of resource events. |
| ... | @@ -48,7 +48,7 @@ public final class ResourceEvent extends AbstractEvent<ResourceEvent.Type, Resou | ... | @@ -48,7 +48,7 @@ public final class ResourceEvent extends AbstractEvent<ResourceEvent.Type, Resou |
| 48 | * @param type type of resource event | 48 | * @param type type of resource event |
| 49 | * @param subject subject of resource event | 49 | * @param subject subject of resource event |
| 50 | */ | 50 | */ |
| 51 | - public ResourceEvent(Type type, ResourcePath subject) { | 51 | + public ResourceEvent(Type type, Resource subject) { |
| 52 | super(checkNotNull(type), checkNotNull(subject)); | 52 | super(checkNotNull(type), checkNotNull(subject)); |
| 53 | } | 53 | } |
| 54 | } | 54 | } | ... | ... |
| ... | @@ -38,7 +38,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource | ... | @@ -38,7 +38,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource |
| 38 | * @param resource resource to be allocated | 38 | * @param resource resource to be allocated |
| 39 | * @return allocation information enclosed by Optional. If the allocation fails, the return value is empty | 39 | * @return allocation information enclosed by Optional. If the allocation fails, the return value is empty |
| 40 | */ | 40 | */ |
| 41 | - default Optional<ResourceAllocation> allocate(ResourceConsumer consumer, ResourcePath resource) { | 41 | + default Optional<ResourceAllocation> allocate(ResourceConsumer consumer, Resource resource) { |
| 42 | checkNotNull(consumer); | 42 | checkNotNull(consumer); |
| 43 | checkNotNull(resource); | 43 | checkNotNull(resource); |
| 44 | 44 | ||
| ... | @@ -65,7 +65,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource | ... | @@ -65,7 +65,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource |
| 65 | * @param resources resources to be allocated | 65 | * @param resources resources to be allocated |
| 66 | * @return non-empty list of allocation information if succeeded, otherwise empty list | 66 | * @return non-empty list of allocation information if succeeded, otherwise empty list |
| 67 | */ | 67 | */ |
| 68 | - List<ResourceAllocation> allocate(ResourceConsumer consumer, List<ResourcePath> resources); | 68 | + List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources); |
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | * Transactionally allocates the specified resources to the specified user. | 71 | * Transactionally allocates the specified resources to the specified user. |
| ... | @@ -75,7 +75,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource | ... | @@ -75,7 +75,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource |
| 75 | * @param resources resources to be allocated | 75 | * @param resources resources to be allocated |
| 76 | * @return non-empty list of allocation information if succeeded, otherwise empty list | 76 | * @return non-empty list of allocation information if succeeded, otherwise empty list |
| 77 | */ | 77 | */ |
| 78 | - default List<ResourceAllocation> allocate(ResourceConsumer consumer, ResourcePath... resources) { | 78 | + default List<ResourceAllocation> allocate(ResourceConsumer consumer, Resource... resources) { |
| 79 | checkNotNull(consumer); | 79 | checkNotNull(consumer); |
| 80 | checkNotNull(resources); | 80 | checkNotNull(resources); |
| 81 | 81 | ||
| ... | @@ -132,18 +132,18 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource | ... | @@ -132,18 +132,18 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource |
| 132 | * @return list of allocation information. | 132 | * @return list of allocation information. |
| 133 | * If the resource is not allocated, the return value is an empty list. | 133 | * If the resource is not allocated, the return value is an empty list. |
| 134 | */ | 134 | */ |
| 135 | - List<ResourceAllocation> getResourceAllocation(ResourcePath resource); | 135 | + List<ResourceAllocation> getResourceAllocation(Resource resource); |
| 136 | 136 | ||
| 137 | /** | 137 | /** |
| 138 | * Returns allocated resources being as children of the specified parent and being the specified resource type. | 138 | * Returns allocated resources being as children of the specified parent and being the specified resource type. |
| 139 | * | 139 | * |
| 140 | - * @param parent parent resource path | 140 | + * @param parent parent resource |
| 141 | * @param cls class to specify a type of resource | 141 | * @param cls class to specify a type of resource |
| 142 | * @param <T> type of the resource | 142 | * @param <T> type of the resource |
| 143 | * @return non-empty collection of resource allocations if resources are allocated with the subject and type, | 143 | * @return non-empty collection of resource allocations if resources are allocated with the subject and type, |
| 144 | * empty collection if no resource is allocated with the subject and type | 144 | * empty collection if no resource is allocated with the subject and type |
| 145 | */ | 145 | */ |
| 146 | - <T> Collection<ResourceAllocation> getResourceAllocations(ResourcePath parent, Class<T> cls); | 146 | + <T> Collection<ResourceAllocation> getResourceAllocations(Resource parent, Class<T> cls); |
| 147 | 147 | ||
| 148 | /** | 148 | /** |
| 149 | * Returns resources allocated to the specified consumer. | 149 | * Returns resources allocated to the specified consumer. |
| ... | @@ -154,12 +154,12 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource | ... | @@ -154,12 +154,12 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource |
| 154 | Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer); | 154 | Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer); |
| 155 | 155 | ||
| 156 | /** | 156 | /** |
| 157 | - * Returns resource paths that point available child resources under the specified resource path. | 157 | + * Returns resources that point available child resources under the specified resource. |
| 158 | * | 158 | * |
| 159 | - * @param parent parent resource path | 159 | + * @param parent parent resource |
| 160 | - * @return available resource paths under the specified resource path | 160 | + * @return available resources under the specified resource |
| 161 | */ | 161 | */ |
| 162 | - Collection<ResourcePath> getAvailableResources(ResourcePath parent); | 162 | + Collection<Resource> getAvailableResources(Resource parent); |
| 163 | 163 | ||
| 164 | /** | 164 | /** |
| 165 | * Returns the availability of the specified resource. | 165 | * Returns the availability of the specified resource. |
| ... | @@ -167,7 +167,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource | ... | @@ -167,7 +167,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource |
| 167 | * @param resource resource to check the availability | 167 | * @param resource resource to check the availability |
| 168 | * @return true if available, otherwise false | 168 | * @return true if available, otherwise false |
| 169 | */ | 169 | */ |
| 170 | - boolean isAvailable(ResourcePath resource); | 170 | + boolean isAvailable(Resource resource); |
| 171 | 171 | ||
| 172 | // TODO: listener and event mechanism need to be considered | 172 | // TODO: listener and event mechanism need to be considered |
| 173 | } | 173 | } | ... | ... |
| ... | @@ -36,7 +36,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -36,7 +36,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 36 | * @param resources resources to be registered | 36 | * @param resources resources to be registered |
| 37 | * @return true if the registration succeeds, false otherwise | 37 | * @return true if the registration succeeds, false otherwise |
| 38 | */ | 38 | */ |
| 39 | - boolean register(List<ResourcePath> resources); | 39 | + boolean register(List<Resource> resources); |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * Unregisters the resources in transactional way. | 42 | * Unregisters the resources in transactional way. |
| ... | @@ -47,7 +47,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -47,7 +47,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 47 | * @param resources resources to be unregistered | 47 | * @param resources resources to be unregistered |
| 48 | * @return true if the registration succeeds, false otherwise | 48 | * @return true if the registration succeeds, false otherwise |
| 49 | */ | 49 | */ |
| 50 | - boolean unregister(List<ResourcePath> resources); | 50 | + boolean unregister(List<Resource> resources); |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * Allocates the specified resources to the specified consumer in transactional way. | 53 | * Allocates the specified resources to the specified consumer in transactional way. |
| ... | @@ -59,7 +59,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -59,7 +59,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 59 | * @param consumer resource consumer which the resources are allocated to | 59 | * @param consumer resource consumer which the resources are allocated to |
| 60 | * @return true if the allocation succeeds, false otherwise. | 60 | * @return true if the allocation succeeds, false otherwise. |
| 61 | */ | 61 | */ |
| 62 | - boolean allocate(List<ResourcePath> resources, ResourceConsumer consumer); | 62 | + boolean allocate(List<Resource> resources, ResourceConsumer consumer); |
| 63 | 63 | ||
| 64 | /** | 64 | /** |
| 65 | * Releases the specified resources allocated to the specified corresponding consumers | 65 | * Releases the specified resources allocated to the specified corresponding consumers |
| ... | @@ -73,7 +73,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -73,7 +73,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 73 | * @param consumers resource consumers to whom the resource allocated to | 73 | * @param consumers resource consumers to whom the resource allocated to |
| 74 | * @return true if succeeds, otherwise false | 74 | * @return true if succeeds, otherwise false |
| 75 | */ | 75 | */ |
| 76 | - boolean release(List<ResourcePath> resources, List<ResourceConsumer> consumers); | 76 | + boolean release(List<Resource> resources, List<ResourceConsumer> consumers); |
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| 79 | * Returns the resource consumers to whom the specified resource is allocated. | 79 | * Returns the resource consumers to whom the specified resource is allocated. |
| ... | @@ -84,7 +84,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -84,7 +84,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 84 | * @return resource consumers who are allocated the resource. | 84 | * @return resource consumers who are allocated the resource. |
| 85 | * Returns empty list if there is no such consumer. | 85 | * Returns empty list if there is no such consumer. |
| 86 | */ | 86 | */ |
| 87 | - List<ResourceConsumer> getConsumers(ResourcePath resource); | 87 | + List<ResourceConsumer> getConsumers(Resource resource); |
| 88 | 88 | ||
| 89 | /** | 89 | /** |
| 90 | * Returns the availability of the specified resource. | 90 | * Returns the availability of the specified resource. |
| ... | @@ -92,7 +92,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -92,7 +92,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 92 | * @param resource resource to check the availability | 92 | * @param resource resource to check the availability |
| 93 | * @return true if available, otherwise false | 93 | * @return true if available, otherwise false |
| 94 | */ | 94 | */ |
| 95 | - boolean isAvailable(ResourcePath resource); | 95 | + boolean isAvailable(Resource resource); |
| 96 | 96 | ||
| 97 | /** | 97 | /** |
| 98 | * Returns a collection of the resources allocated to the specified consumer. | 98 | * Returns a collection of the resources allocated to the specified consumer. |
| ... | @@ -100,7 +100,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -100,7 +100,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 100 | * @param consumer resource consumer whose allocated resource are searched for | 100 | * @param consumer resource consumer whose allocated resource are searched for |
| 101 | * @return a collection of the resources allocated to the specified consumer | 101 | * @return a collection of the resources allocated to the specified consumer |
| 102 | */ | 102 | */ |
| 103 | - Collection<ResourcePath> getResources(ResourceConsumer consumer); | 103 | + Collection<Resource> getResources(ResourceConsumer consumer); |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | * Returns a collection of the child resources of the specified parent. | 106 | * Returns a collection of the child resources of the specified parent. |
| ... | @@ -108,7 +108,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -108,7 +108,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 108 | * @param parent parent of the resource to be returned | 108 | * @param parent parent of the resource to be returned |
| 109 | * @return a collection of the child resources of the specified resource | 109 | * @return a collection of the child resources of the specified resource |
| 110 | */ | 110 | */ |
| 111 | - Collection<ResourcePath> getChildResources(ResourcePath parent); | 111 | + Collection<Resource> getChildResources(Resource parent); |
| 112 | 112 | ||
| 113 | /** | 113 | /** |
| 114 | * Returns a collection of the resources which are children of the specified parent and | 114 | * Returns a collection of the resources which are children of the specified parent and |
| ... | @@ -120,5 +120,5 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat | ... | @@ -120,5 +120,5 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat |
| 120 | * @return a collection of the resources which belongs to the specified subject and | 120 | * @return a collection of the resources which belongs to the specified subject and |
| 121 | * whose type is the specified class. | 121 | * whose type is the specified class. |
| 122 | */ | 122 | */ |
| 123 | - <T> Collection<ResourcePath> getAllocatedResources(ResourcePath parent, Class<T> cls); | 123 | + <T> Collection<Resource> getAllocatedResources(Resource parent, Class<T> cls); |
| 124 | } | 124 | } | ... | ... |
| ... | @@ -32,9 +32,9 @@ public class ResourceAllocationTest { | ... | @@ -32,9 +32,9 @@ public class ResourceAllocationTest { |
| 32 | 32 | ||
| 33 | @Test | 33 | @Test |
| 34 | public void testEquals() { | 34 | public void testEquals() { |
| 35 | - ResourceAllocation alloc1 = new ResourceAllocation(ResourcePath.discrete(D1, P1, VLAN1), IID1); | 35 | + ResourceAllocation alloc1 = new ResourceAllocation(Resource.discrete(D1, P1, VLAN1), IID1); |
| 36 | - ResourceAllocation sameAsAlloc1 = new ResourceAllocation(ResourcePath.discrete(D1, P1, VLAN1), IID1); | 36 | + ResourceAllocation sameAsAlloc1 = new ResourceAllocation(Resource.discrete(D1, P1, VLAN1), IID1); |
| 37 | - ResourceAllocation alloc2 = new ResourceAllocation(ResourcePath.discrete(D2, P1, VLAN1), IID1); | 37 | + ResourceAllocation alloc2 = new ResourceAllocation(Resource.discrete(D2, P1, VLAN1), IID1); |
| 38 | 38 | ||
| 39 | new EqualsTester() | 39 | new EqualsTester() |
| 40 | .addEqualityGroup(alloc1, sameAsAlloc1) | 40 | .addEqualityGroup(alloc1, sameAsAlloc1) | ... | ... |
| ... | @@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.contains; | ... | @@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.contains; |
| 28 | import static org.hamcrest.Matchers.is; | 28 | import static org.hamcrest.Matchers.is; |
| 29 | import static org.junit.Assert.assertThat; | 29 | import static org.junit.Assert.assertThat; |
| 30 | 30 | ||
| 31 | -public class ResourcePathTest { | 31 | +public class ResourceTest { |
| 32 | 32 | ||
| 33 | private static final DeviceId D1 = DeviceId.deviceId("of:001"); | 33 | private static final DeviceId D1 = DeviceId.deviceId("of:001"); |
| 34 | private static final DeviceId D2 = DeviceId.deviceId("of:002"); | 34 | private static final DeviceId D2 = DeviceId.deviceId("of:002"); |
| ... | @@ -39,11 +39,11 @@ public class ResourcePathTest { | ... | @@ -39,11 +39,11 @@ public class ResourcePathTest { |
| 39 | 39 | ||
| 40 | @Test | 40 | @Test |
| 41 | public void testEquals() { | 41 | public void testEquals() { |
| 42 | - ResourcePath resource1 = ResourcePath.discrete(D1, P1, VLAN1); | 42 | + Resource resource1 = Resource.discrete(D1, P1, VLAN1); |
| 43 | - ResourcePath sameAsResource1 = ResourcePath.discrete(D1, P1, VLAN1); | 43 | + Resource sameAsResource1 = Resource.discrete(D1, P1, VLAN1); |
| 44 | - ResourcePath resource2 = ResourcePath.discrete(D2, P1, VLAN1); | 44 | + Resource resource2 = Resource.discrete(D2, P1, VLAN1); |
| 45 | - ResourcePath resource3 = ResourcePath.continuous(BW1.bps(), D1, P1, BW1); | 45 | + Resource resource3 = Resource.continuous(BW1.bps(), D1, P1, BW1); |
| 46 | - ResourcePath sameAsResource3 = ResourcePath.continuous(BW1.bps(), D1, P1, BW1); | 46 | + Resource sameAsResource3 = Resource.continuous(BW1.bps(), D1, P1, BW1); |
| 47 | 47 | ||
| 48 | new EqualsTester() | 48 | new EqualsTester() |
| 49 | .addEqualityGroup(resource1, sameAsResource1) | 49 | .addEqualityGroup(resource1, sameAsResource1) |
| ... | @@ -54,19 +54,19 @@ public class ResourcePathTest { | ... | @@ -54,19 +54,19 @@ public class ResourcePathTest { |
| 54 | 54 | ||
| 55 | @Test | 55 | @Test |
| 56 | public void testComponents() { | 56 | public void testComponents() { |
| 57 | - ResourcePath port = ResourcePath.discrete(D1, P1); | 57 | + Resource port = Resource.discrete(D1, P1); |
| 58 | 58 | ||
| 59 | assertThat(port.components(), contains(D1, P1)); | 59 | assertThat(port.components(), contains(D1, P1)); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | @Test | 62 | @Test |
| 63 | public void testIdEquality() { | 63 | public void testIdEquality() { |
| 64 | - ResourceId id1 = ResourcePath.discrete(D1, P1, VLAN1).id(); | 64 | + ResourceId id1 = Resource.discrete(D1, P1, VLAN1).id(); |
| 65 | - ResourceId sameAsId1 = ResourcePath.discrete(D1, P1, VLAN1).id(); | 65 | + ResourceId sameAsId1 = Resource.discrete(D1, P1, VLAN1).id(); |
| 66 | - ResourceId id2 = ResourcePath.discrete(D2, P1, VLAN1).id(); | 66 | + ResourceId id2 = Resource.discrete(D2, P1, VLAN1).id(); |
| 67 | - ResourceId id3 = ResourcePath.continuous(BW1.bps(), D1, P1, BW1).id(); | 67 | + ResourceId id3 = Resource.continuous(BW1.bps(), D1, P1, BW1).id(); |
| 68 | // intentionally set a different value | 68 | // intentionally set a different value |
| 69 | - ResourceId sameAsId3 = ResourcePath.continuous(BW2.bps(), D1, P1, BW1).id(); | 69 | + ResourceId sameAsId3 = Resource.continuous(BW2.bps(), D1, P1, BW1).id(); |
| 70 | 70 | ||
| 71 | new EqualsTester() | 71 | new EqualsTester() |
| 72 | .addEqualityGroup(id1, sameAsId1) | 72 | .addEqualityGroup(id1, sameAsId1) |
| ... | @@ -76,32 +76,32 @@ public class ResourcePathTest { | ... | @@ -76,32 +76,32 @@ public class ResourcePathTest { |
| 76 | 76 | ||
| 77 | @Test | 77 | @Test |
| 78 | public void testChild() { | 78 | public void testChild() { |
| 79 | - ResourcePath r1 = ResourcePath.discrete(D1).child(P1); | 79 | + Resource r1 = Resource.discrete(D1).child(P1); |
| 80 | - ResourcePath sameAsR2 = ResourcePath.discrete(D1, P1); | 80 | + Resource sameAsR2 = Resource.discrete(D1, P1); |
| 81 | 81 | ||
| 82 | assertThat(r1, is(sameAsR2)); | 82 | assertThat(r1, is(sameAsR2)); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | @Test | 85 | @Test |
| 86 | public void testThereIsParent() { | 86 | public void testThereIsParent() { |
| 87 | - ResourcePath path = ResourcePath.discrete(D1, P1, VLAN1); | 87 | + Resource resource = Resource.discrete(D1, P1, VLAN1); |
| 88 | - ResourcePath parent = ResourcePath.discrete(D1, P1); | 88 | + Resource parent = Resource.discrete(D1, P1); |
| 89 | 89 | ||
| 90 | - assertThat(path.parent(), is(Optional.of(parent))); | 90 | + assertThat(resource.parent(), is(Optional.of(parent))); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | @Test | 93 | @Test |
| 94 | public void testNoParent() { | 94 | public void testNoParent() { |
| 95 | - ResourcePath path = ResourcePath.discrete(D1); | 95 | + Resource resource = Resource.discrete(D1); |
| 96 | 96 | ||
| 97 | - assertThat(path.parent(), is(Optional.of(ResourcePath.ROOT))); | 97 | + assertThat(resource.parent(), is(Optional.of(Resource.ROOT))); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | @Test | 100 | @Test |
| 101 | public void testBase() { | 101 | public void testBase() { |
| 102 | - ResourcePath path = ResourcePath.discrete(D1); | 102 | + Resource resource = Resource.discrete(D1); |
| 103 | 103 | ||
| 104 | - DeviceId child = (DeviceId) path.last(); | 104 | + DeviceId child = (DeviceId) resource.last(); |
| 105 | assertThat(child, is(D1)); | 105 | assertThat(child, is(D1)); |
| 106 | } | 106 | } |
| 107 | } | 107 | } | ... | ... |
| ... | @@ -49,7 +49,7 @@ import org.onosproject.net.intent.Intent; | ... | @@ -49,7 +49,7 @@ import org.onosproject.net.intent.Intent; |
| 49 | import org.onosproject.net.intent.IntentCompiler; | 49 | import org.onosproject.net.intent.IntentCompiler; |
| 50 | import org.onosproject.net.intent.IntentExtensionService; | 50 | import org.onosproject.net.intent.IntentExtensionService; |
| 51 | import org.onosproject.net.intent.MplsPathIntent; | 51 | import org.onosproject.net.intent.MplsPathIntent; |
| 52 | -import org.onosproject.net.newresource.ResourcePath; | 52 | +import org.onosproject.net.newresource.Resource; |
| 53 | import org.onosproject.net.newresource.ResourceService; | 53 | import org.onosproject.net.newresource.ResourceService; |
| 54 | import org.onosproject.net.resource.link.LinkResourceAllocations; | 54 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| 55 | import org.slf4j.Logger; | 55 | import org.slf4j.Logger; |
| ... | @@ -123,10 +123,10 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -123,10 +123,10 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
| 123 | 123 | ||
| 124 | // for short term solution: same label is used for both directions | 124 | // for short term solution: same label is used for both directions |
| 125 | // TODO: introduce the concept of Tx and Rx resources of a port | 125 | // TODO: introduce the concept of Tx and Rx resources of a port |
| 126 | - Set<ResourcePath> resources = labels.entrySet().stream() | 126 | + Set<Resource> resources = labels.entrySet().stream() |
| 127 | .flatMap(x -> Stream.of( | 127 | .flatMap(x -> Stream.of( |
| 128 | - ResourcePath.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()), | 128 | + Resource.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()), |
| 129 | - ResourcePath.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue()) | 129 | + Resource.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue()) |
| 130 | )) | 130 | )) |
| 131 | .collect(Collectors.toSet()); | 131 | .collect(Collectors.toSet()); |
| 132 | List<org.onosproject.net.newresource.ResourceAllocation> allocations = | 132 | List<org.onosproject.net.newresource.ResourceAllocation> allocations = |
| ... | @@ -154,7 +154,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -154,7 +154,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | private Set<MplsLabel> findMplsLabel(ConnectPoint cp) { | 156 | private Set<MplsLabel> findMplsLabel(ConnectPoint cp) { |
| 157 | - return resourceService.getAvailableResources(ResourcePath.discrete(cp.deviceId(), cp.port())).stream() | 157 | + return resourceService.getAvailableResources(Resource.discrete(cp.deviceId(), cp.port())).stream() |
| 158 | .filter(x -> x.last() instanceof MplsLabel) | 158 | .filter(x -> x.last() instanceof MplsLabel) |
| 159 | .map(x -> (MplsLabel) x.last()) | 159 | .map(x -> (MplsLabel) x.last()) |
| 160 | .collect(Collectors.toSet()); | 160 | .collect(Collectors.toSet()); | ... | ... |
| ... | @@ -50,7 +50,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent; | ... | @@ -50,7 +50,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent; |
| 50 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 50 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
| 51 | import org.onosproject.net.intent.impl.IntentCompilationException; | 51 | import org.onosproject.net.intent.impl.IntentCompilationException; |
| 52 | import org.onosproject.net.newresource.ResourceAllocation; | 52 | import org.onosproject.net.newresource.ResourceAllocation; |
| 53 | -import org.onosproject.net.newresource.ResourcePath; | 53 | +import org.onosproject.net.newresource.Resource; |
| 54 | import org.onosproject.net.newresource.ResourceService; | 54 | import org.onosproject.net.newresource.ResourceService; |
| 55 | import org.onosproject.net.resource.device.IntentSetMultimap; | 55 | import org.onosproject.net.resource.device.IntentSetMultimap; |
| 56 | import org.onosproject.net.resource.link.LinkResourceAllocations; | 56 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| ... | @@ -160,9 +160,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -160,9 +160,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 160 | log.debug("Compiling optical circuit intent between {} and {}", src, dst); | 160 | log.debug("Compiling optical circuit intent between {} and {}", src, dst); |
| 161 | 161 | ||
| 162 | // Reserve OduClt ports | 162 | // Reserve OduClt ports |
| 163 | - ResourcePath srcPortPath = ResourcePath.discrete(src.deviceId(), src.port()); | 163 | + Resource srcPortResource = Resource.discrete(src.deviceId(), src.port()); |
| 164 | - ResourcePath dstPortPath = ResourcePath.discrete(dst.deviceId(), dst.port()); | 164 | + Resource dstPortResource = Resource.discrete(dst.deviceId(), dst.port()); |
| 165 | - List<ResourceAllocation> allocation = resourceService.allocate(intent.id(), srcPortPath, dstPortPath); | 165 | + List<ResourceAllocation> allocation = resourceService.allocate(intent.id(), srcPortResource, dstPortResource); |
| 166 | if (allocation.isEmpty()) { | 166 | if (allocation.isEmpty()) { |
| 167 | throw new IntentCompilationException("Unable to reserve ports for intent " + intent); | 167 | throw new IntentCompilationException("Unable to reserve ports for intent " + intent); |
| 168 | } | 168 | } |
| ... | @@ -312,7 +312,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -312,7 +312,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 312 | if (ochCP != null) { | 312 | if (ochCP != null) { |
| 313 | OchPort ochPort = (OchPort) deviceService.getPort(ochCP.deviceId(), ochCP.port()); | 313 | OchPort ochPort = (OchPort) deviceService.getPort(ochCP.deviceId(), ochCP.port()); |
| 314 | Optional<IntentId> intentId = | 314 | Optional<IntentId> intentId = |
| 315 | - resourceService.getResourceAllocation(ResourcePath.discrete(ochCP.deviceId(), ochCP.port())) | 315 | + resourceService.getResourceAllocation(Resource.discrete(ochCP.deviceId(), ochCP.port())) |
| 316 | .stream() | 316 | .stream() |
| 317 | .map(ResourceAllocation::consumer) | 317 | .map(ResourceAllocation::consumer) |
| 318 | .filter(x -> x instanceof IntentId) | 318 | .filter(x -> x instanceof IntentId) |
| ... | @@ -333,7 +333,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -333,7 +333,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | Optional<IntentId> intentId = | 335 | Optional<IntentId> intentId = |
| 336 | - resourceService.getResourceAllocation(ResourcePath.discrete(oduPort.deviceId(), port.number())) | 336 | + resourceService.getResourceAllocation(Resource.discrete(oduPort.deviceId(), port.number())) |
| 337 | .stream() | 337 | .stream() |
| 338 | .map(ResourceAllocation::consumer) | 338 | .map(ResourceAllocation::consumer) |
| 339 | .filter(x -> x instanceof IntentId) | 339 | .filter(x -> x instanceof IntentId) | ... | ... |
| ... | @@ -44,7 +44,7 @@ import org.onosproject.net.intent.OpticalConnectivityIntent; | ... | @@ -44,7 +44,7 @@ import org.onosproject.net.intent.OpticalConnectivityIntent; |
| 44 | import org.onosproject.net.intent.OpticalPathIntent; | 44 | import org.onosproject.net.intent.OpticalPathIntent; |
| 45 | import org.onosproject.net.intent.impl.IntentCompilationException; | 45 | import org.onosproject.net.intent.impl.IntentCompilationException; |
| 46 | import org.onosproject.net.newresource.ResourceAllocation; | 46 | import org.onosproject.net.newresource.ResourceAllocation; |
| 47 | -import org.onosproject.net.newresource.ResourcePath; | 47 | +import org.onosproject.net.newresource.Resource; |
| 48 | import org.onosproject.net.newresource.ResourceService; | 48 | import org.onosproject.net.newresource.ResourceService; |
| 49 | import org.onosproject.net.resource.link.LinkResourceAllocations; | 49 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| 50 | import org.onosproject.net.topology.LinkWeight; | 50 | import org.onosproject.net.topology.LinkWeight; |
| ... | @@ -109,10 +109,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -109,10 +109,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
| 109 | log.debug("Compiling optical connectivity intent between {} and {}", src, dst); | 109 | log.debug("Compiling optical connectivity intent between {} and {}", src, dst); |
| 110 | 110 | ||
| 111 | // Reserve OCh ports | 111 | // Reserve OCh ports |
| 112 | - ResourcePath srcPortPath = ResourcePath.discrete(src.deviceId(), src.port()); | 112 | + Resource srcPortResource = Resource.discrete(src.deviceId(), src.port()); |
| 113 | - ResourcePath dstPortPath = ResourcePath.discrete(dst.deviceId(), dst.port()); | 113 | + Resource dstPortResource = Resource.discrete(dst.deviceId(), dst.port()); |
| 114 | List<org.onosproject.net.newresource.ResourceAllocation> allocation = | 114 | List<org.onosproject.net.newresource.ResourceAllocation> allocation = |
| 115 | - resourceService.allocate(intent.id(), srcPortPath, dstPortPath); | 115 | + resourceService.allocate(intent.id(), srcPortResource, dstPortResource); |
| 116 | if (allocation.isEmpty()) { | 116 | if (allocation.isEmpty()) { |
| 117 | throw new IntentCompilationException("Unable to reserve ports for intent " + intent); | 117 | throw new IntentCompilationException("Unable to reserve ports for intent " + intent); |
| 118 | } | 118 | } |
| ... | @@ -182,10 +182,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -182,10 +182,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | List<OchSignal> minLambda = findFirstLambda(lambdas, slotCount()); | 184 | List<OchSignal> minLambda = findFirstLambda(lambdas, slotCount()); |
| 185 | - List<ResourcePath> lambdaResources = path.links().stream() | 185 | + List<Resource> lambdaResources = path.links().stream() |
| 186 | .flatMap(x -> Stream.of( | 186 | .flatMap(x -> Stream.of( |
| 187 | - ResourcePath.discrete(x.src().deviceId(), x.src().port()), | 187 | + Resource.discrete(x.src().deviceId(), x.src().port()), |
| 188 | - ResourcePath.discrete(x.dst().deviceId(), x.dst().port()) | 188 | + Resource.discrete(x.dst().deviceId(), x.dst().port()) |
| 189 | )) | 189 | )) |
| 190 | .flatMap(x -> minLambda.stream().map(l -> x.child(l))) | 190 | .flatMap(x -> minLambda.stream().map(l -> x.child(l))) |
| 191 | .collect(Collectors.toList()); | 191 | .collect(Collectors.toList()); |
| ... | @@ -214,8 +214,8 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -214,8 +214,8 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
| 214 | private Set<OchSignal> findCommonLambdasOverLinks(List<Link> links) { | 214 | private Set<OchSignal> findCommonLambdasOverLinks(List<Link> links) { |
| 215 | return links.stream() | 215 | return links.stream() |
| 216 | .flatMap(x -> Stream.of( | 216 | .flatMap(x -> Stream.of( |
| 217 | - ResourcePath.discrete(x.src().deviceId(), x.src().port()), | 217 | + Resource.discrete(x.src().deviceId(), x.src().port()), |
| 218 | - ResourcePath.discrete(x.dst().deviceId(), x.dst().port()) | 218 | + Resource.discrete(x.dst().deviceId(), x.dst().port()) |
| 219 | )) | 219 | )) |
| 220 | .map(resourceService::getAvailableResources) | 220 | .map(resourceService::getAvailableResources) |
| 221 | .map(x -> Iterables.filter(x, r -> r.last() instanceof OchSignal)) | 221 | .map(x -> Iterables.filter(x, r -> r.last() instanceof OchSignal)) | ... | ... |
| ... | @@ -44,7 +44,7 @@ import org.onosproject.net.intent.IntentExtensionService; | ... | @@ -44,7 +44,7 @@ import org.onosproject.net.intent.IntentExtensionService; |
| 44 | import org.onosproject.net.intent.PathIntent; | 44 | import org.onosproject.net.intent.PathIntent; |
| 45 | import org.onosproject.net.intent.constraint.EncapsulationConstraint; | 45 | import org.onosproject.net.intent.constraint.EncapsulationConstraint; |
| 46 | import org.onosproject.net.intent.impl.IntentCompilationException; | 46 | import org.onosproject.net.intent.impl.IntentCompilationException; |
| 47 | -import org.onosproject.net.newresource.ResourcePath; | 47 | +import org.onosproject.net.newresource.Resource; |
| 48 | import org.onosproject.net.newresource.ResourceService; | 48 | import org.onosproject.net.newresource.ResourceService; |
| 49 | import org.onosproject.net.resource.link.LinkResourceAllocations; | 49 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| 50 | import org.slf4j.Logger; | 50 | import org.slf4j.Logger; |
| ... | @@ -250,10 +250,10 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { | ... | @@ -250,10 +250,10 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | //same VLANID is used for both directions | 252 | //same VLANID is used for both directions |
| 253 | - Set<ResourcePath> resources = vlanIds.entrySet().stream() | 253 | + Set<Resource> resources = vlanIds.entrySet().stream() |
| 254 | .flatMap(x -> Stream.of( | 254 | .flatMap(x -> Stream.of( |
| 255 | - ResourcePath.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()), | 255 | + Resource.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()), |
| 256 | - ResourcePath.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue()) | 256 | + Resource.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue()) |
| 257 | )) | 257 | )) |
| 258 | .collect(Collectors.toSet()); | 258 | .collect(Collectors.toSet()); |
| 259 | List<org.onosproject.net.newresource.ResourceAllocation> allocations = | 259 | List<org.onosproject.net.newresource.ResourceAllocation> allocations = |
| ... | @@ -280,7 +280,7 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { | ... | @@ -280,7 +280,7 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | private Set<VlanId> findVlanId(ConnectPoint cp) { | 282 | private Set<VlanId> findVlanId(ConnectPoint cp) { |
| 283 | - return resourceService.getAvailableResources(ResourcePath.discrete(cp.deviceId(), cp.port())).stream() | 283 | + return resourceService.getAvailableResources(Resource.discrete(cp.deviceId(), cp.port())).stream() |
| 284 | .filter(x -> x.last() instanceof VlanId) | 284 | .filter(x -> x.last() instanceof VlanId) |
| 285 | .map(x -> (VlanId) x.last()) | 285 | .map(x -> (VlanId) x.last()) |
| 286 | .collect(Collectors.toSet()); | 286 | .collect(Collectors.toSet()); | ... | ... |
| ... | @@ -35,7 +35,7 @@ import org.onosproject.net.device.DeviceService; | ... | @@ -35,7 +35,7 @@ import org.onosproject.net.device.DeviceService; |
| 35 | import org.onosproject.net.driver.DriverHandler; | 35 | import org.onosproject.net.driver.DriverHandler; |
| 36 | import org.onosproject.net.driver.DriverService; | 36 | import org.onosproject.net.driver.DriverService; |
| 37 | import org.onosproject.net.newresource.ResourceAdminService; | 37 | import org.onosproject.net.newresource.ResourceAdminService; |
| 38 | -import org.onosproject.net.newresource.ResourcePath; | 38 | +import org.onosproject.net.newresource.Resource; |
| 39 | import org.slf4j.Logger; | 39 | import org.slf4j.Logger; |
| 40 | import org.slf4j.LoggerFactory; | 40 | import org.slf4j.LoggerFactory; |
| 41 | 41 | ||
| ... | @@ -108,15 +108,15 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -108,15 +108,15 @@ final class ResourceDeviceListener implements DeviceListener { |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | private void registerDeviceResource(Device device) { | 110 | private void registerDeviceResource(Device device) { |
| 111 | - executor.submit(() -> adminService.registerResources(ResourcePath.discrete(device.id()))); | 111 | + executor.submit(() -> adminService.registerResources(Resource.discrete(device.id()))); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | private void unregisterDeviceResource(Device device) { | 114 | private void unregisterDeviceResource(Device device) { |
| 115 | - executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(device.id()))); | 115 | + executor.submit(() -> adminService.unregisterResources(Resource.discrete(device.id()))); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | private void registerPortResource(Device device, Port port) { | 118 | private void registerPortResource(Device device, Port port) { |
| 119 | - ResourcePath portPath = ResourcePath.discrete(device.id(), port.number()); | 119 | + Resource portPath = Resource.discrete(device.id(), port.number()); |
| 120 | executor.submit(() -> { | 120 | executor.submit(() -> { |
| 121 | adminService.registerResources(portPath); | 121 | adminService.registerResources(portPath); |
| 122 | 122 | ||
| ... | @@ -155,7 +155,7 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -155,7 +155,7 @@ final class ResourceDeviceListener implements DeviceListener { |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | private void unregisterPortResource(Device device, Port port) { | 157 | private void unregisterPortResource(Device device, Port port) { |
| 158 | - ResourcePath resource = ResourcePath.discrete(device.id(), port.number()); | 158 | + Resource resource = Resource.discrete(device.id(), port.number()); |
| 159 | executor.submit(() -> adminService.unregisterResources(resource)); | 159 | executor.submit(() -> adminService.unregisterResources(resource)); |
| 160 | } | 160 | } |
| 161 | 161 | ... | ... |
| ... | @@ -31,7 +31,7 @@ import org.onosproject.net.newresource.ResourceConsumer; | ... | @@ -31,7 +31,7 @@ import org.onosproject.net.newresource.ResourceConsumer; |
| 31 | import org.onosproject.net.newresource.ResourceEvent; | 31 | import org.onosproject.net.newresource.ResourceEvent; |
| 32 | import org.onosproject.net.newresource.ResourceListener; | 32 | import org.onosproject.net.newresource.ResourceListener; |
| 33 | import org.onosproject.net.newresource.ResourceService; | 33 | import org.onosproject.net.newresource.ResourceService; |
| 34 | -import org.onosproject.net.newresource.ResourcePath; | 34 | +import org.onosproject.net.newresource.Resource; |
| 35 | import org.onosproject.net.newresource.ResourceStore; | 35 | import org.onosproject.net.newresource.ResourceStore; |
| 36 | import org.onosproject.net.newresource.ResourceStoreDelegate; | 36 | import org.onosproject.net.newresource.ResourceStoreDelegate; |
| 37 | 37 | ||
| ... | @@ -69,7 +69,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent | ... | @@ -69,7 +69,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent |
| 69 | 69 | ||
| 70 | @Override | 70 | @Override |
| 71 | public List<ResourceAllocation> allocate(ResourceConsumer consumer, | 71 | public List<ResourceAllocation> allocate(ResourceConsumer consumer, |
| 72 | - List<ResourcePath> resources) { | 72 | + List<Resource> resources) { |
| 73 | checkNotNull(consumer); | 73 | checkNotNull(consumer); |
| 74 | checkNotNull(resources); | 74 | checkNotNull(resources); |
| 75 | 75 | ||
| ... | @@ -87,7 +87,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent | ... | @@ -87,7 +87,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent |
| 87 | public boolean release(List<ResourceAllocation> allocations) { | 87 | public boolean release(List<ResourceAllocation> allocations) { |
| 88 | checkNotNull(allocations); | 88 | checkNotNull(allocations); |
| 89 | 89 | ||
| 90 | - List<ResourcePath> resources = allocations.stream() | 90 | + List<Resource> resources = allocations.stream() |
| 91 | .map(ResourceAllocation::resource) | 91 | .map(ResourceAllocation::resource) |
| 92 | .collect(Collectors.toList()); | 92 | .collect(Collectors.toList()); |
| 93 | List<ResourceConsumer> consumers = allocations.stream() | 93 | List<ResourceConsumer> consumers = allocations.stream() |
| ... | @@ -106,7 +106,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent | ... | @@ -106,7 +106,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | @Override | 108 | @Override |
| 109 | - public List<ResourceAllocation> getResourceAllocation(ResourcePath resource) { | 109 | + public List<ResourceAllocation> getResourceAllocation(Resource resource) { |
| 110 | checkNotNull(resource); | 110 | checkNotNull(resource); |
| 111 | 111 | ||
| 112 | List<ResourceConsumer> consumers = store.getConsumers(resource); | 112 | List<ResourceConsumer> consumers = store.getConsumers(resource); |
| ... | @@ -116,12 +116,12 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent | ... | @@ -116,12 +116,12 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | @Override | 118 | @Override |
| 119 | - public <T> Collection<ResourceAllocation> getResourceAllocations(ResourcePath parent, Class<T> cls) { | 119 | + public <T> Collection<ResourceAllocation> getResourceAllocations(Resource parent, Class<T> cls) { |
| 120 | checkNotNull(parent); | 120 | checkNotNull(parent); |
| 121 | checkNotNull(cls); | 121 | checkNotNull(cls); |
| 122 | 122 | ||
| 123 | // We access store twice in this method, then the store may be updated by others | 123 | // We access store twice in this method, then the store may be updated by others |
| 124 | - Collection<ResourcePath> resources = store.getAllocatedResources(parent, cls); | 124 | + Collection<Resource> resources = store.getAllocatedResources(parent, cls); |
| 125 | return resources.stream() | 125 | return resources.stream() |
| 126 | .flatMap(resource -> store.getConsumers(resource).stream() | 126 | .flatMap(resource -> store.getConsumers(resource).stream() |
| 127 | .map(consumer -> new ResourceAllocation(resource, consumer))) | 127 | .map(consumer -> new ResourceAllocation(resource, consumer))) |
| ... | @@ -132,17 +132,17 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent | ... | @@ -132,17 +132,17 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent |
| 132 | public Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer) { | 132 | public Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer) { |
| 133 | checkNotNull(consumer); | 133 | checkNotNull(consumer); |
| 134 | 134 | ||
| 135 | - Collection<ResourcePath> resources = store.getResources(consumer); | 135 | + Collection<Resource> resources = store.getResources(consumer); |
| 136 | return resources.stream() | 136 | return resources.stream() |
| 137 | .map(x -> new ResourceAllocation(x, consumer)) | 137 | .map(x -> new ResourceAllocation(x, consumer)) |
| 138 | .collect(Collectors.toList()); | 138 | .collect(Collectors.toList()); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | @Override | 141 | @Override |
| 142 | - public Collection<ResourcePath> getAvailableResources(ResourcePath parent) { | 142 | + public Collection<Resource> getAvailableResources(Resource parent) { |
| 143 | checkNotNull(parent); | 143 | checkNotNull(parent); |
| 144 | 144 | ||
| 145 | - Collection<ResourcePath> children = store.getChildResources(parent); | 145 | + Collection<Resource> children = store.getChildResources(parent); |
| 146 | return children.stream() | 146 | return children.stream() |
| 147 | // We access store twice in this method, then the store may be updated by others | 147 | // We access store twice in this method, then the store may be updated by others |
| 148 | .filter(store::isAvailable) | 148 | .filter(store::isAvailable) |
| ... | @@ -150,21 +150,21 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent | ... | @@ -150,21 +150,21 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | @Override | 152 | @Override |
| 153 | - public boolean isAvailable(ResourcePath resource) { | 153 | + public boolean isAvailable(Resource resource) { |
| 154 | checkNotNull(resource); | 154 | checkNotNull(resource); |
| 155 | 155 | ||
| 156 | return store.isAvailable(resource); | 156 | return store.isAvailable(resource); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | @Override | 159 | @Override |
| 160 | - public boolean registerResources(List<ResourcePath> resources) { | 160 | + public boolean registerResources(List<Resource> resources) { |
| 161 | checkNotNull(resources); | 161 | checkNotNull(resources); |
| 162 | 162 | ||
| 163 | return store.register(resources); | 163 | return store.register(resources); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | @Override | 166 | @Override |
| 167 | - public boolean unregisterResources(List<ResourcePath> resources) { | 167 | + public boolean unregisterResources(List<Resource> resources) { |
| 168 | checkNotNull(resources); | 168 | checkNotNull(resources); |
| 169 | 169 | ||
| 170 | return store.unregister(resources); | 170 | return store.unregister(resources); | ... | ... |
| ... | @@ -41,7 +41,7 @@ import org.onosproject.net.intent.MockIdGenerator; | ... | @@ -41,7 +41,7 @@ import org.onosproject.net.intent.MockIdGenerator; |
| 41 | import org.onosproject.net.link.LinkEvent; | 41 | import org.onosproject.net.link.LinkEvent; |
| 42 | import org.onosproject.net.newresource.ResourceEvent; | 42 | import org.onosproject.net.newresource.ResourceEvent; |
| 43 | import org.onosproject.net.newresource.ResourceListener; | 43 | import org.onosproject.net.newresource.ResourceListener; |
| 44 | -import org.onosproject.net.newresource.ResourcePath; | 44 | +import org.onosproject.net.newresource.Resource; |
| 45 | import org.onosproject.net.topology.Topology; | 45 | import org.onosproject.net.topology.Topology; |
| 46 | import org.onosproject.net.topology.TopologyEvent; | 46 | import org.onosproject.net.topology.TopologyEvent; |
| 47 | import org.onosproject.net.topology.TopologyListener; | 47 | import org.onosproject.net.topology.TopologyListener; |
| ... | @@ -232,7 +232,7 @@ public class ObjectiveTrackerTest { | ... | @@ -232,7 +232,7 @@ public class ObjectiveTrackerTest { |
| 232 | @Test | 232 | @Test |
| 233 | public void testResourceEvent() throws Exception { | 233 | public void testResourceEvent() throws Exception { |
| 234 | ResourceEvent event = new ResourceEvent(RESOURCE_ADDED, | 234 | ResourceEvent event = new ResourceEvent(RESOURCE_ADDED, |
| 235 | - ResourcePath.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1))); | 235 | + Resource.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1))); |
| 236 | resourceListener.event(event); | 236 | resourceListener.event(event); |
| 237 | 237 | ||
| 238 | assertThat( | 238 | assertThat( | ... | ... |
| ... | @@ -21,7 +21,7 @@ import org.onlab.packet.VlanId; | ... | @@ -21,7 +21,7 @@ import org.onlab.packet.VlanId; |
| 21 | import org.onosproject.net.newresource.ResourceAllocation; | 21 | import org.onosproject.net.newresource.ResourceAllocation; |
| 22 | import org.onosproject.net.newresource.ResourceConsumer; | 22 | import org.onosproject.net.newresource.ResourceConsumer; |
| 23 | import org.onosproject.net.newresource.ResourceListener; | 23 | import org.onosproject.net.newresource.ResourceListener; |
| 24 | -import org.onosproject.net.newresource.ResourcePath; | 24 | +import org.onosproject.net.newresource.Resource; |
| 25 | import org.onosproject.net.newresource.ResourceService; | 25 | import org.onosproject.net.newresource.ResourceService; |
| 26 | 26 | ||
| 27 | import java.util.Collection; | 27 | import java.util.Collection; |
| ... | @@ -34,10 +34,10 @@ import java.util.stream.Collectors; | ... | @@ -34,10 +34,10 @@ import java.util.stream.Collectors; |
| 34 | 34 | ||
| 35 | class MockResourceService implements ResourceService { | 35 | class MockResourceService implements ResourceService { |
| 36 | 36 | ||
| 37 | - private final Map<ResourcePath, ResourceConsumer> assignment = new HashMap<>(); | 37 | + private final Map<Resource, ResourceConsumer> assignment = new HashMap<>(); |
| 38 | 38 | ||
| 39 | @Override | 39 | @Override |
| 40 | - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<ResourcePath> resources) { | 40 | + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { |
| 41 | assignment.putAll( | 41 | assignment.putAll( |
| 42 | resources.stream().collect(Collectors.toMap(x -> x, x -> consumer)) | 42 | resources.stream().collect(Collectors.toMap(x -> x, x -> consumer)) |
| 43 | ); | 43 | ); |
| ... | @@ -56,7 +56,7 @@ class MockResourceService implements ResourceService { | ... | @@ -56,7 +56,7 @@ class MockResourceService implements ResourceService { |
| 56 | 56 | ||
| 57 | @Override | 57 | @Override |
| 58 | public boolean release(ResourceConsumer consumer) { | 58 | public boolean release(ResourceConsumer consumer) { |
| 59 | - List<ResourcePath> resources = assignment.entrySet().stream() | 59 | + List<Resource> resources = assignment.entrySet().stream() |
| 60 | .filter(x -> x.getValue().equals(consumer)) | 60 | .filter(x -> x.getValue().equals(consumer)) |
| 61 | .map(Map.Entry::getKey) | 61 | .map(Map.Entry::getKey) |
| 62 | .collect(Collectors.toList()); | 62 | .collect(Collectors.toList()); |
| ... | @@ -68,14 +68,14 @@ class MockResourceService implements ResourceService { | ... | @@ -68,14 +68,14 @@ class MockResourceService implements ResourceService { |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | @Override | 70 | @Override |
| 71 | - public List<ResourceAllocation> getResourceAllocation(ResourcePath resource) { | 71 | + public List<ResourceAllocation> getResourceAllocation(Resource resource) { |
| 72 | return Optional.ofNullable(assignment.get(resource)) | 72 | return Optional.ofNullable(assignment.get(resource)) |
| 73 | .map(x -> ImmutableList.of(new ResourceAllocation(resource, x))) | 73 | .map(x -> ImmutableList.of(new ResourceAllocation(resource, x))) |
| 74 | .orElse(ImmutableList.of()); | 74 | .orElse(ImmutableList.of()); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | @Override | 77 | @Override |
| 78 | - public <T> Collection<ResourceAllocation> getResourceAllocations(ResourcePath parent, Class<T> cls) { | 78 | + public <T> Collection<ResourceAllocation> getResourceAllocations(Resource parent, Class<T> cls) { |
| 79 | return assignment.entrySet().stream() | 79 | return assignment.entrySet().stream() |
| 80 | .filter(x -> x.getKey().parent().isPresent()) | 80 | .filter(x -> x.getKey().parent().isPresent()) |
| 81 | .filter(x -> x.getKey().parent().get().equals(parent)) | 81 | .filter(x -> x.getKey().parent().get().equals(parent)) |
| ... | @@ -92,16 +92,16 @@ class MockResourceService implements ResourceService { | ... | @@ -92,16 +92,16 @@ class MockResourceService implements ResourceService { |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | @Override | 94 | @Override |
| 95 | - public Collection<ResourcePath> getAvailableResources(ResourcePath parent) { | 95 | + public Collection<Resource> getAvailableResources(Resource parent) { |
| 96 | 96 | ||
| 97 | - Collection<ResourcePath> resources = new HashSet<ResourcePath>(); | 97 | + Collection<Resource> resources = new HashSet<Resource>(); |
| 98 | resources.add(parent.child(VlanId.vlanId((short) 10))); | 98 | resources.add(parent.child(VlanId.vlanId((short) 10))); |
| 99 | resources.add(parent.child(MplsLabel.mplsLabel(10))); | 99 | resources.add(parent.child(MplsLabel.mplsLabel(10))); |
| 100 | return ImmutableList.copyOf(resources); | 100 | return ImmutableList.copyOf(resources); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | @Override | 103 | @Override |
| 104 | - public boolean isAvailable(ResourcePath resource) { | 104 | + public boolean isAvailable(Resource resource) { |
| 105 | return true; | 105 | return true; |
| 106 | } | 106 | } |
| 107 | 107 | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -174,7 +174,7 @@ import org.onosproject.net.link.DefaultLinkDescription; | ... | @@ -174,7 +174,7 @@ import org.onosproject.net.link.DefaultLinkDescription; |
| 174 | import org.onosproject.net.meter.MeterId; | 174 | import org.onosproject.net.meter.MeterId; |
| 175 | import org.onosproject.net.newresource.ResourceAllocation; | 175 | import org.onosproject.net.newresource.ResourceAllocation; |
| 176 | import org.onosproject.net.newresource.ResourceId; | 176 | import org.onosproject.net.newresource.ResourceId; |
| 177 | -import org.onosproject.net.newresource.ResourcePath; | 177 | +import org.onosproject.net.newresource.Resource; |
| 178 | import org.onosproject.net.packet.DefaultOutboundPacket; | 178 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 179 | import org.onosproject.net.packet.DefaultPacketRequest; | 179 | import org.onosproject.net.packet.DefaultPacketRequest; |
| 180 | import org.onosproject.net.packet.PacketPriority; | 180 | import org.onosproject.net.packet.PacketPriority; |
| ... | @@ -433,9 +433,9 @@ public final class KryoNamespaces { | ... | @@ -433,9 +433,9 @@ public final class KryoNamespaces { |
| 433 | DefaultLinkResourceAllocations.class, | 433 | DefaultLinkResourceAllocations.class, |
| 434 | BandwidthResourceAllocation.class, | 434 | BandwidthResourceAllocation.class, |
| 435 | LambdaResourceAllocation.class, | 435 | LambdaResourceAllocation.class, |
| 436 | - ResourcePath.class, | 436 | + Resource.class, |
| 437 | - ResourcePath.Discrete.class, | 437 | + Resource.Discrete.class, |
| 438 | - ResourcePath.Continuous.class, | 438 | + Resource.Continuous.class, |
| 439 | ResourceId.class, | 439 | ResourceId.class, |
| 440 | ResourceAllocation.class, | 440 | ResourceAllocation.class, |
| 441 | // Constraints | 441 | // Constraints | ... | ... |
| ... | @@ -62,7 +62,7 @@ import org.onosproject.net.flow.FlowId; | ... | @@ -62,7 +62,7 @@ import org.onosproject.net.flow.FlowId; |
| 62 | import org.onosproject.net.flow.FlowRule; | 62 | import org.onosproject.net.flow.FlowRule; |
| 63 | import org.onosproject.net.flow.FlowRuleBatchEntry; | 63 | import org.onosproject.net.flow.FlowRuleBatchEntry; |
| 64 | import org.onosproject.net.intent.IntentId; | 64 | import org.onosproject.net.intent.IntentId; |
| 65 | -import org.onosproject.net.newresource.ResourcePath; | 65 | +import org.onosproject.net.newresource.Resource; |
| 66 | import org.onosproject.net.provider.ProviderId; | 66 | import org.onosproject.net.provider.ProviderId; |
| 67 | import org.onosproject.net.resource.link.BandwidthResource; | 67 | import org.onosproject.net.resource.link.BandwidthResource; |
| 68 | import org.onosproject.net.resource.link.BandwidthResourceAllocation; | 68 | import org.onosproject.net.resource.link.BandwidthResourceAllocation; |
| ... | @@ -374,19 +374,19 @@ public class KryoSerializerTest { | ... | @@ -374,19 +374,19 @@ public class KryoSerializerTest { |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | @Test | 376 | @Test |
| 377 | - public void testResourcePath() { | 377 | + public void testResource() { |
| 378 | - testSerializedEquals(ResourcePath.discrete(DID1, P1, VLAN1)); | 378 | + testSerializedEquals(Resource.discrete(DID1, P1, VLAN1)); |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | @Test | 381 | @Test |
| 382 | public void testResourceKey() { | 382 | public void testResourceKey() { |
| 383 | - testSerializedEquals(ResourcePath.discrete(DID1, P1).id()); | 383 | + testSerializedEquals(Resource.discrete(DID1, P1).id()); |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | @Test | 386 | @Test |
| 387 | public void testResourceAllocation() { | 387 | public void testResourceAllocation() { |
| 388 | testSerializedEquals(new org.onosproject.net.newresource.ResourceAllocation( | 388 | testSerializedEquals(new org.onosproject.net.newresource.ResourceAllocation( |
| 389 | - ResourcePath.discrete(DID1, P1, VLAN1), | 389 | + Resource.discrete(DID1, P1, VLAN1), |
| 390 | IntentId.valueOf(30))); | 390 | IntentId.valueOf(30))); |
| 391 | } | 391 | } |
| 392 | 392 | ... | ... |
-
Please register or login to post a comment