Class NearCache<K,V>
- java.lang.Object
-
- com.tangosol.net.cache.CachingMap<K,V>
-
- com.tangosol.net.cache.NearCache<K,V>
-
- All Implemented Interfaces:
ClassLoaderAware
,CacheMap<K,V>
,NamedCache<K,V>
,NamedCollection
,NamedMap<K,V>
,Releasable
,ConcurrentMap<K,V>
,InvocableMap<K,V>
,ObservableMap<K,V>
,QueryMap<K,V>
,AutoCloseable
,Map<K,V>
- Direct Known Subclasses:
VersionedNearCache
public class NearCache<K,V> extends CachingMap<K,V> implements NamedCache<K,V>, ClassLoaderAware
A "near cache" is a CachingMap whose front map is a size-limited and/or auto-expiring local cache, and whose back map is a distributed cache. (A CachingMap is a map that has a "front" map and a "back" map; the front map is assumed to be low latency but incomplete, and the back map is assumed to be complete but high latency.)- Author:
- ag/cp 2002.10.20, gg 2003.10.16
- See Also:
Invalidation strategies
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
NearCache.BackServiceListener
MemberListener for the back cache's service.-
Nested classes/interfaces inherited from class com.tangosol.net.cache.CachingMap
CachingMap.DeactivationListener, CachingMap.FrontMapListener, CachingMap.PrimingListener, CachingMap.SimpleListener
-
Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap
InvocableMap.Entry<K,V>, InvocableMap.EntryAggregator<K,V,R>, InvocableMap.EntryProcessor<K,V,R>, InvocableMap.ParallelAwareAggregator<K,V,P,R>, InvocableMap.StreamingAggregator<K,V,P,R>
-
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K extends Object,V extends Object>
-
Nested classes/interfaces inherited from interface com.tangosol.net.NamedMap
NamedMap.Option
-
Nested classes/interfaces inherited from interface com.tangosol.util.QueryMap
QueryMap.Entry<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected MemberListener
f_listenerBackService
The back cache service MemberListener.protected CacheService
f_service
The back cache service.protected String
f_sName
The cache name.protected String
f_sServiceName
The back cache service name.protected boolean
m_fDestroyed
True if {#link destroy()} has been called on this cache.-
Fields inherited from class com.tangosol.net.cache.CachingMap
LISTEN_ALL, LISTEN_AUTO, LISTEN_LOGICAL, LISTEN_NONE, LISTEN_PRESENT, m_listenerDeactivation, m_nStrategyCurrent, m_nStrategyTarget
-
Fields inherited from interface com.tangosol.net.cache.CacheMap
EXPIRY_DEFAULT, EXPIRY_NEVER
-
Fields inherited from interface com.tangosol.util.ConcurrentMap
LOCK_ALL
-
-
Constructor Summary
Constructors Constructor Description NearCache(Map<K,V> mapFront, NamedCache<K,V> mapBack)
Construct a NearCache, using a mapBack NamedCache as the complete (back) storage and mapFront Map as a near (front) storage using theCachingMap.LISTEN_AUTO
invalidation strategy.NearCache(Map<K,V> mapFront, NamedCache<K,V> mapBack, int nStrategy)
Construct a NearCache, using a mapBack NamedCache as the complete (back) storage and mapFront Map as a near (front) storage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T,E>
voidaddIndex(ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
Add an index to this QueryMap.void
addMapListener(MapListener<? super K,? super V> listener)
Add a standard map listener.void
addMapListener(MapListener<? super K,? super V> listener, Filter filter, boolean fLite)
Add a map listener that receives events based on a filter evaluation.void
addMapListener(MapListener<? super K,? super V> listener, K oKey, boolean fLite)
Add a map listener for a specific key.<R> R
aggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation against the set of entries that are selected by the given Filter.<R> R
aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation against the entries specified by the passed keys.AsyncNamedCache<K,V>
async(AsyncNamedMap.Option... options)
Return an asynchronous wrapper for this NamedCache.V
computeIfAbsent(K key, Remote.Function<? super K,? extends V> mappingFunction)
Compute the value using the given mapping function and enter it into this map (unlessnull
), if the specified key is not already associated with a value (or is mapped tonull
).V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
Note that the previous example will not work as expected if this method is called on a distributed map, as theadd
method will be called on a client-side copy of the collection stored on the server.void
destroy()
Release and destroy this instance of NamedCollection.Set<Map.Entry<K,V>>
entrySet(Filter filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.Set<Map.Entry<K,V>>
entrySet(Filter filter, Comparator comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.NamedCache<K,V>
getBackCache()
Obtain the NamedCache object that sits behind this NearCache.String
getCacheName()
Return the cache name.CacheService
getCacheService()
Return the CacheService that this NamedCache is a part of.ClassLoader
getContextClassLoader()
Retrieve the context ClassLoader for this object.V
getOrDefault(Object oKey, V defaultValue)
String
getRegistrationContext()
Obtain the context (tier) used to register a CacheMBean for this cache.<R> R
invoke(K key, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.<R> Map<K,R>
invokeAll(Filter filter, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.<R> Map<K,R>
invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.boolean
isActive()
Specifies whether or not the NamedCache is active.boolean
isDestroyed()
Specifies whether or not this NamedCollection has been destroyed.boolean
isReady()
Returns whether thisNamedMap
is ready to be used.boolean
isReleased()
Specifies whether or this Releasable has been released.Set<K>
keySet(Filter filter)
Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.boolean
lock(Object oKey)
Attempt to lock the specified item and return immediately.boolean
lock(Object oKey, long lMillis)
Attempt to lock the specified item within the specified period of time.V
put(K oKey, V oValue, long cMillis)
Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry.protected MemberListener
registerBackServiceListener()
Instantiate and register a MemberListener with the back cache service.void
registerMBean()
Register an MBean representing this NearCache.void
release()
Release the CachingMap.protected void
release(boolean fDestroy)
Release this cache, optionally destroying it.<T,E>
voidremoveIndex(ValueExtractor<? super T,? extends E> extractor)
Remove an index from this QueryMap.void
removeMapListener(MapListener<? super K,? super V> listener)
Remove a standard map listener.void
removeMapListener(MapListener<? super K,? super V> listener, Filter filter)
Remove a map listener that previously signed up for events based on a filter evaluation.void
removeMapListener(MapListener<? super K,? super V> listener, K oKey)
Remove a map listener that previously signed up for events about a specific key.void
setContextClassLoader(ClassLoader loader)
Specify the context ClassLoader for this object.void
setRegistrationContext(String sCtx)
Set the context (tier) used to register a CacheMBean for this cache.void
truncate()
Removes all mappings from this map.boolean
unlock(Object oKey)
Unlock the specified item.protected void
unregisterBackServiceListener()
Unregister back cache service member listener.protected void
unregisterMBean()
Unregister an associated CacheMBean.-
Methods inherited from class com.tangosol.net.cache.CachingMap
clear, containsKey, containsValue, ensureInvalidationStrategy, entrySet, get, getAll, getAllFromFrontMap, getBackMap, getCacheStatistics, getControlMap, getFrontMap, getInvalidationHits, getInvalidationMisses, getInvalidationStrategy, getTotalRegisterListener, instantiateBackMapListener, instantiateFrontMapListener, invalidateFront, isCheckPrimingExclusively, isCoherent, isEmpty, isPriming, keySet, put, put, putAll, registerDeactivationListener, registerFrontListener, registerListener, registerListener, registerListeners, remove, removeKeyHolder, resetFrontMap, resetInvalidationStrategy, setKeyHolder, size, toString, tryLock, unregisterDeactivationListener, unregisterFrontListener, unregisterListener, unregisterListener, unregisterListeners, validate, values
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tangosol.util.ConcurrentMap
containsKey, containsValue, get, isEmpty, put, putAll, remove, size
-
Methods inherited from interface com.tangosol.util.InvocableMap
aggregate, compute, compute, computeIfPresent, computeIfPresent, invokeAll, merge, merge, putIfAbsent, remove, replace, replace, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
-
Methods inherited from interface com.tangosol.net.NamedCache
as, async, forEach, view
-
Methods inherited from interface com.tangosol.net.NamedMap
clear, getAll, getName, getService
-
Methods inherited from interface com.tangosol.util.QueryMap
addIndex, forEach, forEach, values, values
-
Methods inherited from interface com.tangosol.net.Releasable
close
-
-
-
-
Field Detail
-
m_fDestroyed
protected boolean m_fDestroyed
True if {#link destroy()} has been called on this cache.
-
f_sName
protected final String f_sName
The cache name.
-
f_service
protected final CacheService f_service
The back cache service.
-
f_listenerBackService
protected final MemberListener f_listenerBackService
The back cache service MemberListener.
-
f_sServiceName
protected final String f_sServiceName
The back cache service name.
-
-
Constructor Detail
-
NearCache
public NearCache(Map<K,V> mapFront, NamedCache<K,V> mapBack)
Construct a NearCache, using a mapBack NamedCache as the complete (back) storage and mapFront Map as a near (front) storage using theCachingMap.LISTEN_AUTO
invalidation strategy.- Parameters:
mapFront
- Map to put in front of the back cachemapBack
- NamedCache to put behind the front cache
-
NearCache
public NearCache(Map<K,V> mapFront, NamedCache<K,V> mapBack, int nStrategy)
Construct a NearCache, using a mapBack NamedCache as the complete (back) storage and mapFront Map as a near (front) storage.- Parameters:
mapFront
- Map to put in front of the back cachemapBack
- NamedCache to put behind the front cachenStrategy
- specifies the strategy used for the front map invalidation; valid values are:
LISTEN_NONE
,LISTEN_PRESENT
,LISTEN_ALL
,LISTEN_AUTO
- Since:
- Coherence 2.3
-
-
Method Detail
-
getBackCache
public NamedCache<K,V> getBackCache()
Obtain the NamedCache object that sits behind this NearCache.- Returns:
- the NamedCache object, which is the back map of this NearCache
- Throws:
IllegalStateException
- if this NamedCache has been released
-
getRegistrationContext
public String getRegistrationContext()
Obtain the context (tier) used to register a CacheMBean for this cache.- Returns:
- the corresponding context string
-
setRegistrationContext
public void setRegistrationContext(String sCtx)
Set the context (tier) used to register a CacheMBean for this cache.- Parameters:
sCtx
- the corresponding context string
-
async
public AsyncNamedCache<K,V> async(AsyncNamedMap.Option... options)
Description copied from interface:NamedCache
Return an asynchronous wrapper for this NamedCache.By default, the order of execution of asynchronous operation invoked on the returned AsyncNamedCache will be preserved by ensuring that all operations invoked from the same client thread are executed on the server sequentially, using the same
unit-of-order
. This tends to provide the best performance for fast, non-blocking operations.However, when invoking CPU-intensive or blocking operations, such as read- or write-through operations that access remote database or web service, for example, it may be very beneficial to allow the server to parallelize execution by passing
AsyncNamedMap.OrderBy.none()
configuration option to this method. Note, that in that case there are no guarantees for the order of execution.
-
getCacheName
public String getCacheName()
Return the cache name.- Specified by:
getCacheName
in interfaceNamedCache<K,V>
- Returns:
- the cache name
-
getCacheService
public CacheService getCacheService()
Return the CacheService that this NamedCache is a part of.- Specified by:
getCacheService
in interfaceNamedCache<K,V>
- Returns:
- the CacheService
-
isActive
public boolean isActive()
Specifies whether or not the NamedCache is active.
-
isReady
public boolean isReady()
Description copied from interface:NamedMap
Returns whether thisNamedMap
is ready to be used. An example of when this method would returnfalse
would be where a partitioned cache service that owns this cache has no storage-enabled members.
-
release
public void release()
Release the CachingMap. If the BackMap implements an ObservableMap calling this method is necessary to remove the BackMap listener. Any access to the CachingMap which has been released will cause IllegalStateException.- Specified by:
release
in interfaceReleasable
- Overrides:
release
in classCachingMap<K,V>
-
destroy
public void destroy()
Release and destroy this instance of NamedCollection.Warning: This method is used to completely destroy the specified collection across the cluster. All references in the entire cluster to this collection will be invalidated, the collection data will be cleared, and all internal resources will be released.
- Specified by:
destroy
in interfaceNamedCollection
-
truncate
public void truncate()
Removes all mappings from this map.Note: the removal of entries caused by this truncate operation will not be observable. This includes any registered
listeners
,triggers
, orinterceptors
. However, aCacheLifecycleEvent
is raised to notify subscribers of the execution of this operation.
-
isDestroyed
public boolean isDestroyed()
Specifies whether or not this NamedCollection has been destroyed. Implementations must override this method to provide the necessary information.- Specified by:
isDestroyed
in interfaceNamedCollection
- Returns:
- true if the NamedCollection has been destroyed; false otherwise
-
isReleased
public boolean isReleased()
Specifies whether or this Releasable has been released. Implementations must override this method to provide the necessary information.- Specified by:
isReleased
in interfaceReleasable
- Returns:
- true if the Releasable has been released; false otherwise
-
addMapListener
public void addMapListener(MapListener<? super K,? super V> listener)
Add a standard map listener. Expensive: Listening always occurs on the back cache.- Specified by:
addMapListener
in interfaceObservableMap<K,V>
- Parameters:
listener
- the MapEvent listener to add
-
removeMapListener
public void removeMapListener(MapListener<? super K,? super V> listener)
Remove a standard map listener.- Specified by:
removeMapListener
in interfaceObservableMap<K,V>
- Parameters:
listener
- the MapEvent listener to remove
-
addMapListener
public void addMapListener(MapListener<? super K,? super V> listener, K oKey, boolean fLite)
Add a map listener for a specific key. Expensive: Listening always occurs on the back cache.- Specified by:
addMapListener
in interfaceObservableMap<K,V>
- Parameters:
listener
- the listener to addoKey
- the key that identifies the entry for which to raise eventsfLite
- true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizations- Since:
- Coherence 2.3
-
removeMapListener
public void removeMapListener(MapListener<? super K,? super V> listener, K oKey)
Remove a map listener that previously signed up for events about a specific key.- Specified by:
removeMapListener
in interfaceObservableMap<K,V>
- Parameters:
listener
- the listener to removeoKey
- the key that identifies the entry for which to raise events- Since:
- Coherence 2.3
-
addMapListener
public void addMapListener(MapListener<? super K,? super V> listener, Filter filter, boolean fLite)
Add a map listener that receives events based on a filter evaluation. Expensive: Listening always occurs on the back cache.- Specified by:
addMapListener
in interfaceObservableMap<K,V>
- Parameters:
listener
- the listener to addfilter
- a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent; null is equivalent to a filter that always returns truefLite
- true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizations- Since:
- Coherence 2.3
-
removeMapListener
public void removeMapListener(MapListener<? super K,? super V> listener, Filter filter)
Remove a map listener that previously signed up for events based on a filter evaluation.- Specified by:
removeMapListener
in interfaceObservableMap<K,V>
- Parameters:
listener
- the listener to removefilter
- a filter used to evaluate events- Since:
- Coherence 2.3
-
put
public V put(K oKey, V oValue, long cMillis)
Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry. If the cache previously contained a mapping for this key, the old value is replaced.- Specified by:
put
in interfaceCacheMap<K,V>
- Specified by:
put
in interfaceNamedCache<K,V>
- Parameters:
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keycMillis
- the number of milliseconds until the cache entry will expire- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
- Throws:
UnsupportedOperationException
- if the requested expiry is a positive value and either the front map or the back map implementations do not support the expiration functionality- See Also:
CacheMap.put(Object oKey, Object oValue, long cMillis)
-
lock
public boolean lock(Object oKey)
Attempt to lock the specified item and return immediately. Expensive: Locking always occurs on the back cache.- Specified by:
lock
in interfaceConcurrentMap<K,V>
- Parameters:
oKey
- key being locked- Returns:
- true if the item was successfully locked; false otherwise
-
lock
public boolean lock(Object oKey, long lMillis)
Attempt to lock the specified item within the specified period of time. Expensive: Locking always occurs on the back cache.- Specified by:
lock
in interfaceConcurrentMap<K,V>
- Parameters:
oKey
- key being lockedlMillis
- the number of milliseconds to continue trying to obtain a lock; pass zero to return immediately; pass -1 to block the calling thread until the lock could be obtained- Returns:
- true if the item was successfully locked within the specified time; false otherwise
-
unlock
public boolean unlock(Object oKey)
Unlock the specified item.- Specified by:
unlock
in interfaceConcurrentMap<K,V>
- Parameters:
oKey
- key being unlocked- Returns:
- true if the item was successfully unlocked; false otherwise
-
keySet
public Set<K> keySet(Filter filter)
Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.Unlike the
Map.keySet()
method, the set returned by this method may not be backed by the map, so changes to the set may not reflected in the map, and vice-versa.Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.
The operation always executes against the back cache.
-
entrySet
public Set<Map.Entry<K,V>> entrySet(Filter filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is aMap.Entry
.Unlike the
Map.entrySet()
method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.
The operation always executes against the back cache.
-
entrySet
public Set<Map.Entry<K,V>> entrySet(Filter filter, Comparator comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is aMap.Entry
. It is further guaranteed that its iterator will traverse the set in such a way that the entry values come up in ascending order, sorted by the specified Comparator or according to the natural ordering (seeComparable
).Unlike the
Map.entrySet()
method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.
The operation always executes against the back cache.
- Specified by:
entrySet
in interfaceQueryMap<K,V>
- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycomparator
- the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used- Returns:
- a set of entries that satisfy the specified criteria
- See Also:
ChainedComparator
-
addIndex
public <T,E> void addIndex(ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
Add an index to this QueryMap. This allows to correlate values stored in this indexed Map (or attributes of those values) to the corresponding keys in the indexed Map and increase the performance of methods that useFilters
.The ordering maintained by this map (as determined by either the specified Comparator or the natural ordering of the indexed values) must be consistent with equals (see
Comparable
orComparator
for a precise definition of consistent with equals.)This method is only intended as a hint to the map implementation, and as such it may be ignored by the map if indexes are not supported or if the desired index (or a similar index) already exists. It is expected that an application will call this method to suggest an index even if the index may already exist, just so that the application is certain that index has been suggested. For example in a distributed environment, each server will likely suggest the same set of indexes when it starts, and there is no downside to the application blindly requesting those indexes regardless of whether another server has already requested the same indexes.
The operation always executes against the back cache.
- Specified by:
addIndex
in interfaceQueryMap<K,V>
- Type Parameters:
T
- the type of the value to extract fromE
- the type of value that will be extracted- Parameters:
extractor
- the ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.fOrdered
- true iff the contents of the indexed information should be ordered; false otherwisecomparator
- the Comparator object which imposes an ordering on entries in the indexed map; or null if the entries' values natural ordering should be used- See Also:
ReflectionExtractor
,ChainedComparator
-
removeIndex
public <T,E> void removeIndex(ValueExtractor<? super T,? extends E> extractor)
Remove an index from this QueryMap.The operation always executes against the back cache.
- Specified by:
removeIndex
in interfaceQueryMap<K,V>
- Type Parameters:
T
- the type of the value to extract fromE
- the type of value that will be extracted- Parameters:
extractor
- the ValueExtractor object that is used to extract an indexable Object from a value stored in the Map.
-
computeIfAbsent
public V computeIfAbsent(K key, Remote.Function<? super K,? extends V> mappingFunction)
Compute the value using the given mapping function and enter it into this map (unlessnull
), if the specified key is not already associated with a value (or is mapped tonull
).If the mapping function returns
null
no mapping is recorded. If the function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded.The most common usage is to construct a new object serving as an initial mapped value or memoized result, as in:
map.computeIfAbsent(key, k -> new Value(f(k)));
Or to implement a multi-value map,
Map<K, Collection<V>>
, supporting multiple values per key:map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);
add
method will be called on the client-side copy of the collection stored on the server.The operation executes against the back cache if the value is not in the front.
- Specified by:
computeIfAbsent
in interfaceInvocableMap<K,V>
- Parameters:
key
- key with which the specified value is to be associatedmappingFunction
- the function to compute a value- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
Note that the previous example will not work as expected if this method is called on a distributed map, as theadd
method will be called on a client-side copy of the collection stored on the server.The operation executes against the back cache if the value is not in the front.
- Specified by:
computeIfAbsent
in interfaceInvocableMap<K,V>
- Specified by:
computeIfAbsent
in interfaceMap<K,V>
-
invoke
public <R> R invoke(K key, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.The operation always executes against the back cache.
- Specified by:
invoke
in interfaceInvocableMap<K,V>
- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
key
- the key to process; it is not required to exist within the Mapprocessor
- the EntryProcessor to use to process the specified key- Returns:
- the result of the invocation as returned from the EntryProcessor
-
invokeAll
public <R> Map<K,R> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.The operation always executes against the back cache.
- Specified by:
invokeAll
in interfaceInvocableMap<K,V>
- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
collKeys
- the keys to process; these keys are not required to exist within the Mapprocessor
- the EntryProcessor to use to process the specified keys- Returns:
- a Map containing the results of invoking the EntryProcessor against each of the specified keys
-
invokeAll
public <R> Map<K,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.Unless specified otherwise, InvocableMap implementations will perform this operation in two steps: (1) use the filter to retrieve a matching entry set; (2) apply the agent to every filtered entry. This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads. If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the
ConditionalProcessor
.The operation always executes against the back cache.
- Specified by:
invokeAll
in interfaceInvocableMap<K,V>
- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
filter
- a Filter that results in the set of keys to be processedprocessor
- the EntryProcessor to use to process the specified keys- Returns:
- a Map containing the results of invoking the EntryProcessor against the keys that are selected by the given Filter
-
aggregate
public <R> R aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation against the entries specified by the passed keys.The operation always executes against the back cache.
- Specified by:
aggregate
in interfaceInvocableMap<K,V>
- Type Parameters:
R
- the type of value returned by the EntryAggregator- Parameters:
collKeys
- the Collection of keys that specify the entries within this Map to aggregate acrossaggregator
- the EntryAggregator that is used to aggregate across the specified entries of this Map- Returns:
- the result of the aggregation
-
aggregate
public <R> R aggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation against the set of entries that are selected by the given Filter.The operation always executes against the back cache.
- Specified by:
aggregate
in interfaceInvocableMap<K,V>
- Type Parameters:
R
- the type of value returned by the EntryAggregator- Parameters:
filter
- the Filter that is used to select entries within this Map to aggregate acrossaggregator
- the EntryAggregator that is used to aggregate across the selected entries of this Map- Returns:
- the result of the aggregation
-
getOrDefault
public V getOrDefault(Object oKey, V defaultValue)
- Specified by:
getOrDefault
in interfaceInvocableMap<K,V>
- Specified by:
getOrDefault
in interfaceMap<K,V>
-
release
protected void release(boolean fDestroy)
Release this cache, optionally destroying it.- Parameters:
fDestroy
- true to destroy the cache as well
-
registerBackServiceListener
protected MemberListener registerBackServiceListener()
Instantiate and register a MemberListener with the back cache service.The primary goal of that listener is invalidation of the front map in case of the service [automatic] restart.
- Returns:
- the instantiated and registered MemberListener object
-
unregisterBackServiceListener
protected void unregisterBackServiceListener()
Unregister back cache service member listener.
-
registerMBean
public void registerMBean()
Register an MBean representing this NearCache.
-
unregisterMBean
protected void unregisterMBean()
Unregister an associated CacheMBean.- Overrides:
unregisterMBean
in classCachingMap<K,V>
-
getContextClassLoader
public ClassLoader getContextClassLoader()
Retrieve the context ClassLoader for this object. The context ClassLoader is provided by the creator of the object for use by the object when loading classes and resources.- Specified by:
getContextClassLoader
in interfaceClassLoaderAware
- Returns:
- the context ClassLoader for this object
- See Also:
Thread.getContextClassLoader()
-
setContextClassLoader
public void setContextClassLoader(ClassLoader loader)
Specify the context ClassLoader for this object. The context ClassLoader can be set when the object is created, and allows the creator to provide the appropriate class loader to be used by the object when when loading classes and resources.- Specified by:
setContextClassLoader
in interfaceClassLoaderAware
- Parameters:
loader
- the context ClassLoader for this object
-
-