K
- the key type for this IMap
proxy.V
- the value type for this IMap
proxy.public class NearCachedClientMapProxy<K,V> extends ClientMapProxy<K,V>
IMap
implementation which is fronted by a Near Cache.NULL_AGGREGATOR_IS_NOT_ALLOWED, NULL_ENTRY_PROCESSOR_IS_NOT_ALLOWED, NULL_KEY_IS_NOT_ALLOWED, NULL_LISTENER_IS_NOT_ALLOWED, NULL_MAX_IDLE_UNIT_IS_NOT_ALLOWED, NULL_PREDICATE_IS_NOT_ALLOWED, NULL_PROJECTION_IS_NOT_ALLOWED, NULL_TIMEUNIT_IS_NOT_ALLOWED, NULL_TTL_UNIT_IS_NOT_ALLOWED, NULL_VALUE_IS_NOT_ALLOWED
name
Constructor and Description |
---|
NearCachedClientMapProxy(String serviceName,
String name,
ClientContext context) |
Modifier and Type | Method and Description |
---|---|
UUID |
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) |
<R> R |
executeOnKeyInternal(Object key,
EntryProcessor<K,V,R> entryProcessor) |
protected void |
finalizePutAll(Map<? extends K,? extends V> map,
Map<Integer,List<Map.Entry<Data,Data>>> entryMap) |
protected void |
getAllInternal(Set<K> keys,
Map<Integer,List<Data>> partitionToKeyData,
List<Object> resultingKeyValuePairs) |
InternalCompletableFuture<V> |
getAsync(K key)
Asynchronously gets the given key.
|
protected V |
getInternal(Object key) |
LocalMapStats |
getLocalMapStats()
Returns LocalMapStats for this map.
|
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 <R> Map<K,R> |
prepareResult(Collection<Map.Entry<Data,Data>> entrySet) |
protected InternalCompletableFuture<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 InternalCompletableFuture<V> |
removeAsyncInternal(Object key) |
protected 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 InternalCompletableFuture<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) |
<R> InternalCompletableFuture<R> |
submitToKeyInternal(Object key,
EntryProcessor<K,V,R> entryProcessor) |
<R> void |
submitToKeyInternal(Object key,
EntryProcessor<K,V,R> entryProcessor,
ExecutionCallback<? super R> callback) |
protected boolean |
tryPutInternal(long timeout,
TimeUnit timeunit,
Object key,
Object value) |
protected boolean |
tryRemoveInternal(long timeout,
TimeUnit timeunit,
Object key) |
addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addIndex, addInterceptor, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addPartitionLostListener, 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, putAllAsync, 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
deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, preDestroy, registerListener, toData, toObject
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
destroy, getName, getPartitionKey, getServiceName
public NearCachedClientMapProxy(String serviceName, String name, ClientContext context)
protected void onInitialize()
ClientProxy
onInitialize
in class ClientMapProxy<K,V>
protected boolean containsKeyInternal(Object key)
containsKeyInternal
in class ClientMapProxy<K,V>
protected V getInternal(Object key)
getInternal
in class ClientMapProxy<K,V>
protected boolean setTtlInternal(Object key, long ttl, TimeUnit timeUnit)
setTtlInternal
in class ClientMapProxy<K,V>
public InternalCompletableFuture<V> getAsync(@Nonnull K key)
IMap
CompletionStage
can be converted to a
CompletableFuture
to obtain the value in a blocking way:
CompletionStage future = map.getAsync(key); // do some other stuff, when ready get the result. Object value = future.toCompletableFuture().get();Additionally, the client can register further computation stages to be invoked upon completion of the
CompletionStage
via any of CompletionStage
methods:
// assuming an IMap<String, String>
CompletionStage<String> future = map.getAsync("a");
future.thenAcceptAsync(response -> System.out.println(response));
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.
getAsync
in interface IMap<K,V>
getAsync
in class ClientMapProxy<K,V>
key
- the key of the map entryCompletionStage
protected MapRemoveCodec.ResponseParameters removeInternal(Object key)
removeInternal
in class ClientMapProxy<K,V>
protected boolean removeInternal(Object key, Object value)
removeInternal
in class ClientMapProxy<K,V>
protected void removeAllInternal(Predicate predicate)
removeAllInternal
in class ClientMapProxy<K,V>
protected void deleteInternal(Object key)
deleteInternal
in class ClientMapProxy<K,V>
protected InternalCompletableFuture<V> putAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
putAsyncInternal
in class ClientMapProxy<K,V>
protected InternalCompletableFuture<Void> setAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
setAsyncInternal
in class ClientMapProxy<K,V>
protected InternalCompletableFuture<V> removeAsyncInternal(Object key)
removeAsyncInternal
in class ClientMapProxy<K,V>
protected boolean tryRemoveInternal(long timeout, TimeUnit timeunit, Object key)
tryRemoveInternal
in class ClientMapProxy<K,V>
protected boolean tryPutInternal(long timeout, TimeUnit timeunit, Object key, Object value)
tryPutInternal
in class ClientMapProxy<K,V>
protected V putInternal(long ttl, TimeUnit ttlUnit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
putInternal
in class ClientMapProxy<K,V>
protected void putTransientInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
putTransientInternal
in class ClientMapProxy<K,V>
protected V putIfAbsentInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
putIfAbsentInternal
in class ClientMapProxy<K,V>
protected boolean replaceIfSameInternal(Object key, Object oldValue, Object newValue)
replaceIfSameInternal
in class ClientMapProxy<K,V>
protected V replaceInternal(Object key, Object value)
replaceInternal
in class ClientMapProxy<K,V>
protected void setInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
setInternal
in class ClientMapProxy<K,V>
protected boolean evictInternal(Object key)
evictInternal
in class ClientMapProxy<K,V>
public void evictAll()
IMap
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)
.
evictAll
in interface IMap<K,V>
evictAll
in class ClientMapProxy<K,V>
IMap.clear()
public void loadAll(boolean replaceExistingValues)
IMap
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.
protected void loadAllInternal(boolean replaceExistingValues, Collection<?> keysParameter)
loadAllInternal
in class ClientMapProxy<K,V>
protected void getAllInternal(Set<K> keys, Map<Integer,List<Data>> partitionToKeyData, List<Object> resultingKeyValuePairs)
getAllInternal
in class ClientMapProxy<K,V>
public LocalMapStats getLocalMapStats()
IMap
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.
getLocalMapStats
in interface IMap<K,V>
getLocalMapStats
in class ClientMapProxy<K,V>
public <R> R executeOnKeyInternal(Object key, EntryProcessor<K,V,R> entryProcessor)
executeOnKeyInternal
in class ClientMapProxy<K,V>
public <R> InternalCompletableFuture<R> submitToKeyInternal(Object key, EntryProcessor<K,V,R> entryProcessor)
submitToKeyInternal
in class ClientMapProxy<K,V>
public <R> void submitToKeyInternal(Object key, EntryProcessor<K,V,R> entryProcessor, ExecutionCallback<? super R> callback)
submitToKeyInternal
in class ClientMapProxy<K,V>
protected <R> Map<K,R> prepareResult(Collection<Map.Entry<Data,Data>> entrySet)
prepareResult
in class ClientMapProxy<K,V>
protected void finalizePutAll(Map<? extends K,? extends V> map, Map<Integer,List<Map.Entry<Data,Data>>> entryMap)
finalizePutAll
in class ClientMapProxy<K,V>
public void clear()
IMap
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.
protected void postDestroy()
ClientProxy
postDestroy
in class ClientProxy
protected void onShutdown()
ClientProxy
onShutdown
in class ClientProxy
public UUID addNearCacheInvalidationListener(EventHandler handler)
Copyright © 2019 Hazelcast, Inc.. All rights reserved.