Class WrapperNamedCache<K,V>
- java.lang.Object
- 
- com.tangosol.util.Base
- 
- com.tangosol.util.AbstractKeyBasedMap<K,V>
- 
- com.tangosol.util.AbstractKeySetBasedMap<K,V>
- 
- com.tangosol.util.WrapperObservableMap<K,V>
- 
- com.tangosol.util.WrapperConcurrentMap<K,V>
- 
- com.tangosol.net.cache.WrapperNamedCache<K,V>
 
 
 
 
 
 
- 
- Type Parameters:
- K- the type of the cache entry keys
- V- the type of the cache entry values
 - All Implemented Interfaces:
- 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:
- BundlingNamedCache,- ReadonlyNamedCache
 
 public class WrapperNamedCache<K,V> extends WrapperConcurrentMap<K,V> implements NamedCache<K,V> A simple implementation of NamedCache interface built as a wrapper around any Map implementation.- Author:
- cp 2003.05.19
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.tangosol.util.WrapperConcurrentMapWrapperConcurrentMap.Lock
 - 
Nested classes/interfaces inherited from class com.tangosol.util.WrapperObservableMapWrapperObservableMap.InternalListener
 - 
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMapAbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection
 - 
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeyBasedMapAbstractKeyBasedMap.DeferredCacheEvent<K,V>
 - 
Nested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
 - 
Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMapInvocableMap.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.MapMap.Entry<K extends Object,V extends Object>
 - 
Nested classes/interfaces inherited from interface com.tangosol.net.NamedMapNamedMap.Option
 - 
Nested classes/interfaces inherited from interface com.tangosol.util.QueryMapQueryMap.Entry<K,V>
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected CacheServicem_serviceThe CacheService this NamedCache is a part of.protected Stringm_sNameThe name of the cache.- 
Fields inherited from class com.tangosol.util.WrapperConcurrentMapm_cWaitMillis, m_fEnforceLocking, m_gateMap, m_mapLock
 - 
Fields inherited from class com.tangosol.util.WrapperObservableMapm_fDeferredEvent, m_fTranslateEvents, m_listenerInternal, m_listenerSupport, m_map, m_stats
 - 
Fields inherited from class com.tangosol.util.BaseDEFAULT_LOAD_FACTOR, LOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
 - 
Fields inherited from interface com.tangosol.net.cache.CacheMapEXPIRY_DEFAULT, EXPIRY_NEVER
 - 
Fields inherited from interface com.tangosol.util.ConcurrentMapLOCK_ALL
 
- 
 - 
Constructor SummaryConstructors Constructor Description WrapperNamedCache(String sName)Construct a NamedCache wrapper for an empty HashMap.WrapperNamedCache(Map<K,V> map, String sName)Construct a NamedCache wrapper based on the specified map.WrapperNamedCache(Map<K,V> map, String sName, CacheService service)Construct a NamedCache wrapper based on the specified map.
 - 
