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 at replace(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 Details

    • fetch

      <K, V> AtomicCacheEntry<K,V,R> fetch(K key, Serializer<K> keySerializer, Deserializer<V> valueDeserializer) throws IOException
      Fetch a CacheEntry with a key.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      key - the key to lookup in the map
      keySerializer - key serializer
      valueDeserializer - 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,R> entry, Serializer<K> keySerializer, Serializer<V> valueSerializer) throws IOException
      Replace an existing key with new value.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      entry - should provide the new value for AtomicCacheEntry.getValue(), and the same revision in the cache storage for AtomicCacheEntry.getRevision(), if the revision does not match with the one in the cache storage, value will not be replaced.
      keySerializer - key serializer
      valueSerializer - value serializer
      Returns:
      true only if the key is replaced.
      Throws:
      IOException - if unable to communicate with the remote instance