[ONOS-6412] allocate resource by Intent.Key
- Allocate resources by Intent.Key instead of IntentId
- ONOS-5808 changed the IntentManager's Intent withdrawal behavior to
release resouces allocated by Intent.Key
(was releasing resource allocated by IntentId)
Change-Id: I62e048e4ee8f841b92d9985784c95abba3d37a0a
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index a44d837..a62a5b0 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -187,7 +187,7 @@
// Release of intent resources here is only a temporary solution for handling the
// case of recompiling due to intent restoration (when intent state is FAILED).
// TODO: try to release intent resources in IntentManager.
- resourceService.release(intent.id());
+ resourceService.release(intent.key());
// Check OduClt ports availability
Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
@@ -269,7 +269,7 @@
}
}
- if (resourceService.allocate(intent.id(), required).isEmpty()) {
+ if (resourceService.allocate(intent.key(), required).isEmpty()) {
throw new OpticalIntentCompilationException("Unable to allocate resources for intent " + intent
+ ": resources=" + required);
}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index 1fb4969..5183a3e 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -118,7 +118,7 @@
// Release of intent resources here is only a temporary solution for handling the
// case of recompiling due to intent restoration (when intent state is FAILED).
// TODO: try to release intent resources in IntentManager.
- resourceService.release(intent.id());
+ resourceService.release(intent.key());
// Check OCh port availability
Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
@@ -244,9 +244,9 @@
private void allocateResources(Intent intent, List<Resource> resources) {
// reserve all of required resources
- List<ResourceAllocation> allocations = resourceService.allocate(intent.id(), resources);
+ List<ResourceAllocation> allocations = resourceService.allocate(intent.key(), resources);
if (allocations.isEmpty()) {
- log.error("Resource allocation for {} failed (resource request: {})", intent.id(), resources);
+ log.error("Resource allocation for {} failed (resource request: {})", intent.key(), resources);
if (log.isDebugEnabled()) {
log.debug("requested resources:\n\t{}", resources.stream()
.map(Resource::toString)
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
index b722285..17072a2 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
@@ -131,7 +131,7 @@
// Release of intent resources here is only a temporary solution for handling the
// case of recompiling due to intent restoration (when intent state is FAILED).
// TODO: try to release intent resources in IntentManager.
- resourceService.release(intent.id());
+ resourceService.release(intent.key());
// Check OduClt ports availability
Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
@@ -221,7 +221,7 @@
private void allocateResources(Intent intent, List<Resource> resources) {
// reserve all of required resources
- List<ResourceAllocation> allocations = resourceService.allocate(intent.id(), resources);
+ List<ResourceAllocation> allocations = resourceService.allocate(intent.key(), resources);
if (allocations.isEmpty()) {
log.info("Resource allocation for {} failed (resource request: {})", intent, resources);
throw new OpticalIntentCompilationException("Unable to allocate resources: " + resources);
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 7d58b82..0853836 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -406,6 +406,7 @@
<completers>
<ref component-id="deviceIdCompleter"/>
<ref component-id="portNumberCompleter"/>
+ <null/>
</completers>
</command>
<command>
@@ -413,6 +414,7 @@
<completers>
<ref component-id="deviceIdCompleter"/>
<ref component-id="portNumberCompleter"/>
+ <null/>
</completers>
</command>
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java
index e3c7d02..4241eae 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java
@@ -417,8 +417,8 @@
List<Resource> resources = concat(primaryResources, secondaryResources)
.collect(Collectors.toList());
- log.trace("Calling allocate({},{})", intent.id(), resources);
- if (resourceService.allocate(intent.id(), resources).isEmpty()) {
+ log.trace("Calling allocate({},{})", intent.key(), resources);
+ if (resourceService.allocate(intent.key(), resources).isEmpty()) {
log.warn("Allocation failed, retrying");
continue;
}
diff --git a/core/net/src/main/java/org/onosproject/net/resource/impl/LabelAllocator.java b/core/net/src/main/java/org/onosproject/net/resource/impl/LabelAllocator.java
index e19044e..22b3500 100644
--- a/core/net/src/main/java/org/onosproject/net/resource/impl/LabelAllocator.java
+++ b/core/net/src/main/java/org/onosproject/net/resource/impl/LabelAllocator.java
@@ -237,6 +237,8 @@
))
.collect(Collectors.toSet());
+ // FIXME resource allocated by IntentId will not be released
+ // when Intent is withdrawn. Behaviour changed by ONOS-5808
List<ResourceAllocation> allocations = resourceService.allocate(id, ImmutableList.copyOf(resources));
if (allocations.isEmpty()) {