Sho SHIMIZU

Rename class by replacing Store with SubStore

Change-Id: I3775d930f593eab983a8da8a4823bae8d45645cb
......@@ -41,11 +41,11 @@ import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_
import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER;
import static org.onosproject.store.resource.impl.ContinuousResourceAllocation.hasEnoughResource;
class ConsistentContinuousResourceStore {
class ConsistentContinuousResourceSubStore {
private ConsistentMap<ContinuousResourceId, ContinuousResourceAllocation> consumers;
private ConsistentMap<DiscreteResourceId, Set<ContinuousResource>> childMap;
ConsistentContinuousResourceStore(StorageService service) {
ConsistentContinuousResourceSubStore(StorageService service) {
this.consumers = service.<ContinuousResourceId, ContinuousResourceAllocation>consistentMapBuilder()
.withName(MapNames.CONTINUOUS_CONSUMER_MAP)
.withSerializer(SERIALIZER)
......@@ -59,8 +59,8 @@ class ConsistentContinuousResourceStore {
ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY);
}
TransactionalContinuousResourceStore transactional(TransactionContext tx) {
return new TransactionalContinuousResourceStore(tx);
TransactionalContinuousResourceSubStore transactional(TransactionContext tx) {
return new TransactionalContinuousResourceSubStore(tx);
}
// computational complexity: O(n) where n is the number of the existing allocations for the resource
......
......@@ -40,11 +40,11 @@ import static org.onosproject.store.resource.impl.ConsistentResourceStore.MAX_RE
import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_DELAY;
import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER;
class ConsistentDiscreteResourceStore {
class ConsistentDiscreteResourceSubStore {
private ConsistentMap<DiscreteResourceId, ResourceConsumerId> consumers;
private ConsistentMap<DiscreteResourceId, Set<DiscreteResource>> childMap;
ConsistentDiscreteResourceStore(StorageService service) {
ConsistentDiscreteResourceSubStore(StorageService service) {
this.consumers = service.<DiscreteResourceId, ResourceConsumerId>consistentMapBuilder()
.withName(MapNames.DISCRETE_CONSUMER_MAP)
.withSerializer(SERIALIZER)
......@@ -58,8 +58,8 @@ class ConsistentDiscreteResourceStore {
ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY);
}
TransactionalDiscreteResourceStore transactional(TransactionContext tx) {
return new TransactionalDiscreteResourceStore(tx);
TransactionalDiscreteResourceSubStore transactional(TransactionContext tx) {
return new TransactionalDiscreteResourceSubStore(tx);
}
// computational complexity: O(1)
......
......@@ -80,13 +80,13 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService service;
private ConsistentDiscreteResourceStore discreteStore;
private ConsistentContinuousResourceStore continuousStore;
private ConsistentDiscreteResourceSubStore discreteStore;
private ConsistentContinuousResourceSubStore continuousStore;
@Activate
public void activate() {
discreteStore = new ConsistentDiscreteResourceStore(service);
continuousStore = new ConsistentContinuousResourceStore(service);
discreteStore = new ConsistentDiscreteResourceSubStore(service);
continuousStore = new ConsistentContinuousResourceSubStore(service);
log.info("Started");
}
......@@ -120,8 +120,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
.filter(x -> x.parent().isPresent())
.collect(Collectors.groupingBy(x -> x.parent().get(), LinkedHashMap::new, Collectors.toList()));
TransactionalDiscreteResourceStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx);
TransactionalDiscreteResourceSubStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceSubStore continuousTxStore = continuousStore.transactional(tx);
for (Map.Entry<DiscreteResource, List<Resource>> entry : resourceMap.entrySet()) {
DiscreteResourceId parentId = entry.getKey().id();
if (!discreteTxStore.lookup(parentId).isPresent()) {
......@@ -154,8 +154,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
TransactionalDiscreteResourceStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx);
TransactionalDiscreteResourceSubStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceSubStore continuousTxStore = continuousStore.transactional(tx);
// Look up resources by resource IDs
List<Resource> resources = ids.stream()
.filter(x -> x.parent().isPresent())
......@@ -205,8 +205,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
TransactionalDiscreteResourceStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx);
TransactionalDiscreteResourceSubStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceSubStore continuousTxStore = continuousStore.transactional(tx);
for (Resource resource : resources) {
if (resource instanceof DiscreteResource) {
if (!discreteTxStore.allocate(consumer.consumerId(), (DiscreteResource) resource)) {
......@@ -229,8 +229,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
TransactionalDiscreteResourceStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceStore continuousTxStore = continuousStore.transactional(tx);
TransactionalDiscreteResourceSubStore discreteTxStore = discreteStore.transactional(tx);
TransactionalContinuousResourceSubStore continuousTxStore = continuousStore.transactional(tx);
for (ResourceAllocation allocation : allocations) {
Resource resource = allocation.resource();
ResourceConsumerId consumerId = allocation.consumerId();
......@@ -323,8 +323,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
* @return true if the operation succeeds, false otherwise.
*/
// computational complexity: O(n) where n is the number of the specified value
private boolean register(TransactionalDiscreteResourceStore discreteTxStore,
TransactionalContinuousResourceStore continuousTxStore,
private boolean register(TransactionalDiscreteResourceSubStore discreteTxStore,
TransactionalContinuousResourceSubStore continuousTxStore,
DiscreteResourceId key, List<Resource> values) {
// it's assumed that the passed "values" is non-empty
......@@ -352,8 +352,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
* @param values values to be removed
* @return true if the operation succeeds, false otherwise
*/
private boolean unregister(TransactionalDiscreteResourceStore discreteTxStore,
TransactionalContinuousResourceStore continuousTxStore,
private boolean unregister(TransactionalDiscreteResourceSubStore discreteTxStore,
TransactionalContinuousResourceSubStore continuousTxStore,
DiscreteResourceId key, List<Resource> values) {
// it's assumed that the passed "values" is non-empty
......
......@@ -37,12 +37,12 @@ import static com.google.common.base.Preconditions.checkArgument;
import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER;
import static org.onosproject.store.resource.impl.ContinuousResourceAllocation.hasEnoughResource;
class TransactionalContinuousResourceStore {
class TransactionalContinuousResourceSubStore {
private final Logger log = LoggerFactory.getLogger(getClass());
private final TransactionalMap<DiscreteResourceId, Set<ContinuousResource>> childMap;
private final TransactionalMap<ContinuousResourceId, ContinuousResourceAllocation> consumers;
TransactionalContinuousResourceStore(TransactionContext tx) {
TransactionalContinuousResourceSubStore(TransactionContext tx) {
this.childMap = tx.getTransactionalMap(MapNames.CONTINUOUS_CHILD_MAP, SERIALIZER);
this.consumers = tx.getTransactionalMap(MapNames.CONTINUOUS_CONSUMER_MAP, SERIALIZER);
}
......
......@@ -33,12 +33,12 @@ import java.util.Set;
import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER;
class TransactionalDiscreteResourceStore {
class TransactionalDiscreteResourceSubStore {
private final Logger log = LoggerFactory.getLogger(getClass());
private final TransactionalMap<DiscreteResourceId, Set<DiscreteResource>> childMap;
private final TransactionalMap<DiscreteResourceId, ResourceConsumerId> consumers;
TransactionalDiscreteResourceStore(TransactionContext tx) {
TransactionalDiscreteResourceSubStore(TransactionContext tx) {
this.childMap = tx.getTransactionalMap(MapNames.DISCRETE_CHILD_MAP, SERIALIZER);
this.consumers = tx.getTransactionalMap(MapNames.DISCRETE_CONSUMER_MAP, SERIALIZER);
}
......