Package io.atomix.client.map
Interface AsyncAtomicCounterMap<K>
- All Superinterfaces:
AsyncPrimitive<AsyncAtomicCounterMap<K>,,AtomicCounterMap<K>> DistributedPrimitive
public interface AsyncAtomicCounterMap<K>
extends AsyncPrimitive<AsyncAtomicCounterMap<K>,AtomicCounterMap<K>>
An async atomic counter map dispenses monotonically increasing values associated with key.
-
Method Summary
Modifier and TypeMethodDescriptionAdds delta to the value currently associated with key, and returns the new value.clear()Removes all entries from the map.decrementAndGet(K key) Decrements by one the value currently associated with key, and returns the new value.Returns the value associated with key, or zero if there is no value associated with key.Adds delta to the value currently associated with key, and returns the old value.getAndDecrement(K key) Decrements by one the value currently associated with key, and returns the old value.getAndIncrement(K key) Increments by one the value currently associated with key, and returns the old value.incrementAndGet(K key) Increments by one the value currently associated with key, and returns the new value.isEmpty()Returns a boolean indicating whether the map is empty.Associates ewValue with key in this map, and returns the value previously associated with key, or zero if there was no such value.putIfAbsent(K key, long newValue) If key is not already associated with a value or if key is associated with zero, associate it with newValue.Removes and returns the value associated with key.If (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.If (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method return false.size()Returns the number of entries in the map.default AtomicCounterMap<K>Returns a synchronous wrapper around the asynchronous primitive.Methods inherited from interface io.atomix.client.AsyncPrimitive
close, syncMethods inherited from interface io.atomix.client.DistributedPrimitive
name
-
Method Details
-
incrementAndGet
Increments by one the value currently associated with key, and returns the new value.- Parameters:
key- key with which the specified value is to be associated- Returns:
- incremented value
-
decrementAndGet
Decrements by one the value currently associated with key, and returns the new value.- Parameters:
key- key with which the specified value is to be associated- Returns:
- updated value
-
getAndIncrement
Increments by one the value currently associated with key, and returns the old value.- Parameters:
key- key with which the specified value is to be associated- Returns:
- previous value
-
getAndDecrement
Decrements by one the value currently associated with key, and returns the old value.- Parameters:
key- key with which the specified value is to be associated- Returns:
- previous value
-
addAndGet
Adds delta to the value currently associated with key, and returns the new value.- Parameters:
key- key with which the specified value is to be associateddelta- the value to add- Returns:
- updated value
-
getAndAdd
Adds delta to the value currently associated with key, and returns the old value.- Parameters:
key- key with which the specified value is to be associateddelta- the value to add- Returns:
- previous value
-
get
Returns the value associated with key, or zero if there is no value associated with key.- Parameters:
key- key with which the specified value is to be associated- Returns:
- current value
-
put
Associates ewValue with key in this map, and returns the value previously associated with key, or zero if there was no such value.- Parameters:
key- key with which the specified value is to be associatednewValue- the value to put- Returns:
- previous value or zero
-
putIfAbsent
If key is not already associated with a value or if key is associated with zero, associate it with newValue. Returns the previous value associated with key, or zero if there was no mapping for key.- Parameters:
key- key with which the specified value is to be associatednewValue- the value to put- Returns:
- previous value or zero
-
replace
If (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method return false.If expectedOldValue is zero, this method will succeed if (key, zero) is currently in the map, or if key is not in the map at all.
- Parameters:
key- key with which the specified value is to be associatedexpectedOldValue- the expected valuenewValue- the value to replace- Returns:
- true if the value was replaced, false otherwise
-
remove
Removes and returns the value associated with key. If key is not in the map, this method has no effect and returns zero.- Parameters:
key- key with which the specified value is to be associated- Returns:
- the previous value associated with the specified key or null
-
remove
If (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.- Parameters:
key- key with which the specified value is to be associatedvalue- the value to remove- Returns:
- true if the value was removed, false otherwise
-
size
CompletableFuture<Integer> size()Returns the number of entries in the map.- Returns:
- the number of entries in the map
-
isEmpty
CompletableFuture<Boolean> isEmpty()Returns a boolean indicating whether the map is empty.- Returns:
- true if the map is empty, false otherwise
-
clear
CompletableFuture<Void> clear()Removes all entries from the map.- Returns:
- void
-
sync
Description copied from interface:AsyncPrimitiveReturns a synchronous wrapper around the asynchronous primitive.- Specified by:
syncin interfaceAsyncPrimitive<AsyncAtomicCounterMap<K>,AtomicCounterMap<K>> - Parameters:
operationTimeout- the synchronous operation timeout- Returns:
- the synchronous primitive
-