public interface AsyncConsistentMap<K,V>
This map offers strong read-after-update (where update == create/update/delete) consistency. All operations to the map are serialized and applied in a consistent manner.
The stronger consistency comes at the expense of availability in the event of a network partition. A network partition can be either due to a temporary disruption in network connectivity between participating nodes or due to a node being temporarily down.
All values stored in this map are versioned and the API supports optimistic concurrency by allowing conditional updates that take into consideration the version or value that was previously read.
This map does not allow null values. All methods can throw a ConsistentMapException (which extends RuntimeException) to indicate failures.
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
clear()
Removes all of the mappings from this map (optional operation).
|
CompletableFuture<Versioned<V>> |
compute(K key,
java.util.function.BiFunction<? super K,? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value (or
null if there is no current mapping).
|
CompletableFuture<Versioned<V>> |
computeIf(K key,
java.util.function.Predicate<? super V> condition,
java.util.function.BiFunction<? super K,? super V,? extends V> remappingFunction)
If the value for the specified key satisfies a condition, attempts to compute a new
mapping given the key and its current mapped value.
|
CompletableFuture<Versioned<V>> |
computeIfAbsent(K key,
java.util.function.Function<? super K,? extends V> mappingFunction)
If the specified key is not already associated with a value (or is mapped to null),
attempts to compute its value using the given mapping function and enters it into
this map unless null.
|
CompletableFuture<Versioned<V>> |
computeIfPresent(K key,
java.util.function.BiFunction<? super K,? super V,? extends V> remappingFunction)
If the value for the specified key is present and non-null, attempts to compute a new
mapping given the key and its current mapped value.
|
CompletableFuture<Boolean> |
containsKey(K key)
Returns true if this map contains a mapping for the specified key.
|
CompletableFuture<Boolean> |
containsValue(V value)
Returns true if this map contains the specified value.
|
CompletableFuture<Set<Map.Entry<K,Versioned<V>>>> |
entrySet()
Returns the set of entries contained in this map.
|
CompletableFuture<Versioned<V>> |
get(K key)
Returns the value (and version) to which the specified key is mapped, or null if this
map contains no mapping for the key.
|
CompletableFuture<Boolean> |
isEmpty()
Returns true if the map is empty.
|
CompletableFuture<Set<K>> |
keySet()
Returns a Set view of the keys contained in this map.
|
CompletableFuture<Versioned<V>> |
put(K key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
CompletableFuture<Versioned<V>> |
putAndGet(K key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
CompletableFuture<Versioned<V>> |
putIfAbsent(K key,
V value)
If the specified key is not already associated with a value
associates it with the given value and returns null, else returns the current value.
|
CompletableFuture<Optional<Versioned<V>>> |
putIfAbsentAndGet(K key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
CompletableFuture<Versioned<V>> |
remove(K key)
Removes the mapping for a key from this map if it is present (optional operation).
|
CompletableFuture<Boolean> |
remove(K key,
long version)
Removes the entry for the specified key only if its current
version in the map is equal to the specified version.
|
CompletableFuture<Boolean> |
remove(K key,
V value)
Removes the entry for the specified key only if it is currently
mapped to the specified value.
|
CompletableFuture<Boolean> |
replace(K key,
long oldVersion,
V newValue)
Replaces the entry for the specified key only if it is currently mapped to the
specified version.
|
CompletableFuture<Boolean> |
replace(K key,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently mapped
to the specified value.
|
CompletableFuture<Optional<Versioned<V>>> |
replaceAndGet(K key,
long oldVersion,
V newValue)
Replaces the entry for the specified key only if it is currently mapped to the
specified version.
|
CompletableFuture<Integer> |
size()
Returns the number of entries in the map.
|
CompletableFuture<Collection<Versioned<V>>> |
values()
Returns the collection of values (and associated versions) contained in this map.
|
CompletableFuture<Integer> size()
CompletableFuture<Boolean> isEmpty()
CompletableFuture<Boolean> containsKey(K key)
key - keyCompletableFuture<Boolean> containsValue(V value)
value - valueCompletableFuture<Versioned<V>> get(K key)
key - the key whose associated value (and version) is to be returnedCompletableFuture<Versioned<V>> computeIfAbsent(K key, java.util.function.Function<? super K,? extends V> mappingFunction)
key - key with which the specified value is to be associatedmappingFunction - the function to compute a valueCompletableFuture<Versioned<V>> computeIfPresent(K key, java.util.function.BiFunction<? super K,? super V,? extends V> remappingFunction)
key - key with which the specified value is to be associatedremappingFunction - the function to compute a valueCompletableFuture<Versioned<V>> compute(K key, java.util.function.BiFunction<? super K,? super V,? extends V> remappingFunction)
key - key with which the specified value is to be associatedremappingFunction - the function to compute a valueCompletableFuture<Versioned<V>> computeIf(K key, java.util.function.Predicate<? super V> condition, java.util.function.BiFunction<? super K,? super V,? extends V> remappingFunction)
key - key with which the specified value is to be associatedcondition - condition that should evaluate to true for the computation to proceedremappingFunction - the function to compute a valueCompletableFuture<Versioned<V>> put(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyCompletableFuture<Versioned<V>> putAndGet(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyCompletableFuture<Optional<Versioned<V>>> putIfAbsentAndGet(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyCompletableFuture<Versioned<V>> remove(K key)
key - key whose value is to be removed from the mapCompletableFuture<Void> clear()
CompletableFuture<Set<K>> keySet()
CompletableFuture<Collection<Versioned<V>>> values()
CompletableFuture<Set<Map.Entry<K,Versioned<V>>>> entrySet()
CompletableFuture<Versioned<V>> putIfAbsent(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyCompletableFuture<Boolean> remove(K key, V value)
key - key with which the specified value is associatedvalue - value expected to be associated with the specified keyCompletableFuture<Boolean> remove(K key, long version)
key - key with which the specified version is associatedversion - version expected to be associated with the specified keyCompletableFuture<Boolean> replace(K key, V oldValue, V newValue)
key - key with which the specified value is associatedoldValue - value expected to be associated with the specified keynewValue - value to be associated with the specified keyCompletableFuture<Boolean> replace(K key, long oldVersion, V newValue)
key - key key with which the specified value is associatedoldVersion - version expected to be associated with the specified keynewValue - value to be associated with the specified keyCompletableFuture<Optional<Versioned<V>>> replaceAndGet(K key, long oldVersion, V newValue)
key - key key with which the specified value is associatedoldVersion - version expected to be associated with the specified keynewValue - value to be associated with the specified keyCopyright © 2015. All rights reserved.