Committed by
Gerrit Code Review
Remove base (p0) partition in StorageManager
Change-Id: Idae636173a9638da19f391e203bec0bccb399328
Showing
6 changed files
with
23 additions
and
39 deletions
... | @@ -48,6 +48,7 @@ public final class ClusterMetadata implements Provided { | ... | @@ -48,6 +48,7 @@ public final class ClusterMetadata implements Provided { |
48 | private final Set<ControllerNode> nodes; | 48 | private final Set<ControllerNode> nodes; |
49 | private final Set<Partition> partitions; | 49 | private final Set<Partition> partitions; |
50 | 50 | ||
51 | + @SuppressWarnings("unused") | ||
51 | private ClusterMetadata() { | 52 | private ClusterMetadata() { |
52 | providerId = null; | 53 | providerId = null; |
53 | name = null; | 54 | name = null; | ... | ... |
... | @@ -24,17 +24,14 @@ import org.onosproject.store.service.LeaderElectorBuilder; | ... | @@ -24,17 +24,14 @@ import org.onosproject.store.service.LeaderElectorBuilder; |
24 | */ | 24 | */ |
25 | public class DefaultLeaderElectorBuilder extends LeaderElectorBuilder { | 25 | public class DefaultLeaderElectorBuilder extends LeaderElectorBuilder { |
26 | 26 | ||
27 | - private final DistributedPrimitiveCreator base; | 27 | + private final DistributedPrimitiveCreator primitiveCreator; |
28 | - private final DistributedPrimitiveCreator federated; | ||
29 | 28 | ||
30 | - public DefaultLeaderElectorBuilder(DistributedPrimitiveCreator base, DistributedPrimitiveCreator federated) { | 29 | + public DefaultLeaderElectorBuilder(DistributedPrimitiveCreator primitiveCreator) { |
31 | - this.base = base; | 30 | + this.primitiveCreator = primitiveCreator; |
32 | - this.federated = federated; | ||
33 | } | 31 | } |
34 | 32 | ||
35 | @Override | 33 | @Override |
36 | public AsyncLeaderElector build() { | 34 | public AsyncLeaderElector build() { |
37 | - DistributedPrimitiveCreator creator = partitionsDisabled() ? base : federated; | 35 | + return primitiveCreator.newAsyncLeaderElector(name()); |
38 | - return creator.newAsyncLeaderElector(name()); | ||
39 | } | 36 | } |
40 | } | 37 | } | ... | ... |
... | @@ -24,17 +24,14 @@ import org.onosproject.store.service.AtomicCounterBuilder; | ... | @@ -24,17 +24,14 @@ import org.onosproject.store.service.AtomicCounterBuilder; |
24 | */ | 24 | */ |
25 | public class NewDefaultAtomicCounterBuilder extends AtomicCounterBuilder { | 25 | public class NewDefaultAtomicCounterBuilder extends AtomicCounterBuilder { |
26 | 26 | ||
27 | - private final DistributedPrimitiveCreator base; | 27 | + private final DistributedPrimitiveCreator primitiveCreator; |
28 | - private final DistributedPrimitiveCreator federated; | ||
29 | 28 | ||
30 | - public NewDefaultAtomicCounterBuilder(DistributedPrimitiveCreator base, DistributedPrimitiveCreator federated) { | 29 | + public NewDefaultAtomicCounterBuilder(DistributedPrimitiveCreator primitiveCreator) { |
31 | - this.base = base; | 30 | + this.primitiveCreator = primitiveCreator; |
32 | - this.federated = federated; | ||
33 | } | 31 | } |
34 | 32 | ||
35 | @Override | 33 | @Override |
36 | public AsyncAtomicCounter build() { | 34 | public AsyncAtomicCounter build() { |
37 | - DistributedPrimitiveCreator creator = partitionsDisabled() ? base : federated; | 35 | + return primitiveCreator.newAsyncCounter(name()); |
38 | - return creator.newAsyncCounter(name()); | ||
39 | } | 36 | } |
40 | } | 37 | } | ... | ... |
... | @@ -28,12 +28,10 @@ import org.onosproject.store.service.ConsistentMapBuilder; | ... | @@ -28,12 +28,10 @@ import org.onosproject.store.service.ConsistentMapBuilder; |
28 | */ | 28 | */ |
29 | public class NewDefaultConsistentMapBuilder<K, V> extends ConsistentMapBuilder<K, V> { | 29 | public class NewDefaultConsistentMapBuilder<K, V> extends ConsistentMapBuilder<K, V> { |
30 | 30 | ||
31 | - private final DistributedPrimitiveCreator base; | 31 | + private final DistributedPrimitiveCreator primitiveCreator; |
32 | - private final DistributedPrimitiveCreator federated; | ||
33 | 32 | ||
34 | - public NewDefaultConsistentMapBuilder(DistributedPrimitiveCreator base, DistributedPrimitiveCreator federated) { | 33 | + public NewDefaultConsistentMapBuilder(DistributedPrimitiveCreator primitiveCreator) { |
35 | - this.base = base; | 34 | + this.primitiveCreator = primitiveCreator; |
36 | - this.federated = federated; | ||
37 | } | 35 | } |
38 | 36 | ||
39 | @Override | 37 | @Override |
... | @@ -43,8 +41,7 @@ public class NewDefaultConsistentMapBuilder<K, V> extends ConsistentMapBuilder<K | ... | @@ -43,8 +41,7 @@ public class NewDefaultConsistentMapBuilder<K, V> extends ConsistentMapBuilder<K |
43 | 41 | ||
44 | @Override | 42 | @Override |
45 | public AsyncConsistentMap<K, V> buildAsyncMap() { | 43 | public AsyncConsistentMap<K, V> buildAsyncMap() { |
46 | - DistributedPrimitiveCreator creator = partitionsDisabled() ? base : federated; | 44 | + AsyncConsistentMap<K, V> map = primitiveCreator.newAsyncConsistentMap(name(), serializer()); |
47 | - AsyncConsistentMap<K, V> map = creator.newAsyncConsistentMap(name(), serializer()); | ||
48 | map = relaxedReadConsistency() ? DistributedPrimitives.newCachingMap(map) : map; | 45 | map = relaxedReadConsistency() ? DistributedPrimitives.newCachingMap(map) : map; |
49 | map = readOnly() ? DistributedPrimitives.newUnmodifiableMap(map) : map; | 46 | map = readOnly() ? DistributedPrimitives.newUnmodifiableMap(map) : map; |
50 | return meteringEnabled() ? DistributedPrimitives.newMeteredMap(map) : map; | 47 | return meteringEnabled() ? DistributedPrimitives.newMeteredMap(map) : map; | ... | ... |
... | @@ -25,24 +25,21 @@ import org.onosproject.store.service.TransactionContextBuilder; | ... | @@ -25,24 +25,21 @@ import org.onosproject.store.service.TransactionContextBuilder; |
25 | public class NewDefaultTransactionContextBuilder extends TransactionContextBuilder { | 25 | public class NewDefaultTransactionContextBuilder extends TransactionContextBuilder { |
26 | 26 | ||
27 | private final TransactionId transactionId; | 27 | private final TransactionId transactionId; |
28 | - private final DistributedPrimitiveCreator base; | 28 | + private final DistributedPrimitiveCreator primitiveCreator; |
29 | - private final DistributedPrimitiveCreator federated; | ||
30 | private final TransactionCoordinator transactionCoordinator; | 29 | private final TransactionCoordinator transactionCoordinator; |
31 | 30 | ||
32 | public NewDefaultTransactionContextBuilder(TransactionId transactionId, | 31 | public NewDefaultTransactionContextBuilder(TransactionId transactionId, |
33 | - DistributedPrimitiveCreator base, | 32 | + DistributedPrimitiveCreator primitiveCreator, |
34 | - DistributedPrimitiveCreator federated, | ||
35 | TransactionCoordinator transactionCoordinator) { | 33 | TransactionCoordinator transactionCoordinator) { |
36 | this.transactionId = transactionId; | 34 | this.transactionId = transactionId; |
37 | - this.base = base; | 35 | + this.primitiveCreator = primitiveCreator; |
38 | - this.federated = federated; | ||
39 | this.transactionCoordinator = transactionCoordinator; | 36 | this.transactionCoordinator = transactionCoordinator; |
40 | } | 37 | } |
41 | 38 | ||
42 | @Override | 39 | @Override |
43 | public TransactionContext build() { | 40 | public TransactionContext build() { |
44 | return new NewDefaultTransactionContext(transactionId, | 41 | return new NewDefaultTransactionContext(transactionId, |
45 | - this.partitionsDisabled() ? base : federated, | 42 | + primitiveCreator, |
46 | transactionCoordinator); | 43 | transactionCoordinator); |
47 | } | 44 | } |
48 | } | 45 | } | ... | ... |
... | @@ -24,7 +24,6 @@ import java.util.UUID; | ... | @@ -24,7 +24,6 @@ import java.util.UUID; |
24 | import java.util.function.Supplier; | 24 | import java.util.function.Supplier; |
25 | import java.util.stream.Collectors; | 25 | import java.util.stream.Collectors; |
26 | 26 | ||
27 | -import org.apache.commons.collections.ListUtils; | ||
28 | import org.apache.felix.scr.annotations.Activate; | 27 | import org.apache.felix.scr.annotations.Activate; |
29 | import org.apache.felix.scr.annotations.Component; | 28 | import org.apache.felix.scr.annotations.Component; |
30 | import org.apache.felix.scr.annotations.Deactivate; | 29 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -58,6 +57,7 @@ import org.onosproject.store.service.StorageService; | ... | @@ -58,6 +57,7 @@ import org.onosproject.store.service.StorageService; |
58 | import org.onosproject.store.service.TransactionContextBuilder; | 57 | import org.onosproject.store.service.TransactionContextBuilder; |
59 | import org.slf4j.Logger; | 58 | import org.slf4j.Logger; |
60 | 59 | ||
60 | +import com.google.common.collect.ImmutableMap; | ||
61 | import com.google.common.collect.Maps; | 61 | import com.google.common.collect.Maps; |
62 | import com.google.common.util.concurrent.Futures; | 62 | import com.google.common.util.concurrent.Futures; |
63 | 63 | ||
... | @@ -87,14 +87,12 @@ public class StorageManager implements StorageService, StorageAdminService { | ... | @@ -87,14 +87,12 @@ public class StorageManager implements StorageService, StorageAdminService { |
87 | 87 | ||
88 | private final Supplier<TransactionId> transactionIdGenerator = | 88 | private final Supplier<TransactionId> transactionIdGenerator = |
89 | () -> TransactionId.from(UUID.randomUUID().toString()); | 89 | () -> TransactionId.from(UUID.randomUUID().toString()); |
90 | - private DistributedPrimitiveCreator basePrimitiveCreator; | ||
91 | private DistributedPrimitiveCreator federatedPrimitiveCreator; | 90 | private DistributedPrimitiveCreator federatedPrimitiveCreator; |
92 | private AsyncConsistentMap<TransactionId, Transaction.State> transactions; | 91 | private AsyncConsistentMap<TransactionId, Transaction.State> transactions; |
93 | private TransactionCoordinator transactionCoordinator; | 92 | private TransactionCoordinator transactionCoordinator; |
94 | 93 | ||
95 | @Activate | 94 | @Activate |
96 | public void activate() { | 95 | public void activate() { |
97 | - basePrimitiveCreator = partitionService.getDistributedPrimitiveCreator(PartitionId.from(0)); | ||
98 | Map<PartitionId, DistributedPrimitiveCreator> partitionMap = Maps.newHashMap(); | 96 | Map<PartitionId, DistributedPrimitiveCreator> partitionMap = Maps.newHashMap(); |
99 | partitionService.getAllPartitionIds().stream() | 97 | partitionService.getAllPartitionIds().stream() |
100 | .filter(id -> !id.equals(PartitionId.from(0))) | 98 | .filter(id -> !id.equals(PartitionId.from(0))) |
... | @@ -126,7 +124,7 @@ public class StorageManager implements StorageService, StorageAdminService { | ... | @@ -126,7 +124,7 @@ public class StorageManager implements StorageService, StorageAdminService { |
126 | 124 | ||
127 | @Override | 125 | @Override |
128 | public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() { | 126 | public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() { |
129 | - return new NewDefaultConsistentMapBuilder<>(basePrimitiveCreator, federatedPrimitiveCreator); | 127 | + return new NewDefaultConsistentMapBuilder<>(federatedPrimitiveCreator); |
130 | } | 128 | } |
131 | 129 | ||
132 | @Override | 130 | @Override |
... | @@ -142,7 +140,7 @@ public class StorageManager implements StorageService, StorageAdminService { | ... | @@ -142,7 +140,7 @@ public class StorageManager implements StorageService, StorageAdminService { |
142 | 140 | ||
143 | @Override | 141 | @Override |
144 | public AtomicCounterBuilder atomicCounterBuilder() { | 142 | public AtomicCounterBuilder atomicCounterBuilder() { |
145 | - return new NewDefaultAtomicCounterBuilder(basePrimitiveCreator, federatedPrimitiveCreator); | 143 | + return new NewDefaultAtomicCounterBuilder(federatedPrimitiveCreator); |
146 | } | 144 | } |
147 | 145 | ||
148 | @Override | 146 | @Override |
... | @@ -150,7 +148,6 @@ public class StorageManager implements StorageService, StorageAdminService { | ... | @@ -150,7 +148,6 @@ public class StorageManager implements StorageService, StorageAdminService { |
150 | Supplier<ConsistentMapBuilder<String, byte[]>> mapBuilderSupplier = | 148 | Supplier<ConsistentMapBuilder<String, byte[]>> mapBuilderSupplier = |
151 | () -> this.<String, byte[]>consistentMapBuilder() | 149 | () -> this.<String, byte[]>consistentMapBuilder() |
152 | .withName("onos-atomic-values") | 150 | .withName("onos-atomic-values") |
153 | - .withMeteringDisabled() | ||
154 | .withSerializer(Serializer.using(KryoNamespaces.BASIC)); | 151 | .withSerializer(Serializer.using(KryoNamespaces.BASIC)); |
155 | return new DefaultAtomicValueBuilder<>(mapBuilderSupplier); | 152 | return new DefaultAtomicValueBuilder<>(mapBuilderSupplier); |
156 | } | 153 | } |
... | @@ -158,20 +155,18 @@ public class StorageManager implements StorageService, StorageAdminService { | ... | @@ -158,20 +155,18 @@ public class StorageManager implements StorageService, StorageAdminService { |
158 | @Override | 155 | @Override |
159 | public TransactionContextBuilder transactionContextBuilder() { | 156 | public TransactionContextBuilder transactionContextBuilder() { |
160 | return new NewDefaultTransactionContextBuilder(transactionIdGenerator.get(), | 157 | return new NewDefaultTransactionContextBuilder(transactionIdGenerator.get(), |
161 | - basePrimitiveCreator, | ||
162 | federatedPrimitiveCreator, | 158 | federatedPrimitiveCreator, |
163 | transactionCoordinator); | 159 | transactionCoordinator); |
164 | } | 160 | } |
165 | 161 | ||
166 | @Override | 162 | @Override |
167 | public LeaderElectorBuilder leaderElectorBuilder() { | 163 | public LeaderElectorBuilder leaderElectorBuilder() { |
168 | - return new DefaultLeaderElectorBuilder(basePrimitiveCreator, | 164 | + return new DefaultLeaderElectorBuilder(federatedPrimitiveCreator); |
169 | - federatedPrimitiveCreator); | ||
170 | } | 165 | } |
171 | 166 | ||
172 | @Override | 167 | @Override |
173 | public List<MapInfo> getMapInfo() { | 168 | public List<MapInfo> getMapInfo() { |
174 | - return ListUtils.union(listMapInfo(basePrimitiveCreator), listMapInfo(federatedPrimitiveCreator)); | 169 | + return listMapInfo(federatedPrimitiveCreator); |
175 | } | 170 | } |
176 | 171 | ||
177 | @Override | 172 | @Override |
... | @@ -184,7 +179,7 @@ public class StorageManager implements StorageService, StorageAdminService { | ... | @@ -184,7 +179,7 @@ public class StorageManager implements StorageService, StorageAdminService { |
184 | 179 | ||
185 | @Override | 180 | @Override |
186 | public Map<String, Long> getInMemoryDatabaseCounters() { | 181 | public Map<String, Long> getInMemoryDatabaseCounters() { |
187 | - return getCounters(basePrimitiveCreator); | 182 | + return ImmutableMap.of(); |
188 | } | 183 | } |
189 | 184 | ||
190 | @Override | 185 | @Override | ... | ... |
-
Please register or login to post a comment