ReliableHashMap<K,V> Class
- java.
lang. Object - microsoft.
servicefabric. data. collections. ReliableCollectionsNativeAPIs - microsoft.
servicefabric. data. collections. ReliableHashMap<K,V>
- microsoft.
- microsoft.
Type Parameters
- K
- V
public class ReliableHashMap<K extends String,V> implements ReliableCollection
Constructor Summary
Constructor | Description | |
---|---|---|
ReliableHashMap(long store, long replicaId, String name, String traceId) |
Method Summary
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Void> |
clearAsync()
Removes all state from the ReliableCollection, including replicated and persisted store. |
void | close() |
CompletableFuture<V> |
computeAsync(Transaction txn, K key, 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<V> |
computeAsync(Transaction txn, K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, Duration timeout, CancellationToken cancellationToken)
Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping). |
CompletableFuture<V> |
computeIfAbsentAsync(Transaction txn, K key, Function<? super K, ? extends V> mappingFunction)
If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map unless null. |
CompletableFuture<V> |
computeIfAbsentAsync(Transaction txn, K key, Function<? super K, ? extends V> mappingFunction, Duration timeout, CancellationToken cancellationToken)
If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map unless null. |
CompletableFuture<V> |
computeIfPresentAsync(Transaction txn, K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction)
If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value. |
CompletableFuture<V> |
computeIfPresentAsync(Transaction txn, K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, Duration timeout, CancellationToken cancellationToken)
If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value. |
CompletableFuture<Boolean> |
containsKeyAsync(Transaction txn, K key)
Tests if the specified object is a key in this table. |
CompletableFuture<Boolean> |
containsKeyAsync(Transaction txn, K key, Duration timeout, CancellationToken cancellationToken)
Tests if the specified object is a key in this table. |
CompletableFuture<Boolean> |
containsKeyAsync(Transaction txn, K key, LockMode lockMode)
Tests if the specified object is a key in this table. |
CompletableFuture<Boolean> |
containsKeyAsync(Transaction txn, K key, LockMode lockMode, Duration timeout, CancellationToken cancellationToken)
Tests if the specified object is a key in this table. |
CompletableFuture<Async |
elementsAsync(Transaction txn)
Returns an enumeration of the values in this table. |
CompletableFuture<V> |
getAsync(Transaction txn, K key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. |
CompletableFuture<V> |
getAsync(Transaction txn, K key, Duration timeout, CancellationToken cancellationToken)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. |
long |
getCount()
Gets the number of elements contained in the ReliableCollection |
URI |
getName()
Gets the unique URI name for the Reliable HashMap |
CompletableFuture<Async |
keysAsync(Transaction txn)
Returns an enumeration of the keys in this table. |
CompletableFuture<Async |
keyValuesAsync(Transaction txn)
Returns an enumeration of the key-value pairs in this table. |
CompletableFuture<Boolean> |
putAsync(Transaction txn, K key, V value)
Maps the specified key to the specified value in this table. Neither the key nor the value can be null. |
CompletableFuture<Boolean> |
putAsync(Transaction txn, K key, V value, Duration timeout, CancellationToken cancellationToken)
Maps the specified key to the specified value in this table. Neither the key nor the value can be null. |
CompletableFuture<Boolean> |
putIfAbsentAsync(Transaction txn, K key, V value)
If the specified key is not already associated with a value, associate it with the given value. |
CompletableFuture<Boolean> |
putIfAbsentAsync(Transaction txn, K key, V value, Duration timeout, CancellationToken cancellationToken)
If the specified key is not already associated with a value, associate it with the given value. |
CompletableFuture<Boolean> |
removeAsync(Transaction txn, K key)
Removes the key (and its corresponding value) from this map. This method does nothing if the key is not in the map. |
CompletableFuture<Boolean> |
removeAsync(Transaction txn, K key, Duration timeout, CancellationToken cancellationToken)
Removes the key (and its corresponding value) from this map. This method does nothing if the key is not in the map. |
CompletableFuture<Boolean> |
replaceAsync(Transaction txn, K key, V value)
Replaces the entry for a key only if currently mapped to some value. |
CompletableFuture<Boolean> |
replaceAsync(Transaction txn, K key, V value, Duration timeout, CancellationToken cancellationToken)
Replaces the entry for a key only if currently mapped to some value. |
long |
size()
Returns the number of mappings. |
Inherited Members
Constructor Details
ReliableHashMap
public ReliableHashMap(long store, long replicaId, String name, String traceId)
Parameters:
Method Details
clearAsync
public CompletableFuture
Removes all state from the ReliableCollection, including replicated and persisted store.
Overrides:
ReliableHashMap<K,V>.clearAsync()Returns:
close
public void close()
computeAsync
public CompletableFuture
Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).
Parameters:
Returns:
CompletableFuture with the new(computed) value associated with the specified key, or null if the computed value is null. The future completes exceptionally with FabricException for fabric related failures.
Throws:
computeAsync
public CompletableFuture
Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with the new(computed) value associated with the specified key, or null if the computed value is null. The future completes exceptionally with FabricException for fabric related failures.
Throws:
computeIfAbsentAsync
public CompletableFuture
If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map unless null.
Parameters:
Returns:
CompletableFuture with the new(computed) value if there was no previous mapping, or null if the computed value is null or if a mapping already exists for the specified key. The future completes exceptionally with FabricException for fabric related failures.
Throws:
computeIfAbsentAsync
public CompletableFuture
If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map unless null.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with the new(computed) value if there was no previous mapping, or null if the computed value is null or if a mapping already exists for the specified key. The future completes exceptionally with FabricException for fabric related failures.
Throws:
computeIfPresentAsync
public CompletableFuture
If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.
Parameters:
Returns:
CompletableFuture with the new(computed) value if there was a previous mapping, or null if the computed value is null or if no mapping exists for the specified key. The future completes exceptionally with FabricException for fabric related failures.
Throws:
computeIfPresentAsync
public CompletableFuture
If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with the new(computed) value if there was a previous mapping, or null if the computed value is null or if no mapping exists for the specified key. The future completes exceptionally with FabricException for fabric related failures.
Throws:
containsKeyAsync
public CompletableFuture
Tests if the specified object is a key in this table.
Parameters:
Returns:
CompletableFuture with result true if the key is found in this Map, false otherwise. The future completes exceptionally with FabricException for fabric related failures.
Throws:
containsKeyAsync
public CompletableFuture
Tests if the specified object is a key in this table.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with result true if the key is found in this Map, false otherwise. The future completes exceptionally with FabricException for fabric related failures.
Throws:
containsKeyAsync
public CompletableFuture
Tests if the specified object is a key in this table.
Parameters:
Returns:
CompletableFuture with result true if the key is found in this Map, false otherwise. The future completes exceptionally with FabricException for fabric related failures.
Throws:
containsKeyAsync
public CompletableFuture
Tests if the specified object is a key in this table.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with result true if the key is found in this Map, false otherwise. The future completes exceptionally with FabricException for fabric related failures.
Throws:
elementsAsync
public CompletableFuture
Returns an enumeration of the values in this table.
Parameters:
Returns:
CompletableFuture with an enumeration of the values in this Map. The future completes exceptionally with FabricException for fabric related failures.
Throws:
getAsync
public CompletableFuture
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
Parameters:
Returns:
CompletableFuture with value to which the specified key is mapped, null if no such mapping exists. The future completes exceptionally with IOException or ClassNotFoundException for deserialization failures, FabricException for fabric related failures.
Throws:
getAsync
public CompletableFuture
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with value to which the specified key is mapped, null if no such mapping exists. The future completes exceptionally with IOException or ClassNotFoundException for deserialization failures, FabricException for fabric related failures.
Throws:
getCount
public long getCount()
Gets the number of elements contained in the ReliableCollection
Overrides:
ReliableHashMap<K,V>.getCount()Returns:
getName
public URI getName()
Gets the unique URI name for the Reliable HashMap
Overrides:
ReliableHashMap<K,V>.getName()keysAsync
public CompletableFuture
Returns an enumeration of the keys in this table.
Parameters:
Returns:
CompletableFuture with an enumeration of the keys in this Map. The future completes exceptionally with FabricException for fabric related failures.
Throws:
keyValuesAsync
public CompletableFuture
Returns an enumeration of the key-value pairs in this table.
Parameters:
Returns:
CompletableFuture with an enumeration of KeyValuePair in this Map. The future completes exceptionally with FabricException for fabric related failures.
Throws:
putAsync
public CompletableFuture
Maps the specified key to the specified value in this table. Neither the key nor the value can be null.
Parameters:
Returns:
CompletableFuture with result true if there was a previous mapping, false otherwise. The future completes exceptionally with IOException for serialization failures, FabricException for fabric related failures.
Throws:
putAsync
public CompletableFuture
Maps the specified key to the specified value in this table. Neither the key nor the value can be null.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with result true if there was a previous mapping, false otherwise. The future completes exceptionally with IOException for serialization failures, FabricException for fabric related failures.
Throws:
putIfAbsentAsync
public CompletableFuture
If the specified key is not already associated with a value, associate it with the given value.
Parameters:
Returns:
CompletableFuture with result true if the value is applied, false otherwise. The future completes exceptionally with IOException for serialization failures, FabricException for fabric related failures.
Throws:
putIfAbsentAsync
public CompletableFuture
If the specified key is not already associated with a value, associate it with the given value.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with result true if the value is applied, false otherwise. The future completes exceptionally with IOException for serialization failures, FabricException for fabric related failures.
Throws:
removeAsync
public CompletableFuture
Removes the key (and its corresponding value) from this map. This method does nothing if the key is not in the map.
Parameters:
Returns:
CompletableFuture with result true if the key is found and remove succeeds, false otherwise. The future completes exceptionally with FabricException for fabric related failures.
Throws:
removeAsync
public CompletableFuture
Removes the key (and its corresponding value) from this map. This method does nothing if the key is not in the map.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with result true if the key is found and remove succeeds, false otherwise. The future completes exceptionally with FabricException for fabric related failures.
Throws:
replaceAsync
public CompletableFuture
Replaces the entry for a key only if currently mapped to some value.
Parameters:
Returns:
CompletableFuture with result true if the key is found and replace succeeds, false otherwise. The future completes exceptionally with IOException for serialization failures, FabricException for fabric related failures.
Throws:
replaceAsync
public CompletableFuture
Replaces the entry for a key only if currently mapped to some value.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
CompletableFuture with result true if the key is found and replace succeeds, false otherwise. The future completes exceptionally with IOException for serialization failures, FabricException for fabric related failures.
Throws:
size
public long size()
Returns the number of mappings.
Returns: