Class RemoteCacheImpl<K,V>

java.lang.Object
org.infinispan.client.hotrod.impl.RemoteCacheSupport<K,V>
org.infinispan.client.hotrod.impl.RemoteCacheImpl<K,V>
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, InternalRemoteCache<K,V>, RemoteCache<K,V>, org.infinispan.commons.api.AsyncCache<K,V>, org.infinispan.commons.api.BasicCache<K,V>, org.infinispan.commons.api.Lifecycle, org.infinispan.commons.api.TransactionalCache
Direct Known Subclasses:
TransactionalRemoteCacheImpl

public class RemoteCacheImpl<K,V> extends RemoteCacheSupport<K,V> implements InternalRemoteCache<K,V>
Since:
4.1
Author:
Mircea.Markus@jboss.com
  • Field Details

  • Constructor Details

  • Method Details

    • init

      public void init(OperationsFactory operationsFactory, Configuration configuration, ObjectName jmxParent)
      Specified by:
      init in interface InternalRemoteCache<K,V>
    • init

      public void init(OperationsFactory operationsFactory, Configuration configuration)
      Inititalize without mbeans
      Specified by:
      init in interface InternalRemoteCache<K,V>
    • getOperationsFactory

      public OperationsFactory getOperationsFactory()
      Specified by:
      getOperationsFactory in interface InternalRemoteCache<K,V>
    • getRemoteCacheContainer

      public RemoteCacheContainer getRemoteCacheContainer()
      Description copied from interface: RemoteCache
      Returns the RemoteCacheContainer that created this cache.
      Specified by:
      getRemoteCacheContainer in interface RemoteCache<K,V>
    • removeWithVersionAsync

      public CompletableFuture<Boolean> removeWithVersionAsync(K key, long version)
      Specified by:
      removeWithVersionAsync in interface RemoteCache<K,V>
      Specified by:
      removeWithVersionAsync in class RemoteCacheSupport<K,V>
      See Also:
    • mergeAsync

      public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Specified by:
      mergeAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      mergeAsync in class RemoteCacheSupport<K,V>
    • replaceWithVersionAsync

      public CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, long lifespan, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit)
      Specified by:
      replaceWithVersionAsync in interface RemoteCache<K,V>
      See Also:
    • retrieveEntries

      public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>> retrieveEntries(String filterConverterFactory, Object[] filterConverterParams, Set<Integer> segments, int batchSize)
      Description copied from interface: RemoteCache
      Retrieve entries from the server.
      Specified by:
      retrieveEntries in interface RemoteCache<K,V>
      Parameters:
      filterConverterFactory - Factory name for the KeyValueFilterConverter or null for no filtering.
      filterConverterParams - Parameters to the KeyValueFilterConverter
      segments - The segments to iterate. If null all segments will be iterated. An empty set will filter out all entries.
      batchSize - The number of entries transferred from the server at a time.
      Returns:
      Iterator for the entries
    • publishEntries

      public <E> org.reactivestreams.Publisher<Map.Entry<K,E>> publishEntries(String filterConverterFactory, Object[] filterConverterParams, Set<Integer> segments, int batchSize)
      Description copied from interface: RemoteCache
      Publishes the entries from the server in a non blocking fashion.

      Any subscriber that subscribes to the returned Publisher must not block. It is therefore recommended to offload any blocking or long running operations to a different thread and not use the invoking one. Failure to do so may cause concurrent operations to stall.

      Specified by:
      publishEntries in interface RemoteCache<K,V>
      Parameters:
      filterConverterFactory - Factory name for the KeyValueFilterConverter or null for no filtering.
      filterConverterParams - Parameters to the KeyValueFilterConverter
      segments - The segments to utilize. If null all segments will be utilized. An empty set will filter out all entries.
      batchSize - The number of entries transferred from the server at a time.
      Returns:
      Publisher for the entries
    • retrieveEntriesByQuery

      public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>> retrieveEntriesByQuery(org.infinispan.query.dsl.Query<?> filterQuery, Set<Integer> segments, int batchSize)
      Description copied from interface: RemoteCache
      Retrieve entries from the server matching a query.
      Specified by:
      retrieveEntriesByQuery in interface RemoteCache<K,V>
      Parameters:
      filterQuery - Query
      segments - The segments to iterate. If null all segments will be iterated. An empty set will filter out all entries.
      batchSize - The number of entries transferred from the server at a time.
      Returns:
      CloseableIterator
    • publishEntriesByQuery

      public <E> org.reactivestreams.Publisher<Map.Entry<K,E>> publishEntriesByQuery(org.infinispan.query.dsl.Query<?> filterQuery, Set<Integer> segments, int batchSize)
      Description copied from interface: RemoteCache
      Publish entries from the server matching a query.

      Any subscriber that subscribes to the returned Publisher must not block. It is therefore recommended to offload any blocking or long running operations to a different thread and not use the invoking one. Failure to do so may cause concurrent operations to stall.

      Specified by:
      publishEntriesByQuery in interface RemoteCache<K,V>
      Parameters:
      filterQuery - Query
      segments - The segments to utilize. If null all segments will be utilized. An empty set will filter out all entries.
      batchSize - The number of entries transferred from the server at a time.
      Returns:
      Publisher containing matching entries
    • retrieveEntriesWithMetadata

      public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,MetadataValue<Object>>> retrieveEntriesWithMetadata(Set<Integer> segments, int batchSize)
      Description copied from interface: RemoteCache
      Retrieve entries with metadata information
      Specified by:
      retrieveEntriesWithMetadata in interface RemoteCache<K,V>
    • publishEntriesWithMetadata

      public org.reactivestreams.Publisher<Map.Entry<K,MetadataValue<V>>> publishEntriesWithMetadata(Set<Integer> segments, int batchSize)
      Description copied from interface: RemoteCache
      Publish entries with metadata information

      Any subscriber that subscribes to the returned Publisher must not block. It is therefore recommended to offload any blocking or long running operations to a different thread and not use the invoking one. Failure to do so may cause concurrent operations to stall.

      Specified by:
      publishEntriesWithMetadata in interface RemoteCache<K,V>
      Parameters:
      segments - The segments to utilize. If null all segments will be utilized. An empty set will filter out all entries.
      batchSize - The number of entries transferred from the server at a time.
      Returns:
      Publisher containing entries along with metadata
    • getWithMetadataAsync

      public CompletableFuture<MetadataValue<V>> getWithMetadataAsync(K key)
      Description copied from interface: RemoteCache
      Asynchronously returns the MetadataValue associated to the supplied key param, or null if it doesn't exist.
      Specified by:
      getWithMetadataAsync in interface RemoteCache<K,V>
      Specified by:
      getWithMetadataAsync in class RemoteCacheSupport<K,V>
    • getWithMetadataAsync

      public RetryAwareCompletionStage<MetadataValue<V>> getWithMetadataAsync(K key, SocketAddress preferredAddres)
      Specified by:
      getWithMetadataAsync in interface InternalRemoteCache<K,V>
    • putAllAsync

      public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      putAllAsync in interface RemoteCache<K,V>
      Specified by:
      putAllAsync in class RemoteCacheSupport<K,V>
      See Also:
    • sizeAsync

      public CompletableFuture<Long> sizeAsync()
      Specified by:
      sizeAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      sizeAsync in class RemoteCacheSupport<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • clientStatistics

      public ClientStatistics clientStatistics()
      Description copied from interface: RemoteCache
      Returns client-side statistics for this cache.
      Specified by:
      clientStatistics in interface InternalRemoteCache<K,V>
      Specified by:
      clientStatistics in interface RemoteCache<K,V>
    • serverStatistics

      public ServerStatistics serverStatistics()
      Description copied from interface: RemoteCache
      Returns server-side statistics for this cache.
      Specified by:
      serverStatistics in interface RemoteCache<K,V>
    • serverStatisticsAsync

      public CompletionStage<ServerStatistics> serverStatisticsAsync()
      Description copied from interface: RemoteCache
      Returns server-side statistics for this cache.
      Specified by:
      serverStatisticsAsync in interface RemoteCache<K,V>
    • putAsync

      public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Specified by:
      putAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      putAsync in class RemoteCacheSupport<K,V>
    • clearAsync

      public CompletableFuture<Void> clearAsync()
      Specified by:
      clearAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
    • computeAsync

      public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Specified by:
      computeAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      computeAsync in class RemoteCacheSupport<K,V>
    • computeIfAbsentAsync

      public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Specified by:
      computeIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      computeIfAbsentAsync in class RemoteCacheSupport<K,V>
    • computeIfPresentAsync

      public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Specified by:
      computeIfPresentAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      computeIfPresentAsync in class RemoteCacheSupport<K,V>
    • replaceAll

      public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
      Specified by:
      replaceAll in interface ConcurrentMap<K,V>
      Specified by:
      replaceAll in interface Map<K,V>
      Specified by:
      replaceAll in class RemoteCacheSupport<K,V>
    • putIfAbsentAsync

      public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Specified by:
      putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      putIfAbsentAsync in class RemoteCacheSupport<K,V>
    • replaceAsync

      public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Specified by:
      replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      replaceAsync in class RemoteCacheSupport<K,V>
    • removeAsync

      public CompletableFuture<V> removeAsync(Object key)
      Specified by:
      removeAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      removeAsync in class RemoteCacheSupport<K,V>
    • removeAsync

      public CompletableFuture<Boolean> removeAsync(Object key, Object value)
      Specified by:
      removeAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      removeAsync in class RemoteCacheSupport<K,V>
    • replaceAsync

      public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Specified by:
      replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      replaceAsync in class RemoteCacheSupport<K,V>
    • containsKeyAsync

      public CompletableFuture<Boolean> containsKeyAsync(K key)
      Specified by:
      containsKeyAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      containsKeyAsync in class RemoteCacheSupport<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • getAllAsync

      public CompletableFuture<Map<K,V>> getAllAsync(Set<?> keys)
      Specified by:
      getAllAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      getAllAsync in class RemoteCacheSupport<K,V>
    • start

      public void start()
      Specified by:
      start in interface org.infinispan.commons.api.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.infinispan.commons.api.Lifecycle
    • getName

      public String getName()
      Specified by:
      getName in interface org.infinispan.commons.api.BasicCache<K,V>
    • getVersion

      public String getVersion()
      Specified by:
      getVersion in interface org.infinispan.commons.api.BasicCache<K,V>
    • query

      public <T> org.infinispan.query.dsl.Query<T> query(String query)
      Specified by:
      query in interface org.infinispan.commons.api.BasicCache<K,V>
    • continuousQuery

      public org.infinispan.commons.api.query.ContinuousQuery<K,V> continuousQuery()
      Specified by:
      continuousQuery in interface org.infinispan.commons.api.BasicCache<K,V>
    • getProtocolVersion

      public String getProtocolVersion()
      Description copied from interface: RemoteCache
      Returns the HotRod protocol version supported by this RemoteCache implementation
      Specified by:
      getProtocolVersion in interface RemoteCache<K,V>
    • addClientListener

      public void addClientListener(Object listener)
      Description copied from interface: RemoteCache
      Add a client listener to receive events that happen in the remote cache. The listener object must be annotated with @ClientListener annotation.
      Specified by:
      addClientListener in interface RemoteCache<K,V>
    • addClientListener

      public void addClientListener(Object listener, Object[] filterFactoryParams, Object[] converterFactoryParams)
      Description copied from interface: RemoteCache
      Add a client listener to receive events that happen in the remote cache. The listener object must be annotated with @ClientListener annotation.
      Specified by:
      addClientListener in interface RemoteCache<K,V>
    • addNearCacheListener

      public SocketAddress addNearCacheListener(Object listener, int bloomBits)
      Description copied from interface: InternalRemoteCache
      Add a client listener to handle near cache with bloom filter optimization The listener object must be annotated with @ClientListener annotation.
      Specified by:
      addNearCacheListener in interface InternalRemoteCache<K,V>
    • removeClientListener

      public void removeClientListener(Object listener)
      Description copied from interface: RemoteCache
      Remove a previously added client listener. If the listener was not added before, this operation is a no-op.
      Specified by:
      removeClientListener in interface RemoteCache<K,V>
    • withFlags

      public InternalRemoteCache<K,V> withFlags(Flag... flags)
      Description copied from interface: RemoteCache
      Applies one or more Flags to the scope of a single invocation. See the Flag enumeration to for information on available flags.

      Sample usage:

          remoteCache.withFlags(Flag.FORCE_RETURN_VALUE).put("hello", "world");
       
      Specified by:
      withFlags in interface InternalRemoteCache<K,V>
      Specified by:
      withFlags in interface RemoteCache<K,V>
      Parameters:
      flags -
      Returns:
      the current RemoteCache instance to continue running operations on.
    • getAsync

      public CompletableFuture<V> getAsync(Object key)
      Specified by:
      getAsync in interface org.infinispan.commons.api.AsyncCache<K,V>
      Specified by:
      getAsync in class RemoteCacheSupport<K,V>
    • ping

      public CompletionStage<PingResponse> ping()
      Specified by:
      ping in interface InternalRemoteCache<K,V>
    • keyToBytes

      public byte[] keyToBytes(Object o)
      Specified by:
      keyToBytes in interface InternalRemoteCache<K,V>
    • valueToBytes

      protected byte[] valueToBytes(Object o)
    • assertRemoteCacheManagerIsStarted

      protected void assertRemoteCacheManagerIsStarted()
    • keySet

      public org.infinispan.commons.util.CloseableIteratorSet<K> keySet(org.infinispan.commons.util.IntSet segments)
      Description copied from interface: RemoteCache
      This method is identical to RemoteCache.keySet() except that it will only return keys that map to the given segments. Note that these segments will be determined by the remote server. Thus you should be aware of how many segments it has configured and hashing algorithm it is using. If the segments and hashing algorithm are not the same this method may return unexpected keys.
      Specified by:
      keySet in interface RemoteCache<K,V>
      Parameters:
      segments - the segments of keys to return - null means all available
      Returns:
      set containing keys that map to the given segments
      See Also:
    • keyIterator

      public org.infinispan.commons.util.CloseableIterator<K> keyIterator(org.infinispan.commons.util.IntSet segments)
      Specified by:
      keyIterator in interface InternalRemoteCache<K,V>
    • entrySet

      public org.infinispan.commons.util.CloseableIteratorSet<Map.Entry<K,V>> entrySet(org.infinispan.commons.util.IntSet segments)
      Description copied from interface: RemoteCache
      This method is identical to RemoteCache.entrySet() except that it will only return entries that map to the given segments. Note that these segments will be determined by the remote server. Thus you should be aware of how many segments it has configured and hashing algorithm it is using. If the segments and hashing algorithm are not the same this method may return unexpected entries.
      Specified by:
      entrySet in interface RemoteCache<K,V>
      Parameters:
      segments - the segments of entries to return - null means all available
      Returns:
      set containing entries that map to the given segments
      See Also:
    • entryIterator

      public org.infinispan.commons.util.CloseableIterator<Map.Entry<K,V>> entryIterator(org.infinispan.commons.util.IntSet segments)
      Specified by:
      entryIterator in interface InternalRemoteCache<K,V>
    • values

      public org.infinispan.commons.util.CloseableIteratorCollection<V> values(org.infinispan.commons.util.IntSet segments)
      Description copied from interface: RemoteCache
      This method is identical to RemoteCache.values() except that it will only return values that map to the given segments. Note that these segments will be determined by the remote server. Thus you should be aware of how many segments it has configured and hashing algorithm it is using. If the segments and hashing algorithm are not the same this method may return unexpected values.
      Specified by:
      values in interface RemoteCache<K,V>
      Parameters:
      segments - the segments of values to return - null means all available
      Returns:
      collection containing values that map to the given segments
      See Also:
    • execute

      public <T> T execute(String taskName, Map<String,?> params)
      Description copied from interface: RemoteCache
      Executes a remote task passing a set of named parameters
      Specified by:
      execute in interface RemoteCache<K,V>
    • execute

      public <T> T execute(String taskName, Map<String,?> params, Object key)
      Description copied from interface: RemoteCache
      Executes a remote task passing a set of named parameters, hinting that the task should be executed on the server that is expected to store given key. The key itself is not transferred to the server.
      Specified by:
      execute in interface RemoteCache<K,V>
    • getCacheTopologyInfo

      public CacheTopologyInfo getCacheTopologyInfo()
      Description copied from interface: RemoteCache
      Returns CacheTopologyInfo for this cache.
      Specified by:
      getCacheTopologyInfo in interface RemoteCache<K,V>
    • streaming

      public StreamingRemoteCache<K> streaming()
      Description copied from interface: RemoteCache
      Returns a cache where values are manipulated using InputStream and OutputStream
      Specified by:
      streaming in interface RemoteCache<K,V>
    • withDataFormat

      public <T, U> InternalRemoteCache<T,U> withDataFormat(DataFormat newDataFormat)
      Description copied from interface: RemoteCache
      Return a new instance of RemoteCache using the supplied DataFormat.
      Specified by:
      withDataFormat in interface InternalRemoteCache<K,V>
      Specified by:
      withDataFormat in interface RemoteCache<K,V>
    • resolveStorage

      public void resolveStorage(boolean objectStorage)
      Specified by:
      resolveStorage in interface InternalRemoteCache<K,V>
    • resolveStorage

      public void resolveStorage(org.infinispan.commons.dataconversion.MediaType key, org.infinispan.commons.dataconversion.MediaType value, boolean objectStorage)
      Specified by:
      resolveStorage in interface InternalRemoteCache<K,V>
    • getDataFormat

      public DataFormat getDataFormat()
      Description copied from interface: RemoteCache
      Return the currently DataFormat being used.
      Specified by:
      getDataFormat in interface RemoteCache<K,V>
    • isTransactional

      public boolean isTransactional()
      Specified by:
      isTransactional in interface RemoteCache<K,V>
      Returns:
      true if the cache can participate in a transaction, false otherwise.
    • isObjectStorage

      public boolean isObjectStorage()
      Specified by:
      isObjectStorage in interface InternalRemoteCache<K,V>
    • hasForceReturnFlag

      public boolean hasForceReturnFlag()
      Specified by:
      hasForceReturnFlag in interface InternalRemoteCache<K,V>
    • updateBloomFilter

      public CompletionStage<Void> updateBloomFilter()
      Description copied from interface: InternalRemoteCache
      Sends the current bloom filter to the listener node where a near cache listener is installed. If this cache does not have near caching this will return an already completed stage.
      Specified by:
      updateBloomFilter in interface InternalRemoteCache<K,V>
      Returns:
      stage that when complete the filter was sent to the listener node
    • toString

      public String toString()
      Overrides:
      toString in class Object