K
- the key type for this IMap
proxy.V
- the value type for this IMap
proxy.public class NearCachedMapProxyImpl<K,V> extends MapProxyImpl<K,V>
IMap
implementation which is fronted by a Near Cache.Modifier and Type | Field and Description |
---|---|
protected LocalMapStatsImpl |
localMapStats |
protected LockProxySupport |
lockSupport |
protected MapConfig |
mapConfig |
protected MapServiceContext |
mapServiceContext |
protected String |
name |
protected static String |
NULL_AGGREGATOR_IS_NOT_ALLOWED |
protected static String |
NULL_KEY_IS_NOT_ALLOWED |
protected static String |
NULL_KEYS_ARE_NOT_ALLOWED |
protected static String |
NULL_LISTENER_IS_NOT_ALLOWED |
protected static String |
NULL_PREDICATE_IS_NOT_ALLOWED |
protected static String |
NULL_PROJECTION_IS_NOT_ALLOWED |
protected static String |
NULL_VALUE_IS_NOT_ALLOWED |
protected MapOperationProvider |
operationProvider |
protected OperationService |
operationService |
protected IPartitionService |
partitionService |
protected PartitioningStrategy |
partitionStrategy |
protected SerializationService |
serializationService |
protected boolean |
statisticsEnabled |
protected Address |
thisAddress |
PARTITIONING_STRATEGY
Constructor and Description |
---|
NearCachedMapProxyImpl(String name,
MapService mapService,
NodeEngine nodeEngine,
MapConfig mapConfig) |
Modifier and Type | Method and Description |
---|---|
protected String |
addEntryListenerInternal(Object listener,
Data key,
boolean includeValue) |
protected String |
addEntryListenerInternal(Object listener,
Predicate predicate,
Data key,
boolean includeValue) |
void |
addIndex(String attribute,
boolean ordered)
Adds an index to this map for the specified entries so
that queries can run faster.
|
String |
addLocalEntryListenerInternal(Object listener) |
String |
addLocalEntryListenerInternal(Object listener,
Predicate predicate,
Data key,
boolean includeValue) |
String |
addMapInterceptorInternal(MapInterceptor interceptor) |
String |
addNearCacheInvalidationListener(InvalidationListener listener) |
protected String |
addPartitionLostListenerInternal(MapPartitionLostListener listener) |
void |
clearInternal() |
protected boolean |
containsKeyInternal(Object key) |
boolean |
containsValueInternal(Data dataValue) |
protected Iterable<Data> |
convertToData(Iterable<K> keys) |
protected void |
deleteInternal(Object key) |
protected void |
evictAllInternal() |
protected boolean |
evictInternal(Object key)
Evicts a key from a map.
|
void |
executeOnEntriesInternal(EntryProcessor entryProcessor,
Predicate predicate,
List<Data> resultingKeyValuePairs)
|
Data |
executeOnKeyInternal(Object key,
EntryProcessor entryProcessor) |
InternalCompletableFuture<Object> |
executeOnKeyInternal(Object key,
EntryProcessor entryProcessor,
ExecutionCallback<Object> callback) |
Map<K,Object> |
executeOnKeysInternal(Set<K> keys,
Set<Data> dataKeys,
EntryProcessor entryProcessor) |
protected void |
finalizePutAll(Map<?,?> map) |
void |
flush()
If this map has a MapStore, this method flushes
all the local dirty entries by calling MapStore.storeAll() and/or MapStore.deleteAll().
|
protected void |
getAllInternal(Set<K> keys,
List<Data> dataKeys,
List<Object> resultingKeyValuePairs) |
protected InternalCompletableFuture<Data> |
getAsyncInternal(Object key) |
protected EntryView |
getEntryViewInternal(Data key) |
protected V |
getInternal(Object key) |
LocalMapStats |
getLocalMapStats()
Returns LocalMapStats for this map.
|
protected MapQueryEngine |
getMapQueryEngine() |
String |
getName()
Returns the unique name for this DistributedObject.
|
NearCache<Object,Object> |
getNearCache() |
MapOperationProvider |
getOperationProvider() |
PartitioningStrategy |
getPartitionStrategy() |
String |
getServiceName()
Returns the service name for this object.
|
int |
getTotalBackupCount() |
void |
initialize() |
protected void |
invalidateNearCache(Object key) |
protected void |
invokePutAllOperationFactory(long size,
int[] partitions,
MapEntries[] entries) |
boolean |
isEmpty()
Returns true if this map contains no entries.
|
protected boolean |
isMapStoreEnabled() |
void |
loadAllInternal(boolean replaceExistingValues) |
protected void |
loadInternal(Set<K> keys,
Iterable<Data> dataKeys,
boolean replaceExistingValues)
Maps keys to corresponding partitions and sends operations to them.
|
protected void |
postDestroy() |
protected boolean |
preDestroy() |
protected void |
putAllInternal(Map<?,?> map)
This method will group all puts per partition and send a
PutAllPartitionAwareOperationFactory per member. |
protected InternalCompletableFuture<Data> |
putAsyncInternal(Object key,
Data value,
long ttl,
TimeUnit timeunit) |
protected Data |
putIfAbsentInternal(Object key,
Data value,
long ttl,
TimeUnit timeunit) |
protected Data |
putInternal(Object key,
Data value,
long ttl,
TimeUnit timeunit) |
protected void |
putTransientInternal(Object key,
Data value,
long ttl,
TimeUnit timeunit) |
protected void |
removeAllInternal(Predicate predicate) |
protected InternalCompletableFuture<Data> |
removeAsyncInternal(Object key) |
protected boolean |
removeEntryListenerInternal(String id) |
protected Data |
removeInternal(Object key) |
protected boolean |
removeInternal(Object key,
Data value) |
void |
removeMapInterceptorInternal(String id) |
protected boolean |
removePartitionLostListenerInternal(String id) |
protected Data |
replaceInternal(Object key,
Data value) |
protected boolean |
replaceInternal(Object key,
Data expect,
Data update) |
protected InternalCompletableFuture<Data> |
setAsyncInternal(Object key,
Data value,
long ttl,
TimeUnit timeunit) |
protected void |
setInternal(Object key,
Data value,
long ttl,
TimeUnit timeunit) |
void |
setOperationProvider(MapOperationProvider operationProvider) |
int |
size()
Returns the number of entries in this map.
|
protected Data |
toData(Object object,
PartitioningStrategy partitioningStrategy) |
protected void |
toDataCollectionWithNonNullKeyValidation(Set<K> keys,
Collection<Data> dataKeys) |
protected Data |
toDataWithStrategy(Object object) |
protected <T> T |
toObject(Object object) |
protected boolean |
tryPutInternal(Object key,
Data value,
long timeout,
TimeUnit timeunit) |
protected boolean |
tryRemoveInternal(Object key,
long timeout,
TimeUnit timeunit) |
void |
waitUntilLoaded() |
addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addEntryListener, addInterceptor, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addLocalEntryListener, addPartitionLostListener, aggregate, aggregate, aggregate, aggregate, clear, clearMapOnly, containsKey, containsValue, delete, entrySet, entrySet, evict, evictAll, executeOnEntries, executeOnEntries, executeOnKey, executeOnKeys, forceUnlock, get, getAll, getAsync, getEntryView, getQueryCache, getQueryCache, getQueryCache, invoke, isLocked, iterator, iterator, keySet, keySet, loadAll, loadAll, localKeySet, localKeySet, lock, lock, project, project, put, put, putAll, putAsync, putAsync, putIfAbsent, putIfAbsent, putTransient, readFromEventJournal, remove, remove, removeAll, removeAsync, removeEntryListener, removeInterceptor, removePartitionLostListener, replace, replace, set, set, setAsync, setAsync, submitToKey, submitToKey, subscribeToEventJournal, toString, tryLock, tryLock, tryLock, tryPut, tryRemove, unlock, values, values
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, throwNotActiveException, toData
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
destroy, getPartitionKey
protected static final String NULL_KEY_IS_NOT_ALLOWED
protected static final String NULL_KEYS_ARE_NOT_ALLOWED
protected static final String NULL_VALUE_IS_NOT_ALLOWED
protected static final String NULL_PREDICATE_IS_NOT_ALLOWED
protected static final String NULL_LISTENER_IS_NOT_ALLOWED
protected static final String NULL_AGGREGATOR_IS_NOT_ALLOWED
protected static final String NULL_PROJECTION_IS_NOT_ALLOWED
protected final String name
protected final LocalMapStatsImpl localMapStats
protected final LockProxySupport lockSupport
protected final PartitioningStrategy partitionStrategy
protected final MapServiceContext mapServiceContext
protected final IPartitionService partitionService
protected final Address thisAddress
protected final OperationService operationService
protected final SerializationService serializationService
protected final boolean statisticsEnabled
protected final MapConfig mapConfig
protected MapOperationProvider operationProvider
public NearCachedMapProxyImpl(String name, MapService mapService, NodeEngine nodeEngine, MapConfig mapConfig)
public void initialize()
initialize
in interface InitializingObject
protected InternalCompletableFuture<Data> getAsyncInternal(Object key)
protected boolean tryPutInternal(Object key, Data value, long timeout, TimeUnit timeunit)
protected Data putIfAbsentInternal(Object key, Data value, long ttl, TimeUnit timeunit)
protected void putTransientInternal(Object key, Data value, long ttl, TimeUnit timeunit)
protected InternalCompletableFuture<Data> putAsyncInternal(Object key, Data value, long ttl, TimeUnit timeunit)
protected InternalCompletableFuture<Data> setAsyncInternal(Object key, Data value, long ttl, TimeUnit timeunit)
protected boolean evictInternal(Object key)
key
- the key to evicttrue
if eviction was successful, false
otherwiseprotected void evictAllInternal()
public void clearInternal()
public void loadAllInternal(boolean replaceExistingValues)
protected void loadInternal(Set<K> keys, Iterable<Data> dataKeys, boolean replaceExistingValues)
protected void removeAllInternal(Predicate predicate)
protected void deleteInternal(Object key)
protected InternalCompletableFuture<Data> removeAsyncInternal(Object key)
protected boolean containsKeyInternal(Object key)
protected void getAllInternal(Set<K> keys, List<Data> dataKeys, List<Object> resultingKeyValuePairs)
protected void invokePutAllOperationFactory(long size, int[] partitions, MapEntries[] entries) throws Exception
Exception
protected void finalizePutAll(Map<?,?> map)
public Data executeOnKeyInternal(Object key, EntryProcessor entryProcessor)
public Map<K,Object> executeOnKeysInternal(Set<K> keys, Set<Data> dataKeys, EntryProcessor entryProcessor)
public InternalCompletableFuture<Object> executeOnKeyInternal(Object key, EntryProcessor entryProcessor, ExecutionCallback<Object> callback)
public void executeOnEntriesInternal(EntryProcessor entryProcessor, Predicate predicate, List<Data> resultingKeyValuePairs)
protected void postDestroy()
postDestroy
in class AbstractDistributedObject<MapService>
protected void invalidateNearCache(Object key)
public String addNearCacheInvalidationListener(InvalidationListener listener)
public final String getName()
DistributedObject
DistributedObjectUtil.getName(DistributedObject)
because this might be also a PrefixedDistributedObject
.getName
in interface DistributedObject
public final String getServiceName()
DistributedObject
getServiceName
in interface DistributedObject
getServiceName
in class AbstractDistributedObject<MapService>
public PartitioningStrategy getPartitionStrategy()
public MapOperationProvider getOperationProvider()
public void setOperationProvider(MapOperationProvider operationProvider)
public int getTotalBackupCount()
protected MapQueryEngine getMapQueryEngine()
protected boolean isMapStoreEnabled()
public void waitUntilLoaded()
public int size()
BaseMap
public boolean containsValueInternal(Data dataValue)
public boolean isEmpty()
BaseMap
protected void putAllInternal(Map<?,?> map)
PutAllPartitionAwareOperationFactory
per member.
If there are e.g. five keys for a single member, there will only be a single remote invocation instead of having five remote invocations.
There is also an optional support for batching to send smaller packages.
Takes care about null
checks for keys and values.
public void flush()
IMap
public String addMapInterceptorInternal(MapInterceptor interceptor)
public void removeMapInterceptorInternal(String id)
public String addLocalEntryListenerInternal(Object listener, Predicate predicate, Data key, boolean includeValue)
protected String addEntryListenerInternal(Object listener, Data key, boolean includeValue)
protected String addEntryListenerInternal(Object listener, Predicate predicate, Data key, boolean includeValue)
protected boolean removeEntryListenerInternal(String id)
protected String addPartitionLostListenerInternal(MapPartitionLostListener listener)
protected boolean removePartitionLostListenerInternal(String id)
protected <T> T toObject(Object object)
protected Data toData(Object object, PartitioningStrategy partitioningStrategy)
public void addIndex(String attribute, boolean ordered)
IMap
Let's say your map values are Employee objects.
public class Employee implements Serializable { private boolean active = false; private int age; private String name = null; // other fields // getters setter }If you are querying your values mostly based on age and active then you should consider indexing these fields.
IMap imap = Hazelcast.getMap("employees"); imap.addIndex("age", true); // ordered, since we have ranged queries for this field imap.addIndex("active", false); // not ordered, because boolean field cannot have rangeIndex attribute should either have a getter method or be public. You should also make sure to add the indexes before adding entries to this map.
Time to Index
Indexing time is executed in parallel on each partition by operation threads. The Map is not blocked during this operation.
The time taken in proportional to the size of the Map and the number Members.
Searches while indexes are being built
Until the index finishes being created, any searches for the attribute will use a full Map scan, thus avoiding using a partially built index and returning incorrect results.
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.
getLocalMapStats
in interface IMap<K,V>
protected boolean preDestroy()
preDestroy
in class AbstractDistributedObject<MapService>
protected void toDataCollectionWithNonNullKeyValidation(Set<K> keys, Collection<Data> dataKeys)
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.