summaryrefslogtreecommitdiffstats
path: root/resource-assignment
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2018-11-28 22:42:03 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-28 22:42:03 +0000
commit6eb11a73f23b46e94f4209687a368dc1396e5404 (patch)
treeac23d581d6ed6526983573a76172a3da5ad3979b /resource-assignment
parent28de81829d5b951dae9222ce8cf97e9861206db0 (diff)
parent749a3c537f597505087a939a33532aef3de90c78 (diff)
Merge "RA: Release resources on specific target"
Diffstat (limited to 'resource-assignment')
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java69
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ReleaseFunction.java16
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManager.java4
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java30
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/ResourceDao.java4
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceDaoImpl.java109
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDao.java4
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDaoImpl.java25
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java7
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java10
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java300
11 files changed, 472 insertions, 106 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
index e0391bc1..5700cd72 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
@@ -48,7 +48,8 @@ public class ResourceAllocator implements SvcLogicResource {
private static final Logger log = LoggerFactory.getLogger(ResourceAllocator.class);
private static final String[] INPUT_PREFIX = {"ra-input.", "tmp.resource-allocator."};
- private static final String START_RELEASE_LC = "Starting release for: {}";
+ private static final String START_RELEASE = "Starting release for: {}";
+ private static final String START_RELEASE_FOR_TARGET = "Starting release for: {} on target: {}";
private ResourceManager resourceManager;
private EndPointAllocator endPointAllocator;
@@ -201,6 +202,10 @@ public class ResourceAllocator implements SvcLogicResource {
getParam(ctx, new String[] {"reservation-entity-type", "resource-entity-type"}, true, null);
String resourceEntityVersion =
getParam(ctx, new String[] {"reservation-entity-version", "resource-entity-version"}, false, null);
+ String resourceTargetId =
+ getParam(ctx, new String[] {"reservation-target-id", "resource-target-id"}, false, null);
+ String resourceTargetType =
+ getParam(ctx, new String[] {"reservation-target-type", "resource-target-type"}, false, null);
String endPointPosition = getParam(ctx, "endpoint-position", false, null);
@@ -212,8 +217,12 @@ public class ResourceAllocator implements SvcLogicResource {
ResourceRequest rr = new ResourceRequest();
rr.endPointPosition = endPointPosition;
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetType = resourceTargetType;
+ rt.resourceTargetId = resourceTargetId;
+
try {
- this.release(sd, rr);
+ this.release(sd, rr, rt);
} catch (Exception e) {
throw new SvcLogicException(e.getMessage());
}
@@ -221,54 +230,54 @@ public class ResourceAllocator implements SvcLogicResource {
}
public AllocationStatus release(ResourceEntity sd) throws Exception {
-
- if (sd.resourceEntityVersion != null) {
- String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + sd.resourceEntityVersion;
- log.info(START_RELEASE_LC, resourceSet);
-
- resourceManager.releaseResourceSet(resourceSet);
- } else {
- String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId;
- log.info(START_RELEASE_LC, resourceUnion);
-
- resourceManager.releaseResourceUnion(resourceUnion);
- }
-
- return AllocationStatus.Success;
-
+ return release(sd, null, null);
}
public AllocationStatus release(ResourceEntity sd, ResourceRequest rr) throws Exception {
+ return release(sd, rr, null);
+ }
+
+ public AllocationStatus release(ResourceEntity sd, ResourceRequest rr, ResourceTarget rt) throws Exception {
if (sd != null && sd.resourceEntityVersion != null) {
+ String resourceSet = null;
+
if (rr != null && rr.endPointPosition != null && !rr.endPointPosition.isEmpty()) {
- String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + rr.endPointPosition
- + "::" + sd.resourceEntityVersion;
- log.info(START_RELEASE_LC, resourceSet);
- resourceManager.releaseResourceSet(resourceSet);
+ resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + rr.endPointPosition + "::"
+ + sd.resourceEntityVersion;
+ } else {
+ resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + sd.resourceEntityVersion;
+ }
+ if (rt != null && rt.resourceTargetId != null && rt.resourceTargetType != null) {
+ String assetId = rt.resourceTargetType + "::" + rt.resourceTargetId;
+ log.info(START_RELEASE_FOR_TARGET, resourceSet, assetId);
+ resourceManager.releaseResourceSet(resourceSet, assetId);
} else {
- String resourceSet =
- sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + sd.resourceEntityVersion;
- log.info(START_RELEASE_LC, resourceSet);
+ log.info(START_RELEASE, resourceSet);
resourceManager.releaseResourceSet(resourceSet);
}
} else if (sd != null && (sd.resourceEntityVersion == null || sd.resourceEntityVersion.isEmpty())) {
+ String resourceUnion = null;
+
if (rr != null && rr.endPointPosition != null && !rr.endPointPosition.isEmpty()) {
- String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + rr.endPointPosition;
- log.info(START_RELEASE_LC, resourceUnion);
- resourceManager.releaseResourceUnion(resourceUnion);
+ resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + rr.endPointPosition;
+ } else {
+ resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId;
+ }
+ if (rt != null && rt.resourceTargetId != null && rt.resourceTargetType != null) {
+ String assetId = rt.resourceTargetType + "::" + rt.resourceTargetId;
+ log.info(START_RELEASE_FOR_TARGET, resourceUnion, assetId);
+ resourceManager.releaseResourceUnion(resourceUnion, assetId);
} else {
- String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId;
- log.info(START_RELEASE_LC, resourceUnion);
+ log.info(START_RELEASE, resourceUnion);
resourceManager.releaseResourceUnion(resourceUnion);
}
}
return AllocationStatus.Success;
-
}
private QueryStatus allocateResources(SvcLogicContext ctx, boolean checkOnly, String prefix)
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ReleaseFunction.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ReleaseFunction.java
index c0dec8bb..17641845 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ReleaseFunction.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ReleaseFunction.java
@@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.adaptors.rm.comp;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-
import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelper;
import org.onap.ccsdk.sli.adaptors.lock.comp.ResourceLockedException;
import org.onap.ccsdk.sli.adaptors.lock.comp.SynchronizedFunction;
@@ -42,21 +41,24 @@ class ReleaseFunction extends SynchronizedFunction {
private ResourceDao resourceDao;
- private String resourceSetId, resourceUnionId;
+ private String resourceSetId, resourceUnionId, assetId;
- public ReleaseFunction(LockHelper lockHelper, ResourceDao resourceDao, String resourceSetId,
- String resourceUnionId, Collection<String> lockNames, int lockTimeout) {
+ public ReleaseFunction(LockHelper lockHelper, ResourceDao resourceDao, String resourceSetId, String resourceUnionId,
+ String assetId, Collection<String> lockNames, int lockTimeout) {
super(lockHelper, lockNames, lockTimeout);
this.resourceDao = resourceDao;
this.resourceSetId = resourceSetId;
this.resourceUnionId = resourceUnionId;
+ this.assetId = assetId;
}
@Override
public void _exec() throws ResourceLockedException {
- List<Resource> resourceList =
- resourceSetId != null
- ? resourceDao.getResourceSet(resourceSetId) : resourceDao.getResourceUnion(resourceUnionId);
+ List<Resource> resourceList = assetId != null
+ ? (resourceSetId != null ? resourceDao.getResourceSetForAsset(resourceSetId, assetId)
+ : resourceDao.getResourceUnionForAsset(resourceUnionId, assetId))
+ : (resourceSetId != null ? resourceDao.getResourceSet(resourceSetId)
+ : resourceDao.getResourceUnion(resourceUnionId));
for (Resource r : resourceList) {
boolean updated = false;
if (r.allocationItems != null) {
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManager.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManager.java
index ee77dee9..68d25158 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManager.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManager.java
@@ -38,6 +38,10 @@ public interface ResourceManager {
void releaseResourceUnion(String resourceUnionId);
+ void releaseResourceSet(String resourceSetId, String assetId);
+
+ void releaseResourceUnion(String resourceUnionId, String assetId);
+
Resource queryResource(String resourceName, String assetId, String resourceUnionFilter,
String resourceShareGroupFilter);
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
index 9ba88912..c4d53ce7 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
@@ -88,7 +88,7 @@ public class ResourceManagerImpl implements ResourceManager {
Set<String> lockNames = getLockNames(resourceList);
ReleaseFunction releaseFunction =
- new ReleaseFunction(lockHelper, resourceDao, resourceSetId, null, lockNames, lockTimeout);
+ new ReleaseFunction(lockHelper, resourceDao, resourceSetId, null, null, lockNames, lockTimeout);
releaseFunction.exec();
}
@@ -101,7 +101,33 @@ public class ResourceManagerImpl implements ResourceManager {
Set<String> lockNames = getLockNames(resourceList);
ReleaseFunction releaseFunction =
- new ReleaseFunction(lockHelper, resourceDao, null, resourceUnionId, lockNames, lockTimeout);
+ new ReleaseFunction(lockHelper, resourceDao, null, resourceUnionId, null, lockNames, lockTimeout);
+ releaseFunction.exec();
+ }
+
+ @Override
+ public void releaseResourceSet(String resourceSetId, String assetId) {
+ List<Resource> resourceList = resourceDao.getResourceSetForAsset(resourceSetId, assetId);
+ if (resourceList == null || resourceList.isEmpty()) {
+ return;
+ }
+
+ Set<String> lockNames = getLockNames(resourceList);
+ ReleaseFunction releaseFunction =
+ new ReleaseFunction(lockHelper, resourceDao, resourceSetId, null, assetId, lockNames, lockTimeout);
+ releaseFunction.exec();
+ }
+
+ @Override
+ public void releaseResourceUnion(String resourceUnionId, String assetId) {
+ List<Resource> resourceList = resourceDao.getResourceUnionForAsset(resourceUnionId, assetId);
+ if (resourceList == null || resourceList.isEmpty()) {
+ return;
+ }
+
+ Set<String> lockNames = getLockNames(resourceList);
+ ReleaseFunction releaseFunction =
+ new ReleaseFunction(lockHelper, resourceDao, null, resourceUnionId, assetId, lockNames, lockTimeout);
releaseFunction.exec();
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/ResourceDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/ResourceDao.java
index 57c3e938..87baf26c 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/ResourceDao.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/ResourceDao.java
@@ -36,6 +36,10 @@ public interface ResourceDao {
List<Resource> getResourceUnion(String resourceUnionId);
+ List<Resource> getResourceSetForAsset(String resourceSetId, String assetId);
+
+ List<Resource> getResourceUnionForAsset(String resourceUnionId, String assetId);
+
Resource query(String assetId, String resourceName, String resourceUnionFilter, String resourceShareGroupFilter);
List<Resource> query(String assetIdFilter, String resourceName);
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceDaoImpl.java
index 17265163..21f5575f 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceDaoImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceDaoImpl.java
@@ -44,25 +44,7 @@ public class ResourceDaoImpl implements ResourceDao {
@Override
public org.onap.ccsdk.sli.adaptors.rm.data.Resource getResource(String assetId, String resourceName) {
Resource rEntity = resourceJdbcDao.getResource(assetId, resourceName);
- org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
-
- if (r != null) {
- List<AllocationItem> aiEntityList = allocationItemJdbcDao.getAllocationItems(rEntity.id);
- r.allocationItems = new ArrayList<>();
- for (AllocationItem aiEntity : aiEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem ai = createAllocationItem(r, aiEntity);
- r.allocationItems.add(ai);
- }
-
- List<ResourceLoad> rlEntityList = resourceLoadJdbcDao.getResourceLoads(rEntity.id);
- r.resourceLoadList = new ArrayList<>();
- for (ResourceLoad rlEntity : rlEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.ResourceLoad rl = createResourceLoad(r, rlEntity);
- r.resourceLoadList.add(rl);
- }
- }
-
- return r;
+ return createResourceWithItems(rEntity);
}
@Override
@@ -96,22 +78,8 @@ public class ResourceDaoImpl implements ResourceDao {
List<Resource> rEntityList = resourceJdbcDao.queryResources(assetIdFilter, resourceName);
List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
for (Resource rEntity : rEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
+ org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResourceWithItems(rEntity);
rlist.add(r);
-
- List<AllocationItem> aiEntityList = allocationItemJdbcDao.getAllocationItems(rEntity.id);
- r.allocationItems = new ArrayList<>();
- for (AllocationItem aiEntity : aiEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem ai = createAllocationItem(r, aiEntity);
- r.allocationItems.add(ai);
- }
-
- List<ResourceLoad> rlEntityList = resourceLoadJdbcDao.getResourceLoads(rEntity.id);
- r.resourceLoadList = new ArrayList<>();
- for (ResourceLoad rlEntity : rlEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.ResourceLoad rl = createResourceLoad(r, rlEntity);
- r.resourceLoadList.add(rl);
- }
}
return rlist;
}
@@ -254,22 +222,8 @@ public class ResourceDaoImpl implements ResourceDao {
List<Resource> rEntityList = resourceJdbcDao.getResourceSet(resourceSetId);
List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
for (Resource rEntity : rEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
+ org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResourceWithItems(rEntity);
rlist.add(r);
-
- List<AllocationItem> aiEntityList = allocationItemJdbcDao.getAllocationItems(rEntity.id);
- r.allocationItems = new ArrayList<>();
- for (AllocationItem aiEntity : aiEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem ai = createAllocationItem(r, aiEntity);
- r.allocationItems.add(ai);
- }
-
- List<ResourceLoad> rlEntityList = resourceLoadJdbcDao.getResourceLoads(rEntity.id);
- r.resourceLoadList = new ArrayList<>();
- for (ResourceLoad rlEntity : rlEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.ResourceLoad rl = createResourceLoad(r, rlEntity);
- r.resourceLoadList.add(rl);
- }
}
return rlist;
}
@@ -279,22 +233,32 @@ public class ResourceDaoImpl implements ResourceDao {
List<Resource> rEntityList = resourceJdbcDao.getResourceUnion(resourceUnionId);
List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
for (Resource rEntity : rEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
+ org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResourceWithItems(rEntity);
rlist.add(r);
+ }
+ return rlist;
+ }
- List<AllocationItem> aiEntityList = allocationItemJdbcDao.getAllocationItems(rEntity.id);
- r.allocationItems = new ArrayList<>();
- for (AllocationItem aiEntity : aiEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem ai = createAllocationItem(r, aiEntity);
- r.allocationItems.add(ai);
- }
+ @Override
+ public List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> getResourceSetForAsset(String resourceSetId,
+ String assetId) {
+ List<Resource> rEntityList = resourceJdbcDao.getResourceSetForAsset(resourceSetId, assetId);
+ List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
+ for (Resource rEntity : rEntityList) {
+ org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResourceWithItems(rEntity);
+ rlist.add(r);
+ }
+ return rlist;
+ }
- List<ResourceLoad> rlEntityList = resourceLoadJdbcDao.getResourceLoads(rEntity.id);
- r.resourceLoadList = new ArrayList<>();
- for (ResourceLoad rlEntity : rlEntityList) {
- org.onap.ccsdk.sli.adaptors.rm.data.ResourceLoad rl = createResourceLoad(r, rlEntity);
- r.resourceLoadList.add(rl);
- }
+ @Override
+ public List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> getResourceUnionForAsset(String resourceUnionId,
+ String assetId) {
+ List<Resource> rEntityList = resourceJdbcDao.getResourceUnionForAsset(resourceUnionId, assetId);
+ List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
+ for (Resource rEntity : rEntityList) {
+ org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResourceWithItems(rEntity);
+ rlist.add(r);
}
return rlist;
}
@@ -374,6 +338,27 @@ public class ResourceDaoImpl implements ResourceDao {
}
}
+ private org.onap.ccsdk.sli.adaptors.rm.data.Resource createResourceWithItems(Resource rEntity) {
+ org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
+
+ if (r != null) {
+ List<AllocationItem> aiEntityList = allocationItemJdbcDao.getAllocationItems(rEntity.id);
+ r.allocationItems = new ArrayList<>();
+ for (AllocationItem aiEntity : aiEntityList) {
+ org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem ai = createAllocationItem(r, aiEntity);
+ r.allocationItems.add(ai);
+ }
+
+ List<ResourceLoad> rlEntityList = resourceLoadJdbcDao.getResourceLoads(rEntity.id);
+ r.resourceLoadList = new ArrayList<>();
+ for (ResourceLoad rlEntity : rlEntityList) {
+ org.onap.ccsdk.sli.adaptors.rm.data.ResourceLoad rl = createResourceLoad(r, rlEntity);
+ r.resourceLoadList.add(rl);
+ }
+ }
+ return r;
+ }
+
private org.onap.ccsdk.sli.adaptors.rm.data.Resource createResource(Resource resourceEntity) {
if (resourceEntity == null) {
return null;
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDao.java
index fe19fd90..d4d9a054 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDao.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDao.java
@@ -33,6 +33,10 @@ public interface ResourceJdbcDao {
List<Resource> getResourceUnion(String resourceUnionId);
+ List<Resource> getResourceSetForAsset(String resourceSetId, String assetId);
+
+ List<Resource> getResourceUnionForAsset(String resourceUnionId, String assetId);
+
void add(Resource r);
void delete(long id);
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDaoImpl.java
index 9283df9e..c94a5d8a 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDaoImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceJdbcDaoImpl.java
@@ -50,6 +50,12 @@ public class ResourceJdbcDaoImpl implements ResourceJdbcDao {
private static final String RESOURCE_UNION_SQL = "SELECT * FROM RESOURCE WHERE resource_id IN (\n"
+ "SELECT DISTINCT resource_id FROM ALLOCATION_ITEM WHERE resource_union_id = ?)";
+ private static final String RESOURCE_SET_FOR_ASSET_SQL = "SELECT * FROM RESOURCE WHERE resource_id IN (\n"
+ + "SELECT DISTINCT resource_id FROM ALLOCATION_ITEM WHERE resource_set_id = ?) AND asset_id = ?";
+
+ private static final String RESOURCE_UNION_FOR_ASSET_SQL = "SELECT * FROM RESOURCE WHERE resource_id IN (\n"
+ + "SELECT DISTINCT resource_id FROM ALLOCATION_ITEM WHERE resource_union_id = ?) AND asset_id = ?";
+
private static final String INSERT_SQL = "INSERT INTO RESOURCE (\n"
+ " asset_id, resource_name, resource_type, lt_used, ll_label, ll_reference_count, rr_used)\n"
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
@@ -103,6 +109,25 @@ public class ResourceJdbcDaoImpl implements ResourceJdbcDao {
}
@Override
+ public List<Resource> getResourceSetForAsset(String resourceSetId, String assetId) {
+ if (resourceSetId == null) {
+ return Collections.emptyList();
+ }
+
+ return jdbcTemplate.query(RESOURCE_SET_FOR_ASSET_SQL, new Object[] {resourceSetId, assetId}, resourceRowMapper);
+ }
+
+ @Override
+ public List<Resource> getResourceUnionForAsset(String resourceUnionId, String assetId) {
+ if (resourceUnionId == null) {
+ return Collections.emptyList();
+ }
+
+ return jdbcTemplate.query(RESOURCE_UNION_FOR_ASSET_SQL, new Object[] {resourceUnionId, assetId},
+ resourceRowMapper);
+ }
+
+ @Override
public void add(final Resource r) {
PreparedStatementCreator psc = dbc -> {
PreparedStatement ps = dbc.prepareStatement(INSERT_SQL, new String[] {"resource_id"});
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
index b41c068e..5dcf5991 100644
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
@@ -89,6 +89,13 @@ public class DataSetup {
return used.equals(usedInDb);
}
+ public boolean checkLimitItem(String resourceName, String assetId, String resourceSetId, int used) {
+ String where = "resource_id = (SELECT resource_id FROM RESOURCE WHERE resource_name = '" + resourceName
+ + "' AND asset_id = '" + assetId + "') AND resource_set_id = '" + resourceSetId + "' AND lt_used = "
+ + used;
+ return allocationItem.exists(where);
+ }
+
public void setTestDb(TestDb testDb) {
this.testDb = testDb;
}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
index a968c3fb..04ee3811 100644
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
@@ -79,7 +79,7 @@ public class TestGetResource {
public void test001() throws Exception {
String t = "001";
- log.info("============== query node " + t + " ================================");
+ log.info("============== get-resource node " + t + " ================================");
log.info("=== Test query for resource target - no additional criteria");
setupResourceData();
@@ -106,7 +106,7 @@ public class TestGetResource {
public void test002() throws Exception {
String t = "002";
- log.info("============== query node " + t + " ================================");
+ log.info("============== get-resource node " + t + " ================================");
log.info("=== Test query for resource target - with resource entity condition");
setupResourceData();
@@ -136,7 +136,7 @@ public class TestGetResource {
public void test003() throws Exception {
String t = "003";
- log.info("============== query node " + t + " ================================");
+ log.info("============== get-resource node " + t + " ================================");
log.info("=== Test query for resource target - with resource share group condition");
setupResourceData();
@@ -165,7 +165,7 @@ public class TestGetResource {
public void test004() throws Exception {
String t = "004";
- log.info("============== query node " + t + " ================================");
+ log.info("============== get-resource node " + t + " ================================");
log.info("=== Test query for resource target - with resource share group condition NULL");
setupResourceData();
@@ -194,7 +194,7 @@ public class TestGetResource {
public void test005() throws Exception {
String t = "005";
- log.info("============== query node " + t + " ================================");
+ log.info("============== get-resource node " + t + " ================================");
log.info("=== Test query for resource target - with both resource entity and resource share group conditions");
setupResourceData();
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java
new file mode 100644
index 00000000..a936786a
--- /dev/null
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java
@@ -0,0 +1,300 @@
+package jtest.org.onap.ccsdk.sli.adaptors.ra;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:test-context.xml"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestRelease {
+
+ private static final Logger log = LoggerFactory.getLogger(TestRelease.class);
+
+ @Autowired(required = true)
+ private ResourceAllocator resourceAllocator;
+
+ @Autowired(required = true)
+ private DataSetup dataSetup;
+
+ private void setupResourceData() {
+ dataSetup.cleanup();
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-1::1", "EVC::TEST-1", "1");
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-2::1", "EVC::TEST-2", "2");
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-2::2", "EVC::TEST-2", "2");
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "EVC::TEST-3", "3");
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "EVC::TEST-3", "4");
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::1", "EVC::TEST-4", "5");
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::2", "EVC::TEST-4", "5");
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::3", "EVC::TEST-4", "6");
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-1::1", "EVC::TEST-1", "1");
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "EVC::TEST-3", "3");
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "EVC::TEST-3", "4");
+
+ dataSetup.setupRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-5::1", "EVC::TEST-5", "5");
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-1::1", "EVC::TEST-1", 100);
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-2::1", "EVC::TEST-2", 200);
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-2::2", "EVC::TEST-2", 200);
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "EVC::TEST-3", 300);
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "EVC::TEST-3", 400);
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::1", "EVC::TEST-4", 500);
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::2", "EVC::TEST-4", 500);
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::3", "EVC::TEST-4", 600);
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-1::1", "EVC::TEST-1", 100);
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "EVC::TEST-3", 300);
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "EVC::TEST-3", 400);
+
+ dataSetup.setupLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-5::1", "EVC::TEST-5", 500);
+ }
+
+ @Test
+ public void test001() throws Exception {
+
+ String t = "001";
+ log.info("============== release node " + t + " ================================");
+ log.info("=== Test release - with resource set");
+
+ setupResourceData();
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::1", "5"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::2", "5"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::3", "6"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::1", 500));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::2", 500));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::3", 600));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-entity-type", "EVC");
+ ctx.setAttribute("ra-input.resource-entity-id", "TEST-4");
+ ctx.setAttribute("ra-input.resource-entity-version", "2");
+
+ QueryStatus st = resourceAllocator.release("NETWORK-CAPACITY", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::1", "5"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::2", "5"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::3", "6"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::1", 500));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::2", 500));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::3", 600));
+ }
+
+ @Test
+ public void test002() throws Exception {
+
+ String t = "002";
+ log.info("============== query node " + t + " ================================");
+ log.info("=== Test release - with resource union");
+
+ setupResourceData();
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::1", "5"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::2", "5"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::3", "6"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::1", 500));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::2", 500));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::3", 600));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-entity-type", "EVC");
+ ctx.setAttribute("ra-input.resource-entity-id", "TEST-4");
+
+ QueryStatus st = resourceAllocator.release("NETWORK-CAPACITY", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::1", "5"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::2", "5"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-4::3", "6"));
+
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::1", 500));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::2", 500));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-4::3", 600));
+ }
+
+ @Test
+ public void test003() throws Exception {
+
+ String t = "003";
+ log.info("============== release node " + t + " ================================");
+ log.info("=== Test release - with resource set on 2 ports");
+
+ setupResourceData();
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-entity-type", "EVC");
+ ctx.setAttribute("ra-input.resource-entity-id", "TEST-3");
+ ctx.setAttribute("ra-input.resource-entity-version", "1");
+
+ QueryStatus st = resourceAllocator.release("NETWORK-CAPACITY", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+ }
+
+ @Test
+ public void test004() throws Exception {
+
+ String t = "004";
+ log.info("============== release node " + t + " ================================");
+ log.info("=== Test release - with resource union on 2 ports");
+
+ setupResourceData();
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-entity-type", "EVC");
+ ctx.setAttribute("ra-input.resource-entity-id", "TEST-3");
+
+ QueryStatus st = resourceAllocator.release("NETWORK-CAPACITY", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+ }
+
+ @Test
+ public void test005() throws Exception {
+
+ String t = "005";
+ log.info("============== release node " + t + " ================================");
+ log.info("=== Test release - with resource set and asset");
+
+ setupResourceData();
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-entity-type", "EVC");
+ ctx.setAttribute("ra-input.resource-entity-id", "TEST-3");
+ ctx.setAttribute("ra-input.resource-entity-version", "1");
+
+ ctx.setAttribute("ra-input.resource-target-type", "Port");
+ ctx.setAttribute("ra-input.resource-target-id", "TESTPORT-1");
+
+ QueryStatus st = resourceAllocator.release("NETWORK-CAPACITY", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+ }
+
+ @Test
+ public void test006() throws Exception {
+
+ String t = "006";
+ log.info("============== release node " + t + " ================================");
+ log.info("=== Test release - with resource union on 2 ports");
+
+ setupResourceData();
+
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-entity-type", "EVC");
+ ctx.setAttribute("ra-input.resource-entity-id", "TEST-3");
+
+ ctx.setAttribute("ra-input.resource-target-type", "Port");
+ ctx.setAttribute("ra-input.resource-target-id", "TESTPORT-1");
+
+ QueryStatus st = resourceAllocator.release("NETWORK-CAPACITY", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::1", "3"));
+ Assert.assertFalse(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-1", "EVC::TEST-3::2", "4"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::1", "3"));
+ Assert.assertTrue(dataSetup.checkRangeItem("test-range-1", "Port::TESTPORT-2", "EVC::TEST-3::2", "4"));
+
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::1", 300));
+ Assert.assertFalse(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-1", "EVC::TEST-3::2", 400));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::1", 300));
+ Assert.assertTrue(dataSetup.checkLimitItem("test-limit-1", "Port::TESTPORT-2", "EVC::TEST-3::2", 400));
+ }
+}