Committed by
Sho Shimizu
Pull out ContinuousResourceAllocation from ConsistentResourceStore
Change-Id: I30eeb84f3e3237aa191d41896b60da8f789ea8ea
Showing
5 changed files
with
41 additions
and
24 deletions
| ... | @@ -37,7 +37,6 @@ import java.util.List; | ... | @@ -37,7 +37,6 @@ import java.util.List; |
| 37 | import java.util.Set; | 37 | import java.util.Set; |
| 38 | import java.util.stream.Stream; | 38 | import java.util.stream.Stream; |
| 39 | 39 | ||
| 40 | -import static org.onosproject.store.resource.impl.ConsistentResourceStore.ContinuousResourceAllocation; | ||
| 41 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.MAX_RETRIES; | 40 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.MAX_RETRIES; |
| 42 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_DELAY; | 41 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_DELAY; |
| 43 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER; | 42 | import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER; | ... | ... |
| ... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
| 16 | package org.onosproject.store.resource.impl; | 16 | package org.onosproject.store.resource.impl; |
| 17 | 17 | ||
| 18 | import com.google.common.annotations.Beta; | 18 | import com.google.common.annotations.Beta; |
| 19 | -import com.google.common.collect.ImmutableList; | ||
| 20 | import com.google.common.collect.ImmutableSet; | 19 | import com.google.common.collect.ImmutableSet; |
| 21 | import org.apache.felix.scr.annotations.Activate; | 20 | import org.apache.felix.scr.annotations.Activate; |
| 22 | import org.apache.felix.scr.annotations.Component; | 21 | import org.apache.felix.scr.annotations.Component; |
| ... | @@ -390,24 +389,4 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -390,24 +389,4 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
| 390 | return discreteTxStore.unregister(key, discreteValues) | 389 | return discreteTxStore.unregister(key, discreteValues) |
| 391 | && continuousTxStore.unregister(key, continuousValues); | 390 | && continuousTxStore.unregister(key, continuousValues); |
| 392 | } | 391 | } |
| 393 | - | ||
| 394 | - // internal use only | ||
| 395 | - static final class ContinuousResourceAllocation { | ||
| 396 | - private final ContinuousResource original; | ||
| 397 | - private final ImmutableList<ResourceAllocation> allocations; | ||
| 398 | - | ||
| 399 | - ContinuousResourceAllocation(ContinuousResource original, | ||
| 400 | - ImmutableList<ResourceAllocation> allocations) { | ||
| 401 | - this.original = original; | ||
| 402 | - this.allocations = allocations; | ||
| 403 | - } | ||
| 404 | - | ||
| 405 | - ContinuousResource original() { | ||
| 406 | - return original; | ||
| 407 | - } | ||
| 408 | - | ||
| 409 | - ImmutableList<ResourceAllocation> allocations() { | ||
| 410 | - return allocations; | ||
| 411 | - } | ||
| 412 | - } | ||
| 413 | } | 392 | } | ... | ... |
core/store/dist/src/main/java/org/onosproject/store/resource/impl/ContinuousResourceAllocation.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.store.resource.impl; | ||
| 17 | + | ||
| 18 | +import com.google.common.collect.ImmutableList; | ||
| 19 | +import org.onosproject.net.resource.ContinuousResource; | ||
| 20 | +import org.onosproject.net.resource.ResourceAllocation; | ||
| 21 | + | ||
| 22 | +// internal use only | ||
| 23 | +final class ContinuousResourceAllocation { | ||
| 24 | + private final ContinuousResource original; | ||
| 25 | + private final ImmutableList<ResourceAllocation> allocations; | ||
| 26 | + | ||
| 27 | + ContinuousResourceAllocation(ContinuousResource original, | ||
| 28 | + ImmutableList<ResourceAllocation> allocations) { | ||
| 29 | + this.original = original; | ||
| 30 | + this.allocations = allocations; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + ContinuousResource original() { | ||
| 34 | + return original; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + ImmutableList<ResourceAllocation> allocations() { | ||
| 38 | + return allocations; | ||
| 39 | + } | ||
| 40 | +} |
| ... | @@ -33,7 +33,7 @@ final class ResourceStoreUtil { | ... | @@ -33,7 +33,7 @@ final class ResourceStoreUtil { |
| 33 | // computational complexity: O(n) where n is the number of allocations | 33 | // computational complexity: O(n) where n is the number of allocations |
| 34 | static boolean hasEnoughResource(ContinuousResource original, | 34 | static boolean hasEnoughResource(ContinuousResource original, |
| 35 | ContinuousResource request, | 35 | ContinuousResource request, |
| 36 | - ConsistentResourceStore.ContinuousResourceAllocation allocation) { | 36 | + ContinuousResourceAllocation allocation) { |
| 37 | if (allocation == null) { | 37 | if (allocation == null) { |
| 38 | return request.value() <= original.value(); | 38 | return request.value() <= original.value(); |
| 39 | } | 39 | } | ... | ... |
| ... | @@ -24,7 +24,6 @@ import org.onosproject.net.resource.DiscreteResourceId; | ... | @@ -24,7 +24,6 @@ import org.onosproject.net.resource.DiscreteResourceId; |
| 24 | import org.onosproject.net.resource.Resource; | 24 | import org.onosproject.net.resource.Resource; |
| 25 | import org.onosproject.net.resource.ResourceAllocation; | 25 | import org.onosproject.net.resource.ResourceAllocation; |
| 26 | import org.onosproject.net.resource.ResourceConsumer; | 26 | import org.onosproject.net.resource.ResourceConsumer; |
| 27 | -import org.onosproject.store.resource.impl.ConsistentResourceStore.ContinuousResourceAllocation; | ||
| 28 | import org.onosproject.store.service.TransactionContext; | 27 | import org.onosproject.store.service.TransactionContext; |
| 29 | import org.onosproject.store.service.TransactionalMap; | 28 | import org.onosproject.store.service.TransactionalMap; |
| 30 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; | ... | ... |
-
Please register or login to post a comment