Class ContinuousQueryCache<K,V_BACK,V_FRONT>
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.AbstractKeyBasedMap<K,V>
-
- com.tangosol.util.AbstractKeySetBasedMap<K,V_FRONT>
-
- com.tangosol.net.cache.ContinuousQueryCache<K,V_BACK,V_FRONT>
-
- Type Parameters:
K- the type of the cache entry keysV_BACK- the type of the entry values in the back cache that is used as the source for thisContinuousQueryCacheV_FRONT- the type of the entry values in thisContinuousQueryCache, which will be the same asV_BACK, unless atransformeris specified when creating thisContinuousQueryCache
- All Implemented Interfaces:
CacheMap<K,V_FRONT>,NamedCache<K,V_FRONT>,NamedCollection,NamedMap<K,V_FRONT>,Releasable,ConcurrentMap<K,V_FRONT>,InvocableMap<K,V_FRONT>,ObservableMap<K,V_FRONT>,QueryMap<K,V_FRONT>,AutoCloseable,Map<K,V_FRONT>
public class ContinuousQueryCache<K,V_BACK,V_FRONT> extends AbstractKeySetBasedMap<K,V_FRONT> implements NamedCache<K,V_FRONT>
Create a materialized view of aNamedCacheusing theCoherenceContinuous Query capability.In addition to providing an up-to-date view of the backing
NamedCache, this class supports server-side transformation of cache values. For example, you could create a client-side view of a cache containingPortfolioinstances that only contains the value of each portfolio:NamedCache<String, Portfolio> cache = CacheFactory.getTypedCache("portfolio", TypeAssertion.withoutTypeChecking()); NamedCache<String, Double> cqc = new ContinuousQueryCache<>(cache, AlwaysFilter.INSTANCE, Portfolio::getValue);- Since:
- Coherence 3.1
- Author:
- cp 2006.01.19
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classContinuousQueryCache.AddListenerAMapListenerfor adding items to theContinuousQueryCache.protected classContinuousQueryCache.ConverterAsynchronousProcessorWraps anAsynchronousProcessorto ensure the result of the EntryProcessor execution is deserialized prior to passing to the provided AsynchronousProcessor.protected classContinuousQueryCache.DeactivationListenerDeactivationListener for the underlying NamedCache.protected classContinuousQueryCache.EventRouter<K,V>An EventRouter routes events from the internal cache of theContinuousQueryCacheto the client listeners, and it can do so asynchronously when appropriate.protected classContinuousQueryCache.InternalMapListenerThis listener allows interception of all events triggered by the the internalObservableMapof theContinuousQueryCache.classContinuousQueryCache.RemoveListenerAMapListenerfor evicting items from theContinuousQueryCache.protected classContinuousQueryCache.ServiceListenerMemberListenerfor the underlying cache's service.-
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap
AbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection
-
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeyBasedMap
AbstractKeyBasedMap.DeferredCacheEvent<K,V>
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
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 Converterm_converterFromBinaryprotected Converterm_converterToBinaryprotected longm_cReconnectMillisThe interval (in milliseconds) that indicates how often theContinuousQueryCacheshould attempt to synchronize its content with the underlying cache in case the connection is severed.protected TaskDaemonm_eventQueueThe event queue for thisContinuousQueryCache.protected booleanm_fCacheValuesThe option of whether or not to locally cache values.protected Filterm_filterThe filter that represents the subset of information from the underlyingNamedCachethat thisContinuousQueryCacherepresents.protected MapEventFilterm_filterAddTheMapEventFilterthat uses theContinuousQueryCache'sfilter to select events that would add elements to this cache's contents.protected MapEventFilterm_filterRemoveTheMapEventFilterthat uses theContinuousQueryCache'sfilter to select events that would remove elements from this cache's contents.protected booleanm_fListenersKeeps track of whether theContinuousQueryCachehas listeners that require this cache to cache values.protected booleanm_fReadOnlyThe option to disallow modifications through thisContinuousQueryCacheinterface.protected longm_ldtConnectionTimestampThe timestamp when the synchronization was last attempted.protected MapListener<K,V_FRONT>m_listenerAddThelistenerthat gets information about what should be in this cache.protected com.tangosol.internal.net.NamedCacheDeactivationListenerm_listenerDeactivationTheNamedCacheDeactivationListener.protected MapListener<K,V_FRONT>m_listenerRemoveThelistenerthat gets information about what should be thrown out of this cache.protected MemberListenerm_listenerServiceThe cache serviceMemberListenerfor the underlyingNamedCache.protected MapListenerSupportm_listenerSupportLocallistener supportto allow theContinuousQueryCacheto intercept all events dispatched by the internalObservableMap.protected ClassLoaderm_loaderTheClassLoaderto use when de-serializing/serializing keys and values.protected Mapm_mapIndexThe map of indexes maintained by this cache.protected MapListener<? super K,? super V_FRONT>m_mapListenerThe optionalMapListenerthat may be provided duringContinuousQueryCacheconstruction.protected ObservableMap<K,V_FRONT>m_mapLocalThe keys that are in thisContinuousQueryCache, and (ifm_fCacheValuesis true) the corresponding values as well.protected Mapm_mapSyncReqWhile theContinuousQueryCacheis configuring or re-configuring its listeners and content, any events that are received must be logged to ensure that the corresponding content is in sync.protected Integerm_nStateState of theContinuousQueryCache.protected Stringm_sNameThe name of the underlyingNamedCache.protected ValueExtractor<? super V_BACK,? extends V_FRONT>m_transformerThe transformer that should be used to convert values from the underlying cache.static intSTATE_CONFIGUREDState: TheContinuousQueryCachehas been configured.static intSTATE_CONFIGURINGState: TheContinuousQueryCacheis configuring or re-configuring its listeners and content.static intSTATE_DISCONNECTEDState: Disconnected state.static intSTATE_SYNCHRONIZEDState: TheContinuousQueryCachehas been configured and fully synchronized.-
Fields inherited from class com.tangosol.util.Base
DEFAULT_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.CacheMap
EXPIRY_DEFAULT, EXPIRY_NEVER
-
Fields inherited from interface com.tangosol.util.ConcurrentMap
LOCK_ALL
-
-
Constructor Summary
Constructors Constructor Description ContinuousQueryCache(NamedCache<K,V_BACK> cache)Create a locally materialized view of aNamedCacheusing aFilter.ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter)Create a locally materialized view of aNamedCacheusing a Filter.ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, boolean fCacheValues)Create a materialized view of aNamedCacheusing a Filter.ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, boolean fCacheValues, MapListener<? super K,? super V_FRONT> listener, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)Construct the ContinuousQueryCache.ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, MapListener<? super K,? super V_FRONT> listener)Create a materialized view of aNamedCacheusing a Filter.ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, MapListener<? super K,? super V_FRONT> listener, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)Create a materialized view of aNamedCacheusing aFilter.ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)Create a locally materialized view of aNamedCacheusing aFilterand a transformer.ContinuousQueryCache(Supplier<NamedCache<K,V_BACK>> supplierCache)Create a locally materialized view of aNamedCacheusing aFilter.ContinuousQueryCache(Supplier<NamedCache<K,V_BACK>> supplierCache, Filter filter)Create a locally materialized view of aNamedCacheusing aFilter.ContinuousQueryCache(Supplier<NamedCache<K,V_BACK>> supplierCache, Filter filter, boolean fCacheValues, MapListener<? super K,? super V_FRONT> listener, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer, ClassLoader loader)Create a materialized view of aNamedCacheusing aFilter.
-
Method Summary
All Methods Static 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)IfisCacheValues()istrue, the index will be created locally as well as on theNamedCachethisContinuousQueryCachewraps, otherwise, the index will be created on the wrappedNamedCacheonly.voidaddMapListener(MapListener<? super K,? super V_FRONT> listener)Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included.voidaddMapListener(MapListener<? super K,? super V_FRONT> listener, Filter filter, boolean fLite)Add a map listener that receives events based on a filter evaluation.voidaddMapListener(MapListener<? super K,? super V_FRONT> listener, K oKey, boolean fLite)Add a map listener for a specific key.<R> Raggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V_FRONT,R> aggregator)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_FRONT,R> aggregator)Perform an aggregating operation against the entries specified by the passed keys.AsyncNamedCache<K,V_FRONT>async(AsyncNamedMap.Option... options)Return an asynchronous wrapper for this NamedCache.protected voidchangeState(int nState)Change the state of theContinuousQueryCache.protected voidcheckEntry(Object oKey, Object oValue)Check the passed value to verify that it does belong in this ContinuousQueryCache.protected voidcheckEntry(Map.Entry entry)Check the passed value to verify that it does belong in this ContinuousQueryCache.protected voidcheckReadOnly()Check the read-only setting to verify that the cache is NOT read-only.voidclear()Clear all key/value mappings.protected voidconfigureSynchronization(boolean fReload)Set up the listeners that keep theContinuousQueryCacheup-to-date.protected FiltercreateTransformerFilter(MapEventFilter filterAdd)Wrap specifiedMapEventFilterwith aMapEventTransformerFilterthat will either transform cache value using transformer defined for thisContinuousQueryCache, or remove the old value from the event usingSemiLiteEventTransformer, if no transformer is defined for thisContinuousQueryCache.protected RuntimeExceptioncreateUnexpectedStateException(int nExpectedState, int nActualState)Simple helper to create an exception for communicating invalid state transitions.voiddestroy()Release and destroy this instance of NamedCollection.protected InvocableMap.EntryProcessorensureConverted(InvocableMap.EntryProcessor processor)Wrap anyAsynchronousProcessorinstances with a custom wrapper to perform conversion of result returned by the processor.protected NamedCacheensureConverters(NamedCache cache)Instantiate theconvertersnecessary to support the processing mode that thisContinuousQueryCachewill be operating under.protected TaskDaemonensureEventQueue()Obtain the existing event queue or create one if none exists.protected MapensureIndexMap()Ensure that the map of indexes maintained by this cache exists.protected V_FRONTensureInflated(Object oKey, Object oValue)If the internal cache value associated with the provided key isBinary, deserialize the value and store it back to the internal cache in its deserialized form.protected ObservableMap<K,V_FRONT>ensureInternalCache()Create and initialize thisContinuousQueryCache's (if not already present) internal cache.protected MapListenerSupportensureListenerSupport()Configure the localMapListenerSupportand register the interceptingMapListenerwith the internalObservableMap.protected voidensureSynchronized(boolean fReload)Ensure that theContinuousQueryCachelisteners have been registered and its content synchronized with the underlyingNamedCache.Set<Map.Entry<K,V_FRONT>>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_FRONT>>entrySet(Filter filter, Comparator comparator)Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.protected Set<Map.Entry<K,V_FRONT>>entrySetInternal(Filter filter)Return multiple values from the back cache based on a filter, transforming them in the process if necessary.protected Set<Map.Entry<K,V_FRONT>>entrySetInternal(Filter filter, Comparator comparator)Return multiple values from the back cache based on a filter, transforming them in the process if necessary.protected <T> TfromInternal(Object binValue)Deserialize the providedBinaryvalue.V_FRONTget(Object oKey)Returns the value to which this map maps the specified key.Map<K,V_FRONT>getAll(Collection<? extends K> colKeys)Get all the specified keys, if they are in the Map.protected Map<K,V_FRONT>getAllInternal(Collection<? extends K> colKeys)Return multiple values from the back cache, transforming them in the process if necessary.NamedCache<K,V_BACK>getCache()Obtain theNamedCachethat thisContinuousQueryCacheis based on.StringgetCacheName()Return the cache name.CacheServicegetCacheService()Return the CacheService that this NamedCache is a part of.protected static StringgetDefaultName(String sCacheName, Filter filter, ValueExtractor transformer)Return the default name used by the CQC.protected TaskDaemongetEventQueue()Obtain thisContinuousQueryCache's event queue.FiltergetFilter()protected MapgetIndexMap()Get the map of indexes maintained by this cache.protected V_FRONTgetInternal(Object oKey)Return the value from the back cache, transforming it in the process if necessary.protected ObservableMap<K,V_FRONT>getInternalCache()Obtain a reference to the internal cache.protected Set<K>getInternalKeySet()Obtain a set of keys that are represented by this Map.MapListener<? super K,? super V_FRONT>getMapListener()Obtain the configuredMapListenerfor thisContinuousQueryCache.longgetReconnectInterval()Return the reconnection interval (in milliseconds).intgetState()Obtain the state of theContinuousQueryCache.protected StringgetStateString(int nState)Return a String description of the providedSTATE_*variables.ValueExtractor<? super V_BACK,? extends V_FRONT>getTransformer()Obtain the transformer that thisContinuousQueryCacheis using to transform the results from the underlying cache prior to storing them locally.protected MapListener<K,V_FRONT>instantiateAddListener()Factory Method: Instantiate aMapListenerfor adding items to theContinuousQueryCache, and (if there are listeners on theContinuousQueryCache) for dispatching inserts and updates.protected Map<K,V_FRONT>instantiateConverterMap(Map<K,V_FRONT> map)Provides out-bound conversion (i.e. conversion to values clients expect) of internal values.protected TaskDaemoninstantiateEventQueue()Create a self-processing event queue.protected ContinuousQueryCache.EventRouter<K,V_FRONT>instantiateEventRouter(MapListener<? super K,? super V_FRONT> listener, boolean fLite)Factory Method: Instantiate a listener on the internal map that will direct events to the passed listener, either synchronously or asynchronously as appropriate.protected ObservableMap<K,V_FRONT>instantiateInternalCache()Create the internal cache used by theContinuousQueryCache.protected MapListener<K,V_FRONT>instantiateRemoveListener()Factory Method: Instantiate aMapListenerfor evicting items from theContinuousQueryCache.protected SerializerinstantiateSerializer()Create aSerializerappropriate for the mode this cache is operating under (i.e., binary vs non-binary).<R> Rinvoke(K key, InvocableMap.EntryProcessor<K,V_FRONT,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_FRONT,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_FRONT,R> processor)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.protected booleanisBinaryNamedCache()Returntrueif the current back cache is configured to useBinaryvalues.protected booleanisBinaryNamedCache(NamedCache cache)Returnstrueif provided cache is configured to use theNullImplementation classloaderwhich means the values to/from from the cache will beBinary.booleanisCacheValues()Determine if thisContinuousQueryCachecaches values locally.booleanisDestroyed()Specifies whether or not this NamedCollection has been destroyed.protected booleanisEventDeferred(Object oKey)Called when an event has occurred.protected booleanisObserved()Determine if theContinuousQueryCachehas any listeners that cannot be served by this Map listening to lite events.booleanisReadOnly()Determine if thisContinuousQueryCachedisallows data modification operations.booleanisReady()Returns whether thisNamedMapis ready to be used.booleanisReleased()Specifies whether or this Releasable has been released.booleanisTransformed()Determine if thisContinuousQueryCachetransforms values.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.booleanlock(Object oKey)Attempt to lock the specified item and return immediately.booleanlock(Object oKey, long cWait)Attempt to lock the specified item within the specified period of time.protected FiltermergeFilter(Filter filter)V_FRONTput(K oKey, V_FRONT oValue)Associates the specified value with the specified key in this map.V_FRONTput(K oKey, V_FRONT oValue, long cMillis)Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry.voidputAll(Map<? extends K,? extends V_FRONT> map)Copies all of the mappings from the specified map to this map.protected voidregisterDeactivationListener()Instantiate and register aNamedCacheDeactivationListenerwith the underlying cache service.protected voidregisterServiceListener()Instantiate and register aMemberListenerwith the underlying cache service.voidrelease()Release local resources associated with this Releasable instance.protected voidreleaseIndexMap()Release the the entire index map.protected voidreleaseListeners()Release thelisteners.V_FRONTremove(Object oKey)Removes the mapping for this key from this map if present.protected booleanremoveBlind(Object oKey)Removes the mapping for this key from this map if present.<T,E>
voidremoveIndex(ValueExtractor<? super T,? extends E> extractor)IfisCacheValues()istrue, the index will be removed locally, however, this call will not cause the index on theNamedCachethisContinuousQueryCachewraps.voidremoveMapListener(MapListener<? super K,? super V_FRONT> listener)Remove a standard map listener that previously signed up for all events.voidremoveMapListener(MapListener<? super K,? super V_FRONT> listener, Filter filter)Remove a map listener that previously signed up for events based on a filter evaluation.voidremoveMapListener(MapListener<? super K,? super V_FRONT> listener, K oKey)Remove a map listener that previously signed up for events about a specific key.protected voidresetCacheRefs()Reset cache references to null.voidsetCacheName(String sCacheName)Set the cache name for thisContinuousQueryCacheas returned bygetCacheName().voidsetCacheValues(boolean fCacheValues)Modify the local-caching option for theContinuousQueryCache.protected voidsetObserved(boolean fObserved)Specify whether theContinuousQueryCachehas any listeners that cannot be served by this Map listening to lite events.voidsetReadOnly(boolean fReadOnly)Modify the read-only option for theContinuousQueryCache.voidsetReconnectInterval(long cReconnectMillis)Specify the reconnection interval (in milliseconds).protected voidshutdownEventQueue()Shut down running event queue.protected BinarytoInternal(Object oValue)Serialize the provided value into aBinary.protected Map<K,V_FRONT>transform(Set<Map.Entry<K,V_BACK>> setIn, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)Transform a set of entries.voidtruncate()Removes all mappings from this map.booleanunlock(Object oKey)Unlock the specified item.protected voidunregisterDeactivationListener()Unregister underlying cache service member listener.protected voidunregisterServiceListener()Unregister underlying cache servicemember listener.-
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap
containsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, isInternalKeySetIteratorMutable, iterateKeys, size
-
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap
clone, containsValue, entrySet, equals, hashCode, keySet, toString, values
-
Methods inherited from class com.tangosol.util.Base
azzert, 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.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tangosol.util.ConcurrentMap
containsKey, containsValue, isEmpty, size
-
Methods inherited from interface com.tangosol.util.InvocableMap
aggregate, 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.NamedCache
as, async, forEach, view
-
Methods inherited from interface com.tangosol.net.NamedMap
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
-
STATE_DISCONNECTED
public static final int STATE_DISCONNECTED
State: Disconnected state. The content of theContinuousQueryCacheis not fully synchronized with the underlying [clustered] cache. If the value of the ReconnectInterval property is zero, it must be configured (synchronized) before it can be used.- Since:
- Coherence 3.4
- See Also:
- Constant Field Values
-
STATE_CONFIGURING
public static final int STATE_CONFIGURING
State: TheContinuousQueryCacheis configuring or re-configuring its listeners and content.- See Also:
- Constant Field Values
-
STATE_CONFIGURED
public static final int STATE_CONFIGURED
State: TheContinuousQueryCachehas been configured.- See Also:
- Constant Field Values
-
STATE_SYNCHRONIZED
public static final int STATE_SYNCHRONIZED
State: TheContinuousQueryCachehas been configured and fully synchronized.- See Also:
- Constant Field Values
-
m_sName
protected String m_sName
The name of the underlyingNamedCache. A copy is kept here because the reference to the underlyingNamedCacheis discarded when this cache is released.
-
m_filter
protected Filter m_filter
The filter that represents the subset of information from the underlyingNamedCachethat thisContinuousQueryCacherepresents.
-
m_fCacheValues
protected boolean m_fCacheValues
The option of whether or not to locally cache values.
-
m_transformer
protected ValueExtractor<? super V_BACK,? extends V_FRONT> m_transformer
The transformer that should be used to convert values from the underlying cache.
-
m_fReadOnly
protected boolean m_fReadOnly
The option to disallow modifications through thisContinuousQueryCacheinterface.
-
m_cReconnectMillis
protected long m_cReconnectMillis
The interval (in milliseconds) that indicates how often theContinuousQueryCacheshould attempt to synchronize its content with the underlying cache in case the connection is severed.
-
m_ldtConnectionTimestamp
protected volatile long m_ldtConnectionTimestamp
The timestamp when the synchronization was last attempted.
-
m_mapLocal
protected ObservableMap<K,V_FRONT> m_mapLocal
The keys that are in thisContinuousQueryCache, and (ifm_fCacheValuesis true) the corresponding values as well.
-
m_nState
protected volatile Integer m_nState
State of theContinuousQueryCache. One of theSTATE_*enums.
-
m_mapSyncReq
protected volatile Map m_mapSyncReq
While theContinuousQueryCacheis configuring or re-configuring its listeners and content, any events that are received must be logged to ensure that the corresponding content is in sync.
-
m_eventQueue
protected volatile TaskDaemon m_eventQueue
The event queue for thisContinuousQueryCache.
-
m_fListeners
protected boolean m_fListeners
Keeps track of whether theContinuousQueryCachehas listeners that require this cache to cache values.
-
m_filterAdd
protected MapEventFilter m_filterAdd
TheMapEventFilterthat uses theContinuousQueryCache'sfilter to select events that would add elements to this cache's contents.
-
m_filterRemove
protected MapEventFilter m_filterRemove
TheMapEventFilterthat uses theContinuousQueryCache'sfilter to select events that would remove elements from this cache's contents.
-
m_listenerAdd
protected MapListener<K,V_FRONT> m_listenerAdd
Thelistenerthat gets information about what should be in this cache.
-
m_listenerRemove
protected MapListener<K,V_FRONT> m_listenerRemove
Thelistenerthat gets information about what should be thrown out of this cache.
-
m_listenerService
protected MemberListener m_listenerService
The cache serviceMemberListenerfor the underlyingNamedCache.
-
m_mapIndex
protected Map m_mapIndex
The map of indexes maintained by this cache. The keys of the Map areValueExtractorobjects, and for each key, the corresponding value stored in the Map is a MapIndex object.
-
m_listenerDeactivation
protected com.tangosol.internal.net.NamedCacheDeactivationListener m_listenerDeactivation
TheNamedCacheDeactivationListener.- Since:
- 12.2.1.4
-
m_mapListener
protected MapListener<? super K,? super V_FRONT> m_mapListener
The optionalMapListenerthat may be provided duringContinuousQueryCacheconstruction.- Since:
- 12.2.1.4
-
m_converterFromBinary
protected Converter m_converterFromBinary
- Since:
- 12.2.1.4
-
m_converterToBinary
protected Converter m_converterToBinary
- Since:
- 12.2.1.4
-
m_loader
protected ClassLoader m_loader
TheClassLoaderto use when de-serializing/serializing keys and values.- Since:
- 12.2.1.4
-
m_listenerSupport
protected MapListenerSupport m_listenerSupport
Locallistener supportto allow theContinuousQueryCacheto intercept all events dispatched by the internalObservableMap.- Since:
- 12.2.1.4
-
-
Constructor Detail
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache)
Create a locally materialized view of aNamedCacheusing aFilter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a
ContinuousQueryCachethat caches both its keys and values locally.- Parameters:
cache- theNamedCachewith which the view will be created- Since:
- 12.2.1.4
-
ContinuousQueryCache
public ContinuousQueryCache(Supplier<NamedCache<K,V_BACK>> supplierCache)
Create a locally materialized view of aNamedCacheusing aFilter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a
ContinuousQueryCachethat caches both its keys and values locally.- Parameters:
supplierCache- aSupplierthat returns aNamedCachewith which theContinuousQueryCachewill be created The Supplier must return a new instance each timeSupplier.get()is called- Since:
- 12.2.1.4
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter)
Create a locally materialized view of aNamedCacheusing a Filter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a
ContinuousQueryCachethat caches both its keys and values locally.- Parameters:
cache- theNamedCacheto create a view offilter- the filter that defines the view
-
ContinuousQueryCache
public ContinuousQueryCache(Supplier<NamedCache<K,V_BACK>> supplierCache, Filter filter)
Create a locally materialized view of aNamedCacheusing aFilter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a
ContinuousQueryCachethat caches both its keys and values locally.- Parameters:
supplierCache- aSupplierthat returns aNamedCachewith which theContinuousQueryCachewill be created The Supplier must return a new instance each timeSupplier.get()is calledfilter- theFilterthat defines the view- Since:
- 12.2.1.4
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)
Create a locally materialized view of aNamedCacheusing aFilterand a transformer. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a read-only ContinuousQueryCache that caches both its keys and transformed values locally.
- Parameters:
cache- theNamedCacheto create a view offilter- theFilterthat defines the viewtransformer- theValueExtractorthat should be used to transform values retrieved from the underlyingNamedCachebefore storing them locally
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, boolean fCacheValues)
Create a materialized view of aNamedCacheusing a Filter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.- Parameters:
cache- theNamedCacheto create a view offilter- theFilterthat defines the viewfCacheValues- passtrueto cache both the keys and values of the materialized view locally, orfalseto only cache the keys
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, MapListener<? super K,? super V_FRONT> listener)
Create a materialized view of aNamedCacheusing a Filter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI. This constructor allows a client to receive all events, including those that result from the initial population of theContinuousQueryCache. In other words, all contents of theContinuousQueryCachewill be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.- Parameters:
cache- theNamedCacheto create a view offilter- theFilterthat defines the viewlistener- aMapListenerthat will receive all the events from theContinuousQueryCache, including those corresponding to its initial population
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, MapListener<? super K,? super V_FRONT> listener, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)
Create a materialized view of aNamedCacheusing aFilter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a read-only
ContinuousQueryCachethat caches both its keys and transformed values locally. It will also allow a client to receive all events, including those that result from the initial population of theContinuousQueryCache. In other words, all contents of theContinuousQueryCachewill be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.- Parameters:
cache- theNamedCacheto create a view offilter- theFilterthat defines the viewlistener- aMapListenerthat will receive all the events from theContinuousQueryCache, including those corresponding to its initial populationtransformer- theValueExtractorthat should be used to transform values retrieved from the underlyingNamedCachebefore storing them locally
-
ContinuousQueryCache
public ContinuousQueryCache(NamedCache<K,V_BACK> cache, Filter filter, boolean fCacheValues, MapListener<? super K,? super V_FRONT> listener, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)
Construct the ContinuousQueryCache.- Parameters:
cache- theNamedCacheto create a view offilter- theFilterthat defines the viewfCacheValues- pass true to cache both the keys and values of the materialized view locally, or false to only cache the keyslistener- an optionalMapListenerthat will receive all events starting from the initialization of theContinuousQueryCachetransformer- an optionalValueExtractorthat would be used to transform values retrieved from the underlying cache before storing them locally; if specified, thisContinuousQueryCachewill become "read-only"
-
ContinuousQueryCache
public ContinuousQueryCache(Supplier<NamedCache<K,V_BACK>> supplierCache, Filter filter, boolean fCacheValues, MapListener<? super K,? super V_FRONT> listener, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer, ClassLoader loader)
Create a materialized view of aNamedCacheusing aFilter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCacheAPI.This constructor will result in a read-only
ContinuousQueryCachethat caches both its keys and transformed values locally. It will also allow a client to receive all events, including those that result from the initial population of theContinuousQueryCache. In other words, all contents of theContinuousQueryCachewill be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.- Parameters:
supplierCache- aSupplierthat returns aNamedCachewith which theContinuousQueryCachewill be created. The Supplier must return a new instance each timeSupplier.get()is calledfilter- theFilterthat defines the viewfCacheValues- passtrueto cache both the keys and values of the materialized view locally, orfalseto only cache the keyslistener- an optionalMapListenerthat will receive all events starting from the initialization of theContinuousQueryCachetransformer- an optionalValueExtractorthat would be used to transform values retrieved from the underlying cache before storing them locally; if specified, thisContinuousQueryCachewill become read-onlyloader- an optionalClassLoader- Since:
- 12.2.1.4
-
-
Method Detail
-
getCache
public NamedCache<K,V_BACK> getCache()
Obtain theNamedCachethat thisContinuousQueryCacheis based on.- Returns:
- the underlying
NamedCache
-
getFilter
public Filter getFilter()
- Returns:
- the
Filterthat this cache uses to select its contents from the underlyingNamedCache
-
getTransformer
public ValueExtractor<? super V_BACK,? extends V_FRONT> getTransformer()
Obtain the transformer that thisContinuousQueryCacheis using to transform the results from the underlying cache prior to storing them locally.- Returns:
- the
ValueExtractorthat this cache uses to transform entries from the underlying cache - Since:
- 12.2.1.4
-
getMapListener
public MapListener<? super K,? super V_FRONT> getMapListener()
Obtain the configuredMapListenerfor thisContinuousQueryCache.- Returns:
- the
MapListenerfor thisContinuousQueryCache - Since:
- 12.2.1.4
-
isCacheValues
public boolean isCacheValues()
Determine if thisContinuousQueryCachecaches values locally.- Returns:
trueif this object caches values locally, andfalseif it relies on the underlyingNamedCache
-
setCacheValues
public void setCacheValues(boolean fCacheValues)
Modify the local-caching option for theContinuousQueryCache. By changing this value from false to true, theContinuousQueryCachewill fully realize its contents locally and maintain them coherently in a manner analogous to the Coherence Near Cache. By changing this value from true to false, theContinuousQueryCachewill discard its locally cached data and rely on the underlying NamedCache.- Parameters:
fCacheValues- passtrueto enable local caching, orfalseto disable it
-
isTransformed
public boolean isTransformed()
Determine if thisContinuousQueryCachetransforms values.- Returns:
trueif thisContinuousQueryCachehas been configured to transform values
-
isReadOnly
public boolean isReadOnly()
Determine if thisContinuousQueryCachedisallows data modification operations.- Returns:
trueif thisContinuousQueryCachehas been configured as read-only
-
setReadOnly
public void setReadOnly(boolean fReadOnly)
Modify the read-only option for theContinuousQueryCache. Note that the cache can be made read-only, but the opposite (making it mutable) is explicitly disallowed.- Parameters:
fReadOnly- passtrueto prohibit clients from making modifications to this cache
-
instantiateInternalCache
protected ObservableMap<K,V_FRONT> instantiateInternalCache()
Create the internal cache used by theContinuousQueryCache.- Returns:
- a new
ObservableMapthat will represent the materialized view of theContinuousQueryCache
-
ensureInternalCache
protected ObservableMap<K,V_FRONT> ensureInternalCache()
Create and initialize thisContinuousQueryCache's (if not already present) internal cache. This method is called byconfigureSynchronization(boolean), as such, it shouldn't be called directly. UsegetInternalCache().- Returns:
- the
ObservableMapfunctioning as thisContinuousQueryCache's internal cache - Since:
- 12.2.1.4
-
getInternalCache
protected ObservableMap<K,V_FRONT> getInternalCache()
Obtain a reference to the internal cache. The internal cache maintains all of the keys in theContinuousQueryCache, and ifisCacheValues()is true, it also maintains the up-to-date values corresponding to those keys.- Returns:
- the internal cache that represents the materialized view of the
ContinuousQueryCache
-
isObserved
protected boolean isObserved()
Determine if theContinuousQueryCachehas any listeners that cannot be served by this Map listening to lite events.- Returns:
trueiff there is at least onelistener
-
setObserved
protected void setObserved(boolean fObserved)
Specify whether theContinuousQueryCachehas any listeners that cannot be served by this Map listening to lite events.- Parameters:
fObserved-trueiff there is at least onelistener
-
getState
public int getState()
Obtain the state of theContinuousQueryCache.- Returns:
- one of the
STATE_enums
-
changeState
protected void changeState(int nState)
Change the state of theContinuousQueryCache.- Parameters:
nState- one of theSTATE_enums
-
resetCacheRefs
protected void resetCacheRefs()
Reset cache references to null.
-
getReconnectInterval
public long getReconnectInterval()
Return the reconnection interval (in milliseconds). This value indicates the period in which re-synchronization with the underlying cache will be delayed in the case the connection is severed. During this time period, local content can be accessed without triggering re-synchronization of the local content.- Returns:
- a reconnection interval (in milliseconds)
- Since:
- Coherence 3.4
- See Also:
setReconnectInterval(long)
-
setReconnectInterval
public void setReconnectInterval(long cReconnectMillis)
Specify the reconnection interval (in milliseconds). This value indicates the period in which re-synchronization with the underlying cache will be delayed in the case the connection is severed. During this time period, local content can be accessed without triggering re-synchronization of the local content.- Parameters:
cReconnectMillis- reconnection interval (in milliseconds). A value of zero or less means that theContinuousQueryCachecannot be used when not connected.- Since:
- Coherence 3.4
-
setCacheName
public void setCacheName(String sCacheName)
Set the cache name for thisContinuousQueryCacheas returned bygetCacheName().Note: setting the cache name to be consistent with the
cache nameof theNamedCachethis CQC is backed by will ensure data structures that cacheNamedCacheinstances based upon the reported cache name would result in an appropriate cache hit.- Parameters:
sCacheName- the name this CQC should report as itscache name- Since:
- 12.2.1.4
-
clear
public void clear()
Description copied from class:AbstractKeyBasedMapClear all key/value mappings.
-
get
public V_FRONT get(Object oKey)
Description copied from class:AbstractKeyBasedMapReturns the value to which this map maps the specified key.- Specified by:
getin interfaceConcurrentMap<K,V_BACK>- Specified by:
getin interfaceMap<K,V_BACK>- Specified by:
getin classAbstractKeyBasedMap<K,V_FRONT>- Parameters:
oKey- the key object- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key
- See Also:
ConcurrentMap.containsKey(Object)
-
put
public V_FRONT put(K oKey, V_FRONT oValue)
Description copied from class:AbstractKeyBasedMapAssociates the specified value with the specified key in this map.- Specified by:
putin interfaceCacheMap<K,V_BACK>- Specified by:
putin interfaceConcurrentMap<K,V_BACK>- Specified by:
putin interfaceMap<K,V_BACK>- Overrides:
putin classAbstractKeyBasedMap<K,V_FRONT>- Parameters:
oKey- key with which the specified value is to be associatedoValue- value to be associated with the specified key- Returns:
- previous value associated with specified key, or null if there was no mapping for key
-
putAll
public void putAll(Map<? extends K,? extends V_FRONT> map)
Description copied from class:AbstractKeyBasedMapCopies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of callingAbstractKeyBasedMap.put(K, V)on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.
-
remove
public V_FRONT remove(Object oKey)
Description copied from class:AbstractKeyBasedMapRemoves the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.- Specified by:
removein interfaceConcurrentMap<K,V_BACK>- Specified by:
removein interfaceMap<K,V_BACK>- Overrides:
removein classAbstractKeyBasedMap<K,V_FRONT>- Parameters:
oKey- key whose mapping is to be removed from the map- 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.
-
getAll
public Map<K,V_FRONT> getAll(Collection<? extends K> colKeys)
Description copied from class:AbstractKeyBasedMapGet 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.- Specified by:
getAllin interfaceCacheMap<K,V_BACK>- Specified by:
getAllin interfaceNamedMap<K,V_BACK>- Overrides:
getAllin classAbstractKeyBasedMap<K,V_FRONT>- Parameters:
colKeys- a collection of keys that may be in the named cache- Returns:
- a Map of keys to values for the specified keys passed in colKeys
-
put
public V_FRONT put(K oKey, V_FRONT oValue, long cMillis)
Description copied from interface:NamedCacheAssociates 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 interfaceCacheMap<K,V_BACK>- Specified by:
putin interfaceNamedCache<K,V_BACK>- 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, also referred to as the entry's "time to live"; passCacheMap.EXPIRY_DEFAULTto use the cache's default time-to-live setting; passCacheMap.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
-
removeBlind
protected boolean removeBlind(Object oKey)
Removes the mapping for this key from this map if present. This method exists to allow sub-classes to optimize remove functionality for situations in which the original value is not required.- Overrides:
removeBlindin classAbstractKeyBasedMap<K,V_FRONT>- Parameters:
oKey- key whose mapping is to be removed from the map- Returns:
trueiff theMapchanged as the result of this operation
-
getInternalKeySet
protected Set<K> getInternalKeySet()
Description copied from class:AbstractKeySetBasedMapObtain a set of keys that are represented by this Map.The AbstractKeySetBasedMap only utilizes the internal key set as a read-only resource.
- Specified by:
getInternalKeySetin classAbstractKeySetBasedMap<K,V_FRONT>- Returns:
- an internal Set of keys that are contained by this Map
-
addMapListener
public void addMapListener(MapListener<? super K,? super V_FRONT> listener)
Description copied from interface:ObservableMapAdd a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included. This has the same result as the following call:addMapListener(listener, (Filter) null, false);
- Specified by:
addMapListenerin interfaceObservableMap<K,V_BACK>- Parameters:
listener- theMapEventlistener to add
-
removeMapListener
public void removeMapListener(MapListener<? super K,? super V_FRONT> listener)
Description copied from interface:ObservableMapRemove a standard map listener that previously signed up for all events. This has the same result as the following call:removeMapListener(listener, (Filter) null);
- Specified by:
removeMapListenerin interfaceObservableMap<K,V_BACK>- Parameters:
listener- the listener to remove
-
addMapListener
public void addMapListener(MapListener<? super K,? super V_FRONT> listener, K oKey, boolean fLite)
Description copied from interface:ObservableMapAdd a map listener for a specific key.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the
ObservableMap.removeMapListener(MapListener, Object)method.- Specified by:
addMapListenerin interfaceObservableMap<K,V_BACK>- Parameters:
listener- theMapEventlistener to addoKey- the key that identifies the entry for which to raise eventsfLite- true to indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
public void removeMapListener(MapListener<? super K,? super V_FRONT> listener, K oKey)
Description copied from interface:ObservableMapRemove a map listener that previously signed up for events about a specific key.- Specified by:
removeMapListenerin interfaceObservableMap<K,V_BACK>- Parameters:
listener- the listener to removeoKey- the key that identifies the entry for which to raise events
-
addMapListener
public void addMapListener(MapListener<? super K,? super V_FRONT> listener, Filter filter, boolean fLite)
Description copied from interface:ObservableMapAdd a map listener that receives events based on a filter evaluation.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the
ObservableMap.removeMapListener(MapListener, Filter)method.- Specified by:
addMapListenerin interfaceObservableMap<K,V_BACK>- Parameters:
listener- theMapEventlistener 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 (seeMapEventFilter); null is equivalent to a filter that alway returns truefLite- true to indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
public void removeMapListener(MapListener<? super K,? super V_FRONT> listener, Filter filter)
Description copied from interface:ObservableMapRemove a map listener that previously signed up for events based on a filter evaluation.- Specified by:
removeMapListenerin interfaceObservableMap<K,V_BACK>- Parameters:
listener- the listener to removefilter- the filter that was passed into the corresponding addMapListener() call
-
keySet
public Set<K> keySet(Filter filter)
Description copied from interface:QueryMapReturn 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.
-
entrySet
public Set<Map.Entry<K,V_FRONT>> entrySet(Filter filter)
Description copied from interface:QueryMapReturn 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.
-
entrySet
public Set<Map.Entry<K,V_FRONT>> entrySet(Filter filter, Comparator comparator)
Description copied from interface:QueryMapReturn 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 interfaceQueryMap<K,V_BACK>- 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)
IfisCacheValues()istrue, the index will be created locally as well as on theNamedCachethisContinuousQueryCachewraps, otherwise, the index will be created on the wrappedNamedCacheonly.- Specified by:
addIndexin interfaceQueryMap<K,V_BACK>- 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- Throws:
IllegalArgumentException- ifextractoris an instance ofMapTriggerListener- See Also:
QueryMap.addIndex(ValueExtractor, boolean, Comparator)
-
removeIndex
public <T,E> void removeIndex(ValueExtractor<? super T,? extends E> extractor)
IfisCacheValues()istrue, the index will be removed locally, however, this call will not cause the index on theNamedCachethisContinuousQueryCachewraps. Developers must remove the index on the wrapped cache manually.- Specified by:
removeIndexin interfaceQueryMap<K,V_BACK>- 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.- See Also:
QueryMap.removeIndex(ValueExtractor),getCache()
-
truncate
public void truncate()
Description copied from interface:NamedMapRemoves 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.
-
invoke
public <R> R invoke(K key, InvocableMap.EntryProcessor<K,V_FRONT,R> processor)
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.In order to invoke an entry processor on a back cache in a type-safe manner you must use
getCache().invoke()instead.- Specified by:
invokein interfaceInvocableMap<K,V_BACK>- 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_FRONT,R> processor)
Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.In order to invoke an entry processor on a back cache in a type-safe manner you must use
getCache().invokeAll()instead.- Specified by:
invokeAllin interfaceInvocableMap<K,V_BACK>- 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_FRONT,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.In order to invoke an entry processor on a back cache in a type-safe manner you must use
getCache().invokeAll()instead.- Specified by:
invokeAllin interfaceInvocableMap<K,V_BACK>- 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_FRONT,R> aggregator)
Description copied from interface:InvocableMapPerform an aggregating operation against the entries specified by the passed keys.- Specified by:
aggregatein interfaceInvocableMap<K,V_BACK>- 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_FRONT,R> aggregator)
Description copied from interface:InvocableMapPerform an aggregating operation against the set of entries that are selected by the given Filter.- Specified by:
aggregatein interfaceInvocableMap<K,V_BACK>- 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
-
lock
public boolean lock(Object oKey, long cWait)
Description copied from interface:ConcurrentMapAttempt to lock the specified item within the specified period of time.The item doesn't have to exist to be locked. While the item is locked there is known to be a lock holder which has an exclusive right to modify (calling put and remove methods) that item.
Lock holder is an abstract concept that depends on the ConcurrentMap implementation. For example, holder could be a cluster member or a thread (or both).
Locking strategy may vary for concrete implementations as well. Lock could have an expiration time (this lock is sometimes called a "lease") or be held indefinitely (until the lock holder terminates).
Some implementations may allow the entire map to be locked. If the map is locked in such a way, then only a lock holder is allowed to perform any of the "put" or "remove" operations. Pass the special constant
ConcurrentMap.LOCK_ALLas the oKey parameter to indicate the map lock.- Specified by:
lockin interfaceConcurrentMap<K,V_BACK>- Parameters:
oKey- key being lockedcWait- 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
-
lock
public boolean lock(Object oKey)
Description copied from interface:ConcurrentMapAttempt to lock the specified item and return immediately.This method behaves exactly as if it simply performs the call lock(oKey, 0).
- Specified by:
lockin interfaceConcurrentMap<K,V_BACK>- Parameters:
oKey- key being locked- Returns:
- true if the item was successfully locked; false otherwise
-
unlock
public boolean unlock(Object oKey)
Description copied from interface:ConcurrentMapUnlock the specified item. The item doesn't have to exist to be unlocked. If the item is currently locked, only the holder of the lock could successfully unlock it.- Specified by:
unlockin interfaceConcurrentMap<K,V_BACK>- Parameters:
oKey- key being unlocked- Returns:
- true if the item was successfully unlocked; false otherwise
-
getCacheName
public String getCacheName()
Description copied from interface:NamedCacheReturn the cache name.- Specified by:
getCacheNamein interfaceNamedCache<K,V_BACK>- Returns:
- the cache name
-
getCacheService
public CacheService getCacheService()
Description copied from interface:NamedCacheReturn the CacheService that this NamedCache is a part of.- Specified by:
getCacheServicein interfaceNamedCache<K,V_BACK>- Returns:
- the CacheService
-
async
public AsyncNamedCache<K,V_FRONT> async(AsyncNamedMap.Option... options)
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.This method returns an AsyncNamedCache instantiated from the back NamedMap. Transformers and filters defined on this CQC are not applied to the returned AsyncNamedCache.
-
isActive
public boolean isActive()
Description copied from interface:NamedMapReturnstrueif this map is not released or destroyed. In other words, callingisActive()is equivalent to calling!cache.isReleased() && !cache.isDestroyed().
-
isReady
public 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.
-
release
public void release()
Description copied from interface:ReleasableRelease local resources associated with this Releasable instance.- Specified by:
releasein interfaceReleasable
-
destroy
public void destroy()
Description copied from interface:NamedCollectionRelease 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 interfaceNamedCollection
-
isDestroyed
public boolean isDestroyed()
Description copied from interface:NamedCollectionSpecifies whether or not this NamedCollection has been destroyed. Implementations must override this method to provide the necessary information.- Specified by:
isDestroyedin interfaceNamedCollection- Returns:
- true if the NamedCollection has been destroyed; false otherwise
-
isReleased
public boolean isReleased()
Description copied from interface:ReleasableSpecifies whether or this Releasable has been released. Implementations must override this method to provide the necessary information.- Specified by:
isReleasedin interfaceReleasable- Returns:
- true if the Releasable has been released; false otherwise
-
getInternal
protected V_FRONT getInternal(Object oKey)
Return the value from the back cache, transforming it in the process if necessary.- Parameters:
oKey- the key to get the associated value for- Returns:
- the value for the given key
-
getAllInternal
protected Map<K,V_FRONT> getAllInternal(Collection<? extends K> colKeys)
Return multiple values from the back cache, transforming them in the process if necessary.- Parameters:
colKeys- the keys to get the associated values for- Returns:
- the value for the given key
-
entrySetInternal
protected Set<Map.Entry<K,V_FRONT>> entrySetInternal(Filter filter)
Return multiple values from the back cache based on a filter, transforming them in the process if necessary.- Parameters:
filter- theFilterto find the entries for- Returns:
- the value for the given key
-
entrySetInternal
protected Set<Map.Entry<K,V_FRONT>> entrySetInternal(Filter filter, Comparator comparator)
Return multiple values from the back cache based on a filter, transforming them in the process if necessary.- Parameters:
filter- theFilterto find the entries forcomparator- theComparator- Returns:
- the value for the given key
-
transform
protected Map<K,V_FRONT> transform(Set<Map.Entry<K,V_BACK>> setIn, ValueExtractor<? super V_BACK,? extends V_FRONT> transformer)
Transform a set of entries.- Parameters:
setIn- the set of entries to transformtransformer- thetransformerto use- Returns:
- a Map containing transformed entries
-
checkReadOnly
protected void checkReadOnly()
Check the read-only setting to verify that the cache is NOT read-only.- Throws:
IllegalStateException- if theContinuousQueryCacheis read-only
-
checkEntry
protected void checkEntry(Map.Entry entry)
Check the passed value to verify that it does belong in this ContinuousQueryCache.- Parameters:
entry- a key value pair to check.- Throws:
IllegalArgumentException- if the entry does not belong in thisContinuousQueryCache(based on the cache's filter)
-
checkEntry
protected void checkEntry(Object oKey, Object oValue)
Check the passed value to verify that it does belong in this ContinuousQueryCache.- Parameters:
oKey- the key for the entryoValue- the value for the entry- Throws:
IllegalArgumentException- if the entry does not belong in thisContinuousQueryCache(based on the cache's filter)
-
getStateString
protected String getStateString(int nState)
Return a String description of the providedSTATE_*variables.- Parameters:
nState- the state for which a description will be returned- Returns:
- the state description
- Throws:
IllegalStateException- if an unknown state is provided- Since:
- 12.2.1.4.5
-
configureSynchronization
protected void configureSynchronization(boolean fReload)
Set up the listeners that keep theContinuousQueryCacheup-to-date.- Parameters:
fReload- passtrueto force a data reload
-
createUnexpectedStateException
protected RuntimeException createUnexpectedStateException(int nExpectedState, int nActualState)
Simple helper to create an exception for communicating invalid state transitions.- Parameters:
nExpectedState- expected statenActualState- actual state- Returns:
- a new
RuntimeExceptionwith a description of the invalid state transition - Since:
- 12.2.1.4.5
-
createTransformerFilter
protected Filter createTransformerFilter(MapEventFilter filterAdd)
Wrap specifiedMapEventFilterwith aMapEventTransformerFilterthat will either transform cache value using transformer defined for thisContinuousQueryCache, or remove the old value from the event usingSemiLiteEventTransformer, if no transformer is defined for thisContinuousQueryCache.- Parameters:
filterAdd- addMapEventFilterto wrap- Returns:
MapEventTransformerFilterthat wraps specified addMapEventFilter
-
ensureSynchronized
protected void ensureSynchronized(boolean fReload)
Ensure that theContinuousQueryCachelisteners have been registered and its content synchronized with the underlyingNamedCache.- Parameters:
fReload- the value to pass to the #configureSynchronization method if theContinuousQueryCacheneeds to be configured and synchronized
-
isEventDeferred
protected boolean isEventDeferred(Object oKey)
Called when an event has occurred. Allows the key to be logged as requiring deferred synchronization if the event occurs during the configuration or population of theContinuousQueryCache.- Parameters:
oKey- the key that the event is related to- Returns:
trueif the event processing has been deferred
-
ensureIndexMap
protected Map ensureIndexMap()
Ensure that the map of indexes maintained by this cache exists.- Returns:
- the map of indexes.
-
getIndexMap
protected Map getIndexMap()
Get the map of indexes maintained by this cache.- Returns:
- the map of indexes.
-
releaseIndexMap
protected void releaseIndexMap()
Release the the entire index map.
-
releaseListeners
protected void releaseListeners()
Release thelisteners.
-
instantiateAddListener
protected MapListener<K,V_FRONT> instantiateAddListener()
Factory Method: Instantiate aMapListenerfor adding items to theContinuousQueryCache, and (if there are listeners on theContinuousQueryCache) for dispatching inserts and updates.- Returns:
- a new
MapListenerthat will add items to and update items in theContinuousQueryCache
-
instantiateRemoveListener
protected MapListener<K,V_FRONT> instantiateRemoveListener()
Factory Method: Instantiate aMapListenerfor evicting items from theContinuousQueryCache.- Returns:
- a new
MapListenerthat will listen to all events that will remove items from theContinuousQueryCache
-
registerServiceListener
protected void registerServiceListener()
Instantiate and register aMemberListenerwith the underlying cache service.The primary goal of that
listeneris invalidation of the front map in case of the service [automatic] restart.
-
unregisterServiceListener
protected void unregisterServiceListener()
Unregister underlying cache servicemember listener.
-
registerDeactivationListener
protected void registerDeactivationListener()
Instantiate and register aNamedCacheDeactivationListenerwith the underlying cache service.The primary goal of that
listeneris invalidation of the named cache in case the named caches is destroyed / truncated.- Since:
- 12.2.1.4
-
unregisterDeactivationListener
protected void unregisterDeactivationListener()
Unregister underlying cache service member listener.
-
instantiateEventRouter
protected ContinuousQueryCache.EventRouter<K,V_FRONT> instantiateEventRouter(MapListener<? super K,? super V_FRONT> listener, boolean fLite)
Factory Method: Instantiate a listener on the internal map that will direct events to the passed listener, either synchronously or asynchronously as appropriate.- Parameters:
listener- thelistenerto route tofLite-trueto indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations- Returns:
- a new
ContinuousQueryCache.EventRouterspecific to the passedlistener
-
instantiateEventQueue
protected TaskDaemon instantiateEventQueue()
Create a self-processing event queue.- Returns:
- a
TaskDaemononto which events can be placed in order to be dispatched asynchronously
-
getEventQueue
protected TaskDaemon getEventQueue()
Obtain thisContinuousQueryCache's event queue.- Returns:
- the event queue that this
ContinuousQueryCacheuses to dispatch its events to its non-synchronous listeners
-
ensureEventQueue
protected TaskDaemon ensureEventQueue()
Obtain the existing event queue or create one if none exists.- Returns:
- the event queue that this
ContinuousQueryCacheuses to dispatch its events to its non-synchronous listeners
-
shutdownEventQueue
protected void shutdownEventQueue()
Shut down running event queue.
-
ensureListenerSupport
protected MapListenerSupport ensureListenerSupport()
Configure the localMapListenerSupportand register the interceptingMapListenerwith the internalObservableMap.- Since:
- 12.2.1.4
-
ensureInflated
protected V_FRONT ensureInflated(Object oKey, Object oValue)
If the internal cache value associated with the provided key isBinary, deserialize the value and store it back to the internal cache in its deserialized form.- Parameters:
oKey- the keyoValue- optional original value associated with the key. If not provided, there will be a cost of an additional call to obtain the value currently associated with the key- Returns:
- the deserialized value
- Since:
- 12.2.1.4
-
fromInternal
protected <T> T fromInternal(Object binValue)
Deserialize the providedBinaryvalue.- Type Parameters:
T- the type parameter- Parameters:
binValue- theBinaryvalue to deserialize- Returns:
- the deserialized result
- Since:
- 12.2.1.4
-
toInternal
protected Binary toInternal(Object oValue)
Serialize the provided value into aBinary.- Parameters:
oValue- the object to serialize.- Returns:
- the serialized result
- Since:
- 12.2.1.4
-
instantiateConverterMap
protected Map<K,V_FRONT> instantiateConverterMap(Map<K,V_FRONT> map)
Provides out-bound conversion (i.e. conversion to values clients expect) of internal values.
-
ensureConverted
protected InvocableMap.EntryProcessor ensureConverted(InvocableMap.EntryProcessor processor)
Wrap anyAsynchronousProcessorinstances with a custom wrapper to perform conversion of result returned by the processor.- Parameters:
processor- theInvocableMap.EntryProcessor- Returns:
- the
InvocableMap.EntryProcessorto leverage when dispatching aggregation requests. - Since:
- 12.2.1.4
-
isBinaryNamedCache
protected boolean isBinaryNamedCache(NamedCache cache)
Returnstrueif provided cache is configured to use theNullImplementation classloaderwhich means the values to/from from the cache will beBinary.- Parameters:
cache- the cache- Returns:
trueif the cache is configured to use theNullImplementation classloader- Since:
- 12.2.1.4
-
isBinaryNamedCache
protected boolean isBinaryNamedCache()
Returntrueif the current back cache is configured to useBinaryvalues.- Returns:
trueif the back cache is configured to useBinaryvalues- Since:
- 12.2.1.4
-
instantiateSerializer
protected Serializer instantiateSerializer()
Create aSerializerappropriate for the mode this cache is operating under (i.e., binary vs non-binary).- Returns:
- a new
Serializer - Since:
- 12.2.1.4
-
ensureConverters
protected NamedCache ensureConverters(NamedCache cache)
Instantiate theconvertersnecessary to support the processing mode that thisContinuousQueryCachewill be operating under.- Parameters:
cache- the underlying cache- Returns:
- the named cache
- Since:
- 12.2.1.4
-
getDefaultName
protected static String getDefaultName(String sCacheName, Filter filter, ValueExtractor transformer)
Return the default name used by the CQC.- Parameters:
sCacheName- the cache name this CQC is backed byfilter- the filter that reduces the set of entries of this CQCtransformer- thetransformerto apply to the raw entries- Returns:
- the default name used by the CQC
-
-