Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.1.0

E18814-01


com.tangosol.net.cache
Class ContinuousQueryCache

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.AbstractKeyBasedMap
          extended by com.tangosol.util.AbstractKeySetBasedMap
              extended by com.tangosol.net.cache.ContinuousQueryCache

All Implemented Interfaces:
CacheMap, NamedCache, ConcurrentMap, InvocableMap, ObservableMap, QueryMap, java.util.Map

public class ContinuousQueryCache
extends AbstractKeySetBasedMap
implements NamedCache

Create a materialized view of a NamedCache using the Coherence Continuous Query capability.

Since:
Coherence 3.1
Author:
cp 2006.01.19

Nested Class Summary
 class ContinuousQueryCache.AddListener
          A MapListener for adding items to the ContinuousQueryCache.
protected  class ContinuousQueryCache.EventRouter
          An EventRouter routes events from the internal cache of the ContinuousQueryCache to the client listeners, and it can do so asynchronously when appropriate.
 class ContinuousQueryCache.RemoveListener
          A MapListener for evicting items from the ContinuousQueryCache.
protected  class ContinuousQueryCache.ServiceListener
          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 interface com.tangosol.util.QueryMap
QueryMap.Entry

 

Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap
InvocableMap.Entry, InvocableMap.EntryAggregator, InvocableMap.EntryProcessor, InvocableMap.ParallelAwareAggregator

 

Field Summary
protected  long m_ldtConnectionTimestamp
          The timestamp when the synchronization was last attempted.
protected  MemberListener m_listenerService
          The cache service MemberListener for the underlying NamedCache.
static int STATE_CONFIGURED
          State: The ContinousQueryCache has been configured.
static int STATE_CONFIGURING
          State: The ContinuousQueryCache is configuring or re-configuring its listeners and content.
static int STATE_DISCONNECTED
          State: Disconnected state.
static int STATE_INIT
          Deprecated. as of Coherence 3.4 this constant is replaced with {link STATE_DISCONNECTED}
static int STATE_SYNCHRONIZED
          State: The ContinousQueryCache has been configured and fully synchronized.

 

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
ContinuousQueryCache(NamedCache cache, Filter filter)
          Create a locally materialized view of a NamedCache using a Filter.
ContinuousQueryCache(NamedCache cache, Filter filter, boolean fCacheValues)
          Create a materialized view of a NamedCache using a Filter.
ContinuousQueryCache(NamedCache cache, Filter filter, MapListener listener)
          Create a materialized view of a NamedCache using a Filter.

 

Method Summary
 void addIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator)
          Add an index to this QueryMap.
 void addMapListener(MapListener 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 listener, Filter filter, boolean fLite)
          Add a map listener that receives events based on a filter evaluation.
 void addMapListener(MapListener listener, java.lang.Object oKey, boolean fLite)
          Add a map listener for a specific key.
 java.lang.Object aggregate(java.util.Collection collKeys, InvocableMap.EntryAggregator agent)
          Perform an aggregating operation against the entries specified by the passed keys.
 java.lang.Object aggregate(Filter filter, InvocableMap.EntryAggregator agent)
          Perform an aggregating operation against the set of entries that are selected by the given Filter.
protected  void changeState(int nState)
          Change the state of the ContinousQueryCache.
protected  void checkEntry(java.util.Map.Entry entry)
          Check the passed value to verify that it does belong in this ContinuousQueryCache.
protected  void checkEntry(java.lang.Object oKey, java.lang.Object oValue)
          Check the passed value to verify that it does belong in this ContinuousQueryCache.
protected  void checkReadOnly()
          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 the ContinuousQueryCache up-to-date.
 void destroy()
          Release and destroy this instance of NamedCache.
protected  TaskDaemon ensureEventQueue()
          Obtain the existing event queue or create one if none exists.
protected  java.util.Map ensureIndexMap()
          Ensure that the map of indexes maintaned by this cache exists.
protected  void ensureSynchronized(boolean fReload)
          Ensure that the ContinousQueryCache listeners have been registered and its content synchronized with the underlying NamedCache.
 java.util.Set entrySet(Filter filter)
          Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.
 java.util.Set entrySet(Filter filter, java.util.Comparator comparator)
          Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.
 java.lang.Object get(java.lang.Object oKey)
          Returns the value to which this map maps the specified key.
 java.util.Map getAll(java.util.Collection colKeys)
          Get all the specified keys, if they are in the Map.
 NamedCache getCache()
          Obtain the NamedCache that this ContinuousQueryCache is based on.
 java.lang.String getCacheName()
          Return the cache name.
 CacheService getCacheService()
          Return the CacheService that this NamedCache is a part of.
