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.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
name
Constructor and Description |
---|
NearCachedClientMapProxy(String serviceName,
String name,
ClientContext context) |
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.
|
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) |
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
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
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 ICompletableFuture<V> getAsync(K key)
IMap
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.
getAsync
in interface IMap<K,V>
getAsync
in interface LegacyAsyncMap<K,V>
getAsync
in class ClientMapProxy<K,V>
key
- the key of the map entryICompletableFuture
protected com.hazelcast.client.impl.protocol.codec.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 ICompletableFuture<V> putAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
putAsyncInternal
in class ClientMapProxy<K,V>
protected ICompletableFuture<Void> setAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value)
setAsyncInternal
in class ClientMapProxy<K,V>
protected ICompletableFuture<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.
loadAll
in interface IMap<K,V>
loadAll
in class ClientMapProxy<K,V>
replaceExistingValues
- when true
, existing values
in the Map will be replaced by those
loaded from the MapLoader
IMap.loadAll(boolean)
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 Object executeOnKeyInternal(Object key, EntryProcessor entryProcessor)
executeOnKeyInternal
in class ClientMapProxy<K,V>
public ICompletableFuture submitToKeyInternal(Object key, EntryProcessor entryProcessor)
submitToKeyInternal
in class ClientMapProxy<K,V>
public void submitToKeyInternal(Object key, EntryProcessor entryProcessor, ExecutionCallback callback)
submitToKeyInternal
in class ClientMapProxy<K,V>
protected Map<K,Object> prepareResult(Collection<Map.Entry<Data,Data>> entrySet)
prepareResult
in class ClientMapProxy<K,V>
protected void putAllInternal(Map<? extends K,? extends V> map, Map<Integer,List<Map.Entry<Data,Data>>> entryMap)
putAllInternal
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 String addNearCacheInvalidationListener(EventHandler handler)
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.