com.hazelcast.client.proxy

## Class NearCachedClientMapProxy<K,V>

- java.lang.Object
- - com.hazelcast.client.spi.ClientProxy
  - - com.hazelcast.client.proxy.ClientMapProxy<K,V>
    - - com.hazelcast.client.proxy.NearCachedClientMapProxy<K,V>

- Type Parameters:
    `K` - the key type for this `IMap` proxy.
    `V` - the value type for this `IMap` proxy.
  All Implemented Interfaces:
    BaseMap<K,V>, DistributedObject, IMap<K,V>, com.hazelcast.internal.journal.EventJournalReader<EventJournalMapEvent<K,V>>, com.hazelcast.map.impl.LegacyAsyncMap<K,V>, ConcurrentMap<K,V>, Map<K,V>

      public class NearCachedClientMapProxy<K,V>
      extends ClientMapProxy<K,V>

  A Client-side `IMap` implementation which is fronted by a Near Cache.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Field Summary

    - ### Fields inherited from class com.hazelcast.client.proxy.ClientMapProxy

      `GET_ASYNC_RESPONSE_DECODER, NULL_AGGREGATOR_IS_NOT_ALLOWED, NULL_KEY_IS_NOT_ALLOWED, NULL_LISTENER_IS_NOT_ALLOWED, NULL_PREDICATE_IS_NOT_ALLOWED, NULL_PROJECTION_IS_NOT_ALLOWED, NULL_VALUE_IS_NOT_ALLOWED`

    - ### Fields inherited from class com.hazelcast.client.spi.ClientProxy

      `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NearCachedClientMapProxy(String serviceName, String name, ClientContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `addNearCacheInvalidationListener(EventHandler handler)`
    `void` | `clear()` Clears the map and deletes the items from the backing map store.
    `protected boolean` | `containsKeyInternal(Object key)`
    `protected void` | `deleteInternal(Object key)`
    `void` | `evictAll()` Evicts all keys from this map except the locked ones.
    `protected boolean` | `evictInternal(Object key)`
    `Object` | `executeOnKeyInternal(Object key, EntryProcessor entryProcessor)`
    `protected void` | `getAllInternal(Set<K> keys, Map<Integer,List<Data>> partitionToKeyData, List<Object> resultingKeyValuePairs)`
    `ICompletableFuture<V>` | `getAsync(K key)` Asynchronously gets the given key.
    `protected V` | `getInternal(Object key)`
    `LocalMapStats` | `getLocalMapStats()` Returns LocalMapStats for this map.
    `com.hazelcast.internal.nearcache.NearCache<Object,Object>` | `getNearCache()`
    `void` | `loadAll(boolean replaceExistingValues)` Loads all keys into the store.
    `protected void` | `loadAllInternal(boolean replaceExistingValues, Collection<?> keysParameter)`
    `protected void` | `onInitialize()` Called when proxy is created.
    `protected void` | `onShutdown()` Called before client shutdown.
    `protected void` | `postDestroy()` Called after proxy is destroyed.
    `protected Map<K,Object>` | `prepareResult(Collection<Map.Entry<Data,Data>> entrySet)`
    `protected void` | `putAllInternal(Map<? extends K,? extends V> map, Map<Integer,List<Map.Entry<Data,Data>>> entryMap)`
    `protected ICompletableFuture<V>` | `putAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)`
    `protected V` | `putIfAbsentInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)`
    `protected V` | `putInternal(long ttl, TimeUnit ttlUnit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)`
    `protected void` | `putTransientInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)`
    `protected void` | `removeAllInternal(Predicate predicate)`
    `protected ICompletableFuture<V>` | `removeAsyncInternal(Object key)`
    `protected com.hazelcast.client.impl.protocol.codec.MapRemoveCodec.ResponseParameters` | `removeInternal(Object key)`
    `protected boolean` | `removeInternal(Object key, Object value)`
    `protected boolean` | `replaceIfSameInternal(Object key, Object oldValue, Object newValue)`
    `protected V` | `replaceInternal(Object key, Object value)`
    `protected ICompletableFuture<Void>` | `setAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)`
    `protected void` | `setInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)`
    `protected boolean` | `setTtlInternal(Object key, long ttl, TimeUnit timeUnit)`
    `ICompletableFuture` | `submitToKeyInternal(Object key, EntryProcessor entryProcessor)`
    `void` | `submitToKeyInternal(Object key, EntryProcessor entryProcessor, ExecutionCallback callback)`
    `protected boolean` | `tryPutInternal(long timeout, TimeUnit timeunit, Object key, Object value)`
    `protected boolean` | `tryRemoveInternal(long timeout, TimeUnit timeunit, Object key)`

    - ### Methods inherited from class com.hazelcast.client.proxy.ClientMapProxy

      `addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addIndex, addInterceptor, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addPartitionLostListener, aggregate, aggregate, aggregate, aggregate, containsKey, containsValue, delete, entrySet, entrySet, evict, executeOnEntries, executeOnEntries, executeOnKey, executeOnKeys, fillPartitionToKeyData, flush, forceUnlock, get, getAll, getAsyncInternal, getEntryView, getQueryCache, getQueryCache, getQueryCache, getQueryCacheContext, isEmpty, isLocked, iterator, iterator, keySet, keySet, loadAll, localKeySet, localKeySet, lock, lock, onDestroy, project, project, put, put, put, putAll, putAsync, putAsync, putAsync, putIfAbsent, putIfAbsent, putIfAbsent, putTransient, putTransient, readFromEventJournal, remove, remove, removeAll, removeAsync, removeEntryListener, removeInterceptor, removePartitionLostListener, replace, replace, set, set, set, setAsync, setAsync, setAsync, setTtl, size, submitToKey, submitToKey, submitToKeys, subscribeToEventJournal, toString, tryLock, tryLock, tryLock, tryPut, tryRemove, unlock, values, values`

    - ### Methods inherited from class com.hazelcast.client.spi.ClientProxy

      `deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, preDestroy, registerListener, setContext, toData, toObject`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.concurrent.ConcurrentMap

      `compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll`

    - ### Methods inherited from interface java.util.Map

      `equals, hashCode`

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getName, getPartitionKey, getServiceName`