protected  TaskDaemon getEventQueue()
          Obtain this ContinuousQueryCache's event queue.
 Filter getFilter()
          Obtain the Filter that this ContinuousQueryCache is using to query the underlying NamedCache.
protected  java.util.Map getIndexMap()
          Get the map of indexes maintaned by this cache.
protected  ObservableMap getInternalCache()
          Obtain a reference to the internal cache.
protected  java.util.Set getInternalKeySet()
          Obtain a set of keys that are represented by this Map.
 long getReconnectInterval()
          Return a reconnection interval (in milliseconds).
 int getState()
          Obtain the state of the ContinousQueryCache.
protected  MapListener instantiateAddListener()
          Factory Method: Instantiate a MapListener for adding items to the ContinuousQueryCache, and (if there are listeners on the ContinuousQueryCache) for dispatching inserts and updates.
protected  TaskDaemon instantiateEventQueue()
          Create a self-processing event queue.
protected  ContinuousQueryCache.EventRouter instantiateEventRouter(MapListener listener)
          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 instantiateInternalCache()
          Create the internal cache used by the ContinuousQueryCache.
protected  MapListener instantiateRemoveListener()
          Factory Method: Instantiate a MapListener for evicting items from the ContinuousQueryCache.
 java.lang.Object invoke(java.lang.Object oKey, InvocableMap.EntryProcessor agent)
          Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.
 java.util.Map invokeAll(java.util.Collection collKeys, InvocableMap.EntryProcessor agent)
          Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.
 java.util.Map invokeAll(Filter filter, InvocableMap.EntryProcessor agent)
          Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.
 boolean isActive()
          Specifies whether or not the NamedCache is active.
 boolean isCacheValues()
          Determine if this ContinuousQueryCache caches values locally.
protected  boolean isEventDeferred(java.lang.Object oKey)
          Called when an event has occurred.
protected  boolean isObserved()
          Determine if the ContinuousQueryCache has any listeners that cannot be served by this Map listening to lite events.
 boolean isReadOnly()
          Determine if this ContinuousQueryCache disallows data modification operations.
 java.util.Set keySet(Filter filter)
          Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.
 boolean lock(java.lang.Object oKey)
          Attempt to lock the specified item and return immediately.
 boolean lock(java.lang.Object oKey, long cWait)
          Attempt to lock the specified item within the specified period of time.
protected  Filter mergeFilter(Filter filter)
          Return a filter which merges the ContinousQueueCache's filter with the supplied filter.
 java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue)
          Associates the specified value with the specified key in this map.
 java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue, long cMillis)
          Associates the specified value with the specified key in this cache.
 void putAll(java.util.Map map)
          Copies all of the mappings from the specified map to this map.
protected  void registerServiceListener()
          Instantiate and register a MemberListener with the underlying caches's service.
 void release()
          Release local resources associated with this instance of NamedCache.
protected  void releaseIndexMap()
          Release the the entire index map.
 java.lang.Object remove(java.lang.Object oKey)
          Removes the mapping for this key from this map if present.
protected  boolean removeBlind(java.lang.Object oKey)
          Removes the mapping for this key from this map if present.
 void removeIndex(ValueExtractor extractor)
          Remove an index from this QueryMap.
 void removeMapListener(MapListener listener)
          Remove a standard map listener that previously signed up for all events.
 void removeMapListener(MapListener listener, Filter filter)
          Remove a map listener that previously signed up for events based on a filter evaluation.
 void removeMapListener(MapListener listener, java.lang.Object oKey)
          Remove a map listener that previously signed up for events about a specific key.
 void setCacheValues(boolean fCacheValues)
          Modify the local-caching option for the ContinuousQueryCache.
protected  void setObserved(boolean fObserved)
          Specify whether the ContinuousQueryCache has any listeners that cannot be served by this Map listening to lite events.
 void setReadOnly(boolean fReadOnly)
          Modify the read-only option for the ContinuousQueryCache.
 void setReconnectInterval(long cReconnectMillis)
          Specify a reconnection interval (in milliseconds).
