Madan Jampani
Committed by Gerrit Code Review

Remove base (p0) partition in StorageManager

Change-Id: Idae636173a9638da19f391e203bec0bccb399328
......@@ -48,6 +48,7 @@ public final class ClusterMetadata implements Provided {
private final Set<ControllerNode> nodes;
private final Set<Partition> partitions;
@SuppressWarnings("unused")
private ClusterMetadata() {
providerId = null;
name = null;
......
......@@ -24,17 +24,14 @@ import org.onosproject.store.service.LeaderElectorBuilder;
*/
public class DefaultLeaderElectorBuilder extends LeaderElectorBuilder {
private final DistributedPrimitiveCreator base;
private final DistributedPrimitiveCreator federated;
private final DistributedPrimitiveCreator primitiveCreator;
public DefaultLeaderElectorBuilder(DistributedPrimitiveCreator base, DistributedPrimitiveCreator federated) {
this.base = base;
this.federated = federated;
public DefaultLeaderElectorBuilder(DistributedPrimitiveCreator primitiveCreator) {
this.primitiveCreator = primitiveCreator;
}
@Override
public AsyncLeaderElector build() {
DistributedPrimitiveCreator creator = partitionsDisabled() ? base : federated;
return creator.newAsyncLeaderElector(name());
return primitiveCreator.newAsyncLeaderElector(name());
}
}
......
......@@ -24,17 +24,14 @@ import org.onosproject.store.service.AtomicCounterBuilder;
*/
public class NewDefaultAtomicCounterBuilder extends AtomicCounterBuilder {
private final DistributedPrimitiveCreator base;
private final DistributedPrimitiveCreator federated;
private final DistributedPrimitiveCreator primitiveCreator;
public NewDefaultAtomicCounterBuilder(DistributedPrimitiveCreator base, DistributedPrimitiveCreator federated) {
this.base = base;
this.federated = federated;
public NewDefaultAtomicCounterBuilder(DistributedPrimitiveCreator primitiveCreator) {
this.primitiveCreator = primitiveCreator;
}
@Override
public AsyncAtomicCounter build() {
DistributedPrimitiveCreator creator = partitionsDisabled() ? base : federated;
return creator.newAsyncCounter(name());
return primitiveCreator.newAsyncCounter(name());
}
}
......
......@@ -28,12 +28,10 @@ import org.onosproject.store.service.ConsistentMapBuilder;
*/
public class NewDefaultConsistentMapBuilder<K, V> extends ConsistentMapBuilder<K, V> {
private final DistributedPrimitiveCreator base;
private final DistributedPrimitiveCreator federated;
private final DistributedPrimitiveCreator primitiveCreator;
public NewDefaultConsistentMapBuilder(DistributedPrimitiveCreator base, DistributedPrimitiveCreator federated) {
this.base = base;
this.federated = federated;
public NewDefaultConsistentMapBuilder(DistributedPrimitiveCreator primitiveCreator) {
this.primitiveCreator = primitiveCreator;
}
@Override
......@@ -43,8 +41,7 @@ public class NewDefaultConsistentMapBuilder<K, V> extends ConsistentMapBuilder<K
@Override
public AsyncConsistentMap<K, V> buildAsyncMap() {
DistributedPrimitiveCreator creator = partitionsDisabled() ? base : federated;
AsyncConsistentMap<K, V> map = creator.newAsyncConsistentMap(name(), serializer());
AsyncConsistentMap<K, V> map = primitiveCreator.newAsyncConsistentMap(name(), serializer());
map = relaxedReadConsistency() ? DistributedPrimitives.newCachingMap(map) : map;
map = readOnly() ? DistributedPrimitives.newUnmodifiableMap(map) : map;
return meteringEnabled() ? DistributedPrimitives.newMeteredMap(map) : map;
......
......@@ -25,24 +25,21 @@ import org.onosproject.store.service.TransactionContextBuilder;
public class NewDefaultTransactionContextBuilder extends TransactionContextBuilder {
private final TransactionId transactionId;
private final DistributedPrimitiveCreator base;
private final DistributedPrimitiveCreator federated;
private final DistributedPrimitiveCreator primitiveCreator;
private final TransactionCoordinator transactionCoordinator;
public NewDefaultTransactionContextBuilder(TransactionId transactionId,
DistributedPrimitiveCreator base,
DistributedPrimitiveCreator federated,
DistributedPrimitiveCreator primitiveCreator,
TransactionCoordinator transactionCoordinator) {
this.transactionId = transactionId;
this.base = base;
this.federated = federated;
this.primitiveCreator = primitiveCreator;
this.transactionCoordinator = transactionCoordinator;
}
@Override
public TransactionContext build() {
return new NewDefaultTransactionContext(transactionId,
this.partitionsDisabled() ? base : federated,
primitiveCreator,
transactionCoordinator);
}
}
......
......@@ -24,7 +24,6 @@ import java.util.UUID;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.apache.commons.collections.ListUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -58,6 +57,7 @@ import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.TransactionContextBuilder;
import org.slf4j.Logger;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.Futures;
......@@ -87,14 +87,12 @@ public class StorageManager implements StorageService, StorageAdminService {
private final Supplier<TransactionId> transactionIdGenerator =
() -> TransactionId.from(UUID.randomUUID().toString());
private DistributedPrimitiveCreator basePrimitiveCreator;
private DistributedPrimitiveCreator federatedPrimitiveCreator;
private AsyncConsistentMap<TransactionId, Transaction.State> transactions;
private TransactionCoordinator transactionCoordinator;
@Activate
public void activate() {
basePrimitiveCreator = partitionService.getDistributedPrimitiveCreator(PartitionId.from(0));
Map<PartitionId, DistributedPrimitiveCreator> partitionMap = Maps.newHashMap();
partitionService.getAllPartitionIds().stream()
.filter(id -> !id.equals(PartitionId.from(0)))
......@@ -126,7 +124,7 @@ public class StorageManager implements StorageService, StorageAdminService {
@Override
public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
return new NewDefaultConsistentMapBuilder<>(basePrimitiveCreator, federatedPrimitiveCreator);
return new NewDefaultConsistentMapBuilder<>(federatedPrimitiveCreator);
}
@Override
......@@ -142,7 +140,7 @@ public class StorageManager implements StorageService, StorageAdminService {
@Override
public AtomicCounterBuilder atomicCounterBuilder() {
return new NewDefaultAtomicCounterBuilder(basePrimitiveCreator, federatedPrimitiveCreator);
return new NewDefaultAtomicCounterBuilder(federatedPrimitiveCreator);
}
@Override
......@@ -150,7 +148,6 @@ public class StorageManager implements StorageService, StorageAdminService {
Supplier<ConsistentMapBuilder<String, byte[]>> mapBuilderSupplier =
() -> this.<String, byte[]>consistentMapBuilder()
.withName("onos-atomic-values")
.withMeteringDisabled()
.withSerializer(Serializer.using(KryoNamespaces.BASIC));
return new DefaultAtomicValueBuilder<>(mapBuilderSupplier);
}
......@@ -158,20 +155,18 @@ public class StorageManager implements StorageService, StorageAdminService {
@Override
public TransactionContextBuilder transactionContextBuilder() {
return new NewDefaultTransactionContextBuilder(transactionIdGenerator.get(),
basePrimitiveCreator,
federatedPrimitiveCreator,
transactionCoordinator);
}
@Override
public LeaderElectorBuilder leaderElectorBuilder() {
return new DefaultLeaderElectorBuilder(basePrimitiveCreator,
federatedPrimitiveCreator);
return new DefaultLeaderElectorBuilder(federatedPrimitiveCreator);
}
@Override
public List<MapInfo> getMapInfo() {
return ListUtils.union(listMapInfo(basePrimitiveCreator), listMapInfo(federatedPrimitiveCreator));
return listMapInfo(federatedPrimitiveCreator);
}
@Override
......@@ -184,7 +179,7 @@ public class StorageManager implements StorageService, StorageAdminService {
@Override
public Map<String, Long> getInMemoryDatabaseCounters() {
return getCounters(basePrimitiveCreator);
return ImmutableMap.of();
}
@Override
......