Class 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 thisContinuousQueryCache
V_FRONT
- the type of the entry values in thisContinuousQueryCache
, which will be the same asV_BACK
, unless atransformer
is 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>
NamedCache
using the Coherence
Continuous 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 containing Portfolio
instances 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
Modifier and TypeClassDescriptionclass
AMapListener
for adding items to theContinuousQueryCache
.protected class
Wraps anAsynchronousProcessor
to ensure the result of the EntryProcessor execution is deserialized prior to passing to the provided AsynchronousProcessor.protected class
DeactivationListener for the underlying NamedCache.protected class
An EventRouter routes events from the internal cache of theContinuousQueryCache
to the client listeners, and it can do so asynchronously when appropriate.protected class
This listener allows interception of all events triggered by the the internalObservableMap
of theContinuousQueryCache
.class
AMapListener
for evicting items from theContinuousQueryCache
.protected class
MemberListener
for 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 com.tangosol.net.NamedMap
NamedMap.Option
Nested classes/interfaces inherited from interface com.tangosol.util.QueryMap
QueryMap.Entry<K,
V> -
Field Summary
Modifier and TypeFieldDescriptionprotected Converter
protected Converter
protected long
The interval (in milliseconds) that indicates how often theContinuousQueryCache
should attempt to synchronize its content with the underlying cache in case the connection is severed.protected TaskDaemon
The event queue for thisContinuousQueryCache
.protected boolean
The option of whether or not to locally cache values.protected Filter
The filter that represents the subset of information from the underlyingNamedCache
that thisContinuousQueryCache
represents.protected MapEventFilter
TheMapEventFilter
that uses theContinuousQueryCache's
filter to select events that would add elements to this cache's contents.protected MapEventFilter
TheMapEventFilter
that uses theContinuousQueryCache's
filter to select events that would remove elements from this cache's contents.protected boolean
Keeps track of whether theContinuousQueryCache
has listeners that require this cache to cache values.protected boolean
The option to disallow modifications through thisContinuousQueryCache
interface.protected long
The timestamp when the synchronization was last attempted.protected MapListener
<K, V_FRONT> Thelistener
that gets information about what should be in this cache.protected com.tangosol.internal.net.NamedCacheDeactivationListener
TheNamedCacheDeactivationListener
.protected MapListener
<K, V_FRONT> Thelistener
that gets information about what should be thrown out of this cache.protected MemberListener
The cache serviceMemberListener
for the underlyingNamedCache
.protected MapListenerSupport
Locallistener support
to allow theContinuousQueryCache
to intercept all events dispatched by the internalObservableMap
.protected ClassLoader
TheClassLoader
to use when de-serializing/serializing keys and values.protected Map
The map of indexes maintained by this cache.protected MapListener
<? super K, ? super V_FRONT> The optionalMapListener
that may be provided duringContinuousQueryCache
construction.protected ObservableMap
<K, V_FRONT> The keys that are in thisContinuousQueryCache
, and (ifm_fCacheValues
is true) the corresponding values as well.protected Map
While theContinuousQueryCache
is 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 int
State of theContinuousQueryCache
.protected String
The name of the underlyingNamedCache
.protected ValueExtractor
<? super V_BACK, ? extends V_FRONT> The transformer that should be used to convert values from the underlying cache.static final int
State: TheContinuousQueryCache
has been configured.static final int
State: TheContinuousQueryCache
is configuring or re-configuring its listeners and content.static final int
State: Disconnected state.static final int
State: TheContinuousQueryCache
has been configured and fully synchronized.Fields inherited from class com.tangosol.util.Base
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
ConstructorDescriptionContinuousQueryCache
(NamedCache<K, V_BACK> cache) Create a locally materialized view of aNamedCache
using aFilter
.ContinuousQueryCache
(NamedCache<K, V_BACK> cache, Filter filter) Create a locally materialized view of aNamedCache
using a Filter.ContinuousQueryCache
(NamedCache<K, V_BACK> cache, Filter filter, boolean fCacheValues) Create a materialized view of aNamedCache
using 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 aNamedCache
using 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 aNamedCache
using aFilter
.ContinuousQueryCache
(NamedCache<K, V_BACK> cache, Filter filter, ValueExtractor<? super V_BACK, ? extends V_FRONT> transformer) Create a locally materialized view of aNamedCache
using aFilter
and a transformer.ContinuousQueryCache
(Supplier<NamedCache<K, V_BACK>> supplierCache) Create a locally materialized view of aNamedCache
using aFilter
.ContinuousQueryCache
(Supplier<NamedCache<K, V_BACK>> supplierCache, Filter filter) Create a locally materialized view of aNamedCache
using 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 aNamedCache
using aFilter
. -
Method Summary
Modifier and TypeMethodDescription<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 theNamedCache
thisContinuousQueryCache
wraps, otherwise, the index will be created on the wrappedNamedCache
only.void
addMapListener
(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.void
addMapListener
(MapListener<? super K, ? super V_FRONT> listener, Filter filter, boolean fLite) Add a map listener that receives events based on a filter evaluation.void
addMapListener
(MapListener<? super K, ? super V_FRONT> listener, K oKey, boolean fLite) Add a map listener for a specific key.<R> R
aggregate
(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> R
aggregate
(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.protected void
changeState
(int nState) Change the state of theContinuousQueryCache
.protected void
checkEntry
(Object oKey, Object oValue) Check the passed value to verify that it does belong in this ContinuousQueryCache.protected void
checkEntry
(Map.Entry entry) Check the passed value to verify that it does belong in this ContinuousQueryCache.protected void
Check the read-only setting to verify that the cache is NOT read-only.void
clear()
Clear all key/value mappings.protected void
configureSynchronization
(boolean fReload) Set up the listeners that keep theContinuousQueryCache
up-to-date.protected Filter
createTransformerFilter
(MapEventFilter filterAdd) Wrap specifiedMapEventFilter
with aMapEventTransformerFilter
that 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 RuntimeException
createUnexpectedStateException
(int nExpectedState, int nActualState) Simple helper to create an exception for communicating invalid state transitions.void
destroy()
Release and destroy this instance of NamedCollection.protected InvocableMap.EntryProcessor
ensureConverted
(InvocableMap.EntryProcessor processor) Wrap anyAsynchronousProcessor
instances with a custom wrapper to perform conversion of result returned by the processor.protected NamedCache
ensureConverters
(NamedCache cache) Instantiate theconverters
necessary to support the processing mode that thisContinuousQueryCache
will be operating under.protected TaskDaemon
Obtain the existing event queue or create one if none exists.protected Map
Ensure that the map of indexes maintained by this cache exists.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.protected ObservableMap
<K, V_FRONT> Create and initialize thisContinuousQueryCache
's (if not already present) internal cache.protected MapListenerSupport
Configure the localMapListenerSupport
and register the interceptingMapListener
with the internalObservableMap
.protected void
ensureSynchronized
(boolean fReload) Ensure that theContinuousQueryCache
listeners have been registered and its content synchronized with the underlyingNamedCache
.Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.entrySet
(Filter filter, Comparator comparator) Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.entrySetInternal
(Filter filter) Return multiple values from the back cache based on a filter, transforming them in the process if necessary.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> T
fromInternal
(Object binValue) Deserialize the providedBinary
value.Returns the value to which this map maps the specified key.getAll
(Collection<? extends K> colKeys) Get all the specified keys, if they are in the Map.getAllInternal
(Collection<? extends K> colKeys) Return multiple values from the back cache, transforming them in the process if necessary.getCache()
Obtain theNamedCache
that thisContinuousQueryCache
is based on.Return the cache name.Return the CacheService that this NamedCache is a part of.protected static String
getDefaultName
(String sCacheName, Filter filter, ValueExtractor transformer) Return the default name used by the CQC.protected TaskDaemon
Obtain thisContinuousQueryCache
's event queue.protected Map
Get the map of indexes maintained by this cache.protected V_FRONT
getInternal
(Object oKey) Return the value from the back cache, transforming it in the process if necessary.protected ObservableMap
<K, V_FRONT> Obtain a reference to the internal cache.Obtain a set of keys that are represented by this Map.MapListener
<? super K, ? super V_FRONT> Obtain the configuredMapListener
for thisContinuousQueryCache
.long
Return the reconnection interval (in milliseconds).int
getState()
Obtain the state of theContinuousQueryCache
.protected String
getStateString
(int nState) Return a String description of the providedSTATE_*
variables.ValueExtractor
<? super V_BACK, ? extends V_FRONT> Obtain the transformer that thisContinuousQueryCache
is using to transform the results from the underlying cache prior to storing them locally.protected MapListener
<K, V_FRONT> Factory Method: Instantiate aMapListener
for adding items to theContinuousQueryCache
, and (if there are listeners on theContinuousQueryCache
) for dispatching inserts and updates.instantiateConverterMap
(Map<K, V_FRONT> map) Provides out-bound conversion (i.e. conversion to values clients expect) of internal values.protected TaskDaemon
Create a self-processing event queue.protected ContinuousQueryCache<K,
V_BACK, V_FRONT>.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> Create the internal cache used by theContinuousQueryCache
.protected MapListener
<K, V_FRONT> Factory Method: Instantiate aMapListener
for evicting items from theContinuousQueryCache
.protected Serializer
Create aSerializer
appropriate for the mode this cache is operating under (i.e., binary vs non-binary).<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.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.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.boolean
isActive()
Returnstrue
if this map is not released or destroyed.protected boolean
Returntrue
if the current back cache is configured to useBinary
values.protected boolean
isBinaryNamedCache
(NamedCache cache) Returnstrue
if provided cache is configured to use theNullImplementation classloader
which means the values to/from from the cache will beBinary
.boolean
Determine if thisContinuousQueryCache
caches values locally.boolean
Specifies whether or not this NamedCollection has been destroyed.protected boolean
isEventDeferred
(Object oKey) Called when an event has occurred.protected boolean
Determine if theContinuousQueryCache
has any listeners that cannot be served by this Map listening to lite events.boolean
Determine if thisContinuousQueryCache
disallows data modification operations.boolean
isReady()
Returns whether thisNamedMap
is ready to be used.boolean
Specifies whether or this Releasable has been released.boolean
Determine if thisContinuousQueryCache
transforms values.Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.boolean
Attempt to lock the specified item and return immediately.boolean
Attempt to lock the specified item within the specified period of time.protected Filter
mergeFilter
(Filter filter) Associates the specified value with the specified key in this map.Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry.void
Copies all of the mappings from the specified map to this map.protected void
Instantiate and register aNamedCacheDeactivationListener
with the underlying cache service.protected void
Instantiate and register aMemberListener
with the underlying cache service.void
release()
Release local resources associated with this Releasable instance.protected void
Release the the entire index map.protected void
Release thelisteners
.Removes the mapping for this key from this map if present.protected boolean
removeBlind
(Object oKey) Removes the mapping for this key from this map if present.<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 theNamedCache
thisContinuousQueryCache
wraps.void
removeMapListener
(MapListener<? super K, ? super V_FRONT> listener) Remove a standard map listener that previously signed up for all events.void
removeMapListener
(MapListener<? super K, ? super V_FRONT> listener, Filter filter) Remove a map listener that previously signed up for events based on a filter evaluation.void
removeMapListener
(MapListener<? super K, ? super V_FRONT> listener, K oKey) Remove a map listener that previously signed up for events about a specific key.protected void
Reset cache references to null.void
setCacheName
(String sCacheName) Set the cache name for thisContinuousQueryCache
as returned bygetCacheName()
.void
setCacheValues
(boolean fCacheValues) Modify the local-caching option for theContinuousQueryCache
.protected void
setObserved
(boolean fObserved) Specify whether theContinuousQueryCache
has any listeners that cannot be served by this Map listening to lite events.void
setReadOnly
(boolean fReadOnly) Modify the read-only option for theContinuousQueryCache
.void
setReconnectInterval
(long cReconnectMillis) Specify the reconnection interval (in milliseconds).protected void
Shut down running event queue.protected Binary
toInternal
(Object oValue) Serialize the provided value into aBinary
.transform
(Set<Map.Entry<K, V_BACK>> setIn, ValueExtractor<? super V_BACK, ? extends V_FRONT> transformer) Transform a set of entries.void
truncate()
Removes all mappings from this map.boolean
Unlock the specified item.protected void
Unregister underlying cache service member listener.protected void
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, 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.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 Details
-
STATE_DISCONNECTED
public static final int STATE_DISCONNECTEDState: Disconnected state. The content of theContinuousQueryCache
is 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:
-
STATE_CONFIGURING
public static final int STATE_CONFIGURINGState: TheContinuousQueryCache
is configuring or re-configuring its listeners and content.- See Also:
-
STATE_CONFIGURED
public static final int STATE_CONFIGUREDState: TheContinuousQueryCache
has been configured.- See Also:
-
STATE_SYNCHRONIZED
public static final int STATE_SYNCHRONIZEDState: TheContinuousQueryCache
has been configured and fully synchronized.- See Also:
-
m_sName
The name of the underlyingNamedCache
. A copy is kept here because the reference to the underlyingNamedCache
is discarded when this cache is released. -
m_filter
The filter that represents the subset of information from the underlyingNamedCache
that thisContinuousQueryCache
represents. -
m_fCacheValues
protected boolean m_fCacheValuesThe option of whether or not to locally cache values. -
m_transformer
The transformer that should be used to convert values from the underlying cache. -
m_fReadOnly
protected boolean m_fReadOnlyThe option to disallow modifications through thisContinuousQueryCache
interface. -
m_cReconnectMillis
protected long m_cReconnectMillisThe interval (in milliseconds) that indicates how often theContinuousQueryCache
should attempt to synchronize its content with the underlying cache in case the connection is severed. -
m_ldtConnectionTimestamp
protected volatile long m_ldtConnectionTimestampThe timestamp when the synchronization was last attempted. -
m_mapLocal
The keys that are in thisContinuousQueryCache
, and (ifm_fCacheValues
is true) the corresponding values as well. -
m_nState
protected volatile int m_nStateState of theContinuousQueryCache
. One of theSTATE_*
enums. -
m_mapSyncReq
While theContinuousQueryCache
is 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
The event queue for thisContinuousQueryCache
. -
m_fListeners
protected boolean m_fListenersKeeps track of whether theContinuousQueryCache
has listeners that require this cache to cache values. -
m_filterAdd
TheMapEventFilter
that uses theContinuousQueryCache's
filter to select events that would add elements to this cache's contents. -
m_filterRemove
TheMapEventFilter
that uses theContinuousQueryCache's
filter to select events that would remove elements from this cache's contents. -
m_listenerAdd
Thelistener
that gets information about what should be in this cache. -
m_listenerRemove
Thelistener
that gets information about what should be thrown out of this cache. -
m_listenerService
The cache serviceMemberListener
for the underlyingNamedCache
. -
m_mapIndex
The map of indexes maintained by this cache. The keys of the Map areValueExtractor
objects, and for each key, the corresponding value stored in the Map is a MapIndex object. -
m_listenerDeactivation
protected com.tangosol.internal.net.NamedCacheDeactivationListener m_listenerDeactivationTheNamedCacheDeactivationListener
.- Since:
- 12.2.1.4
-
m_mapListener
The optionalMapListener
that may be provided duringContinuousQueryCache
construction.- Since:
- 12.2.1.4
-
m_converterFromBinary
- Since:
- 12.2.1.4
-
m_converterToBinary
- Since:
- 12.2.1.4
-
m_loader
TheClassLoader
to use when de-serializing/serializing keys and values.- Since:
- 12.2.1.4
-
m_listenerSupport
Locallistener support
to allow theContinuousQueryCache
to intercept all events dispatched by the internalObservableMap
.- Since:
- 12.2.1.4
-
-
Constructor Details
-
ContinuousQueryCache
Create a locally materialized view of aNamedCache
using aFilter
. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a
ContinuousQueryCache
that caches both its keys and values locally.- Parameters:
cache
- theNamedCache
with which the view will be created- Since:
- 12.2.1.4
-
ContinuousQueryCache
Create a locally materialized view of aNamedCache
using aFilter
. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a
ContinuousQueryCache
that caches both its keys and values locally.- Parameters:
supplierCache
- aSupplier
that returns aNamedCache
with which theContinuousQueryCache
will be created The Supplier must return a new instance each timeSupplier.get()
is called- Since:
- 12.2.1.4
-
ContinuousQueryCache
Create a locally materialized view of aNamedCache
using a Filter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a
ContinuousQueryCache
that caches both its keys and values locally.- Parameters:
cache
- theNamedCache
to create a view offilter
- the filter that defines the view
-
ContinuousQueryCache
Create a locally materialized view of aNamedCache
using aFilter
. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a
ContinuousQueryCache
that caches both its keys and values locally.- Parameters:
supplierCache
- aSupplier
that returns aNamedCache
with which theContinuousQueryCache
will be created The Supplier must return a new instance each timeSupplier.get()
is calledfilter
- theFilter
that 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 aNamedCache
using aFilter
and a transformer. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a read-only ContinuousQueryCache that caches both its keys and transformed values locally.
- Parameters:
cache
- theNamedCache
to create a view offilter
- theFilter
that defines the viewtransformer
- theValueExtractor
that should be used to transform values retrieved from the underlyingNamedCache
before storing them locally
-
ContinuousQueryCache
Create a materialized view of aNamedCache
using a Filter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.- Parameters:
cache
- theNamedCache
to create a view offilter
- theFilter
that defines the viewfCacheValues
- passtrue
to cache both the keys and values of the materialized view locally, orfalse
to 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 aNamedCache
using a Filter. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API. 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 theContinuousQueryCache
will be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.- Parameters:
cache
- theNamedCache
to create a view offilter
- theFilter
that defines the viewlistener
- aMapListener
that 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 aNamedCache
using aFilter
. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a read-only
ContinuousQueryCache
that 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 theContinuousQueryCache
will be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.- Parameters:
cache
- theNamedCache
to create a view offilter
- theFilter
that defines the viewlistener
- aMapListener
that will receive all the events from theContinuousQueryCache
, including those corresponding to its initial populationtransformer
- theValueExtractor
that should be used to transform values retrieved from the underlyingNamedCache
before 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
- theNamedCache
to create a view offilter
- theFilter
that 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 optionalMapListener
that will receive all events starting from the initialization of theContinuousQueryCache
transformer
- an optionalValueExtractor
that would be used to transform values retrieved from the underlying cache before storing them locally; if specified, thisContinuousQueryCache
will 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 aNamedCache
using aFilter
. A materialized view is an implementation of Continuous Query exposed through the standardNamedCache
API.This constructor will result in a read-only
ContinuousQueryCache
that 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 theContinuousQueryCache
will be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.- Parameters:
supplierCache
- aSupplier
that returns aNamedCache
with which theContinuousQueryCache
will be created. The Supplier must return a new instance each timeSupplier.get()
is calledfilter
- theFilter
that defines the viewfCacheValues
- passtrue
to cache both the keys and values of the materialized view locally, orfalse
to only cache the keyslistener
- an optionalMapListener
that will receive all events starting from the initialization of theContinuousQueryCache
transformer
- an optionalValueExtractor
that would be used to transform values retrieved from the underlying cache before storing them locally; if specified, thisContinuousQueryCache
will become read-onlyloader
- an optionalClassLoader
- Since:
- 12.2.1.4
-
-
Method Details
-
getCache
Obtain theNamedCache
that thisContinuousQueryCache
is based on.- Returns:
- the underlying
NamedCache
-
getFilter
- Returns:
- the
Filter
that this cache uses to select its contents from the underlyingNamedCache
-
getTransformer
Obtain the transformer that thisContinuousQueryCache
is using to transform the results from the underlying cache prior to storing them locally.- Returns:
- the
ValueExtractor
that this cache uses to transform entries from the underlying cache - Since:
- 12.2.1.4
-
getMapListener
Obtain the configuredMapListener
for thisContinuousQueryCache
.- Returns:
- the
MapListener
for thisContinuousQueryCache
- Since:
- 12.2.1.4
-
isCacheValues
public boolean isCacheValues()Determine if thisContinuousQueryCache
caches values locally.- Returns:
true
if this object caches values locally, andfalse
if 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, theContinuousQueryCache
will 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, theContinuousQueryCache
will discard its locally cached data and rely on the underlying NamedCache.- Parameters:
fCacheValues
- passtrue
to enable local caching, orfalse
to disable it
-
isTransformed
public boolean isTransformed()Determine if thisContinuousQueryCache
transforms values.- Returns:
true
if thisContinuousQueryCache
has been configured to transform values
-
isReadOnly
public boolean isReadOnly()Determine if thisContinuousQueryCache
disallows data modification operations.- Returns:
true
if thisContinuousQueryCache
has 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
- passtrue
to prohibit clients from making modifications to this cache
-
instantiateInternalCache
Create the internal cache used by theContinuousQueryCache
.- Returns:
- a new
ObservableMap
that will represent the materialized view of theContinuousQueryCache
-
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
ObservableMap
functioning as thisContinuousQueryCache
's internal cache - Since:
- 12.2.1.4
-
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 theContinuousQueryCache
has any listeners that cannot be served by this Map listening to lite events.- Returns:
true
iff there is at least onelistener
-
setObserved
protected void setObserved(boolean fObserved) Specify whether theContinuousQueryCache
has any listeners that cannot be served by this Map listening to lite events.- Parameters:
fObserved
-true
iff 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
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 theContinuousQueryCache
cannot be used when not connected.- Since:
- Coherence 3.4
-
setCacheName
Set the cache name for thisContinuousQueryCache
as returned bygetCacheName()
.Note: setting the cache name to be consistent with the
cache name
of theNamedCache
this CQC is backed by will ensure data structures that cacheNamedCache
instances 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:AbstractKeyBasedMap
Clear all key/value mappings. -
get
Description copied from class:AbstractKeyBasedMap
Returns the value to which this map maps the specified key.- Specified by:
get
in interfaceConcurrentMap<K,
V_BACK> - Specified by:
get
in interfaceMap<K,
V_BACK> - Specified by:
get
in 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:
-
put
Description copied from class:AbstractKeyBasedMap
Associates the specified value with the specified key in this map.- Specified by:
put
in interfaceCacheMap<K,
V_BACK> - Specified by:
put
in interfaceConcurrentMap<K,
V_BACK> - Specified by:
put
in interfaceMap<K,
V_BACK> - Overrides:
put
in 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
Description copied from class:AbstractKeyBasedMap
Copies 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
Description copied from class:AbstractKeyBasedMap
Removes the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.- Specified by:
remove
in interfaceConcurrentMap<K,
V_BACK> - Specified by:
remove
in interfaceMap<K,
V_BACK> - Overrides:
remove
in 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
Description copied from class:AbstractKeyBasedMap
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.- Specified by:
getAll
in interfaceCacheMap<K,
V_BACK> - Specified by:
getAll
in interfaceNamedMap<K,
V_BACK> - Overrides:
getAll
in 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
Description copied from interface:NamedCache
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:
put
in interfaceCacheMap<K,
V_BACK> - Specified by:
put
in 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_DEFAULT
to use the cache's default time-to-live setting; passCacheMap.EXPIRY_NEVER
to 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
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:
removeBlind
in classAbstractKeyBasedMap<K,
V_FRONT> - Parameters:
oKey
- key whose mapping is to be removed from the map- Returns:
true
iff theMap
changed as the result of this operation
-
getInternalKeySet
Description copied from class:AbstractKeySetBasedMap
Obtain 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:
getInternalKeySet
in classAbstractKeySetBasedMap<K,
V_FRONT> - Returns:
- an internal Set of keys that are contained by this Map
-
addMapListener
Description copied from interface:ObservableMap
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. This has the same result as the following call:addMapListener(listener, (Filter) null, false);
- Specified by:
addMapListener
in interfaceObservableMap<K,
V_BACK> - Parameters:
listener
- theMapEvent
listener to add
-
removeMapListener
Description copied from interface:ObservableMap
Remove 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:
removeMapListener
in interfaceObservableMap<K,
V_BACK> - Parameters:
listener
- the listener to remove
-
addMapListener
Description copied from interface:ObservableMap
Add 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:
addMapListener
in interfaceObservableMap<K,
V_BACK> - Parameters:
listener
- theMapEvent
listener to addoKey
- the key that identifies the entry for which to raise eventsfLite
- true to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
Description copied from interface:ObservableMap
Remove a map listener that previously signed up for events about a specific key.- Specified by:
removeMapListener
in 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:ObservableMap
Add 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:
addMapListener
in interfaceObservableMap<K,
V_BACK> - Parameters:
listener
- theMapEvent
listener to addfilter
- a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent (seeMapEventFilter
); null is equivalent to a filter that alway returns truefLite
- true to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
Description copied from interface:ObservableMap
Remove a map listener that previously signed up for events based on a filter evaluation.- Specified by:
removeMapListener
in interfaceObservableMap<K,
V_BACK> - Parameters:
listener
- the listener to removefilter
- the filter that was passed into the corresponding addMapListener() call
-
keySet
Description copied from interface:QueryMap
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.
-
entrySet
Description copied from interface:QueryMap
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.
-
entrySet
Description copied from interface:QueryMap
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:
entrySet
in 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:
-
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 theNamedCache
thisContinuousQueryCache
wraps, otherwise, the index will be created on the wrappedNamedCache
only.- Specified by:
addIndex
in 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
- ifextractor
is an instance ofMapTriggerListener
- See Also:
-
removeIndex
IfisCacheValues()
istrue
, the index will be removed locally, however, this call will not cause the index on theNamedCache
thisContinuousQueryCache
wraps. Developers must remove the index on the wrapped cache manually.- Specified by:
removeIndex
in 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:
-
truncate
public void truncate()Description copied from interface:NamedMap
Removes all mappings from this map.Note: the removal of entries caused by this truncate operation will not be observable. This includes any registered
listeners
,triggers
, orinterceptors
. However, aCacheLifecycleEvent
is raised to notify subscribers of the execution of this operation. -
invoke
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:
invoke
in 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:
invokeAll
in 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
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:
invokeAll
in 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:InvocableMap
Perform an aggregating operation against the entries specified by the passed keys.- Specified by:
aggregate
in 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:InvocableMap
Perform an aggregating operation against the set of entries that are selected by the given Filter.- Specified by:
aggregate
in 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
Description copied from interface:ConcurrentMap
Attempt 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_ALL
as the oKey parameter to indicate the map lock.- Specified by:
lock
in 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
Description copied from interface:ConcurrentMap
Attempt to lock the specified item and return immediately.This method behaves exactly as if it simply performs the call lock(oKey, 0).
- Specified by:
lock
in interfaceConcurrentMap<K,
V_BACK> - Parameters:
oKey
- key being locked- Returns:
- true if the item was successfully locked; false otherwise
-
unlock
Description copied from interface:ConcurrentMap
Unlock 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:
unlock
in interfaceConcurrentMap<K,
V_BACK> - Parameters:
oKey
- key being unlocked- Returns:
- true if the item was successfully unlocked; false otherwise
-
getCacheName
Description copied from interface:NamedCache
Return the cache name.- Specified by:
getCacheName
in interfaceNamedCache<K,
V_BACK> - Returns:
- the cache name
-
getCacheService
Description copied from interface:NamedCache
Return the CacheService that this NamedCache is a part of.- Specified by:
getCacheService
in interfaceNamedCache<K,
V_BACK> - Returns:
- the CacheService
-
isActive
public boolean isActive()Description copied from interface:NamedMap
Returnstrue
if 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:NamedMap
Returns whether thisNamedMap
is ready to be used. An example of when this method would returnfalse
would be where a partitioned cache service that owns this cache has no storage-enabled members. -
release
public void release()Description copied from interface:Releasable
Release local resources associated with this Releasable instance.- Specified by:
release
in interfaceReleasable
-
destroy
public void destroy()Description copied from interface:NamedCollection
Release and destroy this instance of NamedCollection.Warning: This method is used to completely destroy the specified collection across the cluster. All references in the entire cluster to this collection will be invalidated, the collection data will be cleared, and all internal resources will be released.
- Specified by:
destroy
in interfaceNamedCollection
-
isDestroyed
public boolean isDestroyed()Description copied from interface:NamedCollection
Specifies whether or not this NamedCollection has been destroyed. Implementations must override this method to provide the necessary information.- Specified by:
isDestroyed
in interfaceNamedCollection
- Returns:
- true if the NamedCollection has been destroyed; false otherwise
-
isReleased
public boolean isReleased()Description copied from interface:Releasable
Specifies whether or this Releasable has been released. Implementations must override this method to provide the necessary information.- Specified by:
isReleased
in interfaceReleasable
- Returns:
- true if the Releasable has been released; false otherwise
-
getInternal
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
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
Return multiple values from the back cache based on a filter, transforming them in the process if necessary.- Parameters:
filter
- theFilter
to find the entries for- Returns:
- the value for the given key
-
entrySetInternal
Return multiple values from the back cache based on a filter, transforming them in the process if necessary.- Parameters:
filter
- theFilter
to 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
- thetransformer
to use- Returns:
- a Map containing transformed entries
-
mergeFilter
-
checkReadOnly
protected void checkReadOnly()Check the read-only setting to verify that the cache is NOT read-only.- Throws:
IllegalStateException
- if theContinuousQueryCache
is read-only
-
checkEntry
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
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
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 theContinuousQueryCache
up-to-date.- Parameters:
fReload
- passtrue
to force a data reload
-
createUnexpectedStateException
Simple helper to create an exception for communicating invalid state transitions.- Parameters:
nExpectedState
- expected statenActualState
- actual state- Returns:
- a new
RuntimeException
with a description of the invalid state transition - Since:
- 12.2.1.4.5
-
createTransformerFilter
Wrap specifiedMapEventFilter
with aMapEventTransformerFilter
that 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
- addMapEventFilter
to wrap- Returns:
MapEventTransformerFilter
that wraps specified addMapEventFilter
-
ensureSynchronized
protected void ensureSynchronized(boolean fReload) Ensure that theContinuousQueryCache
listeners have been registered and its content synchronized with the underlyingNamedCache
.- Parameters:
fReload
- the value to pass to the #configureSynchronization method if theContinuousQueryCache
needs to be configured and synchronized
-
isEventDeferred
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:
true
if the event processing has been deferred
-
ensureIndexMap
Ensure that the map of indexes maintained by this cache exists.- Returns:
- the map of indexes.
-
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
Factory Method: Instantiate aMapListener
for adding items to theContinuousQueryCache
, and (if there are listeners on theContinuousQueryCache
) for dispatching inserts and updates.- Returns:
- a new
MapListener
that will add items to and update items in theContinuousQueryCache
-
instantiateRemoveListener
Factory Method: Instantiate aMapListener
for evicting items from theContinuousQueryCache
.- Returns:
- a new
MapListener
that will listen to all events that will remove items from theContinuousQueryCache
-
registerServiceListener
protected void registerServiceListener()Instantiate and register aMemberListener
with the underlying cache service.The primary goal of that
listener
is 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 aNamedCacheDeactivationListener
with the underlying cache service.The primary goal of that
listener
is 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<K,V_BACK, instantiateEventRouterV_FRONT>.EventRouter<K, V_FRONT> (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
- thelistener
to route tofLite
-true
to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations- Returns:
- a new
ContinuousQueryCache.EventRouter
specific to the passedlistener
-
instantiateEventQueue
Create a self-processing event queue.- Returns:
- a
TaskDaemon
onto which events can be placed in order to be dispatched asynchronously
-
getEventQueue
Obtain thisContinuousQueryCache
's event queue.- Returns:
- the event queue that this
ContinuousQueryCache
uses to dispatch its events to its non-synchronous listeners
-
ensureEventQueue
Obtain the existing event queue or create one if none exists.- Returns:
- the event queue that this
ContinuousQueryCache
uses to dispatch its events to its non-synchronous listeners
-
shutdownEventQueue
protected void shutdownEventQueue()Shut down running event queue. -
ensureListenerSupport
Configure the localMapListenerSupport
and register the interceptingMapListener
with the internalObservableMap
.- Since:
- 12.2.1.4
-
ensureInflated
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
Deserialize the providedBinary
value.- Type Parameters:
T
- the type parameter- Parameters:
binValue
- theBinary
value to deserialize- Returns:
- the deserialized result
- Since:
- 12.2.1.4
-
toInternal
Serialize the provided value into aBinary
.- Parameters:
oValue
- the object to serialize.- Returns:
- the serialized result
- Since:
- 12.2.1.4
-
instantiateConverterMap
Provides out-bound conversion (i.e. conversion to values clients expect) of internal values. -
ensureConverted
Wrap anyAsynchronousProcessor
instances with a custom wrapper to perform conversion of result returned by the processor.- Parameters:
processor
- theInvocableMap.EntryProcessor
- Returns:
- the
InvocableMap.EntryProcessor
to leverage when dispatching aggregation requests. - Since:
- 12.2.1.4
-
isBinaryNamedCache
Returnstrue
if provided cache is configured to use theNullImplementation classloader
which means the values to/from from the cache will beBinary
.- Parameters:
cache
- the cache- Returns:
true
if the cache is configured to use theNullImplementation classloader
- Since:
- 12.2.1.4
-
isBinaryNamedCache
protected boolean isBinaryNamedCache()Returntrue
if the current back cache is configured to useBinary
values.- Returns:
true
if the back cache is configured to useBinary
values- Since:
- 12.2.1.4
-
instantiateSerializer
Create aSerializer
appropriate for the mode this cache is operating under (i.e., binary vs non-binary).- Returns:
- a new
Serializer
- Since:
- 12.2.1.4
-
ensureConverters
Instantiate theconverters
necessary to support the processing mode that thisContinuousQueryCache
will 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
- thetransformer
to apply to the raw entries- Returns:
- the default name used by the CQC
-