protected  void shutdownEventQueue()
          Shut down running event queue.
 boolean unlock(java.lang.Object oKey)
          Unlock the specified item.
protected  void unregisterServiceListener()
          Unregister underlying caches's service member 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 interface com.tangosol.util.ConcurrentMap
containsKey, containsValue, isEmpty, size

 

Field Detail

STATE_INIT

public static final int STATE_INIT
Deprecated. as of Coherence 3.4 this constant is replaced with {link STATE_DISCONNECTED}
State: Initial state. The ContinousQueryCache must be configured or re-configured before it can be used.
See Also:
Constant Field Values

STATE_DISCONNECTED

public static final int STATE_DISCONNECTED
State: Disconnected state. The content of the ContinousQueryCache 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:
Constant Field Values

STATE_CONFIGURING

public static final int STATE_CONFIGURING
State: The ContinuousQueryCache is configuring or re-configuring its listeners and content.
See Also:
Constant Field Values

STATE_CONFIGURED

public static final int STATE_CONFIGURED
State: The ContinousQueryCache has been configured.
See Also:
Constant Field Values

STATE_SYNCHRONIZED

public static final int STATE_SYNCHRONIZED
State: The ContinousQueryCache has been configured and fully synchronized.
See Also:
Constant Field Values

m_ldtConnectionTimestamp

protected volatile long m_ldtConnectionTimestamp
The timestamp when the synchronization was last attempted.

m_listenerService

protected MemberListener m_listenerService
The cache service MemberListener for the underlying NamedCache.

Constructor Detail

ContinuousQueryCache

public ContinuousQueryCache(NamedCache cache,
                            Filter filter)
Create a locally materialized view of a NamedCache using a Filter. A materialized view is an implementation of Continuous Query exposed through the standard NamedCache API. This constructor will result in a ContinuousQueryCache that caches both its keys and values locally.
Parameters:
cache - the NamedCache to create a view of
filter - the filter that defines the view

ContinuousQueryCache

public ContinuousQueryCache(NamedCache cache,
                            Filter filter,
                            boolean fCacheValues)
Create a materialized view of a NamedCache using a Filter. A materialized view is an implementation of Continuous Query exposed through the standard NamedCache API.
Parameters:
cache - the NamedCache to create a view of
filter - the filter that defines the view
fCacheValues - pass true to cache both the keys and values of the materialized view locally, or false to only cache the keys

ContinuousQueryCache

public ContinuousQueryCache(NamedCache cache,
                            Filter filter,
                            MapListener listener)
Create a materialized view of a NamedCache using a Filter. A materialized view is an implementation of Continuous Query exposed through the standard NamedCache API. This constructor allows a client to receive all events, including those that result from the initial population of the ContinuousQueryCache. In other words, all contents of the ContinuousQueryCache will be delivered to the listener as a sequence of events, including those items that already exist in the underlying (unfiltered) cache.
Parameters:
cache - the NamedCache to create a view of
filter - the Filter that defines the view
listener - an initial MapListener that will receive all the events from the ContinuousQueryCache, including those corresponding to its initial population

Method Detail

getCache

public NamedCache getCache()
Obtain the NamedCache that this ContinuousQueryCache is based on.
Returns:
the underlying NamedCache

getFilter

public Filter getFilter()
Obtain the Filter that this ContinuousQueryCache is using to query the underlying NamedCache.
Returns:
the Filter that this cache uses to select its contents from the underlying NamedCache

isCacheValues

public boolean isCacheValues()
Determine if this ContinuousQueryCache caches values locally.
Returns:
true if this object caches values locally, and false if it relies on the underlying NamedCache

setCacheValues

public void setCacheValues(boolean fCacheValues)
Modify the local-caching option for the ContinuousQueryCache. By changing this value from false to true, the ContinuousQueryCache 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, the ContinuousQueryCache will discard its locally cached data and rely on the underlying NamedCache.

This method is not yet implemented.

Parameters:
fCacheValues - pass true to enable local caching, or false to disable it

isReadOnly

public boolean isReadOnly()
Determine if this ContinuousQueryCache disallows data modification operations.
Returns:
true if this ContinuousQueryCache has been configured as read-only

setReadOnly

