Moving LabelResourceManager to incubator
Breaking apart resource package into {device, link, label}
Refactored cluster serializers so they are visible
Change-Id: I71051bcd5e790ae6abeb154bf58286e584c32858
diff --git a/core/api/src/main/java/org/onosproject/net/intent/Constraint.java b/core/api/src/main/java/org/onosproject/net/intent/Constraint.java
index ca2acdc..ee28f6e 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/Constraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/Constraint.java
@@ -17,7 +17,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.Path;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
/**
* Representation of a connectivity constraint capable of evaluating a link
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentCompiler.java b/core/api/src/main/java/org/onosproject/net/intent/IntentCompiler.java
index 4f0a55d..da39184 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentCompiler.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentCompiler.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.net.intent;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.List;
import java.util.Set;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java
index 6733296..36e6157 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java
@@ -17,7 +17,7 @@
import com.google.common.base.MoreObjects;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Objects;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java
index 26ba61b..df709f9 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java
@@ -18,7 +18,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Objects;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
index be75880..b4518d4 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
@@ -16,9 +16,9 @@
package org.onosproject.net.intent.constraint;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceRequest;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java
index 1a46754..02d4a42 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java
@@ -18,7 +18,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
/**
* Abstract base class for various constraints that evaluate link viability
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
index f9bf42e..a73e375 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
@@ -16,8 +16,8 @@
package org.onosproject.net.intent.constraint;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
index c3f5488..6b47e83 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
@@ -19,7 +19,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java
index 21048cf..590715b 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java
@@ -17,7 +17,7 @@
import com.google.common.collect.ImmutableSet;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Objects;
import java.util.Set;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
index 9f92a39..24ef191 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
@@ -19,7 +19,7 @@
import com.google.common.collect.ImmutableSet;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Collections;
import java.util.Objects;
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
index 49a52ec..579e44d 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
@@ -21,7 +21,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Collections;
import java.util.LinkedList;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/DefaultLabelResource.java b/core/api/src/main/java/org/onosproject/net/resource/DefaultLabelResource.java
deleted file mode 100644
index 41651de..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/DefaultLabelResource.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.onosproject.net.resource;
-
-import java.util.Objects;
-
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.provider.ProviderId;
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * the implementation of a label resource of a device.
- */
-public final class DefaultLabelResource implements LabelResource {
-
- private DeviceId deviceId;
-
- private LabelResourceId labelResourceId;
-
- /**
- * Initialize a label resource object.
- * @param deviceId device identifier
- * @param labelResourceId label resource id
- */
- public DefaultLabelResource(String deviceId, long labelResourceId) {
- this.deviceId = DeviceId.deviceId(deviceId);
- this.labelResourceId = LabelResourceId.labelResourceId(labelResourceId);
- }
-
- /**
- * Initialize a label resource object.
- * @param deviceId device identifier
- * @param labelResourceId label resource id
- */
- public DefaultLabelResource(DeviceId deviceId,
- LabelResourceId labelResourceId) {
- this.deviceId = deviceId;
- this.labelResourceId = labelResourceId;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public LabelResourceId labelResourceId() {
- return labelResourceId;
- }
-
- @Override
- public Annotations annotations() {
- return null;
- }
-
- @Override
- public ProviderId providerId() {
- return null;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(deviceId, labelResourceId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof DefaultLabelResource) {
- DefaultLabelResource that = (DefaultLabelResource) obj;
- return Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.labelResourceId,
- that.labelResourceId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("deviceId", deviceId)
- .add("labelResourceId", labelResourceId).toString();
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResource.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResource.java
deleted file mode 100644
index eac1d81..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResource.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.net.Annotated;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.NetworkResource;
-import org.onosproject.net.Provided;
-
-/**
- * Representation of label resource.
- */
-public interface LabelResource extends Annotated, Provided, NetworkResource {
- /**
- * Returns device id.
- * @return DeviceId
- */
- DeviceId deviceId();
-
- /**
- * Returns labelResource Id.
- * @return LabelResourceId
- */
- LabelResourceId labelResourceId();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceAdminService.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceAdminService.java
deleted file mode 100644
index 8d29500..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceAdminService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.net.DeviceId;
-
-/**
- * Service for managing label resource.
- */
-public interface LabelResourceAdminService {
- /**
- * Creates the only label resource of some device id from begin label to end
- * label.
- *
- * @param deviceId device identifier
- * @param beginLabel represents for the first label id in the range of label
- * pool
- * @param endLabel represents for the last label id in the range of label
- * pool
- * @return success or fail
- */
- boolean createDevicePool(DeviceId deviceId, LabelResourceId beginLabel,
- LabelResourceId endLabel);
-
- /**
- * Creates the only global label resource pool.
- *
- * @param beginLabel represents for the first label id in the range of label
- * pool
- * @param endLabel represents for the last label id in the range of label
- * pool
- * @return success or fail
- */
- boolean createGlobalPool(LabelResourceId beginLabel,
- LabelResourceId endLabel);
-
- /**
- * Destroys a label resource pool of a specific device id.
- *
- * @param deviceId device identifier
- * @return success or fail
- */
- boolean destroyDevicePool(DeviceId deviceId);
-
- /**
- * Destroys the global label resource pool.
- *
- * @return success or fail
- */
- boolean destroyGlobalPool();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceDelegate.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceDelegate.java
deleted file mode 100644
index c8ff44f..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceDelegate.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.store.StoreDelegate;
-/**
- * Label resource store delegate.
- */
-public interface LabelResourceDelegate extends StoreDelegate<LabelResourceEvent> {
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceEvent.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceEvent.java
deleted file mode 100644
index 93f1d19..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.event.AbstractEvent;
-
-/**
- * Describes label resource event.
- */
-public final class LabelResourceEvent
- extends AbstractEvent<LabelResourceEvent.Type, LabelResourcePool> {
-
- /**
- * Type of label resource event.
- */
- public enum Type {
- /**
- * Signifies that a new pool has been administratively created.
- */
- POOL_CREATED,
- /**
- * Signifies that a new pool has been administratively destroyed.
- */
- POOL_DESTROYED,
- /**
- * Signifies that a new pool has been administratively changed.
- */
- POOL_CAPACITY_CHANGED
- }
-
- /**
- * Creates an event of a given type and the given LabelResourcePool.
- *
- * @param type event type
- * @param subject pool
- */
- public LabelResourceEvent(Type type, LabelResourcePool subject) {
- super(type, subject);
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceId.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceId.java
deleted file mode 100644
index f23ad6d..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceId.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.onosproject.net.resource;
-
-import java.util.Objects;
-
-/**
- * Representation of a label.
- */
-public final class LabelResourceId implements ResourceId {
-
- private long labelId;
-
- public static LabelResourceId labelResourceId(long labelResourceId) {
- return new LabelResourceId(labelResourceId);
- }
-
- // Public construction is prohibited
- private LabelResourceId(long labelId) {
- this.labelId = labelId;
- }
-
- public long labelId() {
- return labelId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(labelId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LabelResourceId) {
- LabelResourceId that = (LabelResourceId) obj;
- return Objects.equals(this.labelId, that.labelId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return String.valueOf(this.labelId);
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceListener.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceListener.java
deleted file mode 100644
index 3aee8d8..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceListener.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.event.EventListener;
-/**
- * Entity capable of receiving label resource related events.
- */
-public interface LabelResourceListener extends EventListener<LabelResourceEvent> {
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourcePool.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourcePool.java
deleted file mode 100644
index 02ff9ee..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourcePool.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.onosproject.net.resource;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Set;
-
-import org.onosproject.net.DeviceId;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Abstraction of the capacity of device label resource or global label
- * resource. it's contiguous range of label resource.when a application apply
- * some labels of some device,first catch from Set that store
- * available labels,if the size of the Set less than the apply number,then get
- * labels by calculating with three attributes, beginLabel,endLabel and
- * currentUsedMaxLabelId
- */
-public class LabelResourcePool {
-
- private final DeviceId deviceId;
- private final LabelResourceId beginLabel;
- private final LabelResourceId endLabel;
- private final long totalNum; // capacity of label resource pool
- private final long usedNum; // have used label number
- private final LabelResourceId currentUsedMaxLabelId; // the maximal label
- // number id
- private ImmutableSet<LabelResource> releaseLabelId; // Set of released label
-
- /**
- * Creates a pool by device id,begin label id,end label id.
- *
- * @param deviceId device identifier
- * @param beginLabel represents for the first label id in the range of label
- * resource pool
- * @param endLabel represents for the last label id in the range of label
- * resource pool
- */
- public LabelResourcePool(String deviceId, long beginLabel, long endLabel) {
- this(deviceId, beginLabel, endLabel, endLabel - beginLabel + 1, 0L,
- beginLabel, ImmutableSet.copyOf(Collections.emptySet()));
- }
-
- /**
- * Creates a pool by device id,begin label id,end label id.
- * used to update a pool in the store.
- * @param deviceId device identifier
- * @param beginLabel represents for the first label id in the range of label
- * resource pool
- * @param endLabel represents for the last label id in the range of label
- * resource pool
- * @param totalNum capacity of label resource pool
- * @param usedNum have used label number
- * @param currentUsedMaxLabelId the maximal label number id
- * @param releaseLabelId Set of released label
- */
- public LabelResourcePool(String deviceId, long beginLabel, long endLabel,
- long totalNum, long usedNum,
- long currentUsedMaxLabelId,
- ImmutableSet<LabelResource> releaseLabelId) {
- checkArgument(endLabel >= beginLabel,
- "endLabel %s must be greater than or equal to beginLabel %s",
- endLabel, beginLabel);
- this.deviceId = DeviceId.deviceId(deviceId);
- this.beginLabel = LabelResourceId.labelResourceId(beginLabel);
- this.endLabel = LabelResourceId.labelResourceId(endLabel);
- this.totalNum = totalNum;
- this.usedNum = usedNum;
- this.currentUsedMaxLabelId = LabelResourceId
- .labelResourceId(currentUsedMaxLabelId);
- this.releaseLabelId = releaseLabelId;
- }
-
- /**
- * Returns a device id.
- *
- * @return DeviceId
- */
- public DeviceId deviceId() {
- return deviceId;
- }
-
- /**
- * Returns a begin Label id.
- *
- * @return begin Label id
- */
- public LabelResourceId beginLabel() {
- return beginLabel;
- }
-
- /**
- * Returns a end Label id.
- *
- * @return end Label id
- */
- public LabelResourceId endLabel() {
- return endLabel;
- }
-
- /**
- * Returns a begin Label id.
- *
- * @return current Used Maximal Label Id
- */
- public LabelResourceId currentUsedMaxLabelId() {
- return currentUsedMaxLabelId;
- }
-
- /**
- * Returns total number.
- *
- * @return the total label number
- */
- public long totalNum() {
- return totalNum;
- }
-
- /**
- * Returns used number.
- *
- * @return the used label number
- */
- public long usedNum() {
- return usedNum;
- }
-
- /**
- * Returns the Set of released label before.
- *
- * @return the Set of LabelResource
- */
- public Set<LabelResource> releaseLabelId() {
- return releaseLabelId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(this.deviceId, this.beginLabel, this.endLabel,
- this.totalNum, this.usedNum,
- this.currentUsedMaxLabelId, this.releaseLabelId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LabelResourcePool) {
- LabelResourcePool that = (LabelResourcePool) obj;
- return Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.beginLabel, that.beginLabel)
- && Objects.equals(this.endLabel, that.endLabel)
- && Objects.equals(this.totalNum, that.totalNum)
- && Objects.equals(this.usedNum, that.usedNum)
- && Objects.equals(this.currentUsedMaxLabelId,
- that.currentUsedMaxLabelId)
- && Objects.equals(this.releaseLabelId, that.releaseLabelId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- // TODO Auto-generated method stub
- return MoreObjects.toStringHelper(this).add("deviceId", this.deviceId)
- .add("beginLabel", this.beginLabel)
- .add("endLabel", this.endLabel).add("totalNum", this.totalNum)
- .add("usedNum", this.usedNum)
- .add("currentUsedMaxLabelId", this.currentUsedMaxLabelId)
- .add("releaseLabelId", this.releaseLabelId).toString();
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProvider.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProvider.java
deleted file mode 100644
index 5c5183a..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProvider.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.net.provider.Provider;
-/**
- * Abstraction of an entity providing information about label resource
- * to the core.
- */
-public interface LabelResourceProvider extends Provider {
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProviderRegistry.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProviderRegistry.java
deleted file mode 100644
index 689ff4e..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProviderRegistry.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.net.provider.ProviderRegistry;
-/**
- * Abstraction of an label resource provider registry.
- */
-public interface LabelResourceProviderRegistry
- extends ProviderRegistry<LabelResourceProvider, LabelResourceProviderService> {
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProviderService.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProviderService.java
deleted file mode 100644
index 6e2fa5b..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceProviderService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.provider.ProviderService;
-
-/**
- * Means for injecting label information into the core.
- */
-public interface LabelResourceProviderService extends ProviderService<LabelResourceProvider> {
-
- /**
- * Signals that a device label resource pool has been detected.
- * @param deviceId device identifier
- * @param beginLabel the begin label number of resource
- * @param endLabel the end label number of resource
- */
- void deviceLabelResourcePoolDetected(DeviceId deviceId,
- LabelResourceId beginLabel,
- LabelResourceId endLabel);
-
- /**
- * Signals that an label resource pool has been destroyed.
- * @param deviceId device identifier
- */
- void deviceLabelResourcePoolDestroyed(DeviceId deviceId);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceRequest.java
deleted file mode 100644
index f28e33b..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceRequest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.onosproject.net.resource;
-
-import java.util.Collection;
-import java.util.Objects;
-
-import org.onosproject.net.DeviceId;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableSet;
-/**
- * Represents for a label request.
- */
-public class LabelResourceRequest {
-
- private final DeviceId deviceId;
- private final Type type;
- private final long applyNum;
- private ImmutableSet<LabelResource> releaseCollection;
-
- /**
- * Creates LabelResourceRequest object.
- * @param deviceId device identifier
- * @param type request type
- * @param applyNum apply the number of labels
- * @param releaseCollection Set of released label
- */
- public LabelResourceRequest(DeviceId deviceId,
- Type type,
- long applyNum,
- ImmutableSet<LabelResource> releaseCollection) {
- this.deviceId = deviceId;
- this.type = type;
- this.applyNum = applyNum;
- this.releaseCollection = releaseCollection;
- }
- /**
- * Returns a device id.
- * @return DeviceId
- */
- public DeviceId deviceId() {
- return deviceId;
- }
-
- /**
- * Returns request type.
- * @return Type
- */
- public Type type() {
- return type;
- }
-
- /**
- * Returns apply label number.
- * @return label number
- */
- public long applyNum() {
- return applyNum;
- }
-
- /**
- * Returns the collection of release labels.
- * @return Collection of DefaultLabelResource
- */
- public Collection<LabelResource> releaseCollection() {
- return releaseCollection;
- }
-
- /**
- * Request type.
- */
- public enum Type {
- APPLY, //apple label request
- RELEASE //release label request
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(this.deviceId, this.applyNum, this.type,
- this.releaseCollection);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LabelResourceRequest) {
- LabelResourceRequest that = (LabelResourceRequest) obj;
- return Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.applyNum, that.applyNum)
- && Objects.equals(this.type, that.type)
- && Objects.equals(this.releaseCollection,
- that.releaseCollection);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this).add("deviceId", this.deviceId)
- .add("applyNum", this.applyNum).add("type", this.type)
- .add("releaseCollection", this.releaseCollection).toString();
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceService.java
deleted file mode 100644
index e88a215..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceService.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.onosproject.net.resource;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onosproject.net.DeviceId;
-
-import com.google.common.collect.Multimap;
-
-/**
- * Service for providing label resource allocation.
- */
-public interface LabelResourceService {
-
- /**
- * Returns labels from resource pool by a specific device id.
- *
- * @param deviceId device identifier
- * @param applyNum the applying number
- * @return collection of applying labels
- */
- Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
- long applyNum);
-
- /**
- * Returns labels from the global label resource pool.
- *
- * @param applyNum the applying number
- * @return collection of applying labels
- */
- Collection<LabelResource> applyFromGlobalPool(long applyNum);
-
- /**
- * Releases unused labels to device pools .
- *
- * @param release the collection of releasing labels
- * @return success or fail
- */
- boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release);
-
- /**
- * Releases unused labels to the global resource pool.
- *
- * @param release release the collection of releasing labels
- * @return success or fail
- */
- boolean releaseToGlobalPool(Set<LabelResourceId> release);
-
- /**
- * Judges if the pool of a specific device id is full.
- *
- * @param deviceId device identifier
- * @return yes or no
- */
- boolean isDevicePoolFull(DeviceId deviceId);
-
- /**
- * Judges if the global resource pool is full.
- *
- * @return yes or no
- */
- boolean isGlobalPoolFull();
-
- /**
- * Returns the unused label number of a label resource pool by a specific device
- * id.
- *
- * @param deviceId device identifier
- * @return number of unused labels
- */
- long getFreeNumOfDevicePool(DeviceId deviceId);
-
- /**
- * Returns the unused label number of a global label resource pool.
- *
- * @return number of unused labels
- */
- long getFreeNumOfGlobalPool();
-
- /**
- * Returns the label resource pool of a label resource by a specific device
- * id.
- *
- * @param deviceId device identifier
- * @return the device label resource pool
- */
- LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId);
-
- /**
- * Returns the global label resource pool.
- *
- * @return the global label resource pool
- */
- LabelResourcePool getGlobalLabelResourcePool();
-
- /**
- * Adds the specified label resource listener.
- *
- * @param listener label resource listener
- */
- void addListener(LabelResourceListener listener);
-
- /**
- * Removes the specified label resource listener.
- *
- * @param listener label resource listener
- */
- void removeListener(LabelResourceListener listener);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceStore.java b/core/api/src/main/java/org/onosproject/net/resource/LabelResourceStore.java
deleted file mode 100644
index 451969d..0000000
--- a/core/api/src/main/java/org/onosproject/net/resource/LabelResourceStore.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.onosproject.net.resource;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.Store;
-
-import com.google.common.collect.Multimap;
-
-/**
- * Manages inventory of label; not intended for direct use.
- *
- */
-public interface LabelResourceStore
- extends Store<LabelResourceEvent, LabelResourceDelegate> {
-
- /**
- * Creates a label resource of some device id from begin label to end label.
- *
- * @param deviceId device identifier
- * @param beginLabel represents for the first label id in the range of label
- * pool
- * @param endLabel represents for the last label id in the range of label
- * pool
- * @return success or fail
- */
- boolean createDevicePool(DeviceId deviceId, LabelResourceId beginLabel,
- LabelResourceId endLabel);
-
- /**
- * Creates the global label resource pool.
- *
- * @param beginLabel represents for the first label id in the range of label
- * pool
- * @param endLabel represents for the last label id in the range of label
- * pool
- * @return success or fail
- */
- boolean createGlobalPool(LabelResourceId beginLabel,
- LabelResourceId endLabel);
-
- /**
- * Destroys a label resource pool of a specific device id.
- *
- * @param deviceId device identifier
- * @return success or fail
- */
- boolean destroyDevicePool(DeviceId deviceId);
-
- /**
- * Destroys a the global label resource pool.
- *
- * @return success or fail
- */
- boolean destroyGlobalPool();
-
- /**
- * Returns labels from resource pool by a specific device id.
- *
- * @param deviceId device identifier
- * @param applyNum the applying number
- * @return collection of applying labels
- */
- Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
- long applyNum);
-
- /**
- * Returns labels from the global label resource pool.
- *
- * @param applyNum apply the number of labels
- * @return collection of labels
- */
- Collection<LabelResource> applyFromGlobalPool(long applyNum);
-
- /**
- * Releases unused labels to device pools .
- *
- * @param release the collection of releasing labels
- * @return success or fail
- */
- boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release);
-
- /**
- * Releases unused labels to the global resource pool.
- *
- * @param release release the collection of releasing labels
- * @return success or fail
- */
- boolean releaseToGlobalPool(Set<LabelResourceId> release);
-
- /**
- * Judges if the pool of a specific device id is full.
- *
- * @param deviceId device identifier
- * @return yes or no
- */
- boolean isDevicePoolFull(DeviceId deviceId);
-
- /**
- * Judges if the global resource pool is full.
- *
- * @return yes or no
- */
- boolean isGlobalPoolFull();
-
- /**
- * Returns the unused label number of a label resource pool by a specific device
- * id.
- *
- * @param deviceId device identifier
- * @return number of unused labels
- */
- long getFreeNumOfDevicePool(DeviceId deviceId);
-
- /**
- * Returns the unused number of a global label resource pool.
- *
- * @return number of unused labels
- */
- long getFreeNumOfGlobalPool();
-
- /**
- * Returns the label resource pool by a specific device id.
- *
- * @param deviceId device identifier
- * @return the device label resource pool
- */
- LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId);
-
- /**
- * Returns the global label resource pool.
- *
- * @return the global label resource pool
- */
- LabelResourcePool getGlobalLabelResourcePool();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceId.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceId.java
index 3fbe1d7..dd11153 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ResourceId.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceId.java
@@ -16,7 +16,7 @@
package org.onosproject.net.resource;
/**
- * Representation of ID for allocated resource.
+ * Resource identifier.
*/
public interface ResourceId {
diff --git a/core/api/src/main/java/org/onosproject/net/resource/DeviceResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
similarity index 96%
rename from core/api/src/main/java/org/onosproject/net/resource/DeviceResourceService.java
rename to core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
index 10e5911..acbc486 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/DeviceResourceService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.device;
import org.onosproject.net.Port;
import org.onosproject.net.intent.Intent;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/DeviceResourceStore.java b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
similarity index 95%
rename from core/api/src/main/java/org/onosproject/net/resource/DeviceResourceStore.java
rename to core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
index 5df661c..3437f4b 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/DeviceResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java b/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java
similarity index 97%
rename from core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java
index 3c8ebea..bd0ba23 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import org.onlab.util.Bandwidth;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java
similarity index 90%
rename from core/api/src/main/java/org/onosproject/net/resource/BandwidthResourceAllocation.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java
index 7260536..de2f52f 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResourceAllocation.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
+import org.onosproject.net.resource.ResourceAllocation;
+import org.onosproject.net.resource.ResourceType;
/**
* Representation of allocated bandwidth resource.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java
similarity index 93%
rename from core/api/src/main/java/org/onosproject/net/resource/BandwidthResourceRequest.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java
index bf72d42..91cc3d1 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResourceRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java
@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Objects;
import com.google.common.base.MoreObjects;
+import org.onosproject.net.resource.ResourceRequest;
+import org.onosproject.net.resource.ResourceType;
/**
* Representation of a request for bandwidth resource.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceAllocations.java b/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java
similarity index 94%
rename from core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceAllocations.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java
index 3a2f66d..0227d3f 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceAllocations.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -23,6 +23,9 @@
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
+import org.onosproject.net.resource.ResourceAllocation;
+import org.onosproject.net.resource.ResourceRequest;
+import org.onosproject.net.resource.ResourceType;
import java.util.Collection;
import java.util.Collections;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
similarity index 97%
rename from core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
index 8d08e3b..5153aeb 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Collection;
import java.util.HashSet;
@@ -29,6 +29,8 @@
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.constraint.LambdaConstraint;
+import org.onosproject.net.resource.ResourceRequest;
+import org.onosproject.net.resource.ResourceType;
/**
* Implementation of {@link LinkResourceRequest}.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LambdaResource.java b/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java
similarity index 98%
rename from core/api/src/main/java/org/onosproject/net/resource/LambdaResource.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java
index e4df34e..7ed8847 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LambdaResource.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import org.onosproject.net.IndexedLambda;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LambdaResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java
similarity index 92%
rename from core/api/src/main/java/org/onosproject/net/resource/LambdaResourceAllocation.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java
index e34dab5..210bba6 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LambdaResourceAllocation.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
+import org.onosproject.net.resource.ResourceAllocation;
+import org.onosproject.net.resource.ResourceType;
import java.util.Objects;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LambdaResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java
similarity index 87%
rename from core/api/src/main/java/org/onosproject/net/resource/LambdaResourceRequest.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java
index de64a17..b0391f5 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LambdaResourceRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
+import org.onosproject.net.resource.ResourceRequest;
+import org.onosproject.net.resource.ResourceType;
/**
* Representation of a request for lambda resource.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResource.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java
similarity index 93%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResource.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java
index 2c83dab..6cfa38d 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResource.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
/**
* Abstraction of link resource.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceAllocations.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java
similarity index 90%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceAllocations.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java
index ebca82a..172e902 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceAllocations.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java
@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Set;
import org.onosproject.net.Link;
+import org.onosproject.net.resource.ResourceAllocation;
/**
* Representation of allocated link resources.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceEvent.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java
similarity index 96%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceEvent.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java
index d98e9c4..3edb386 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceEvent.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Collection;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceListener.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java
similarity index 94%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceListener.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java
index 80545b4..599dd4f 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceListener.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import org.onosproject.event.EventListener;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java
similarity index 95%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceRequest.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java
index d0ed945..8023a92 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Collection;
import java.util.Set;
@@ -21,6 +21,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentId;
+import org.onosproject.net.resource.ResourceRequest;
/**
* Representation of a request for link resource.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java
similarity index 96%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceService.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java
index 1d1e697..69bdf4f 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
+import org.onosproject.net.resource.ResourceRequest;
/**
* Service for providing link resource allocation.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceStore.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java
similarity index 95%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceStore.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java
index e3e9db8..e6674db 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Set;
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
+import org.onosproject.net.resource.ResourceAllocation;
/**
* Manages link resources.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceStoreDelegate.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java
similarity index 94%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResourceStoreDelegate.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java
index e108349..6c051d6 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResourceStoreDelegate.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import org.onosproject.store.StoreDelegate;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/LinkResources.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java
similarity index 97%
rename from core/api/src/main/java/org/onosproject/net/resource/LinkResources.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java
index 71fb4f4..dc00522 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/LinkResources.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Set;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/MplsLabel.java b/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java
similarity index 97%
rename from core/api/src/main/java/org/onosproject/net/resource/MplsLabel.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java
index 51bb5a7..317a130 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/MplsLabel.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import java.util.Objects;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/MplsLabelResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java
similarity index 93%
rename from core/api/src/main/java/org/onosproject/net/resource/MplsLabelResourceAllocation.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java
index 995c4a6..1b3b8fc 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/MplsLabelResourceAllocation.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java
@@ -14,9 +14,11 @@
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
+import org.onosproject.net.resource.ResourceAllocation;
+import org.onosproject.net.resource.ResourceType;
import java.util.Objects;
diff --git a/core/api/src/main/java/org/onosproject/net/resource/MplsLabelResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java
similarity index 87%
rename from core/api/src/main/java/org/onosproject/net/resource/MplsLabelResourceRequest.java
rename to core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java
index be1f758..0a03f45 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/MplsLabelResourceRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.net.resource;
+package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
+import org.onosproject.net.resource.ResourceRequest;
+import org.onosproject.net.resource.ResourceType;
/**
* Representation of a request for lambda resource.
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java b/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
index 6e03412..60857ca 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
@@ -19,7 +19,7 @@
import org.junit.Before;
import org.junit.Test;
import org.onosproject.core.IdGenerator;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 47faf4a..6c7fe13 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -36,17 +36,17 @@
import org.onosproject.net.flow.criteria.Criterion.Type;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceRequest;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LambdaResourceRequest;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceListener;
-import org.onosproject.net.resource.LinkResourceRequest;
-import org.onosproject.net.resource.LinkResourceService;
-import org.onosproject.net.resource.MplsLabel;
-import org.onosproject.net.resource.MplsLabelResourceAllocation;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceRequest;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LambdaResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceListener;
+import org.onosproject.net.resource.link.LinkResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceService;
+import org.onosproject.net.resource.link.MplsLabel;
+import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
index 988b0b4..88fa7f4 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
@@ -26,7 +26,7 @@
import org.onosproject.net.NetTestTools;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.intent.constraint.LambdaConstraint;
-import org.onosproject.net.resource.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResource;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/constraint/AnnotationConstraintTest.java b/core/api/src/test/java/org/onosproject/net/intent/constraint/AnnotationConstraintTest.java
index c4f3a36..b87dc12 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/constraint/AnnotationConstraintTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/constraint/AnnotationConstraintTest.java
@@ -24,7 +24,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import static org.easymock.EasyMock.createMock;
import static org.hamcrest.Matchers.closeTo;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java b/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
index cc29a25..743fc252 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
@@ -18,8 +18,8 @@
import org.junit.Test;
import org.onlab.util.Bandwidth;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.LambdaResource;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.LambdaResource;
import com.google.common.testing.EqualsTester;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/constraint/LatencyConstraintTest.java b/core/api/src/test/java/org/onosproject/net/intent/constraint/LatencyConstraintTest.java
index 3d9429e..bab1749 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/constraint/LatencyConstraintTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/constraint/LatencyConstraintTest.java
@@ -27,7 +27,7 @@
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/constraint/ObstacleConstraintTest.java b/core/api/src/test/java/org/onosproject/net/intent/constraint/ObstacleConstraintTest.java
index 291610a..f02787f 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/constraint/ObstacleConstraintTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/constraint/ObstacleConstraintTest.java
@@ -27,7 +27,7 @@
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Arrays;
diff --git a/core/api/src/test/java/org/onosproject/net/intent/constraint/WaypointConstraintTest.java b/core/api/src/test/java/org/onosproject/net/intent/constraint/WaypointConstraintTest.java
index 8e15711..f7e212a 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/constraint/WaypointConstraintTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/constraint/WaypointConstraintTest.java
@@ -25,7 +25,7 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Arrays;
diff --git a/core/api/src/test/java/org/onosproject/net/resource/DefaultLabelResourceTest.java b/core/api/src/test/java/org/onosproject/net/resource/DefaultLabelResourceTest.java
deleted file mode 100644
index 0e5ec27..0000000
--- a/core/api/src/test/java/org/onosproject/net/resource/DefaultLabelResourceTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.junit.Test;
-import org.onosproject.event.AbstractEventTest;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Tests of default label resource.
- */
-public class DefaultLabelResourceTest extends AbstractEventTest {
-
- @Test
- public void testEquality() {
- String deviceId1 = "of:001";
- String deviceId2 = "of:002";
- long labelResourceId1 = 100;
- long labelResourceId2 = 200;
- DefaultLabelResource h1 = new DefaultLabelResource(deviceId1,
- labelResourceId1);
- DefaultLabelResource h2 = new DefaultLabelResource(deviceId1,
- labelResourceId1);
- DefaultLabelResource h3 = new DefaultLabelResource(deviceId2,
- labelResourceId2);
- DefaultLabelResource h4 = new DefaultLabelResource(deviceId2,
- labelResourceId2);
-
- new EqualsTester().addEqualityGroup(h1, h2).addEqualityGroup(h3, h4)
- .testEquals();
- }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/resource/LabelResourcePoolTest.java b/core/api/src/test/java/org/onosproject/net/resource/LabelResourcePoolTest.java
deleted file mode 100644
index f4d91c1..0000000
--- a/core/api/src/test/java/org/onosproject/net/resource/LabelResourcePoolTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.onosproject.net.resource;
-
-import org.junit.Test;
-import org.onosproject.event.AbstractEventTest;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Tests of the label resource pool.
- */
-public class LabelResourcePoolTest extends AbstractEventTest {
-
- @Test
- public void testEquality() {
- LabelResourcePool h1 = new LabelResourcePool("of:001", 0, 100);
- LabelResourcePool h2 = new LabelResourcePool("of:001", 0, 100);
- LabelResourcePool h3 = new LabelResourcePool("of:002", 0, 100);
- LabelResourcePool h4 = new LabelResourcePool("of:002", 0, 100);
- new EqualsTester().addEqualityGroup(h1, h2).addEqualityGroup(h3, h4)
- .testEquals();
- }
-
-}
diff --git a/core/api/src/test/java/org/onosproject/net/resource/LabelResourceRequestTest.java b/core/api/src/test/java/org/onosproject/net/resource/LabelResourceRequestTest.java
deleted file mode 100644
index bc538b2..0000000
--- a/core/api/src/test/java/org/onosproject/net/resource/LabelResourceRequestTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.onosproject.net.resource;
-
-import java.util.Collections;
-
-import org.junit.Test;
-import org.onosproject.event.AbstractEventTest;
-import org.onosproject.net.DeviceId;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.testing.EqualsTester;
-
-/**
- * Tests of the label resource request.
- */
-public class LabelResourceRequestTest extends AbstractEventTest {
-
- @Test
- public void testEquality() {
- DeviceId deviceId1 = DeviceId.deviceId("of:0001");
- DeviceId deviceId2 = DeviceId.deviceId("of:0002");
- long apply = 2;
- ImmutableSet<LabelResource> releaseCollection = ImmutableSet
- .copyOf(Collections.emptySet());
- LabelResourceRequest h1 = new LabelResourceRequest(
- deviceId1,
- LabelResourceRequest.Type.APPLY,
- apply, null);
- LabelResourceRequest h2 = new LabelResourceRequest(
- deviceId1,
- LabelResourceRequest.Type.APPLY,
- apply, null);
- LabelResourceRequest h3 = new LabelResourceRequest(
- deviceId2,
- LabelResourceRequest.Type.RELEASE,
- 0, releaseCollection);
- LabelResourceRequest h4 = new LabelResourceRequest(
- deviceId2,
- LabelResourceRequest.Type.RELEASE,
- 0, releaseCollection);
-
- new EqualsTester().addEqualityGroup(h1, h2).addEqualityGroup(h3, h4)
- .testEquals();
- }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/resource/MplsObjectsTest.java b/core/api/src/test/java/org/onosproject/net/resource/MplsObjectsTest.java
index 42ee5f4..56f7a47 100644
--- a/core/api/src/test/java/org/onosproject/net/resource/MplsObjectsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/resource/MplsObjectsTest.java
@@ -18,6 +18,8 @@
import org.junit.Test;
import com.google.common.testing.EqualsTester;
+import org.onosproject.net.resource.link.MplsLabel;
+import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
index 2104654..94a5bda 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
@@ -49,8 +49,8 @@
import org.onosproject.net.intent.constraint.LatencyConstraint;
import org.onosproject.net.intent.constraint.ObstacleConstraint;
import org.onosproject.net.intent.constraint.WaypointConstraint;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.LambdaResource;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.LambdaResource;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableList;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
index b7ad184..939b9a1 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
@@ -41,9 +41,9 @@
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.Key;
import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.resource.LinkResourceEvent;
-import org.onosproject.net.resource.LinkResourceListener;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceEvent;
+import org.onosproject.net.resource.link.LinkResourceListener;
+import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.topology.TopologyEvent;
import org.onosproject.net.topology.TopologyListener;
import org.onosproject.net.topology.TopologyService;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
index d9e68bd..0a73d9a 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
@@ -29,7 +29,7 @@
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.impl.PathNotFoundException;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyEdge;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
index d8990ea..4116825 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
@@ -31,7 +31,7 @@
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.intent.constraint.AsymmetricPathConstraint;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
index 94f85bd..9085f08 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
@@ -41,7 +41,7 @@
import org.onosproject.net.intent.IntentCompiler;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.LinkCollectionIntent;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
index b59d7eb..609f9a3 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
@@ -19,7 +19,7 @@
import org.onosproject.net.intent.MplsIntent;
import org.onosproject.net.intent.MplsPathIntent;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
@Component(immediate = true)
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
index 9f835cf..d6eae35 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
@@ -42,12 +42,12 @@
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.MplsPathIntent;
import org.onosproject.net.link.LinkStore;
-import org.onosproject.net.resource.DefaultLinkResourceRequest;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceRequest;
-import org.onosproject.net.resource.LinkResourceService;
-import org.onosproject.net.resource.MplsLabel;
-import org.onosproject.net.resource.MplsLabelResourceAllocation;
+import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceService;
+import org.onosproject.net.resource.link.MplsLabel;
+import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceType;
import org.slf4j.Logger;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index d004d6f..3a40622 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -37,7 +37,7 @@
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.impl.PathNotFoundException;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import org.onosproject.net.topology.PathService;
import com.google.common.collect.ImmutableSet;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index 91c9df3..4f8527e 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -40,13 +40,13 @@
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.OpticalPathIntent;
-import org.onosproject.net.resource.DefaultLinkResourceRequest;
-import org.onosproject.net.resource.DeviceResourceService;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceRequest;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
+import org.onosproject.net.resource.device.DeviceResourceService;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceType;
import org.onosproject.net.topology.LinkWeight;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java
index 84368d9..f4b11db 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java
@@ -37,8 +37,8 @@
import org.onosproject.net.intent.IntentCompiler;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalPathIntent;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Collections;
import java.util.LinkedList;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
index 61c13e7..d6187cd 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
@@ -35,7 +35,7 @@
import org.onosproject.net.intent.IntentCompiler;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.PathIntent;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
index 1c24d90..5644ee2 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
@@ -26,7 +26,7 @@
import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.ArrayList;
import java.util.List;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
index 0021cd2..91341d2 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
@@ -30,7 +30,7 @@
import org.onosproject.net.intent.LinkCollectionIntent;
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import com.google.common.collect.ImmutableSet;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
index 63f8ebb..50a6754 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
@@ -22,7 +22,7 @@
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.TwoWayP2PIntent;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import java.util.List;
import java.util.Set;
diff --git a/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java b/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
index cfa290b..71fa9d5 100644
--- a/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
@@ -25,8 +25,8 @@
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.intent.OpticalConnectivityIntent;
-import org.onosproject.net.resource.DeviceResourceService;
-import org.onosproject.net.resource.DeviceResourceStore;
+import org.onosproject.net.resource.device.DeviceResourceService;
+import org.onosproject.net.resource.device.DeviceResourceStore;
import org.slf4j.Logger;
import java.util.Arrays;
diff --git a/core/net/src/main/java/org/onosproject/net/resource/impl/LabelResourceManager.java b/core/net/src/main/java/org/onosproject/net/resource/impl/LabelResourceManager.java
deleted file mode 100644
index e719ab8..0000000
--- a/core/net/src/main/java/org/onosproject/net/resource/impl/LabelResourceManager.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package org.onosproject.net.resource.impl;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.event.EventDeliveryService;
-import org.onosproject.event.ListenerRegistry;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceEvent.Type;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.provider.AbstractProviderRegistry;
-import org.onosproject.net.provider.AbstractProviderService;
-import org.onosproject.net.resource.LabelResource;
-import org.onosproject.net.resource.LabelResourceAdminService;
-import org.onosproject.net.resource.LabelResourceDelegate;
-import org.onosproject.net.resource.LabelResourceEvent;
-import org.onosproject.net.resource.LabelResourceId;
-import org.onosproject.net.resource.LabelResourceListener;
-import org.onosproject.net.resource.LabelResourcePool;
-import org.onosproject.net.resource.LabelResourceProvider;
-import org.onosproject.net.resource.LabelResourceProviderRegistry;
-import org.onosproject.net.resource.LabelResourceProviderService;
-import org.onosproject.net.resource.LabelResourceService;
-import org.onosproject.net.resource.LabelResourceStore;
-import org.slf4j.Logger;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkArgument;
-
-import com.google.common.collect.Multimap;
-
-/**
- * provides implementation of the label resource NB & SB APIs.
- *
- */
-@Component(immediate = true)
-@Service
-public class LabelResourceManager
- extends
- AbstractProviderRegistry<LabelResourceProvider, LabelResourceProviderService>
- implements LabelResourceService, LabelResourceAdminService,
- LabelResourceProviderRegistry {
- private final Logger log = getLogger(getClass());
- private final LabelResourceDelegate delegate = new InternalLabelResourceDelegate();
-
- private final ListenerRegistry<LabelResourceEvent, LabelResourceListener> listenerRegistry
- = new ListenerRegistry<>();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LabelResourceStore store;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected EventDeliveryService eventDispatcher;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- private DeviceListener deviceListener = new InternalDeviceListener();
-
- @Activate
- public void activate() {
- store.setDelegate(delegate);
- eventDispatcher.addSink(LabelResourceEvent.class, listenerRegistry);
- deviceService.addListener(deviceListener);
- log.info("Started");
-
- }
-
- @Deactivate
- public void deactivate() {
- deviceService.removeListener(deviceListener);
- store.unsetDelegate(delegate);
- eventDispatcher.removeSink(LabelResourceEvent.class);
- log.info("Stopped");
- }
-
- @Override
- public boolean createDevicePool(DeviceId deviceId,
- LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- checkNotNull(deviceId, "deviceId is not null");
- checkNotNull(beginLabel, "beginLabel is not null");
- checkNotNull(endLabel, "beginLabel is not null");
- checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0,
- "The value of beginLabel and the value of endLabel must be both positive number.");
- checkArgument(beginLabel.labelId() > endLabel.labelId(),
- "The value of endLabel must be greater than the value of endLabel.");
- return store.createDevicePool(deviceId, beginLabel, endLabel);
- }
-
- @Override
- public boolean createGlobalPool(LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- checkNotNull(beginLabel, "beginLabel is not null");
- checkNotNull(endLabel, "beginLabel is not null");
- checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0,
- "The value of beginLabel and the value of endLabel must be both positive number.");
- checkArgument(beginLabel.labelId() > endLabel.labelId(),
- "The value of endLabel must be greater than the value of endLabel.");
- return store.createGlobalPool(beginLabel, endLabel);
- }
-
- @Override
- public boolean destroyDevicePool(DeviceId deviceId) {
- checkNotNull(deviceId, "deviceId is not null");
- return store.destroyDevicePool(deviceId);
- }
-
- @Override
- public boolean destroyGlobalPool() {
- return store.destroyGlobalPool();
- }
-
- @Override
- public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
- long applyNum) {
- checkNotNull(deviceId, "deviceId is not null");
- checkNotNull(applyNum, "applyNum is not null");
- return store.applyFromDevicePool(deviceId, applyNum);
- }
-
- @Override
- public Collection<LabelResource> applyFromGlobalPool(long applyNum) {
- checkNotNull(applyNum, "applyNum is not null");
- return store.applyFromGlobalPool(applyNum);
- }
-
- @Override
- public boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release) {
- checkNotNull(release, "release is not null");
- return store.releaseToDevicePool(release);
- }
-
- @Override
- public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
- checkNotNull(release, "release is not null");
- return store.releaseToGlobalPool(release);
- }
-
- @Override
- public boolean isDevicePoolFull(DeviceId deviceId) {
- checkNotNull(deviceId, "deviceId is not null");
- return store.isDevicePoolFull(deviceId);
- }
-
- @Override
- public boolean isGlobalPoolFull() {
- return store.isGlobalPoolFull();
- }
-
- @Override
- public long getFreeNumOfDevicePool(DeviceId deviceId) {
- checkNotNull(deviceId, "deviceId is not null");
- return store.getFreeNumOfDevicePool(deviceId);
- }
-
- @Override
- public long getFreeNumOfGlobalPool() {
- return store.getFreeNumOfGlobalPool();
- }
-
- @Override
- public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) {
- checkNotNull(deviceId, "deviceId is not null");
- return store.getDeviceLabelResourcePool(deviceId);
- }
-
- @Override
- public LabelResourcePool getGlobalLabelResourcePool() {
- return store.getGlobalLabelResourcePool();
- }
-
- @Override
- public void addListener(LabelResourceListener listener) {
- listenerRegistry.addListener(listener);
- }
-
- @Override
- public void removeListener(LabelResourceListener listener) {
- listenerRegistry.removeListener(listener);
-
- }
-
- private void post(LabelResourceEvent event) {
- if (event != null) {
- eventDispatcher.post(event);
- }
- }
-
- private class InternalLabelResourceDelegate
- implements LabelResourceDelegate {
-
- @Override
- public void notify(LabelResourceEvent event) {
- post(event);
- }
-
- }
-
- private class InternalDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (Type.DEVICE_REMOVED.equals(event.type())) {
- destroyDevicePool(device.id());
- }
- }
- }
-
- private class InternalLabelResourceProviderService
- extends AbstractProviderService<LabelResourceProvider>
- implements LabelResourceProviderService {
-
- protected InternalLabelResourceProviderService(LabelResourceProvider provider) {
- super(provider);
- }
-
- @Override
- public void deviceLabelResourcePoolDetected(DeviceId deviceId,
- LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- checkNotNull(deviceId, "deviceId is not null");
- checkNotNull(beginLabel, "beginLabel is not null");
- checkNotNull(endLabel, "endLabel is not null");
- createDevicePool(deviceId, beginLabel, endLabel);
- }
-
- @Override
- public void deviceLabelResourcePoolDestroyed(DeviceId deviceId) {
- checkNotNull(deviceId, "deviceId is not null");
- destroyDevicePool(deviceId);
- }
-
- }
-
- @Override
- protected LabelResourceProviderService createProviderService(LabelResourceProvider provider) {
- return new InternalLabelResourceProviderService(provider);
- }
-}
diff --git a/core/net/src/main/java/org/onosproject/net/resource/impl/LinkResourceManager.java b/core/net/src/main/java/org/onosproject/net/resource/impl/LinkResourceManager.java
index 57bae5a..6b02edd 100644
--- a/core/net/src/main/java/org/onosproject/net/resource/impl/LinkResourceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/resource/impl/LinkResourceManager.java
@@ -25,22 +25,22 @@
import org.onosproject.event.EventDeliveryService;
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.BandwidthResourceRequest;
-import org.onosproject.net.resource.DefaultLinkResourceAllocations;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LambdaResourceRequest;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceEvent;
-import org.onosproject.net.resource.LinkResourceListener;
-import org.onosproject.net.resource.LinkResourceRequest;
-import org.onosproject.net.resource.LinkResourceService;
-import org.onosproject.net.resource.LinkResourceStore;
-import org.onosproject.net.resource.LinkResourceStoreDelegate;
-import org.onosproject.net.resource.MplsLabel;
-import org.onosproject.net.resource.MplsLabelResourceAllocation;
-import org.onosproject.net.resource.MplsLabelResourceRequest;
+import org.onosproject.net.resource.link.BandwidthResourceAllocation;
+import org.onosproject.net.resource.link.BandwidthResourceRequest;
+import org.onosproject.net.resource.link.DefaultLinkResourceAllocations;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LambdaResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceEvent;
+import org.onosproject.net.resource.link.LinkResourceListener;
+import org.onosproject.net.resource.link.LinkResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceService;
+import org.onosproject.net.resource.link.LinkResourceStore;
+import org.onosproject.net.resource.link.LinkResourceStoreDelegate;
+import org.onosproject.net.resource.link.MplsLabel;
+import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
+import org.onosproject.net.resource.link.MplsLabelResourceRequest;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
index d48d107..ca75a20 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
@@ -43,7 +43,7 @@
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
import org.onosproject.net.intent.Key;
-import org.onosproject.net.resource.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
import org.onosproject.store.trivial.impl.SimpleIntentStore;
import java.util.Collection;
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java
index 70b00e0..58fa129 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java
@@ -38,8 +38,8 @@
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.resource.LinkResourceEvent;
-import org.onosproject.net.resource.LinkResourceListener;
+import org.onosproject.net.resource.link.LinkResourceEvent;
+import org.onosproject.net.resource.link.LinkResourceListener;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyEvent;
import org.onosproject.net.topology.TopologyListener;
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
index 32d917f..e57d9db 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
@@ -34,9 +34,9 @@
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.intent.impl.PathNotFoundException;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LinkResourceService;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Collections;
import java.util.List;
diff --git a/core/security/impl/src/main/java/org/onosproject/security/impl/PolicyBuilder.java b/core/security/impl/src/main/java/org/onosproject/security/impl/PolicyBuilder.java
index 31174c6..436ed0f 100644
--- a/core/security/impl/src/main/java/org/onosproject/security/impl/PolicyBuilder.java
+++ b/core/security/impl/src/main/java/org/onosproject/security/impl/PolicyBuilder.java
@@ -36,9 +36,7 @@
import org.onosproject.net.link.LinkService;
import org.onosproject.net.packet.PacketService;
import org.onosproject.net.proxyarp.ProxyArpService;
-import org.onosproject.net.resource.LabelResourceAdminService;
-import org.onosproject.net.resource.LinkResourceService;
-import org.onosproject.net.resource.LabelResourceService;
+import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.statistic.StatisticService;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyService;
@@ -107,8 +105,8 @@
DriverAdminService.class.getName(), ServicePermission.GET),
new PermissionInfo(ServicePermission.class.getName(),
StorageAdminService.class.getName(), ServicePermission.GET),
- new PermissionInfo(ServicePermission.class.getName(),
- LabelResourceAdminService.class.getName(), ServicePermission.GET),
+// new PermissionInfo(ServicePermission.class.getName(),
+// LabelResourceAdminService.class.getName(), ServicePermission.GET),
// new PermissionInfo(ServicePermission.class.getName(),
// TunnelAdminService.class.getName(), ServicePermission.GET),
new PermissionInfo(ServicePermission.class.getName(),
@@ -151,8 +149,8 @@
LinkService.class.getName(), ServicePermission.GET),
new PermissionInfo(ServicePermission.class.getName(),
LinkResourceService.class.getName(), ServicePermission.GET),
- new PermissionInfo(ServicePermission.class.getName(),
- LabelResourceService.class.getName(), ServicePermission.GET),
+// new PermissionInfo(ServicePermission.class.getName(),
+// LabelResourceService.class.getName(), ServicePermission.GET),
new PermissionInfo(ServicePermission.class.getName(),
PacketService.class.getName(), ServicePermission.GET),
new PermissionInfo(ServicePermission.class.getName(),
@@ -224,14 +222,14 @@
IntentService.class.getName()));
serviceDirectory.put(Permission.INTENT_EVENT, ImmutableSet.of(
IntentService.class.getName()));
- serviceDirectory.put(Permission.LINK_READ, ImmutableSet.of(
- LinkService.class.getName(), LinkResourceService.class.getName(),
- LabelResourceService.class.getName()));
- serviceDirectory.put(Permission.LINK_WRITE, ImmutableSet.of(
- LinkResourceService.class.getName(), LabelResourceService.class.getName()));
- serviceDirectory.put(Permission.LINK_EVENT, ImmutableSet.of(
- LinkService.class.getName(), LinkResourceService.class.getName(),
- LabelResourceService.class.getName()));
+// serviceDirectory.put(Permission.LINK_READ, ImmutableSet.of(
+// LinkService.class.getName(), LinkResourceService.class.getName(),
+// LabelResourceService.class.getName()));
+// serviceDirectory.put(Permission.LINK_WRITE, ImmutableSet.of(
+// LinkResourceService.class.getName(), LabelResourceService.class.getName()));
+// serviceDirectory.put(Permission.LINK_EVENT, ImmutableSet.of(
+// LinkService.class.getName(), LinkResourceService.class.getName(),
+// LabelResourceService.class.getName()));
serviceDirectory.put(Permission.PACKET_READ, ImmutableSet.of(
PacketService.class.getName(), ProxyArpService.class.getName()));
serviceDirectory.put(Permission.PACKET_WRITE, ImmutableSet.of(
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
index f7f459c..7f45343 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
@@ -69,7 +69,7 @@
import org.onosproject.store.cluster.messaging.MessageSubject;
import org.onosproject.store.impl.Timestamped;
import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
+import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
import org.slf4j.Logger;
import java.io.IOException;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java
index 828b5a0..35d004e 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java
@@ -66,7 +66,7 @@
import org.onosproject.store.flow.ReplicaInfoService;
import org.onosproject.store.serializers.KryoSerializer;
import org.onosproject.store.serializers.StoreSerializer;
-import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
+import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/host/impl/GossipHostStore.java b/core/store/dist/src/main/java/org/onosproject/store/host/impl/GossipHostStore.java
index f5178de..b2e4b97 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/host/impl/GossipHostStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/host/impl/GossipHostStore.java
@@ -62,7 +62,7 @@
import org.onosproject.store.cluster.messaging.MessageSubject;
import org.onosproject.store.impl.Timestamped;
import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
+import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
import org.slf4j.Logger;
import java.io.IOException;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java b/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
index c6a6106..c5045ab 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
@@ -58,7 +58,7 @@
import org.onosproject.store.cluster.messaging.MessageSubject;
import org.onosproject.store.impl.Timestamped;
import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
+import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
import org.slf4j.Logger;
import java.io.IOException;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
index b5e1655..bfdc536 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
@@ -26,7 +26,7 @@
import org.onosproject.net.Port;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.DeviceResourceStore;
+import org.onosproject.net.resource.device.DeviceResourceStore;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.Serializer;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index 454d04c..84f7bb2 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -26,16 +26,16 @@
import org.onosproject.net.LinkKey;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.link.LinkService;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceEvent;
-import org.onosproject.net.resource.LinkResourceStore;
-import org.onosproject.net.resource.LinkResourceStoreDelegate;
-import org.onosproject.net.resource.MplsLabel;
-import org.onosproject.net.resource.MplsLabelResourceAllocation;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceAllocation;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceEvent;
+import org.onosproject.net.resource.link.LinkResourceStore;
+import org.onosproject.net.resource.link.LinkResourceStoreDelegate;
+import org.onosproject.net.resource.link.MplsLabel;
+import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceAllocationException;
import org.onosproject.net.resource.ResourceType;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/DistributedLabelResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/DistributedLabelResourceStore.java
deleted file mode 100644
index ce122c0..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/DistributedLabelResourceStore.java
+++ /dev/null
@@ -1,578 +0,0 @@
-package org.onosproject.store.resource.impl;
-
-import static org.onlab.util.Tools.groupedThreads;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.resource.DefaultLabelResource;
-import org.onosproject.net.resource.LabelResource;
-import org.onosproject.net.resource.LabelResourceDelegate;
-import org.onosproject.net.resource.LabelResourceEvent;
-import org.onosproject.net.resource.LabelResourceEvent.Type;
-import org.onosproject.net.resource.LabelResourceId;
-import org.onosproject.net.resource.LabelResourcePool;
-import org.onosproject.net.resource.LabelResourceRequest;
-import org.onosproject.net.resource.LabelResourceStore;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
-import org.onosproject.store.cluster.messaging.ClusterMessage;
-import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
-import org.onosproject.store.flow.ReplicaInfo;
-import org.onosproject.store.flow.ReplicaInfoService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.slf4j.Logger;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-
-/**
- * Manages label resources using copycat.
- */
-@Component(immediate = true, enabled = true)
-@Service
-public class DistributedLabelResourceStore
- extends AbstractStore<LabelResourceEvent, LabelResourceDelegate>
- implements LabelResourceStore {
- private final Logger log = getLogger(getClass());
-
- private static final String POOL_MAP_NAME = "labelresourcepool";
-
- private static final String GLOBAL_RESOURCE_POOL_DEVICE_ID = "global_resource_pool_device_id";
- // primary data:
- // read/write needs to be locked
- private final ReentrantReadWriteLock resourcePoolLock = new ReentrantReadWriteLock();
-
- private ConsistentMap<DeviceId, LabelResourcePool> resourcePool = null;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ReplicaInfoService replicaInfoManager;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterCommunicationService clusterCommunicator;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- private ExecutorService messageHandlingExecutor;
- private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 8;
- private static final long PEER_REQUEST_TIMEOUT_MS = 5000;
-
- protected static final KryoSerializer SERIALIZER = new KryoSerializer() {
- @Override
- protected void setupKryoPool() {
- serializerPool = KryoNamespace.newBuilder()
- .register(DistributedStoreSerializers.STORE_COMMON)
- .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
- .register(LabelResourceEvent.class)
- .register(LabelResourcePool.class).register(DeviceId.class)
- .register(LabelResourceRequest.class)
- .register(LabelResourceRequest.Type.class)
- .register(LabelResourceEvent.Type.class)
- .register(DefaultLabelResource.class)
- .register(LabelResourceId.class).build();
- }
- };
-
- @Activate
- public void activate() {
-
- resourcePool = storageService
- .<DeviceId, LabelResourcePool>consistentMapBuilder()
- .withName(POOL_MAP_NAME).withSerializer(new Serializer() {
- KryoNamespace kryo = new KryoNamespace.Builder()
- .register(KryoNamespaces.API).build();
-
- @Override
- public <T> byte[] encode(T object) {
- return kryo.serialize(object);
- }
-
- @Override
- public <T> T decode(byte[] bytes) {
- return kryo.deserialize(bytes);
- }
- }).withPartitionsDisabled().build();
- messageHandlingExecutor = Executors
- .newFixedThreadPool(MESSAGE_HANDLER_THREAD_POOL_SIZE,
- groupedThreads("onos/store/flow",
- "message-handlers"));
- clusterCommunicator
- .addSubscriber(LabelResourceMessageSubjects.LABEL_POOL_CREATED,
- new ClusterMessageHandler() {
-
- @Override
- public void handle(ClusterMessage message) {
- LabelResourcePool operation = SERIALIZER
- .decode(message.payload());
- log.trace("received get flow entry request for {}",
- operation);
- boolean b = internalCreate(operation);
- message.respond(SERIALIZER.encode(b));
- }
- }, messageHandlingExecutor);
- clusterCommunicator
- .addSubscriber(LabelResourceMessageSubjects.LABEL_POOL_DESTROYED,
- new ClusterMessageHandler() {
-
- @Override
- public void handle(ClusterMessage message) {
- DeviceId deviceId = SERIALIZER
- .decode(message.payload());
- log.trace("received get flow entry request for {}",
- deviceId);
- boolean b = internalDestroy(deviceId);
- message.respond(SERIALIZER.encode(b));
- }
- }, messageHandlingExecutor);
- clusterCommunicator
- .addSubscriber(LabelResourceMessageSubjects.LABEL_POOL_APPLY,
- new ClusterMessageHandler() {
-
- @Override
- public void handle(ClusterMessage message) {
- LabelResourceRequest request = SERIALIZER
- .decode(message.payload());
- log.trace("received get flow entry request for {}",
- request);
- final Collection<LabelResource> resource = internalApply(request);
- message.respond(SERIALIZER
- .encode(resource));
- }
- }, messageHandlingExecutor);
- clusterCommunicator
- .addSubscriber(LabelResourceMessageSubjects.LABEL_POOL_RELEASE,
- new ClusterMessageHandler() {
-
- @Override
- public void handle(ClusterMessage message) {
- LabelResourceRequest request = SERIALIZER
- .decode(message.payload());
- log.trace("received get flow entry request for {}",
- request);
- final boolean isSuccess = internalRelease(request);
- message.respond(SERIALIZER
- .encode(isSuccess));
- }
- }, messageHandlingExecutor);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- clusterCommunicator
- .removeSubscriber(LabelResourceMessageSubjects.LABEL_POOL_CREATED);
- clusterCommunicator
- .removeSubscriber(LabelResourceMessageSubjects.LABEL_POOL_APPLY);
- clusterCommunicator
- .removeSubscriber(LabelResourceMessageSubjects.LABEL_POOL_DESTROYED);
- clusterCommunicator
- .removeSubscriber(LabelResourceMessageSubjects.LABEL_POOL_RELEASE);
- messageHandlingExecutor.shutdown();
- log.info("Stopped");
- }
-
- @Override
- public boolean createDevicePool(DeviceId deviceId,
- LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- LabelResourcePool pool = new LabelResourcePool(deviceId.toString(),
- beginLabel.labelId(),
- endLabel.labelId());
- return this.create(pool);
- }
-
- @Override
- public boolean createGlobalPool(LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- LabelResourcePool pool = new LabelResourcePool(
- GLOBAL_RESOURCE_POOL_DEVICE_ID,
- beginLabel.labelId(),
- endLabel.labelId());
- return this.internalCreate(pool);
- }
-
- private boolean create(LabelResourcePool pool) {
- Device device = (Device) deviceService.getDevice(pool.deviceId());
- if (device == null) {
- return false;
- }
-
- ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(pool
- .deviceId());
-
- if (!replicaInfo.master().isPresent()) {
- log.warn("Failed to getFlowEntries: No master for {}", pool);
- return false;
- }
-
- if (replicaInfo.master().get()
- .equals(clusterService.getLocalNode().id())) {
- return internalCreate(pool);
- }
-
- log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}",
- replicaInfo.master().orNull(), pool.deviceId());
-
- return complete(clusterCommunicator
- .sendAndReceive(pool,
- LabelResourceMessageSubjects.LABEL_POOL_CREATED,
- SERIALIZER::encode, SERIALIZER::decode,
- replicaInfo.master().get()));
- }
-
- private boolean internalCreate(LabelResourcePool pool) {
- resourcePoolLock.writeLock().lock();
- LabelResourcePool poolOld = resourcePool.get(pool.deviceId()).value();
- if (poolOld == null) {
- resourcePool.put(pool.deviceId(), pool);
- resourcePoolLock.writeLock().unlock();
- LabelResourceEvent event = new LabelResourceEvent(
- Type.POOL_CREATED,
- pool);
- notifyDelegate(event);
- return true;
- }
- resourcePoolLock.writeLock().unlock();
- return false;
- }
-
- @Override
- public boolean destroyDevicePool(DeviceId deviceId) {
- Device device = (Device) deviceService.getDevice(deviceId);
- if (device == null) {
- return false;
- }
- ReplicaInfo replicaInfo = replicaInfoManager
- .getReplicaInfoFor(deviceId);
-
- if (!replicaInfo.master().isPresent()) {
- log.warn("Failed to getFlowEntries: No master for {}", deviceId);
- return false;
- }
-
- if (replicaInfo.master().get()
- .equals(clusterService.getLocalNode().id())) {
- return internalDestroy(deviceId);
- }
-
- log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}",
- replicaInfo.master().orNull(), deviceId);
-
- return complete(clusterCommunicator
- .sendAndReceive(deviceId,
- LabelResourceMessageSubjects.LABEL_POOL_DESTROYED,
- SERIALIZER::encode, SERIALIZER::decode,
- replicaInfo.master().get()));
- }
-
- private boolean internalDestroy(DeviceId deviceId) {
- LabelResourcePool poolOld = resourcePool.get(deviceId).value();
- if (poolOld != null) {
- resourcePool.remove(deviceId);
- LabelResourceEvent event = new LabelResourceEvent(
- Type.POOL_CREATED,
- poolOld);
- notifyDelegate(event);
- }
- log.info("success to destroy the label resource pool of device id {}",
- deviceId);
- return true;
- }
-
- @Override
- public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
- long applyNum) {
- Device device = (Device) deviceService.getDevice(deviceId);
- if (device == null) {
- return Collections.emptyList();
- }
- LabelResourceRequest request = new LabelResourceRequest(
- deviceId,
- LabelResourceRequest.Type.APPLY,
- applyNum, null);
- ReplicaInfo replicaInfo = replicaInfoManager
- .getReplicaInfoFor(deviceId);
-
- if (!replicaInfo.master().isPresent()) {
- log.warn("Failed to getFlowEntries: No master for {}", deviceId);
- return Collections.emptyList();
- }
-
- if (replicaInfo.master().get()
- .equals(clusterService.getLocalNode().id())) {
- return internalApply(request);
- }
-
- log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}",
- replicaInfo.master().orNull(), deviceId);
-
- return complete(clusterCommunicator
- .sendAndReceive(request,
- LabelResourceMessageSubjects.LABEL_POOL_APPLY,
- SERIALIZER::encode, SERIALIZER::decode,
- replicaInfo.master().get()));
- }
-
- private Collection<LabelResource> internalApply(LabelResourceRequest request) {
- resourcePoolLock.writeLock().lock();
- DeviceId deviceId = request.deviceId();
- long applyNum = request.applyNum();
- LabelResourcePool pool = resourcePool.get(deviceId).value();
- Collection<LabelResource> result = new HashSet<LabelResource>();
- long freeNum = this.getFreeNumOfDevicePool(deviceId);
- if (applyNum > freeNum) {
- log.info("the free number of the label resource pool of deviceId {} is not enough.");
- resourcePoolLock.writeLock().unlock();
- return Collections.emptyList();
- }
- Set<LabelResource> releaseLabels = new HashSet<LabelResource>(
- pool.releaseLabelId());
- long tmp = releaseLabels.size() > applyNum ? applyNum : releaseLabels
- .size();
- LabelResource resource = null;
- for (int i = 0; i < tmp; i++) {
- Iterator<LabelResource> it = releaseLabels.iterator();
- if (it.hasNext()) {
- resource = it.next();
- releaseLabels.remove(resource);
- }
- result.add(resource);
- }
- for (long j = pool.currentUsedMaxLabelId().labelId(); j < pool
- .currentUsedMaxLabelId().labelId() + applyNum - tmp; j++) {
- resource = new DefaultLabelResource(deviceId,
- LabelResourceId
- .labelResourceId(j));
- result.add(resource);
- }
- long beginLabel = pool.beginLabel().labelId();
- long endLabel = pool.endLabel().labelId();
- long totalNum = pool.totalNum();
- long current = pool.currentUsedMaxLabelId().labelId() + applyNum - tmp;
- long usedNum = pool.usedNum() + applyNum;
- ImmutableSet<LabelResource> freeLabel = ImmutableSet
- .copyOf(releaseLabels);
- LabelResourcePool newPool = new LabelResourcePool(deviceId.toString(),
- beginLabel, endLabel,
- totalNum, usedNum,
- current, freeLabel);
- resourcePool.put(deviceId, newPool);
- log.info("success to apply label resource");
- resourcePoolLock.writeLock().unlock();
- return result;
- }
-
- @Override
- public boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release) {
- Map<DeviceId, Collection<LabelResource>> maps = release.asMap();
- Set<DeviceId> deviceIdSet = maps.keySet();
- LabelResourceRequest request = null;
- for (Iterator<DeviceId> it = deviceIdSet.iterator(); it.hasNext();) {
- DeviceId deviceId = (DeviceId) it.next();
- Device device = (Device) deviceService.getDevice(deviceId);
- if (device == null) {
- continue;
- }
- ImmutableSet<LabelResource> collection = ImmutableSet.copyOf(maps
- .get(deviceId));
- request = new LabelResourceRequest(
- deviceId,
- LabelResourceRequest.Type.RELEASE,
- 0, collection);
- ReplicaInfo replicaInfo = replicaInfoManager
- .getReplicaInfoFor(deviceId);
-
- if (!replicaInfo.master().isPresent()) {
- log.warn("Failed to getFlowEntries: No master for {}", deviceId);
- return false;
- }
-
- if (replicaInfo.master().get()
- .equals(clusterService.getLocalNode().id())) {
- return internalRelease(request);
- }
-
- log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}",
- replicaInfo.master().orNull(), deviceId);
-
- return complete(clusterCommunicator
- .sendAndReceive(request,
- LabelResourceMessageSubjects.LABEL_POOL_RELEASE,
- SERIALIZER::encode, SERIALIZER::decode,
- replicaInfo.master().get()));
- }
- return false;
- }
-
- private boolean internalRelease(LabelResourceRequest request) {
- resourcePoolLock.writeLock().lock();
- DeviceId deviceId = request.deviceId();
- Collection<LabelResource> release = request.releaseCollection();
- LabelResourcePool pool = resourcePool.get(deviceId).value();
- if (pool == null) {
- resourcePoolLock.writeLock().unlock();
- log.info("the label resource pool of device id {} does not exist");
- return false;
- }
- Set<LabelResource> storeSet = new HashSet<LabelResource>(
- pool.releaseLabelId());
- LabelResource labelResource = null;
- long realReleasedNum = 0;
- for (Iterator<LabelResource> it = release.iterator(); it.hasNext();) {
- labelResource = it.next();
- if (labelResource.labelResourceId().labelId() < pool.beginLabel()
- .labelId()
- || labelResource.labelResourceId().labelId() > pool
- .endLabel().labelId()) {
- continue;
- }
- if (pool.currentUsedMaxLabelId().labelId() > labelResource
- .labelResourceId().labelId()
- || !storeSet.contains(labelResource)) {
- storeSet.add(labelResource);
- realReleasedNum++;
- }
- }
- long beginNum = pool.beginLabel().labelId();
- long endNum = pool.endLabel().labelId();
- long totalNum = pool.totalNum();
- long usedNum = pool.usedNum() - realReleasedNum;
- long current = pool.currentUsedMaxLabelId().labelId();
- ImmutableSet<LabelResource> s = ImmutableSet.copyOf(storeSet);
- LabelResourcePool newPool = new LabelResourcePool(deviceId.toString(),
- beginNum, endNum,
- totalNum, usedNum,
- current, s);
- resourcePool.put(deviceId, newPool);
- log.info("success to release label resource");
- resourcePoolLock.writeLock().unlock();
- return true;
- }
-
- @Override
- public boolean isDevicePoolFull(DeviceId deviceId) {
- LabelResourcePool pool = resourcePool.get(deviceId).value();
- if (pool == null) {
- return true;
- }
- return pool.currentUsedMaxLabelId() == pool.endLabel()
- && pool.releaseLabelId().size() == 0 ? true : false;
- }
-
- @Override
- public long getFreeNumOfDevicePool(DeviceId deviceId) {
- LabelResourcePool pool = resourcePool.get(deviceId).value();
- if (pool == null) {
- return 0;
- }
- return pool.endLabel().labelId()
- - pool.currentUsedMaxLabelId().labelId()
- + pool.releaseLabelId().size();
- }
-
- @Override
- public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) {
- return resourcePool.get(deviceId).value();
- }
-
- @Override
- public boolean destroyGlobalPool() {
- return this.internalDestroy(DeviceId
- .deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID));
- }
-
- @Override
- public Collection<LabelResource> applyFromGlobalPool(long applyNum) {
- LabelResourceRequest request = new LabelResourceRequest(
- DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
- LabelResourceRequest.Type.APPLY,
- applyNum, null);
- return this.internalApply(request);
- }
-
- @Override
- public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
- Set<LabelResource> set = new HashSet<LabelResource>();
- DefaultLabelResource resource = null;
- for (LabelResourceId labelResource : release) {
- resource = new DefaultLabelResource(
- DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
- labelResource);
- set.add(resource);
- }
- LabelResourceRequest request = new LabelResourceRequest(
- DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
- LabelResourceRequest.Type.APPLY,
- 0,
- ImmutableSet
- .copyOf(set));
- return this.internalRelease(request);
- }
-
- @Override
- public boolean isGlobalPoolFull() {
- return this.isDevicePoolFull(DeviceId
- .deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID));
- }
-
- @Override
- public long getFreeNumOfGlobalPool() {
- return this.getFreeNumOfDevicePool(DeviceId
- .deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID));
- }
-
- @Override
- public LabelResourcePool getGlobalLabelResourcePool() {
- return this.getDeviceLabelResourcePool(DeviceId
- .deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID));
- }
-
- private <T> T complete(Future<T> future) {
- try {
- return future.get(PEER_REQUEST_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.error("Interrupted while waiting for operation to complete.", e);
- return null;
- } catch (TimeoutException | ExecutionException e) {
- log.error("Failed remote operation", e);
- return null;
- }
- }
-}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/LabelResourceMessageSubjects.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/LabelResourceMessageSubjects.java
deleted file mode 100644
index 68bce92..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/LabelResourceMessageSubjects.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.onosproject.store.resource.impl;
-
-import org.onosproject.store.cluster.messaging.MessageSubject;
-
-public final class LabelResourceMessageSubjects {
-
- private LabelResourceMessageSubjects() {
- }
- public static final MessageSubject LABEL_POOL_CREATED
- = new MessageSubject("label-resource-pool-created");
- public static final MessageSubject LABEL_POOL_DESTROYED
- = new MessageSubject("label-resource-pool-destroyed");
- public static final MessageSubject LABEL_POOL_APPLY
- = new MessageSubject("label-resource-pool-apply");
- public static final MessageSubject LABEL_POOL_RELEASE
- = new MessageSubject("label-resource-pool-release");
-}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/ClusterMessageSerializer.java b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/ClusterMessageSerializer.java
similarity index 97%
rename from core/store/dist/src/main/java/org/onosproject/store/serializers/impl/ClusterMessageSerializer.java
rename to core/store/dist/src/main/java/org/onosproject/store/serializers/custom/ClusterMessageSerializer.java
index 2038893..76bf798 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/ClusterMessageSerializer.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/ClusterMessageSerializer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.store.serializers.impl;
+package org.onosproject.store.serializers.custom;
import org.onosproject.cluster.NodeId;
import org.onosproject.store.cluster.messaging.ClusterMessage;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/DistributedStoreSerializers.java b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/DistributedStoreSerializers.java
similarity index 96%
rename from core/store/dist/src/main/java/org/onosproject/store/serializers/impl/DistributedStoreSerializers.java
rename to core/store/dist/src/main/java/org/onosproject/store/serializers/custom/DistributedStoreSerializers.java
index d717a31..5465b9b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/DistributedStoreSerializers.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/DistributedStoreSerializers.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.store.serializers.impl;
+package org.onosproject.store.serializers.custom;
import org.onosproject.store.impl.MastershipBasedTimestamp;
import org.onosproject.store.impl.Timestamped;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/MastershipBasedTimestampSerializer.java b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/MastershipBasedTimestampSerializer.java
similarity index 96%
rename from core/store/dist/src/main/java/org/onosproject/store/serializers/impl/MastershipBasedTimestampSerializer.java
rename to core/store/dist/src/main/java/org/onosproject/store/serializers/custom/MastershipBasedTimestampSerializer.java
index 20fbc79..eb1b2b5 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/MastershipBasedTimestampSerializer.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/MastershipBasedTimestampSerializer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.store.serializers.impl;
+package org.onosproject.store.serializers.custom;
import org.onosproject.store.impl.MastershipBasedTimestamp;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/MessageSubjectSerializer.java b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/MessageSubjectSerializer.java
similarity index 96%
rename from core/store/dist/src/main/java/org/onosproject/store/serializers/impl/MessageSubjectSerializer.java
rename to core/store/dist/src/main/java/org/onosproject/store/serializers/custom/MessageSubjectSerializer.java
index 8544019..7ddee1b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/MessageSubjectSerializer.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/MessageSubjectSerializer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.store.serializers.impl;
+package org.onosproject.store.serializers.custom;
import org.onosproject.store.cluster.messaging.MessageSubject;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/package-info.java b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/package-info.java
similarity index 81%
rename from core/store/dist/src/main/java/org/onosproject/store/serializers/impl/package-info.java
rename to core/store/dist/src/main/java/org/onosproject/store/serializers/custom/package-info.java
index e1c5a54..5cd4bee 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/serializers/impl/package-info.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/serializers/custom/package-info.java
@@ -17,4 +17,6 @@
/**
* Cluster messaging and distributed store serializers.
*/
-package org.onosproject.store.serializers.impl;
+//FIXME what is the right name for this package?
+//FIXME can this be moved to onos-core-serializers?
+package org.onosproject.store.serializers.custom;
diff --git a/core/store/dist/src/test/java/org/onosproject/store/impl/MastershipBasedTimestampTest.java b/core/store/dist/src/test/java/org/onosproject/store/impl/MastershipBasedTimestampTest.java
index 48377ce..eb9d324 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/impl/MastershipBasedTimestampTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/impl/MastershipBasedTimestampTest.java
@@ -21,7 +21,7 @@
import org.junit.Test;
import org.onosproject.store.Timestamp;
-import org.onosproject.store.serializers.impl.MastershipBasedTimestampSerializer;
+import org.onosproject.store.serializers.custom.MastershipBasedTimestampSerializer;
import org.onlab.util.KryoNamespace;
import com.google.common.testing.EqualsTester;
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 7220fdb..9356a29 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -152,18 +152,18 @@
import org.onosproject.net.packet.DefaultPacketRequest;
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.BandwidthResourceRequest;
-import org.onosproject.net.resource.DefaultLinkResourceAllocations;
-import org.onosproject.net.resource.DefaultLinkResourceRequest;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LambdaResourceRequest;
-import org.onosproject.net.resource.LinkResourceRequest;
-import org.onosproject.net.resource.MplsLabel;
-import org.onosproject.net.resource.MplsLabelResourceAllocation;
-import org.onosproject.net.resource.MplsLabelResourceRequest;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceAllocation;
+import org.onosproject.net.resource.link.BandwidthResourceRequest;
+import org.onosproject.net.resource.link.DefaultLinkResourceAllocations;
+import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LambdaResourceRequest;
+import org.onosproject.net.resource.link.LinkResourceRequest;
+import org.onosproject.net.resource.link.MplsLabel;
+import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
+import org.onosproject.net.resource.link.MplsLabelResourceRequest;
import org.onosproject.store.Timestamp;
import org.onosproject.store.service.Versioned;
diff --git a/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java b/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
index ad3e440..ac9da38 100644
--- a/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
+++ b/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
@@ -59,13 +59,13 @@
import org.onosproject.net.flow.FlowRuleBatchEntry;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.DefaultLinkResourceAllocations;
-import org.onosproject.net.resource.DefaultLinkResourceRequest;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LinkResourceRequest;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceAllocation;
+import org.onosproject.net.resource.link.DefaultLinkResourceAllocations;
+import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LinkResourceRequest;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.intent.constraint.AnnotationConstraint;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
diff --git a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStore.java b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStore.java
index d8af6be..77b918a 100644
--- a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStore.java
+++ b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStore.java
@@ -32,13 +32,13 @@
import org.onosproject.net.Annotations;
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceEvent;
-import org.onosproject.net.resource.LinkResourceStore;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceAllocation;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceEvent;
+import org.onosproject.net.resource.link.LinkResourceStore;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceAllocationException;
import org.onosproject.net.resource.ResourceType;
diff --git a/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStoreTest.java b/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStoreTest.java
index 78035c2..5841c32 100644
--- a/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStoreTest.java
+++ b/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleLinkResourceStoreTest.java
@@ -31,12 +31,12 @@
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.BandwidthResource;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.LambdaResource;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceStore;
+import org.onosproject.net.resource.link.BandwidthResource;
+import org.onosproject.net.resource.link.BandwidthResourceAllocation;
+import org.onosproject.net.resource.link.LambdaResource;
+import org.onosproject.net.resource.link.LambdaResourceAllocation;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceStore;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceAllocationException;
import org.onosproject.net.resource.ResourceRequest;