- - ### Constructor Detail

    - #### NearCachedClientMapProxy

          public NearCachedClientMapProxy(String serviceName,
                                          String name,
                                          ClientContext context)

  - ### Method Detail

    - #### onInitialize

          protected void onInitialize()

      Description copied from class: `ClientProxy`
      Called when proxy is created. Overriding implementations can add initialization specific logic into this method like registering a listener, creating a cleanup task etc.
      Overrides:
        `onInitialize` in class `ClientMapProxy<K,V>`

    - #### containsKeyInternal

          protected boolean containsKeyInternal(Object key)

      Overrides:
        `containsKeyInternal` in class `ClientMapProxy<K,V>`

    - #### getInternal

          protected V getInternal(Object key)

      Overrides:
        `getInternal` in class `ClientMapProxy<K,V>`

    - #### setTtlInternal

          protected boolean setTtlInternal(Object key,
                                           long ttl,
                                           TimeUnit timeUnit)

      Overrides:
        `setTtlInternal` in class `ClientMapProxy<K,V>`

    - #### getAsync

          public ICompletableFuture<V> getAsync(K key)

      Description copied from interface: `IMap`
      Asynchronously gets the given key.

             ICompletableFuture future = map.getAsync(key);
             // do some other stuff, when ready get the result.
             Object value = future.get();

      `Future.get()` will block until the actual map.get() completes. If the application requires timely response, then `Future.get(long, TimeUnit)` can be used.

             try {
               ICompletableFuture future = map.getAsync(key);
               Object value = future.get(40, TimeUnit.MILLISECOND);
             } catch (TimeoutException t) {
               // time wasn't enough
             }

      Additionally, the client can schedule an `ExecutionCallback` to be invoked upon completion of the `ICompletableFuture` via `ICompletableFuture.andThen(ExecutionCallback)` or `ICompletableFuture.andThen(ExecutionCallback, Executor)`:

             // assuming an IMap<String, String>
             ICompletableFuture<String> future = map.getAsync("a");
             future.andThen(new ExecutionCallback<String>() {
               public void onResponse(String response) {
                 // do something with value in response
               }

               public void onFailure(Throwable t) {
                 // handle failure
               }
             });

      ExecutionException is never thrown.

      Warning:

      This method uses `hashCode` and `equals` of the binary form of the `key`, not the actual implementations of `hashCode` and `equals` defined in the `key`'s class.

      Interactions with the map store

      If value with `key` is not found in memory `MapLoader.load(Object)` is invoked to load the value from the map store backing the map. Exceptions thrown by load fail the operation and are propagated to the caller.

      Specified by:
        `getAsync` in interface `IMap<K,V>`
      Specified by:
        `getAsync` in interface `com.hazelcast.map.impl.LegacyAsyncMap<K,V>`
      Overrides:
        `getAsync` in class `ClientMapProxy<K,V>`
      Parameters:
        `key` - the key of the map entry
      Returns:
        ICompletableFuture from which the value of the key can be retrieved
      See Also:
        `ICompletableFuture`

    - #### removeInternal

          protected com.hazelcast.client.impl.protocol.codec.MapRemoveCodec.ResponseParameters removeInternal(Object key)

      Overrides:
        `removeInternal` in class `ClientMapProxy<K,V>`

    - #### removeInternal

          protected boolean removeInternal(Object key,
                                           Object value)

      Overrides:
        `removeInternal` in class `ClientMapProxy<K,V>`

    - #### removeAllInternal

          protected void removeAllInternal(Predicate predicate)

      Overrides:
        `removeAllInternal` in class `ClientMapProxy<K,V>`

    - #### deleteInternal

          protected void deleteInternal(Object key)

      Overrides:
        `deleteInternal` in class `ClientMapProxy<K,V>`

    - #### putAsyncInternal

          protected ICompletableFuture<V> putAsyncInternal(long ttl,
                                                           TimeUnit timeunit,
                                                           Long maxIdle,
                                                           TimeUnit maxIdleUnit,
                                                           Object key,
                                                           Object value)

      Overrides:
        `putAsyncInternal` in class `ClientMapProxy<K,V>`

    - #### setAsyncInternal

          protected ICompletableFuture<Void> setAsyncInternal(long ttl,
                                                              TimeUnit timeunit,
                                                              Long maxIdle,
                                                              TimeUnit maxIdleUnit,
                                                              Object key,
                                                              Object value)

      Overrides:
        `setAsyncInternal` in class `ClientMapProxy<K,V>`

    - #### removeAsyncInternal

          protected ICompletableFuture<V> removeAsyncInternal(Object key)

      Overrides:
        `removeAsyncInternal` in class `ClientMapProxy<K,V>`

    - #### tryRemoveInternal

          protected boolean tryRemoveInternal(long timeout,
                                              TimeUnit timeunit,
                                              Object key)

      Overrides:
        `tryRemoveInternal` in class `ClientMapProxy<K,V>`

    - #### tryPutInternal

          protected boolean tryPutInternal(long timeout,
                                           TimeUnit timeunit,
                                           Object key,
                                           Object value)

      Overrides:
        `tryPutInternal` in class `ClientMapProxy<K,V>`

    - #### putInternal

          protected V putInternal(long ttl,
                                  TimeUnit ttlUnit,
                                  Long maxIdle,
                                  TimeUnit maxIdleUnit,
                                  Object key,
                                  Object value)

      Overrides:
        `putInternal` in class `ClientMapProxy<K,V>`

    - #### putTransientInternal

          protected void putTransientInternal(long ttl,
                                              TimeUnit timeunit,
                                              Long maxIdle,
                                              TimeUnit maxIdleUnit,
                                              Object key,
                                              Object value)

      Overrides:
        `putTransientInternal` in class `ClientMapProxy<K,V>`

    - #### putIfAbsentInternal

          protected V putIfAbsentInternal(long ttl,
                                          TimeUnit timeunit,
                                          Long maxIdle,
                                          TimeUnit maxIdleUnit,
                                          Object key,
                                          Object value)

      Overrides:
        `putIfAbsentInternal` in class `ClientMapProxy<K,V>`

    - #### replaceIfSameInternal

          protected boolean replaceIfSameInternal(Object key,
                                                  Object oldValue,
                                                  Object newValue)

      Overrides:
        `replaceIfSameInternal` in class `ClientMapProxy<K,V>`

    - #### replaceInternal

          protected V replaceInternal(Object key,
                                      Object value)

      Overrides:
        `replaceInternal` in class `ClientMapProxy<K,V>`

    - #### setInternal

          protected void setInternal(long ttl,
                                     TimeUnit timeunit,
                                     Long maxIdle,
                                     TimeUnit maxIdleUnit,
                                     Object key,
                                     Object value)

      Overrides:
        `setInternal` in class `ClientMapProxy<K,V>`

    - #### evictInternal

          protected boolean evictInternal(Object key)

      Overrides:
        `evictInternal` in class `ClientMapProxy<K,V>`

    - #### evictAll

          public void evictAll()

      Description copied from interface: `IMap`
      Evicts all keys from this map except the locked ones.

      If a `MapStore` is defined for this map, deleteAll is not called by this method. If you do want to `MapStore.deleteAll(Collection)` to be called use the `IMap.clear()` method.

      The EVICT_ALL event is fired for any registered listeners. See `MapEvictedListener.mapEvicted(MapEvent)` .

      Specified by:
        `evictAll` in interface `IMap<K,V>`
      Overrides:
        `evictAll` in class `ClientMapProxy<K,V>`
      See Also:
        `IMap.clear()`

    - #### loadAll

          public void loadAll(boolean replaceExistingValues)

      Description copied from interface: `IMap`
      Loads all keys into the store. This is a batch load operation so that an implementation can optimize multiple loads.

      Interactions with the map store

      Calls `MapLoader.loadAllKeys()` and with the loaded keys calls `MapLoader.loadAll(java.util.Collection)` on each partition. Exceptions thrown by loadAllKeys() or loadAll() are not propagated to the caller.

      Specified by:
        `loadAll` in interface `IMap<K,V>`
      Overrides:
        `loadAll` in class `ClientMapProxy<K,V>`
      Parameters:
        `replaceExistingValues` - when `true`, existing values in the Map will be replaced by those loaded from the MapLoader `IMap.loadAll(boolean)`

    - #### loadAllInternal

          protected void loadAllInternal(boolean replaceExistingValues,
                                         Collection<?> keysParameter)

      Overrides:
        `loadAllInternal` in class `ClientMapProxy<K,V>`

    - #### getAllInternal

          protected void getAllInternal(Set<K> keys,
                                        Map<Integer,List<Data>> partitionToKeyData,
                                        List<Object> resultingKeyValuePairs)

      Overrides:
        `getAllInternal` in class `ClientMapProxy<K,V>`

    - #### getLocalMapStats

          public LocalMapStats getLocalMapStats()

      Description copied from interface: `IMap`
      Returns LocalMapStats for this map.

      LocalMapStats are the statistics for the local portion of this distributed map and contains information such as ownedEntryCount backupEntryCount, lastUpdateTime, lockedEntryCount.

      Since this stats are only for the local portion of this map, if you need the cluster-wide MapStats then you need to get the LocalMapStats from all members of the cluster and combine them.

      It's guaranteed that the returned `LocalMapStats` instance contains an up-to-date statistics. But over the time some parts of the returned instance may become stale while others may be updated. To obtain a fresh up-to-date instance invoke the method one more time.

      Specified by:
        `getLocalMapStats` in interface `IMap<K,V>`
      Overrides:
        `getLocalMapStats` in class `ClientMapProxy<K,V>`
      Returns:
        this map's local statistics

    - #### executeOnKeyInternal

          public Object executeOnKeyInternal(Object key,
                                             EntryProcessor entryProcessor)

      Overrides:
        `executeOnKeyInternal` in class `ClientMapProxy<K,V>`

    - #### submitToKeyInternal

          public ICompletableFuture submitToKeyInternal(Object key,
                                                        EntryProcessor entryProcessor)

      Overrides:
        `submitToKeyInternal` in class `ClientMapProxy<K,V>`

    - #### submitToKeyInternal

          public void submitToKeyInternal(Object key,
                                          EntryProcessor entryProcessor,
                                          ExecutionCallback callback)

      Overrides:
        `submitToKeyInternal` in class `ClientMapProxy<K,V>`

    - #### prepareResult

          protected Map<K,Object> prepareResult(Collection<Map.Entry<Data,Data>> entrySet)

      Overrides:
        `prepareResult` in class `ClientMapProxy<K,V>`

    - #### putAllInternal

          protected void putAllInternal(Map<? extends K,? extends V> map,
                                        Map<Integer,List<Map.Entry<Data,Data>>> entryMap)

      Overrides:
        `putAllInternal` in class `ClientMapProxy<K,V>`

    - #### clear

          public void clear()

      Description copied from interface: `IMap`
      Clears the map and deletes the items from the backing map store.

      The MAP_CLEARED event is fired for any registered listeners. See `MapClearedListener.mapCleared(MapEvent)`.

      To clear the map without removing the items from the map store, use `IMap.evictAll()`.

      Interactions with the map store

      Calls `MapStore.deleteAll(Collection)` on each partition with the keys that the given partition stores. Exceptions thrown by deleteAll() are not propagated to the caller.

      Specified by:
        `clear` in interface `IMap<K,V>`
      Specified by:
        `clear` in interface `Map<K,V>`
      Overrides:
        `clear` in class `ClientMapProxy<K,V>`
      See Also:
        `IMap.evictAll()`

    - #### postDestroy

          protected void postDestroy()

      Description copied from class: `ClientProxy`
      Called after proxy is destroyed.
      Overrides:
        `postDestroy` in class `ClientProxy`

    - #### onShutdown

          protected void onShutdown()

      Description copied from class: `ClientProxy`
      Called before client shutdown. Overriding implementations can add shutdown specific logic here.
      Overrides:
        `onShutdown` in class `ClientProxy`

    - #### getNearCache

          public com.hazelcast.internal.nearcache.NearCache<Object,Object> getNearCache()

    - #### addNearCacheInvalidationListener

          public String addNearCacheInvalidationListener(EventHandler handler)

Copyright © 2019. All rights reserved.