public void setReadOnly(boolean fReadOnly)
Modify the read-only option for the ContinuousQueryCache. Note that the cache can be made read-only, but the opposite (making it mutable) is explicitly disallowed.
Parameters:
fReadOnly - pass true to prohibit clients from making modifications to this cache

instantiateInternalCache

protected ObservableMap instantiateInternalCache()
Create the internal cache used by the ContinuousQueryCache.
Returns:
a new ObservableMap that will represent the materialized view of the ContinuousQueryCache

getInternalCache

protected ObservableMap getInternalCache()
Obtain a reference to the internal cache. The internal cache maintains all of the keys in the ContinuousQueryCache, and if isCacheValues() 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 the ContinuousQueryCache has any listeners that cannot be served by this Map listening to lite events.
Returns:
true iff there is at least one listener

setObserved

protected void setObserved(boolean fObserved)
Specify whether the ContinuousQueryCache has any listeners that cannot be served by this Map listening to lite events.
Parameters:
fObserved - true iff there is at least one listener

getState

public int getState()
Obtain the state of the ContinousQueryCache.
Returns:
one of the STATE_ enums

changeState

protected void changeState(int nState)
Change the state of the ContinousQueryCache.
Parameters:
nState - one of the STATE_ enums

getReconnectInterval

public long getReconnectInterval()
Return a reconnection interval (in milliseconds). This value indicates how often the ContinuousQueryCache should attempt to re-connect with the underlying [clustered] cache in case the connection is severed.
Returns:
a reconnection interval (in milliseconds)
Since:
Coherence 3.4
See Also:
setReconnectInterval(long)

setReconnectInterval

public void setReconnectInterval(long cReconnectMillis)
Specify a reconnection interval (in milliseconds). This value indicates how often the ContinuousQueryCache should attempt to re-connect with the underlying [clustered] cache in case the connection is severed.
Parameters:
cReconnectMillis - reconnection interval (in milliseconds). The value of zero means that the ContinuousQueryCache cannot be used when not connected. If the value is positive, the local content could be accessed (read-only) even if connection is severed.
Since:
Coherence 3.4

clear

public void clear()
Clear all key/value mappings.
Specified by:
clear in interface ConcurrentMap
Specified by:
clear in interface java.util.Map
Overrides:
clear in class AbstractKeyBasedMap

get

public java.lang.Object get(java.lang.Object oKey)
Returns the value to which this map maps the specified key.
Specified by:
get in interface ConcurrentMap
Specified by:
get in interface java.util.Map
Specified by:
get in class AbstractKeyBasedMap
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:
Map.containsKey(Object)

put

public java.lang.Object put(java.lang.Object oKey,
                            java.lang.Object oValue)
Associates the specified value with the specified key in this map.
Specified by:
put in interface CacheMap
Specified by:
put in interface ConcurrentMap
Specified by:
put in interface java.util.Map
Overrides:
put in class AbstractKeyBasedMap
Parameters:
oKey - key with which the specified value is to be associated
oValue - 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(java.util.Map map)
Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of calling AbstractKeyBasedMap.put(java.lang.Object, java.lang.Object) 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.
Specified by:
putAll in interface ConcurrentMap
Specified by:
putAll in interface java.util.Map
Overrides:
putAll in class AbstractKeyBasedMap
Parameters:
map - the Map containing the key/value pairings to put into this Map

remove

public java.lang.Object remove(java.lang.Object oKey)
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 interface ConcurrentMap
Specified by:
remove in interface java.util.Map
Overrides:
remove in class AbstractKeyBasedMap
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 java.util.Map getAll(java.util.Collection colKeys)
Get all the specified keys, if they are in the Map. For each key that is in the cache, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the cache, which may imply (for caches that can load behind the scenes) that the requested data could not be loaded.
Specified by:
getAll in interface CacheMap
Overrides:
getAll in class AbstractKeyBasedMap
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 java.lang.Object put(java.lang.Object oKey,
                            java.lang.Object oValue,
                            long cMillis)
Associates the specified value with the specified key in this cache. If the cache previously contained a mapping for this key, the old value is replaced. This variation of the CacheMap.put(Object oKey, Object oValue) method allows the caller to specify an expiry (or "time to live") for the cache entry.
Specified by:
put in interface CacheMap
Specified by:
put in interface NamedCache
Parameters:
oKey - key with which the specified value is to be associated
oValue - value to be associated with the specified key
cMillis - the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass CacheMap.EXPIRY_DEFAULT to use the cache's default time-to-live setting; pass CacheMap.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

