diff options
author | Stan Bonev <sb5356@att.com> | 2018-07-27 11:49:50 -0400 |
---|---|---|
committer | Stan Bonev <sb5356@att.com> | 2018-07-27 11:49:50 -0400 |
commit | 5d0c8984dc39d465ef6c3ed776213010849d34a5 (patch) | |
tree | 478641f18ef5ccc35dac58804f22de4e063f1c6c /resource-assignment/provider/src/main/java | |
parent | dbb08a26109fbe6cd0b8f96666eeb58cc25ecb03 (diff) |
RA: Add capability to assign new numbers for range
Change-Id: Ibb11219bfe0362055d388a4a10dab81e95979892
Issue-ID: CCSDK-408
Signed-off-by: Stan Bonev <sb5356@att.com>
Diffstat (limited to 'resource-assignment/provider/src/main/java')
6 files changed, 13 insertions, 4 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 426fd289d..0e4b9252d 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 @@ -60,7 +60,7 @@ public class ResourceAllocator implements SvcLogicResource { @Override public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) throws SvcLogicException { - return (QueryStatus.SUCCESS); + return QueryStatus.SUCCESS; } @Override @@ -351,6 +351,8 @@ public class ResourceAllocator implements SvcLogicResource { rr.rangeMinOverride = Integer.parseInt(rangeMinOverrideStr); String rangeMaxOverrideStr = getParam(ctx, "range-max-override", false, "-1"); rr.rangeMaxOverride = Integer.parseInt(rangeMaxOverrideStr); + String rangeForceNewNumbersStr = getParam(ctx, "range-force-new-numbers", false, "false"); + rr.rangeForceNewNumbers = Boolean.parseBoolean(rangeForceNewNumbersStr); String replaceStr = getParam(ctx, "replace", false, "true"); rr.replace = Boolean.parseBoolean(replaceStr); rr.applicationId = getParam(ctx, "application-id", false, "SDNC"); diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java index af6a2801d..b13ef80e8 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java @@ -178,6 +178,7 @@ public class DbAllocationRule implements AllocationRule { ar.rangeList.get(ar.rangeList.size() - 1).max = resourceRequest.rangeMaxOverride; } } + ar.forceNewNumbers = resourceRequest.rangeForceNewNumbers; return ar; } diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java index b5c24fa71..a52ce385d 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java @@ -30,6 +30,7 @@ public class ResourceRequest { public boolean rangeReverseOrder; public int rangeMinOverride; public int rangeMaxOverride; + public boolean rangeForceNewNumbers; public boolean replace; public String requestType; public String serviceModel; diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java index 9cae5fee5..70092db36 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java @@ -267,7 +267,7 @@ class AllocationFunction extends SynchronizedFunction { // First try to reuse the numbers already taken by the same resource union SortedSet<Integer> uu = RangeUtil.getUsed(rr, req.resourceUnionId); - if (uu != null && !uu.isEmpty() && req.replace) { + if (uu != null && !uu.isEmpty() && req.replace && !req.forceNewNumbers) { if (uu.size() >= req.requestedCount) { // Just take the first req.requestedCount numbers from uu Iterator<Integer> i = uu.iterator(); diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java index d87469fd4..7b60d3689 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java @@ -35,4 +35,5 @@ public class RangeAllocationRequest extends AllocationRequest { public int requestedCount = 1; public boolean sequential = false; public boolean reverseOrder = false; + public boolean forceNewNumbers = false; } diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java index 4685233df..fdc8a2b15 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java @@ -76,15 +76,19 @@ public class RangeUtil { found = true; break; } + if (req.forceNewNumbers && rai.used.contains(num)) { + found = true; + break; + } } } - + if (!found) { good = true; break; } } - + return good; } |