Method SummaryAll 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.<R> Raggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V,R> agent)Perform an aggregating operation against the set of entries that are selected by the given Filter.<R> Raggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> agent)Perform an aggregating operation against the entries specified by the passed keys.voiddestroy()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.Map<K,V>getAll(Collection<? extends K> colKeys)Get all the specified keys, if they are in the Map.StringgetCacheName()Return the cache name.CacheServicegetCacheService()Return the CacheService that this NamedCache is a part of.<R> Rinvoke(K key, InvocableMap.EntryProcessor<K,V,R> agent)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> agent)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> agent)Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.booleanisActive()Returnstrueif this map is not released or destroyed.booleanisDestroyed()Specifies whether or not this NamedCollection has been destroyed.booleanisReady()Returns whether thisNamedMapis ready to be used.booleanisReleased()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.Vput(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.voidrelease()Release local resources associated with this Releasable instance.<T,E>
 voidremoveIndex(ValueExtractor<? super T,? extends E> extractor)Remove an index from this QueryMap.voidtruncate()Removes all mappings from this map.- 
Methods inherited from class com.tangosol.util.WrapperConcurrentMapclear, getDescription, getLockDescription, getWaitMillis, instantiateLock, isInternalKeySetIteratorMutable, isLockingEnforced, lock, lock, put, putAll, remove, removeBlind, setLockingEnforced, setWaitMillis, toString, unlock
 - 
Methods inherited from class com.tangosol.util.WrapperObservableMapaddMapListener, addMapListener, addMapListener, containsValue, dispatchEvent, dispatchPendingEvent, ensureInternalListener, ensureMapListenerSupport, equals, get, getCacheStatistics, getInternalKeySet, getMap, getMapListenerSupport, hashCode, hasListeners, instantiateInternalListener, isCollectStats, isEventFabricator, isSynthetic, isTranslateEvents, removeMapListener, removeMapListener, removeMapListener, setCollectStats, setTranslateEvents
 - 
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMapcontainsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, size
 - 
Methods inherited from class com.tangosol.util.AbstractKeyBasedMapclone, entrySet, keySet, values
 - 
Methods inherited from class com.tangosol.util.Baseazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
 - 
Methods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface com.tangosol.util.ConcurrentMapcontainsKey, containsValue, get, isEmpty, lock, lock, put, putAll, remove, size, unlock
 - 
Methods inherited from interface com.tangosol.util.InvocableMapaggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invokeAll, merge, merge, putIfAbsent, remove, replace, replace, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
 - 
Methods inherited from interface com.tangosol.net.NamedMapclear, getName, getService
 - 
Methods inherited from interface com.tangosol.util.ObservableMapaddMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener
 - 
Methods inherited from interface com.tangosol.util.QueryMapaddIndex, forEach, forEach, values, values
 - 
Methods inherited from interface com.tangosol.net.Releasableclose
 
- 
 
- 
- 
- 
Field Detail- 
m_sNameprotected String m_sName The name of the cache.
 - 
m_serviceprotected CacheService m_service The CacheService this NamedCache is a part of.
 
- 
 - 
Constructor Detail- 
WrapperNamedCachepublic WrapperNamedCache(String sName) Construct a NamedCache wrapper for an empty HashMap.- Parameters:
- sName- the cache name
 
 - 
WrapperNamedCachepublic WrapperNamedCache(Map<K,V> map, String sName) Construct a NamedCache wrapper based on the specified map.Note: it is assumed that while the WrapperNamedCache exists, there is no direct manipulation with the content of the wrapped map. - Parameters:
- map- the Map that will be wrapped by this WrapperNamedCache
- sName- the cache name
 
 - 
WrapperNamedCachepublic WrapperNamedCache(Map<K,V> map, String sName, CacheService service) Construct a NamedCache wrapper based on the specified map.Note: it is assumed that while the WrapperNamedCache exists, there is no direct manipulation with the content of the wrapped map. - Parameters:
- map- the Map that will be wrapped by this WrapperNamedCache
- sName- the cache name (could be null if the map is a NamedCache)
- service- the cache service this NamedCache is a part of (ignored if the map is a NamedCache)
 
 
- 
 - 
Method Detail- 
getCacheNamepublic String getCacheName() Return the cache name.- Specified by:
- getCacheNamein interface- NamedCache<K,V>
- Returns:
- the cache name
 
 - 
getCacheServicepublic CacheService getCacheService() Return the CacheService that this NamedCache is a part of.- Specified by:
- getCacheServicein interface- NamedCache<K,V>
- Returns:
- the CacheService
 
 - 
isActivepublic boolean isActive() Returnstrueif this map is not released or destroyed. In other words, callingisActive()is equivalent to calling!cache.isReleased() && !cache.isDestroyed().
 - 
isReadypublic boolean isReady() Description copied from interface:NamedMapReturns whether thisNamedMapis ready to be used. An example of when this method would returnfalsewould be where a partitioned cache service that owns this cache has no storage-enabled members.
 - 
releasepublic void release() Release local resources associated with this Releasable instance.- Specified by:
- releasein interface- Releasable
 
 - 
destroypublic 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:
- destroyin interface- NamedCollection
 
 - 
truncatepublic 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, aCacheLifecycleEventis raised to notify subscribers of the execution of this operation.
 - 
isDestroyedpublic boolean isDestroyed() Specifies whether or not this NamedCollection has been destroyed. Implementations must override this method to provide the necessary information.- Specified by:
- isDestroyedin interface- NamedCollection
- Returns:
- true if the NamedCollection has been destroyed; false otherwise
 
 - 
isReleasedpublic boolean isReleased() Specifies whether or this Releasable has been released. Implementations must override this method to provide the necessary information.- Specified by:
- isReleasedin interface- Releasable
- Returns:
- true if the Releasable has been released; false otherwise
 
 - 
getAllpublic Map<K,V> getAll(Collection<? extends K> colKeys) Get all the specified keys, if they are in the Map. For each key that is in the cache, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the cache, which may imply (for caches that can load behind the scenes) that the requested data could not be loaded.
 - 
putpublic 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.Note: Though NamedCache interface extends CacheMap, not all implementations currently support this functionality.For example, if a cache is configured to be a replicated, optimistic or distributed cache then its backing map must be configured as a local cache. If a cache is configured to be a near cache then the front map must to be configured as a local cache and the back map must support this feature as well, typically by being a distributed cache backed by a local cache (as above.) - Specified by:
- putin interface- CacheMap<K,V>
- Specified by:
- putin interface- NamedCache<K,V>
- Parameters:
- oKey- key with which the specified value is to be associated
- oValue- value to be associated with the specified key
- cMillis- the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass- CacheMap.EXPIRY_DEFAULTto use the cache's default time-to-live setting; pass- CacheMap.EXPIRY_NEVERto indicate that the cache entry should never expire; this milliseconds value is not a date/time value, such as is returned from System.currentTimeMillis()
- 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
 
 - 
keySetpublic 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. 
 - 
entrySetpublic 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. 
 - 
entrySetpublic 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. - Specified by:
- entrySetin interface- QueryMap<K,V>
- Parameters:
- filter- the Filter object representing the criteria that the entries of this map should satisfy
- comparator- 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
 
 - 
addIndexpublic <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 ComparableorComparatorfor 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. - Specified by:
- addIndexin interface- QueryMap<K,V>
- Type Parameters:
- T- the type of the value to extract from
- E- 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 otherwise
- comparator- 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
 
 - 
removeIndexpublic <T,E> void removeIndex(ValueExtractor<? super T,? extends E> extractor) Remove an index from this QueryMap.- Specified by:
- removeIndexin interface- QueryMap<K,V>
- Type Parameters:
- T- the type of the value to extract from
- E- 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.
 
 - 
invokepublic <R> R invoke(K key, InvocableMap.EntryProcessor<K,V,R> agent) Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.- Specified by:
- invokein interface- InvocableMap<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 Map
- agent- the EntryProcessor to use to process the specified key
- Returns:
- the result of the invocation as returned from the EntryProcessor
 
 - 
invokeAllpublic <R> Map<K,R> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> agent) Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.- Specified by:
- invokeAllin interface- InvocableMap<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 Map
- agent- 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
 
 - 
invokeAllpublic <R> Map<K,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<K,V,R> agent) 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.- Specified by:
- invokeAllin interface- InvocableMap<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 processed
- agent- 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
 
 - 
aggregatepublic <R> R aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> agent) Perform an aggregating operation against the entries specified by the passed keys.- Specified by:
- aggregatein interface- InvocableMap<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 across
- agent- the EntryAggregator that is used to aggregate across the specified entries of this Map
- Returns:
- the result of the aggregation
 
 - 
aggregatepublic <R> R aggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V,R> agent) Perform an aggregating operation against the set of entries that are selected by the given Filter.- Specified by:
- aggregatein interface- InvocableMap<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 across
- agent- the EntryAggregator that is used to aggregate across the selected entries of this Map
- Returns:
- the result of the aggregation
 
 
- 
 
-