Interface AtomicDistributedMapCacheClient<R>
- Type Parameters:
R
- The revision type. If the underlying cache storage supports the concept of revision to implement optimistic locking, then a client implementation should use that. Otherwise set the cached value and check if the key is not updated atreplace(AtomicCacheEntry, Serializer, Serializer)
- All Superinterfaces:
org.apache.nifi.components.ConfigurableComponent
,org.apache.nifi.controller.ControllerService
,DistributedMapCacheClient
@Tags({"distributed","client","cluster","map","cache"})
@CapabilityDescription("Provides the ability to communicate with a DistributedMapCacheServer. This allows multiple nodes to coordinate state with a single remote entity.")
public interface AtomicDistributedMapCacheClient<R>
extends DistributedMapCacheClient
This interface defines an API that can be used for interacting with a
Distributed Cache that functions similarly to a Map
.
In addition to the API defined in DistributedMapCacheClient
super class,
this class provides methods for concurrent atomic updates those are added since Map Cache protocol version 2.
If a remote cache server doesn't support Map Cache protocol version 2, these methods throw UnsupportedOperationException.
-
Method Summary
Modifier and TypeMethodDescription<K,
V> AtomicCacheEntry <K, V, R> fetch
(K key, Serializer<K> keySerializer, Deserializer<V> valueDeserializer) Fetch a CacheEntry with a key.<K,
V> boolean replace
(AtomicCacheEntry<K, V, R> entry, Serializer<K> keySerializer, Serializer<V> valueSerializer) Replace an existing key with new value.Methods inherited from interface org.apache.nifi.components.ConfigurableComponent
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
Methods inherited from interface org.apache.nifi.controller.ControllerService
initialize, isStateful, migrateProperties
Methods inherited from interface org.apache.nifi.distributed.cache.client.DistributedMapCacheClient
close, containsKey, get, getAndPutIfAbsent, keySet, put, putAll, putIfAbsent, remove, removeAndGet, subMap
-
Method Details
-
fetch
<K,V> AtomicCacheEntry<K,V, fetchR> (K key, Serializer<K> keySerializer, Deserializer<V> valueDeserializer) throws IOException Fetch a CacheEntry with a key.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
key
- the key to lookup in the mapkeySerializer
- key serializervalueDeserializer
- value deserializer- Returns:
- A CacheEntry instance if one exists, otherwise
null . - Throws:
IOException
- if unable to communicate with the remote instance
-
replace
<K,V> boolean replace(AtomicCacheEntry<K, V, throws IOExceptionR> entry, Serializer<K> keySerializer, Serializer<V> valueSerializer) Replace an existing key with new value.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
entry
- should provide the new value forAtomicCacheEntry.getValue()
, and the same revision in the cache storage forAtomicCacheEntry.getRevision()
, if the revision does not match with the one in the cache storage, value will not be replaced.keySerializer
- key serializervalueSerializer
- value serializer- Returns:
- true only if the key is replaced.
- Throws:
IOException
- if unable to communicate with the remote instance
-