Rename methods to register and unregister resources
appendValues() -> register() removeValues() -> unregister() Change-Id: I27e2f6e941230a323d1237df02b8b3ae06a24931
Showing
3 changed files
with
16 additions
and
16 deletions
... | @@ -128,7 +128,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -128,7 +128,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
128 | return abortTransaction(tx); | 128 | return abortTransaction(tx); |
129 | } | 129 | } |
130 | 130 | ||
131 | - if (!appendValues(discreteTxStore, continuousTxStore, parentId, entry.getValue())) { | 131 | + if (!register(discreteTxStore, continuousTxStore, parentId, entry.getValue())) { |
132 | return abortTransaction(tx); | 132 | return abortTransaction(tx); |
133 | } | 133 | } |
134 | } | 134 | } |
... | @@ -191,7 +191,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -191,7 +191,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
191 | return abortTransaction(tx); | 191 | return abortTransaction(tx); |
192 | } | 192 | } |
193 | 193 | ||
194 | - if (!removeValues(discreteTxStore, continuousTxStore, entry.getKey(), entry.getValue())) { | 194 | + if (!unregister(discreteTxStore, continuousTxStore, entry.getKey(), entry.getValue())) { |
195 | log.warn("Failed to unregister {}: Failed to remove {} values.", | 195 | log.warn("Failed to unregister {}: Failed to remove {} values.", |
196 | entry.getKey(), entry.getValue().size()); | 196 | entry.getKey(), entry.getValue().size()); |
197 | log.debug("Failed to unregister {}: Failed to remove values: {}", | 197 | log.debug("Failed to unregister {}: Failed to remove values: {}", |
... | @@ -343,7 +343,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -343,7 +343,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
343 | * @return true if the operation succeeds, false otherwise. | 343 | * @return true if the operation succeeds, false otherwise. |
344 | */ | 344 | */ |
345 | // computational complexity: O(n) where n is the number of the specified value | 345 | // computational complexity: O(n) where n is the number of the specified value |
346 | - private boolean appendValues(TransactionalDiscreteResourceStore discreteTxStore, | 346 | + private boolean register(TransactionalDiscreteResourceStore discreteTxStore, |
347 | TransactionalContinuousResourceStore continuousTxStore, | 347 | TransactionalContinuousResourceStore continuousTxStore, |
348 | DiscreteResourceId key, List<Resource> values) { | 348 | DiscreteResourceId key, List<Resource> values) { |
349 | // it's assumed that the passed "values" is non-empty | 349 | // it's assumed that the passed "values" is non-empty |
... | @@ -360,14 +360,14 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -360,14 +360,14 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
360 | 360 | ||
361 | // short-circuit decision avoiding unnecessary distributed map operations | 361 | // short-circuit decision avoiding unnecessary distributed map operations |
362 | if (continuousValues.isEmpty()) { | 362 | if (continuousValues.isEmpty()) { |
363 | - return discreteTxStore.appendValues(key, discreteValues); | 363 | + return discreteTxStore.register(key, discreteValues); |
364 | } | 364 | } |
365 | if (discreteValues.isEmpty()) { | 365 | if (discreteValues.isEmpty()) { |
366 | - return continuousTxStore.appendValues(key, continuousValues); | 366 | + return continuousTxStore.register(key, continuousValues); |
367 | } | 367 | } |
368 | 368 | ||
369 | - return discreteTxStore.appendValues(key, discreteValues) | 369 | + return discreteTxStore.register(key, discreteValues) |
370 | - && continuousTxStore.appendValues(key, continuousValues); | 370 | + && continuousTxStore.register(key, continuousValues); |
371 | } | 371 | } |
372 | 372 | ||
373 | /** | 373 | /** |
... | @@ -380,7 +380,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -380,7 +380,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
380 | * @param values values to be removed | 380 | * @param values values to be removed |
381 | * @return true if the operation succeeds, false otherwise | 381 | * @return true if the operation succeeds, false otherwise |
382 | */ | 382 | */ |
383 | - private boolean removeValues(TransactionalDiscreteResourceStore discreteTxStore, | 383 | + private boolean unregister(TransactionalDiscreteResourceStore discreteTxStore, |
384 | TransactionalContinuousResourceStore continuousTxStore, | 384 | TransactionalContinuousResourceStore continuousTxStore, |
385 | DiscreteResourceId key, List<Resource> values) { | 385 | DiscreteResourceId key, List<Resource> values) { |
386 | // it's assumed that the passed "values" is non-empty | 386 | // it's assumed that the passed "values" is non-empty |
... | @@ -397,14 +397,14 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -397,14 +397,14 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
397 | 397 | ||
398 | // short-circuit decision avoiding unnecessary distributed map operations | 398 | // short-circuit decision avoiding unnecessary distributed map operations |
399 | if (continuousValues.isEmpty()) { | 399 | if (continuousValues.isEmpty()) { |
400 | - return discreteTxStore.removeValues(key, discreteValues); | 400 | + return discreteTxStore.unregister(key, discreteValues); |
401 | } | 401 | } |
402 | if (discreteValues.isEmpty()) { | 402 | if (discreteValues.isEmpty()) { |
403 | - return continuousTxStore.removeValues(key, continuousValues); | 403 | + return continuousTxStore.unregister(key, continuousValues); |
404 | } | 404 | } |
405 | 405 | ||
406 | - return discreteTxStore.removeValues(key, discreteValues) | 406 | + return discreteTxStore.unregister(key, discreteValues) |
407 | - && continuousTxStore.removeValues(key, continuousValues); | 407 | + && continuousTxStore.unregister(key, continuousValues); |
408 | } | 408 | } |
409 | 409 | ||
410 | // internal use only | 410 | // internal use only | ... | ... |
... | @@ -66,7 +66,7 @@ class TransactionalContinuousResourceStore { | ... | @@ -66,7 +66,7 @@ class TransactionalContinuousResourceStore { |
66 | .findFirst(); | 66 | .findFirst(); |
67 | } | 67 | } |
68 | 68 | ||
69 | - boolean appendValues(DiscreteResourceId key, List<ContinuousResource> values) { | 69 | + boolean register(DiscreteResourceId key, List<ContinuousResource> values) { |
70 | Set<ContinuousResource> requested = new LinkedHashSet<>(values); | 70 | Set<ContinuousResource> requested = new LinkedHashSet<>(values); |
71 | Set<ContinuousResource> oldValues = childMap.putIfAbsent(key, requested); | 71 | Set<ContinuousResource> oldValues = childMap.putIfAbsent(key, requested); |
72 | if (oldValues == null) { | 72 | if (oldValues == null) { |
... | @@ -94,7 +94,7 @@ class TransactionalContinuousResourceStore { | ... | @@ -94,7 +94,7 @@ class TransactionalContinuousResourceStore { |
94 | return childMap.replace(key, oldValues, newValues); | 94 | return childMap.replace(key, oldValues, newValues); |
95 | } | 95 | } |
96 | 96 | ||
97 | - boolean removeValues(DiscreteResourceId key, List<ContinuousResource> values) { | 97 | + boolean unregister(DiscreteResourceId key, List<ContinuousResource> values) { |
98 | Set<ContinuousResource> oldValues = childMap.putIfAbsent(key, new LinkedHashSet<>()); | 98 | Set<ContinuousResource> oldValues = childMap.putIfAbsent(key, new LinkedHashSet<>()); |
99 | if (oldValues == null) { | 99 | if (oldValues == null) { |
100 | log.trace("No-Op removing values. key {} did not exist", key); | 100 | log.trace("No-Op removing values. key {} did not exist", key); | ... | ... |
... | @@ -62,7 +62,7 @@ class TransactionalDiscreteResourceStore { | ... | @@ -62,7 +62,7 @@ class TransactionalDiscreteResourceStore { |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | - boolean appendValues(DiscreteResourceId key, List<DiscreteResource> values) { | 65 | + boolean register(DiscreteResourceId key, List<DiscreteResource> values) { |
66 | Set<DiscreteResource> requested = new LinkedHashSet<>(values); | 66 | Set<DiscreteResource> requested = new LinkedHashSet<>(values); |
67 | Set<DiscreteResource> oldValues = childMap.putIfAbsent(key, requested); | 67 | Set<DiscreteResource> oldValues = childMap.putIfAbsent(key, requested); |
68 | if (oldValues == null) { | 68 | if (oldValues == null) { |
... | @@ -81,7 +81,7 @@ class TransactionalDiscreteResourceStore { | ... | @@ -81,7 +81,7 @@ class TransactionalDiscreteResourceStore { |
81 | return childMap.replace(key, oldValues, newValues); | 81 | return childMap.replace(key, oldValues, newValues); |
82 | } | 82 | } |
83 | 83 | ||
84 | - boolean removeValues(DiscreteResourceId key, List<DiscreteResource> values) { | 84 | + boolean unregister(DiscreteResourceId key, List<DiscreteResource> values) { |
85 | Set<DiscreteResource> oldValues = childMap.putIfAbsent(key, new LinkedHashSet<>()); | 85 | Set<DiscreteResource> oldValues = childMap.putIfAbsent(key, new LinkedHashSet<>()); |
86 | if (oldValues == null) { | 86 | if (oldValues == null) { |
87 | log.trace("No-Op removing values. key {} did not exist", key); | 87 | log.trace("No-Op removing values. key {} did not exist", key); | ... | ... |
-
Please register or login to post a comment