Sho SHIMIZU

Stop passing duplicate original continuous resource

Change-Id: I3608b1cd362cca5e3c0534b6dfb18a7204c42aef
...@@ -107,7 +107,7 @@ class ConsistentContinuousResourceSubStore { ...@@ -107,7 +107,7 @@ class ConsistentContinuousResourceSubStore {
107 return true; 107 return true;
108 } 108 }
109 109
110 - return allocation.value().hasEnoughResource(allocation.value().original(), resource); 110 + return allocation.value().hasEnoughResource(resource);
111 } 111 }
112 112
113 <T> Stream<ContinuousResource> getAllocatedResources(DiscreteResourceId parent, Class<T> cls) { 113 <T> Stream<ContinuousResource> getAllocatedResources(DiscreteResourceId parent, Class<T> cls) {
......
...@@ -44,12 +44,11 @@ final class ContinuousResourceAllocation { ...@@ -44,12 +44,11 @@ final class ContinuousResourceAllocation {
44 * Checks if there is enough resource volume to allocated the requested resource 44 * Checks if there is enough resource volume to allocated the requested resource
45 * against the specified resource. 45 * against the specified resource.
46 * 46 *
47 - * @param original original resource
48 * @param request requested resource 47 * @param request requested resource
49 * @return true if there is enough resource volume. Otherwise, false. 48 * @return true if there is enough resource volume. Otherwise, false.
50 */ 49 */
51 // computational complexity: O(n) where n is the number of allocations 50 // computational complexity: O(n) where n is the number of allocations
52 - boolean hasEnoughResource(ContinuousResource original, ContinuousResource request) { 51 + boolean hasEnoughResource(ContinuousResource request) {
53 double allocated = allocations.stream() 52 double allocated = allocations.stream()
54 .filter(x -> x.resource() instanceof ContinuousResource) 53 .filter(x -> x.resource() instanceof ContinuousResource)
55 .map(x -> (ContinuousResource) x.resource()) 54 .map(x -> (ContinuousResource) x.resource())
......
...@@ -141,7 +141,7 @@ class TransactionalContinuousResourceSubStore { ...@@ -141,7 +141,7 @@ class TransactionalContinuousResourceSubStore {
141 ContinuousResourceAllocation allocations = consumers.get(request.id()); 141 ContinuousResourceAllocation allocations = consumers.get(request.id());
142 if (!Optional.ofNullable(allocations) 142 if (!Optional.ofNullable(allocations)
143 .orElse(ContinuousResourceAllocation.empty(original)) 143 .orElse(ContinuousResourceAllocation.empty(original))
144 - .hasEnoughResource(original, request)) { 144 + .hasEnoughResource(request)) {
145 return false; 145 return false;
146 } 146 }
147 147
......