Remove base (p0) partition in StorageManager
Change-Id: Idae636173a9638da19f391e203bec0bccb399328
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
index 63a04d1..c492844 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
@@ -48,6 +48,7 @@
private final Set<ControllerNode> nodes;
private final Set<Partition> partitions;
+ @SuppressWarnings("unused")
private ClusterMetadata() {
providerId = null;
name = null;
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultLeaderElectorBuilder.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultLeaderElectorBuilder.java
index 556ad17..58c2c13 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultLeaderElectorBuilder.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultLeaderElectorBuilder.java
@@ -24,17 +24,14 @@
*/
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());
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultAtomicCounterBuilder.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultAtomicCounterBuilder.java
index 42ef659..556774e 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultAtomicCounterBuilder.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultAtomicCounterBuilder.java
@@ -24,17 +24,14 @@
*/
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());
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultConsistentMapBuilder.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultConsistentMapBuilder.java
index 50b3fea..dfef62e 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultConsistentMapBuilder.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultConsistentMapBuilder.java
@@ -28,12 +28,10 @@
*/
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 @@
@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;
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultTransactionContextBuilder.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultTransactionContextBuilder.java
index 3a27122..7d4e22e 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultTransactionContextBuilder.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/NewDefaultTransactionContextBuilder.java
@@ -25,24 +25,21 @@
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);
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageManager.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageManager.java
index b83a977..6410a40 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageManager.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageManager.java
@@ -24,7 +24,6 @@
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.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 @@
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 @@
@Override
public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
- return new NewDefaultConsistentMapBuilder<>(basePrimitiveCreator, federatedPrimitiveCreator);
+ return new NewDefaultConsistentMapBuilder<>(federatedPrimitiveCreator);
}
@Override
@@ -142,7 +140,7 @@
@Override
public AtomicCounterBuilder atomicCounterBuilder() {
- return new NewDefaultAtomicCounterBuilder(basePrimitiveCreator, federatedPrimitiveCreator);
+ return new NewDefaultAtomicCounterBuilder(federatedPrimitiveCreator);
}
@Override
@@ -150,7 +148,6 @@
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 @@
@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 @@
@Override
public Map<String, Long> getInMemoryDatabaseCounters() {
- return getCounters(basePrimitiveCreator);
+ return ImmutableMap.of();
}
@Override