|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
com.tangosol.util.AbstractKeySetBasedMap
com.tangosol.net.cache.ContinuousQueryCache
public class ContinuousQueryCache
Create a materialized view of a NamedCache using the Coherence Continuous Query capability.
Nested Class Summary | |
---|---|
class |
ContinuousQueryCache.AddListener
A MapListener for evicting items from the query. |
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 query. |
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 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_INIT
State: Initial state. |
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,
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,
Object oKey,
boolean fLite)
Add a map listener for a specific key. |
Object |
aggregate(Collection collKeys,
InvocableMap.EntryAggregator agent)
Perform an aggregating operation against the entries specified by the passed keys. |
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(Map.Entry entry)
Check the passed value to verify that it does belong in this ContinuousQueryCache. |
protected void |
checkEntry(Object oKey,
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 void |
ensureSynchronized(boolean fReload)
Ensure that the ContinousQueryCache listeners have been registered and its content synchronized with the underlying NamedCache. |
Set |
entrySet(Filter filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. |
Set |
entrySet(Filter filter,
Comparator comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. |
Object |
get(Object oKey)
Returns the value to which this map maps the specified key. |
Map |
getAll(Collection colKeys)
Get all the specified keys, if they are in the Map. |
NamedCache |
getCache()
Obtain the NamedCache that this ContinuousQueryCache is based on. |
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 ObservableMap |
getInternalCache()
Obtain a reference to the internal cache. |
protected Set |
getInternalKeySet()
Obtain a set of keys that are represented by this Map. |
int |
getState()
Obtain the state of the ContinousQueryCache. |
protected MapListener |
instantiateAddListener()
Factory Method: Instantiate a MapListener for adding items to the query, 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 MapListener |
instantiateRemoveListener()
Factory Method: Instantiate a MapListener for evicting items from the query. |
Object |
invoke(Object oKey,
InvocableMap.EntryProcessor agent)
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation. |
Map |
invokeAll(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. |
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(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. |
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(Object oKey)
Attempt to lock the specified item and return immediately. |
boolean |
lock(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. |
Object |
put(Object oKey,
Object oValue)
Associates the specified value with the specified key in this map. |
Object |
put(Object oKey,
Object oValue,
long cMillis)
Associates the specified value with the specified key in this cache. |
void |
putAll(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. |
Object |
remove(Object oKey)
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. |
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,
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. |
boolean |
unlock(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 |
---|
public static final int STATE_INIT
public static final int STATE_CONFIGURING
public static final int STATE_CONFIGURED
public static final int STATE_SYNCHRONIZED
protected MemberListener m_listenerService
Constructor Detail |
---|
public ContinuousQueryCache(NamedCache cache, Filter filter)
cache
- the NamedCache to create a view offilter
- the filter that defines the viewpublic ContinuousQueryCache(NamedCache cache, Filter filter, boolean fCacheValues)
cache
- the NamedCache to create a view offilter
- the filter that defines the viewfCacheValues
- pass true to cache both the keys and values of the
materialized view locally, or false to only cache
the keyspublic ContinuousQueryCache(NamedCache cache, Filter filter, MapListener listener)
cache
- the NamedCache to create a view offilter
- the Filter that defines the viewlistener
- an initial MapListener that will receive all the
events from the ContinuousQueryCache, including those
corresponding to its initial populationMethod Detail |
---|
public NamedCache getCache()
public Filter getFilter()
Filter
that this cache uses to select its contents
from the underlying NamedCachepublic boolean isCacheValues()
public void setCacheValues(boolean fCacheValues)
fCacheValues
- pass true to enable local caching, or false to
disable itpublic boolean isReadOnly()
public void setReadOnly(boolean fReadOnly)
fReadOnly
- pass true to prohibit clients from making
modifications to this cacheprotected ObservableMap getInternalCache()
isCacheValues()
is true, it also maintains the up-to-date
values corresponding to those keys.
protected boolean isObserved()
protected void setObserved(boolean fObserved)
fObserved
- true iff there is at least one listenerpublic int getState()
protected void changeState(int nState)
nState
- one of the STATE_ enumspublic void clear()
clear
in interface ConcurrentMap
clear
in interface Map
clear
in class AbstractKeyBasedMap
public Object get(Object oKey)
get
in interface ConcurrentMap
get
in interface Map
get
in class AbstractKeyBasedMap
oKey
- the key object
ConcurrentMap.containsKey(Object)
public Object put(Object oKey, Object oValue)
put
in interface CacheMap
put
in interface ConcurrentMap
put
in interface Map
put
in class AbstractKeyBasedMap
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key
public void putAll(Map map)
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.
putAll
in interface ConcurrentMap
putAll
in interface Map
putAll
in class AbstractKeyBasedMap
map
- the Map containing the key/value pairings to put into this
Mappublic Object remove(Object oKey)
remove
in interface ConcurrentMap
remove
in interface Map
remove
in class AbstractKeyBasedMap
oKey
- key whose mapping is to be removed from the map
public Map getAll(Collection colKeys)
getAll
in interface CacheMap
getAll
in class AbstractKeyBasedMap
colKeys
- a collection of keys that may be in the named cache
public Object put(Object oKey, Object oValue, long cMillis)
CacheMap.put(Object oKey, Object oValue)
method allows the caller to specify an expiry (or "time to live")
for the cache entry.
put
in interface CacheMap
put
in interface NamedCache
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";
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()
protected boolean removeBlind(Object oKey)
removeBlind
in class AbstractKeyBasedMap
oKey
- key whose mapping is to be removed from the map
protected Set getInternalKeySet()
getInternalKeySet
in class AbstractKeySetBasedMap
public void addMapListener(MapListener listener)
addMapListener(listener, (Filter) null, false);
addMapListener
in interface ObservableMap
listener
- the MapEvent
listener to addpublic void removeMapListener(MapListener listener)
removeMapListener(listener, (Filter) null);
removeMapListener
in interface ObservableMap
listener
- the listener to removepublic void addMapListener(MapListener listener, Object oKey, boolean fLite)
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.
addMapListener
in interface ObservableMap
listener
- the MapEvent
listener to addoKey
- the key that identifies the entry for which to raise
eventsfLite
- true to indicate that the MapEvent
objects do
not have to include the OldValue and NewValue
property values in order to allow optimizationspublic void removeMapListener(MapListener listener, Object oKey)
removeMapListener
in interface ObservableMap
listener
- the listener to removeoKey
- the key that identifies the entry for which to raise
eventspublic void addMapListener(MapListener listener, Filter filter, boolean fLite)
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.
addMapListener
in interface ObservableMap
listener
- the MapEvent
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 (see
MapEventFilter
);
null is equivalent to a filter that alway returns truefLite
- true to indicate that the MapEvent
objects do
not have to include the OldValue and NewValue
property values in order to allow optimizationspublic void removeMapListener(MapListener listener, Filter filter)
removeMapListener
in interface ObservableMap
listener
- the listener to removefilter
- the filter that was passed into the corresponding
addMapListener() callpublic Set keySet(Filter filter)
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.
keySet
in interface QueryMap
filter
- the Filter object representing the criteria that
the entries of this map should satisfy
public Set entrySet(Filter filter)
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.
entrySet
in interface QueryMap
filter
- the Filter object representing the criteria that
the entries of this map should satisfy
public Set entrySet(Filter filter, Comparator comparator)
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.
entrySet
in interface QueryMap
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
ChainedComparator
public void addIndex(ValueExtractor extractor, boolean fOrdered, Comparator comparator)
addIndex
in interface QueryMap
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
usedReflectionExtractor
,
ChainedComparator
public void removeIndex(ValueExtractor extractor)
removeIndex
in interface QueryMap
extractor
- the ValueExtractor object that is used to extract an
indexable Object from a value stored in the Map.public Object invoke(Object oKey, InvocableMap.EntryProcessor agent)
invoke
in interface InvocableMap
oKey
- the key to process; it is not required to exist within
the Mapagent
- the EntryProcessor to use to process the specified key
public Map invokeAll(Collection collKeys, InvocableMap.EntryProcessor agent)
invokeAll
in interface InvocableMap
collKeys
- the keys to process; these keys are not required to
exist within the Mapagent
- the EntryProcessor to use to process the specified keys
public Map invokeAll(Filter filter, InvocableMap.EntryProcessor agent)
ConditionalProcessor
.
invokeAll
in interface InvocableMap
filter
- a Filter that results in the set of keys to be processedagent
- the EntryProcessor to use to process the specified keys
public Object aggregate(Collection collKeys, InvocableMap.EntryAggregator agent)
aggregate
in interface InvocableMap
collKeys
- the Collection of keys that specify the entries within
this Map to aggregate acrossagent
- the EntryAggregator that is used to aggregate across
the specified entries of this Map
public Object aggregate(Filter filter, InvocableMap.EntryAggregator agent)
aggregate
in interface InvocableMap
filter
- the Filter that is used to select entries within this
Map to aggregate acrossagent
- the EntryAggregator that is used to aggregate across
the selected entries of this Map
public boolean lock(Object oKey, long cWait)
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.
lock
in interface ConcurrentMap
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
public boolean lock(Object oKey)
This method behaves exactly as if it simply performs the call lock(oKey, 0).
lock
in interface ConcurrentMap
oKey
- key being locked
public boolean unlock(Object oKey)
unlock
in interface ConcurrentMap
oKey
- key being unlocked
public String getCacheName()
getCacheName
in interface NamedCache
public CacheService getCacheService()
getCacheService
in interface NamedCache
public boolean isActive()
isActive
in interface NamedCache
public void release()
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 afterword will result in an exception.
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.
release
in interface NamedCache
CacheService.releaseCache(NamedCache)
public void destroy()
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 resources will be released.
destroy
in interface NamedCache
CacheService.destroyCache(NamedCache)
protected Filter mergeFilter(Filter filter)
filter
- the filter to merge with this cache's filter
protected void checkReadOnly()
IllegalStateException
- if the ContinuousQueryCache is read-onlyprotected void checkEntry(Map.Entry entry)
entry
- a key value pair to check.
IllegalArgumentException
- if the entry does not belong in this
ContinuousQueryCache (based on the cache's filter)protected void checkEntry(Object oKey, Object oValue)
oKey
- the key for the entryoValue
- the value for the entry
IllegalArgumentException
- if the entry does not belong in this
ContinuousQueryCache (based on the cache's filter)protected void configureSynchronization(boolean fReload)
fReload
- pass true to force a data reloadprotected void ensureSynchronized(boolean fReload)
fReload
- the value to pass to the #configureSynchronization
method if the ContinousQueryCache needs to be
configured and synchronizedprotected boolean isEventDeferred(Object oKey)
oKey
- the key that the event is related to
protected MapListener instantiateAddListener()
protected MapListener instantiateRemoveListener()
protected void registerServiceListener()
The primary goal of that listener is invalidation of the front map in case of the service [automatic] restart.
protected void unregisterServiceListener()
protected ContinuousQueryCache.EventRouter instantiateEventRouter(MapListener listener)
listener
- the listener to route to
protected TaskDaemon instantiateEventQueue()
protected TaskDaemon getEventQueue()
protected TaskDaemon ensureEventQueue()
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |