K - key typeV - value typepublic class MeteredAsyncConsistentMap<K,V> extends DelegatingAsyncConsistentMap<K,V>
AsyncConsistentMap that meters all its operations.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
MeteredAsyncConsistentMap(AsyncConsistentMap<K,V> backingMap) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addListener(MapEventListener<K,V> listener,
Executor executor)
Registers the specified listener to be notified whenever the map is updated.
|
CompletableFuture<Version> |
begin(TransactionId transactionId)
Begins the transaction.
|
CompletableFuture<Void> |
clear()
Removes all of the mappings from this map (optional operation).
|
CompletableFuture<Void> |
commit(TransactionId transactionId)
Commits a previously prepared transaction and unlocks the object.
|
CompletableFuture<Versioned<V>> |
computeIf(K key,
Predicate<? super V> condition,
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,
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<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<Boolean> |
prepare(TransactionLog<MapUpdate<K,V>> transactionLog)
Prepares a transaction for commitment.
|
CompletableFuture<Boolean> |
prepareAndCommit(TransactionLog<MapUpdate<K,V>> transactionLog)
Prepares and commits a transaction.
|
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 behaves as a get
returning the existing mapping without making any changes.
|
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<Void> |
removeListener(MapEventListener<K,V> listener)
Unregisters the specified listener such that it will no longer
receive map change notifications.
|
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<Versioned<V>> |
replace(K key,
V value)
Replaces the entry for the specified key only if there is any value
which associated with specified key.
|
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<Void> |
rollback(TransactionId transactionId)
Aborts a previously prepared transaction and unlocks the object.
|
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.
|
addStatusChangeListener, equals, getOrDefault, hashCode, removeStatusChangeListener, statusChangeListeners, toStringapplicationId, destroy, name, primitiveTypeclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddListener, asConsistentMap, asConsistentMap, compute, computeIfPresent, destroy, primitiveTypeapplicationId, namepublic MeteredAsyncConsistentMap(AsyncConsistentMap<K,V> backingMap)
public CompletableFuture<Integer> size()
AsyncConsistentMapsize in interface AsyncConsistentMap<K,V>size in class DelegatingAsyncConsistentMap<K,V>public CompletableFuture<Boolean> isEmpty()
AsyncConsistentMappublic CompletableFuture<Boolean> containsKey(K key)
AsyncConsistentMapcontainsKey in interface AsyncConsistentMap<K,V>containsKey in class DelegatingAsyncConsistentMap<K,V>key - keypublic CompletableFuture<Boolean> containsValue(V value)
AsyncConsistentMapcontainsValue in interface AsyncConsistentMap<K,V>containsValue in class DelegatingAsyncConsistentMap<K,V>value - valuepublic CompletableFuture<Versioned<V>> get(K key)
AsyncConsistentMapget in interface AsyncConsistentMap<K,V>get in class DelegatingAsyncConsistentMap<K,V>key - the key whose associated value (and version) is to be returnedpublic CompletableFuture<Versioned<V>> computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
AsyncConsistentMapkey - key with which the specified value is to be associatedmappingFunction - the function to compute a valuepublic CompletableFuture<Versioned<V>> computeIf(K key, Predicate<? super V> condition, BiFunction<? super K,? super V,? extends V> remappingFunction)
AsyncConsistentMapcomputeIf in interface AsyncConsistentMap<K,V>computeIf in class DelegatingAsyncConsistentMap<K,V>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 valuepublic CompletableFuture<Versioned<V>> put(K key, V value)
AsyncConsistentMapput in interface AsyncConsistentMap<K,V>put in class DelegatingAsyncConsistentMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CompletableFuture<Versioned<V>> putAndGet(K key, V value)
AsyncConsistentMapputAndGet in interface AsyncConsistentMap<K,V>putAndGet in class DelegatingAsyncConsistentMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CompletableFuture<Versioned<V>> remove(K key)
AsyncConsistentMapremove in interface AsyncConsistentMap<K,V>remove in class DelegatingAsyncConsistentMap<K,V>key - key whose value is to be removed from the mappublic CompletableFuture<Void> clear()
AsyncConsistentMapclear in interface AsyncConsistentMap<K,V>clear in class DelegatingAsyncConsistentMap<K,V>public CompletableFuture<Set<K>> keySet()
AsyncConsistentMapkeySet in interface AsyncConsistentMap<K,V>keySet in class DelegatingAsyncConsistentMap<K,V>public CompletableFuture<Collection<Versioned<V>>> values()
AsyncConsistentMapvalues in interface AsyncConsistentMap<K,V>values in class DelegatingAsyncConsistentMap<K,V>public CompletableFuture<Set<Map.Entry<K,Versioned<V>>>> entrySet()
AsyncConsistentMapentrySet in interface AsyncConsistentMap<K,V>entrySet in class DelegatingAsyncConsistentMap<K,V>public CompletableFuture<Versioned<V>> putIfAbsent(K key, V value)
AsyncConsistentMapputIfAbsent in interface AsyncConsistentMap<K,V>putIfAbsent in class DelegatingAsyncConsistentMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CompletableFuture<Boolean> remove(K key, V value)
AsyncConsistentMapremove in interface AsyncConsistentMap<K,V>remove in class DelegatingAsyncConsistentMap<K,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic CompletableFuture<Boolean> remove(K key, long version)
AsyncConsistentMapremove in interface AsyncConsistentMap<K,V>remove in class DelegatingAsyncConsistentMap<K,V>key - key with which the specified version is associatedversion - version expected to be associated with the specified keypublic CompletableFuture<Versioned<V>> replace(K key, V value)
AsyncConsistentMapreplace in interface AsyncConsistentMap<K,V>replace in class DelegatingAsyncConsistentMap<K,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic CompletableFuture<Boolean> replace(K key, V oldValue, V newValue)
AsyncConsistentMapreplace in interface AsyncConsistentMap<K,V>replace in class DelegatingAsyncConsistentMap<K,V>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 keypublic CompletableFuture<Boolean> replace(K key, long oldVersion, V newValue)
AsyncConsistentMapreplace in interface AsyncConsistentMap<K,V>replace in class DelegatingAsyncConsistentMap<K,V>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 keypublic CompletableFuture<Void> addListener(MapEventListener<K,V> listener, Executor executor)
AsyncConsistentMapaddListener in interface AsyncConsistentMap<K,V>addListener in class DelegatingAsyncConsistentMap<K,V>listener - listener to notify about map eventsexecutor - executor to use for handling incoming map eventspublic CompletableFuture<Void> removeListener(MapEventListener<K,V> listener)
AsyncConsistentMapremoveListener in interface AsyncConsistentMap<K,V>removeListener in class DelegatingAsyncConsistentMap<K,V>listener - listener to unregisterpublic CompletableFuture<Version> begin(TransactionId transactionId)
Transactionalbegin in interface Transactional<MapUpdate<K,V>>begin in class DelegatingAsyncConsistentMap<K,V>transactionId - the transaction identifier for the transaction to beginpublic CompletableFuture<Boolean> prepare(TransactionLog<MapUpdate<K,V>> transactionLog)
Transactionalprepare in interface Transactional<MapUpdate<K,V>>prepare in class DelegatingAsyncConsistentMap<K,V>transactionLog - transaction logtrue if prepare is successful and transaction is ready to be committed
false otherwisepublic CompletableFuture<Void> commit(TransactionId transactionId)
Transactionalcommit in interface Transactional<MapUpdate<K,V>>commit in class DelegatingAsyncConsistentMap<K,V>transactionId - transaction identifierpublic CompletableFuture<Void> rollback(TransactionId transactionId)
Transactionalrollback in interface Transactional<MapUpdate<K,V>>rollback in class DelegatingAsyncConsistentMap<K,V>transactionId - transaction identifierpublic CompletableFuture<Boolean> prepareAndCommit(TransactionLog<MapUpdate<K,V>> transactionLog)
TransactionalprepareAndCommit in interface Transactional<MapUpdate<K,V>>prepareAndCommit in class DelegatingAsyncConsistentMap<K,V>transactionLog - transaction logtrue if prepare is successful and transaction was committed
false otherwise