protected boolean removeBlind(java.lang.Object oKey)
Removes the mapping for this key from this map if present. This method exists to allow sub-classes to optmiize remove functionalitly for situations in which the original value is not required.
Overrides:
removeBlind in class AbstractKeyBasedMap
Parameters:
oKey - key whose mapping is to be removed from the map
Returns:
true iff the Map changed as the result of this operation

getInternalKeySet

protected java.util.Set getInternalKeySet()
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 class AbstractKeySetBasedMap
Returns:
an internal Set of keys that are contained by this Map

addMapListener

public void addMapListener(MapListener 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. This has the same result as the following call:
   addMapListener(listener, (Filter) null, false);
 
Specified by:
addMapListener in interface ObservableMap
Parameters:
listener - the MapEvent listener to add

removeMapListener

public void removeMapListener(MapListener listener)
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 interface ObservableMap
Parameters:
listener - the listener to remove

addMapListener

public void addMapListener(MapListener listener,
                           java.lang.Object oKey,
                           boolean fLite)
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 interface ObservableMap
Parameters:
listener - the MapEvent listener to add
oKey - the key that identifies the entry for which to raise events
fLite - true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizations

removeMapListener

public void removeMapListener(MapListener listener,
                              java.lang.Object oKey)
Remove a map listener that previously signed up for events about a specific key.
Specified by:
removeMapListener in interface ObservableMap
Parameters:
listener - the listener to remove
oKey - the key that identifies the entry for which to raise events

addMapListener

public void addMapListener(MapListener listener,
                           Filter filter,
                           boolean fLite)
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 interface ObservableMap
Parameters:
listener - the MapEvent listener to add
filter - 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 (see MapEventFilter); null is equivalent to a filter that alway returns true
fLite - true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizations

removeMapListener

public void removeMapListener(MapListener listener,
                              Filter filter)
Remove a map listener that previously signed up for events based on a filter evaluation.
Specified by:
removeMapListener in interface ObservableMap
Parameters:
listener - the listener to remove
filter - the filter that was passed into the corresponding addMapListener() call

keySet

public java.util.Set keySet(Filter filter)
Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.

Unlike the Map.keySet() method, the set returned by this method may not be backed by the map, so changes to the set may not reflected in the map, and vice-versa.

Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.

Specified by:
keySet in interface QueryMap
Parameters:
filter - the Filter object representing the criteria that the entries of this map should satisfy
Returns:
a set of keys for entries that satisfy the specified criteria

entrySet

public java.util.Set entrySet(Filter filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is a Map.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: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.

Specified by:
entrySet in interface QueryMap
Parameters:
filter - the Filter object representing the criteria that the entries of this map should satisfy
Returns:
a set of entries that satisfy the specified criteria

entrySet

public java.util.Set entrySet(Filter filter,
                              java.util.Comparator comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is a Map.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 (see Comparable).

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: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.

Specified by:
entrySet in interface QueryMap
Parameters:
filter - the Filter object representing the criteria that the entries of this map should satisfy
comparator - the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used
Returns:
a set of entries that satisfy the specified criteria
See Also:
ChainedComparator

addIndex

public void addIndex(ValueExtractor extractor,
                     boolean fOrdered,
                     java.util.Comparator comparator)
Add an index to this QueryMap. This allows to correlate values stored in this indexed Map (or attributes of those values) to the corresponding keys in the indexed Map and increase the performance of keySet and entrySet methods.

This method is only intended as a hint to the cache implementation, and as such it may be ignored by the cache if indexes are not supported or if the desired index (or a similar index) already exists. It is expected that an application will call this method to suggest an index even if the index may already exist, just so that the application is certain that index has been suggested. For example in a distributed environment, each server will likely suggest the same set of indexes when it starts, and there is no downside to the application blindly requesting those indexes regardless of whether another server has already requested the same indexes.

Note: Indexes are a feature of Coherence Enterprise Edition and Coherence Grid Edition. This method will have no effect when using Coherence Standard Edition.

Specified by:
addIndex in interface QueryMap
Parameters:
extractor - the ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.
fOrdered - true iff the contents of the indexed information should be ordered; false otherwise
comparator - the Comparator object which imposes an ordering on entries in the indexed map; or null if the entries' values natural ordering should be used
See Also:
ReflectionExtractor, ChainedComparator

removeIndex

public void removeIndex(ValueExtractor extractor)
Remove an index from this QueryMap.
Specified by:
removeIndex in interface QueryMap
Parameters:
extractor - the ValueExtractor object that is used to extract an indexable Object from a value stored in the Map.

invoke

public java.lang.Object invoke(java.lang.Object oKey,
                               InvocableMap.EntryProcessor agent)
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.
Specified by:
invoke in interface InvocableMap
Parameters:
oKey - the key to process; it is not required to exist within the Map
agent - the EntryProcessor to use to process the specified key
Returns:
the result of the invocation as returned from the EntryProcessor

invokeAll

public java.util.Map invokeAll(java.util.Collection collKeys,
                               InvocableMap.EntryProcessor agent)
Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.
Specified by:
invokeAll in interface InvocableMap
Parameters:
collKeys - the keys to process; these keys are not required to exist within the Map
agent - the EntryProcessor to use to process the specified keys
Returns:
a Map containing the results of invoking the EntryProcessor against each of the specified keys

invokeAll

public java.util.Map invokeAll(Filter filter,
                               InvocableMap.EntryProcessor agent)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.

Unless specified otherwise, InvocableMap implementations will perform this operation in two steps: (1) use the filter to retrieve a matching entry set; (2) apply the agent to every filtered entry. This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads. If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the ConditionalProcessor.

Specified by:
invokeAll in interface InvocableMap
Parameters:
filter - a Filter that results in the set of keys to be processed
agent - the EntryProcessor to use to process the specified keys
Returns:
a Map containing the results of invoking the EntryProcessor against the keys that are selected by the given Filter

aggregate

public java.lang.Object aggregate(java.util.Collection collKeys,
                                  InvocableMap.EntryAggregator agent)
Perform an aggregating operation against the entries specified by the passed keys.
Specified by:
aggregate in interface InvocableMap
Parameters:
collKeys - the Collection of keys that specify the entries within this Map to aggregate across
agent - the EntryAggregator that is used to aggregate across the specified entries of this Map
Returns:
the result of the aggregation

aggregate

public java.lang.Object aggregate(Filter filter,
                                  InvocableMap.EntryAggregator agent)
Perform an aggregating operation against the set of entries that are selected by the given Filter.
Specified by:
aggregate in interface InvocableMap
Parameters:
filter - the Filter that is used to select entries within this Map to aggregate across
agent - the EntryAggregator that is used to aggregate across the selected entries of this Map
Returns:
the result of the aggregation

lock

public boolean lock(java.lang.Object oKey,
                    long cWait)
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 interface ConcurrentMap
Parameters:
oKey - key being locked
cWait - 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(java.lang.Object oKey)
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 interface ConcurrentMap
Parameters:
oKey - key being locked
Returns:
true if the item was successfully locked; false otherwise

unlock

public boolean unlock(java.lang.Object oKey)
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 interface ConcurrentMap
Parameters:
oKey - key being unlocked
Returns:
true if the item was successfully unlocked; false otherwise

getCacheName

public java.lang.String getCacheName()
Return the cache name.
Specified by:
getCacheName in interface NamedCache
Returns:
the cache name

getCacheService

public CacheService getCacheService()
Return the CacheService that this NamedCache is a part of.
Specified by:
getCacheService in interface NamedCache
Returns:
the CacheService

isActive

public boolean isActive()
Specifies whether or not the NamedCache is active.
Specified by:
isActive in interface NamedCache
Returns:
true if the NamedCache is active; false otherwise

release

public void release()
Release local resources associated with this instance of NamedCache.

Releasing a cache makes it no longer usable, but does not affect the cache itself. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference. Any attempt to use this reference afterward will result in an exception.

Caches should be released by the same mechanism in which they were obtained. For example:

Except for the case where the application code explicitly allocated the cache, this method should not be called by application code.

The purpose for releasing a cache is to allow the cache implementation to release the ClassLoader used to deserialize items in the cache. The cache implementation ensures that all references to that ClassLoader are released. This implies that objects in the cache that were loaded by that ClassLoader will be re-serialized to release their hold on that ClassLoader. The result is that the ClassLoader can be garbage-collected by Java in situations where the cache is operating in an application server and applications are dynamically loaded and unloaded.

Specified by:
release in interface NamedCache
See Also:
CacheFactory.releaseCache(NamedCache), ConfigurableCacheFactory.releaseCache(NamedCache)

destroy

public void destroy()
Release and destroy this instance of NamedCache.

Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all internal resources will be released.

Caches should be destroyed by the same mechansim in which they were obtained. For example:

Except for the case where the application code expicitly allocated the cache, this method should not be called by application code.
Specified by:
destroy in interface NamedCache
See Also:
CacheFactory.destroyCache(NamedCache), ConfigurableCacheFactory.destroyCache(NamedCache)

mergeFilter

protected Filter mergeFilter(Filter filter)
Return a filter which merges the ContinousQueueCache's filter with the supplied filter.
Parameters:
filter - the filter to merge with this cache's filter
Returns:
the merged filter

checkReadOnly

protected void checkReadOnly()
Check the read-only setting to verify that the cache is NOT read-only.
Throws:
java.lang.IllegalStateException - if the ContinuousQueryCache is read-only

checkEntry

protected void checkEntry(java.util.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:
java.lang.IllegalArgumentException - if the entry does not belong in this ContinuousQueryCache (based on the cache's filter)

checkEntry

protected void checkEntry(java.lang.Object oKey,
                          java.lang.Object oValue)
Check the passed value to verify that it does belong in this ContinuousQueryCache.
Parameters:
oKey - the key for the entry
oValue - the value for the entry
Throws:
java.lang.IllegalArgumentException - if the entry does not belong in this ContinuousQueryCache (based on the cache's filter)

configureSynchronization

protected void configureSynchronization(boolean fReload)
Set up the listeners that keep the ContinuousQueryCache up-to-date.
Parameters:
fReload - pass true to force a data reload

ensureSynchronized

protected void ensureSynchronized(boolean fReload)
Ensure that the ContinousQueryCache listeners have been registered and its content synchronized with the underlying NamedCache.
Parameters:
fReload - the value to pass to the #configureSynchronization method if the ContinousQueryCache needs to be configured and synchronized

isEventDeferred

protected boolean isEventDeferred(java.lang.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 the ContinuousQueryCache.
Parameters:
oKey - the key that the event is related to
Returns:
true if the event processing has been deferred

ensureIndexMap

protected java.util.Map ensureIndexMap()
Ensure that the map of indexes maintaned by this cache exists.
Returns:
the map of indexes.

getIndexMap

protected java.util.Map getIndexMap()
Get the map of indexes maintaned by this cache.
Returns:
the map of indexes.

releaseIndexMap

protected void releaseIndexMap()
Release the the entire index map.

instantiateAddListener

protected MapListener instantiateAddListener()
Factory Method: Instantiate a MapListener for adding items to the ContinuousQueryCache, and (if there are listeners on the ContinuousQueryCache) for dispatching inserts and updates.
Returns:
a new MapListener that will add items to and update items in the ContinuousQueryCache

instantiateRemoveListener

protected MapListener instantiateRemoveListener()
Factory Method: Instantiate a MapListener for evicting items from the ContinuousQueryCache.
Returns:
a new MapListener that will listen to all events that will remove items from the ContinuousQueryCache

registerServiceListener

protected void registerServiceListener()
Instantiate and register a MemberListener with the underlying caches's 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 caches's service member listener.

instantiateEventRouter

protected ContinuousQueryCache.EventRouter instantiateEventRouter(MapListener listener)
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 - the listener to route to
Returns:
a new EventRouter specific to the passed listener

instantiateEventQueue

protected TaskDaemon instantiateEventQueue()
Create a self-processing event queue.
Returns:
a TaskDaemon onto which events can be placed in order to be dispatched asynchronously

getEventQueue

protected TaskDaemon getEventQueue()
Obtain this ContinuousQueryCache's event queue.
Returns:
the event queue that this ContinuousQueryCache uses 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 ContinuousQueryCache uses to dispatch its events to its non-synchronous listeners

shutdownEventQueue

protected void shutdownEventQueue()
Shut down running event queue.

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.1.0

E18814-01


Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.