K2 - key type of other mapV2 - value type of other mapK1 - key type of this mapV1 - value type of this mappublic class TranscodingAsyncConsistentMap<K1,V1,K2,V2> extends Object implements AsyncConsistentMap<K1,V1>
AsyncConsistentMap that maps its operations to operations on a
differently typed AsyncConsistentMap by transcoding operation inputs and outputs.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
TranscodingAsyncConsistentMap(AsyncConsistentMap<K2,V2> backingMap,
Function<K1,K2> keyEncoder,
Function<K2,K1> keyDecoder,
Function<V1,V2> valueEncoder,
Function<V2,V1> valueDecoder) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addListener(MapEventListener<K1,V1> listener,
Executor executor)
Registers the specified listener to be notified whenever the map is updated.
|
void |
addStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
Registers a listener to be called when the primitive's status changes.
|
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<V1>> |
computeIf(K1 key,
Predicate<? super V1> condition,
BiFunction<? super K1,? super V1,? extends V1> 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<Boolean> |
containsKey(K1 key)
Returns true if this map contains a mapping for the specified key.
|
CompletableFuture<Boolean> |
containsValue(V1 value)
Returns true if this map contains the specified value.
|
CompletableFuture<Set<Map.Entry<K1,Versioned<V1>>>> |
entrySet()
Returns the set of entries contained in this map.
|
CompletableFuture<Versioned<V1>> |
get(K1 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<Versioned<V1>> |
getOrDefault(K1 key,
V1 defaultValue)
Returns the value (and version) to which the specified key is mapped, or the provided
default value if this map contains no mapping for the key.
|
CompletableFuture<Set<K1>> |
keySet()
Returns a Set view of the keys contained in this map.
|
String |
name()
Returns the name of this primitive.
|
CompletableFuture<Boolean> |
prepare(TransactionLog<MapUpdate<K1,V1>> transactionLog)
Prepares a transaction for commitment.
|
CompletableFuture<Boolean> |
prepareAndCommit(TransactionLog<MapUpdate<K1,V1>> transactionLog)
Prepares and commits a transaction.
|
CompletableFuture<Versioned<V1>> |
put(K1 key,
V1 value)
Associates the specified value with the specified key in this map (optional operation).
|
CompletableFuture<Versioned<V1>> |
putAndGet(K1 key,
V1 value)
Associates the specified value with the specified key in this map (optional operation).
|
CompletableFuture<Versioned<V1>> |
putIfAbsent(K1 key,
V1 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<V1>> |
remove(K1 key)
Removes the mapping for a key from this map if it is present (optional operation).
|
CompletableFuture<Boolean> |
remove(K1 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(K1 key,
V1 value)
Removes the entry for the specified key only if it is currently
mapped to the specified value.
|
CompletableFuture<Void> |
removeListener(MapEventListener<K1,V1> listener)
Unregisters the specified listener such that it will no longer
receive map change notifications.
|
void |
removeStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
Unregisters a previously registered listener to be called when the primitive's status changes.
|
CompletableFuture<Boolean> |
replace(K1 key,
long oldVersion,
V1 newValue)
Replaces the entry for the specified key only if it is currently mapped to the
specified version.
|
CompletableFuture<Versioned<V1>> |
replace(K1 key,
V1 value)
Replaces the entry for the specified key only if there is any value
which associated with specified key.
|
CompletableFuture<Boolean> |
replace(K1 key,
V1 oldValue,
V1 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.
|
Collection<Consumer<DistributedPrimitive.Status>> |
statusChangeListeners()
Returns the collection of status change listeners previously registered.
|
CompletableFuture<Collection<Versioned<V1>>> |
values()
Returns the collection of values (and associated versions) contained in this map.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, asConsistentMap, asConsistentMap, compute, computeIfAbsent, computeIfPresent, destroy, isEmpty, primitiveTypeapplicationIdpublic String name()
DistributedPrimitivename in interface DistributedPrimitivepublic CompletableFuture<Integer> size()
AsyncConsistentMapsize in interface AsyncConsistentMap<K1,V1>public CompletableFuture<Boolean> containsKey(K1 key)
AsyncConsistentMapcontainsKey in interface AsyncConsistentMap<K1,V1>key - keypublic CompletableFuture<Boolean> containsValue(V1 value)
AsyncConsistentMapcontainsValue in interface AsyncConsistentMap<K1,V1>value - valuepublic CompletableFuture<Versioned<V1>> get(K1 key)
AsyncConsistentMapget in interface AsyncConsistentMap<K1,V1>key - the key whose associated value (and version) is to be returnedpublic CompletableFuture<Versioned<V1>> getOrDefault(K1 key, V1 defaultValue)
AsyncConsistentMapgetOrDefault in interface AsyncConsistentMap<K1,V1>key - the key whose associated value (and version) is to be returneddefaultValue - the default value to return if the key is not setpublic CompletableFuture<Versioned<V1>> computeIf(K1 key, Predicate<? super V1> condition, BiFunction<? super K1,? super V1,? extends V1> remappingFunction)
AsyncConsistentMapcomputeIf in interface AsyncConsistentMap<K1,V1>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<V1>> put(K1 key, V1 value)
AsyncConsistentMapput in interface AsyncConsistentMap<K1,V1>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CompletableFuture<Versioned<V1>> putAndGet(K1 key, V1 value)
AsyncConsistentMapputAndGet in interface AsyncConsistentMap<K1,V1>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CompletableFuture<Versioned<V1>> remove(K1 key)
AsyncConsistentMapremove in interface AsyncConsistentMap<K1,V1>key - key whose value is to be removed from the mappublic CompletableFuture<Void> clear()
AsyncConsistentMapclear in interface AsyncConsistentMap<K1,V1>public CompletableFuture<Set<K1>> keySet()
AsyncConsistentMapkeySet in interface AsyncConsistentMap<K1,V1>public CompletableFuture<Collection<Versioned<V1>>> values()
AsyncConsistentMapvalues in interface AsyncConsistentMap<K1,V1>public CompletableFuture<Set<Map.Entry<K1,Versioned<V1>>>> entrySet()
AsyncConsistentMapentrySet in interface AsyncConsistentMap<K1,V1>public CompletableFuture<Versioned<V1>> putIfAbsent(K1 key, V1 value)
AsyncConsistentMapputIfAbsent in interface AsyncConsistentMap<K1,V1>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CompletableFuture<Boolean> remove(K1 key, V1 value)
AsyncConsistentMapremove in interface AsyncConsistentMap<K1,V1>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic CompletableFuture<Boolean> remove(K1 key, long version)
AsyncConsistentMapremove in interface AsyncConsistentMap<K1,V1>key - key with which the specified version is associatedversion - version expected to be associated with the specified keypublic CompletableFuture<Versioned<V1>> replace(K1 key, V1 value)
AsyncConsistentMapreplace in interface AsyncConsistentMap<K1,V1>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic CompletableFuture<Boolean> replace(K1 key, V1 oldValue, V1 newValue)
AsyncConsistentMapreplace in interface AsyncConsistentMap<K1,V1>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(K1 key, long oldVersion, V1 newValue)
AsyncConsistentMapreplace in interface AsyncConsistentMap<K1,V1>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<K1,V1> listener, Executor executor)
AsyncConsistentMapaddListener in interface AsyncConsistentMap<K1,V1>listener - listener to notify about map eventsexecutor - executor to use for handling incoming map eventspublic CompletableFuture<Void> removeListener(MapEventListener<K1,V1> listener)
AsyncConsistentMapremoveListener in interface AsyncConsistentMap<K1,V1>listener - listener to unregisterpublic CompletableFuture<Version> begin(TransactionId transactionId)
Transactionalbegin in interface Transactional<MapUpdate<K1,V1>>transactionId - the transaction identifier for the transaction to beginpublic CompletableFuture<Boolean> prepare(TransactionLog<MapUpdate<K1,V1>> transactionLog)
Transactionalprepare in interface Transactional<MapUpdate<K1,V1>>transactionLog - transaction logtrue if prepare is successful and transaction is ready to be committed
false otherwisepublic CompletableFuture<Boolean> prepareAndCommit(TransactionLog<MapUpdate<K1,V1>> transactionLog)
TransactionalprepareAndCommit in interface Transactional<MapUpdate<K1,V1>>transactionLog - transaction logtrue if prepare is successful and transaction was committed
false otherwisepublic CompletableFuture<Void> commit(TransactionId transactionId)
Transactionalcommit in interface Transactional<MapUpdate<K1,V1>>transactionId - transaction identifierpublic CompletableFuture<Void> rollback(TransactionId transactionId)
Transactionalrollback in interface Transactional<MapUpdate<K1,V1>>transactionId - transaction identifierpublic void addStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
DistributedPrimitiveaddStatusChangeListener in interface DistributedPrimitivelistener - The listener to be called when the status changes.public void removeStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
DistributedPrimitiveremoveStatusChangeListener in interface DistributedPrimitivelistener - The listener to unregisterpublic Collection<Consumer<DistributedPrimitive.Status>> statusChangeListeners()
DistributedPrimitivestatusChangeListeners in interface DistributedPrimitive