|
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.Objectjava.util.AbstractMap
com.tangosol.net.cache.ReadWriteBackingMap
public class ReadWriteBackingMap
Backing Map implementation that provides a size-limited cache of a persistent store and supports configurable write-behind and refresh- ahead caching. This implementation is not intended to support null keys or null values.
Nested Class Summary | |
---|---|
class |
ReadWriteBackingMap.CacheLoaderCacheStore
A CacheStore wrapped around a CacheLoader. |
class |
ReadWriteBackingMap.CacheStoreWrapper
A wrapper around the original CacheStore to allow operations to be overridden and extended. |
protected class |
ReadWriteBackingMap.EntrySet
A set of entries corresponding to this backing map. |
protected class |
ReadWriteBackingMap.InternalMapListener
A MapListener implementation that listens to the internal cache and routes those events to anyone listening to this ReadWriteBackingMap. |
protected class |
ReadWriteBackingMap.KeySet
A set of entries backed by this backing map. |
protected class |
ReadWriteBackingMap.ReadLatch
A synchronization construct used to coordinate asynchronous loads by the refresh-ahead thread with cache accesses by other threads. |
class |
ReadWriteBackingMap.ReadQueue
A queue of keys that should be read from the underlying CacheStore. |
class |
ReadWriteBackingMap.ReadThread
A thread that removes keys from a ReadWriteBackingMap.ReadQueue , reads the value
for the key from the underlying CacheStore, and caches the
value in the internal ReadWriteBackingMap cache. |
protected class |
ReadWriteBackingMap.ValuesCollection
A collection of values backed by this map. |
class |
ReadWriteBackingMap.WriteQueue
A queue that only releases entries after a configurable period of time. |
class |
ReadWriteBackingMap.WriteThread
This is the write-behind thread that pulls things from the write-behind queue and writes them to the CacheStore that the backing map uses. |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry |
Field Summary | |
---|---|
protected MapListenerSupport |
m_listenerSupport
MapListenerSupport object. |
protected static Object |
NO_VALUE
Marker object used to indicate to the write-behind thread that an entry has been removed from the queue. |
Constructor Summary | |
---|---|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
CacheLoader loader)
Construct a ReadWriteBackingMap using a CacheLoader object. |
|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
CacheStore store,
boolean fReadOnly,
int cWriteBehindSeconds)
Construct a ReadWriteBackingMap. |
|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
CacheStore store,
boolean fReadOnly,
int cWriteBehindSeconds,
double dflRefreshAheadFactor)
Construct a ReadWriteBackingMap. |
Method Summary | |
---|---|
void |
addMapListener(MapListener listener)
Add a standard map listener. |
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. |
void |
clear()
Remove everything from the Map. |
protected void |
configureCacheStore(CacheStore store,
boolean fReadOnly)
Set up the CacheStore that this backing map will use. |
protected void |
configureInternalCache(ObservableMap mapInternal)
Configure the internal cache that this backing map uses to store its "in-memory" data. |
protected void |
configureReadThread(double dflRefreshAheadFactor)
Set up the optional refresh-ahead thread and queue that this backing map will use. |
protected void |
configureWriteThread(int cWriteBehindSeconds)
Set up the optional write-behind thread and queue that this backing map will use. |
boolean |
containsKey(Object oKey)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object oValue)
Returns true if this CachingMap maps one or more keys to the specified value. |
Set |
entrySet()
Returns an set view of the mappings contained in this map. |
boolean |
equals(Object o)
Compares the specified object with this map for equality. |
void |
flush()
Flush the write-behind queue, writing everything immediately. |
protected void |
flush(ReadWriteBackingMap.WriteQueue queue,
ReadWriteBackingMap.CacheStoreWrapper store)
Flush the write-behind queue, writing everything immediately. |
Object |
get(Object oKey)
Returns the value to which this map maps the specified key. |
ReadWriteBackingMap.CacheStoreWrapper |
getCacheStore()
Get the representative of the "persistent" storage for this backing map. |
BackingMapManagerContext |
getContext()
Get the context information provided by the CacheService. |
ConcurrentMap |
getControlMap()
Get the concurrency control map for this backing map. |
ObservableMap |
getInternalCache()
Get the representative of the "in-memory" storage for this backing map. |
protected MapListener |
getInternalListener()
Obtain the MapListener that listens to the internal cache and routes those events to anyone listening to this ReadWriteBackingMap, creating such a listener if one does not already exist. |
protected LocalCache |
getInternalLocalCache()
Get the LocalCache for this backing map. |
Map |
getMissesCache()
Get the optional map used to cache CacheLoader (or CacheStore) misses. |
ReadWriteBackingMap.ReadQueue |
getReadQueue()
Get the queue of keys that are yet to be read. |
protected ReadWriteBackingMap.ReadThread |
getReadThread()
Get the refresh-ahead thread. |
double |
getRefreshAheadFactor()
Return the refresh-ahead factor. |
protected Map |
getSyntheticEventsMap()
Get the map of keys for which the events should be marked as synthetic (internal). |
double |
getWriteBatchFactor()
Return the write-batch factor. |
int |
getWriteBehindSeconds()
Return the number of seconds between write-behind writes to the CacheStore or 0 if write-behind is not enabled. |
ReadWriteBackingMap.WriteQueue |
getWriteQueue()
Get the queue of entries that are yet to be written. |
int |
getWriteRequeueThreshold()
Return the maximum size of the write-behind queue for which failed CacheStore write operations are requeued or 0 if write-behind requeueing is disabled. |
protected ReadWriteBackingMap.WriteThread |
getWriteThread()
Get the write-behind thread. |
int |
hashCode()
Returns the hash code value for this map. |
protected ReadWriteBackingMap.CacheLoaderCacheStore |
instantiateCacheLoaderCacheStore(CacheLoader loader)
Factory pattern: Instantiate a CacheLoaderCacheStore wrapper around a passed CacheLoader. |
protected ReadWriteBackingMap.CacheStoreWrapper |
instantiateCacheStoreWrapper(CacheStore store)
Factory pattern: Instantiate a CacheStore wrapper around the passed CacheStore. |
protected ConcurrentMap |
instantiateControlMap()
Factory pattern: Create the concurrency control map for this backing map. |
protected ReadWriteBackingMap.EntrySet |
instantiateEntrySet()
Factory pattern: instantiate an entry set for this backing map. |
protected MapListener |
instantiateInternalListener()
Factory pattern: Create a MapListener that listens to the internal cache and routes those events to anyone listening to this ReadWriteBackingMap. |
protected ReadWriteBackingMap.KeySet |
instantiateKeySet()
Factory pattern: instantiate a key set for this backing map. |
protected ReadWriteBackingMap.ReadLatch |
instantiateReadLatch(Object oKey)
Factory pattern: Instantiate a new read latch the given key. |
protected ReadWriteBackingMap.ReadQueue |
instantiateReadQueue()
Factory pattern: Instantiate a new ReadQueue object. |
protected ReadWriteBackingMap.ReadThread |
instantiateReadThread()
Factory pattern: Instantiate the refresh-ahead thread. |
protected ReadWriteBackingMap.ValuesCollection |
instantiateValuesCollection()
Factory pattern. |
protected ReadWriteBackingMap.WriteQueue |
instantiateWriteQueue()
Factory pattern: Instantiate a new WriteQueue object. |
protected ReadWriteBackingMap.WriteThread |
instantiateWriteThread()
Factory pattern: Instantiate the write-behind thread. |
boolean |
isActive()
Determine if the backing map is still active. |
boolean |
isReadOnly()
Determine if the backing map should send data changes through the CacheStore, or should just keep them in memory. |
boolean |
isRefreshAhead()
Determine if the backing map preemptively reads soon-to-be expired entries on a refresh-ahead thread. |
boolean |
isRethrowExceptions()
Determine if exceptions caught during synchronous CacheStore operations are rethrown to the calling thread; if false, exceptions are logged. |
boolean |
isWriteBehind()
Determine if the backing map writes changes on a write-behind thread through the CacheStore. |
boolean |
isWriteThrough()
Determine if the backing map writes changes immediately through the CacheStore. |
Set |
keySet()
Returns an set view of the keys contained in this map. |
Object |
put(Object oKey,
Object oValue)
Associates the specified value with the specified key in this map. |
void |
release()
Release the backing map when it is no longer being used. |
Object |
remove(Object oKey)
Removes the mapping for this key from this map if present. |
void |
removeMapListener(MapListener listener)
Remove a standard map listener. |
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 |
setRefreshAheadFactor(double dflRefreshAheadFactor)
Set the refresh-ahead factor, expressed as a percentage of the internal LocalCache expiration interval. |
void |
setRethrowExceptions(boolean fRethrow)
Set the value of the flag that determines if exceptions caught during synchronous CacheStore operations are rethrown to the calling thread; if false, exceptions are logged. |
void |
setWriteBatchFactor(double dflWriteBatchFactor)
Set the write-batch factor, expressed as a percentage of the write-behind interval. |
void |
setWriteBehindSeconds(int cSecs)
Set the number of seconds between write-behind writes to the CacheStore. |
void |
setWriteRequeueThreshold(int cThreshold)
Set the maximum size of the write-behind queue for which failed CacheStore write operations are requeued. |
int |
size()
Returns the number of key-value mappings in this map. |
protected void |
terminateReadThread()
Terminate the refresh-ahead thread. |
protected void |
terminateWriteThread()
Terminate the write-behind thread. |
String |
toString()
For debugging purposes, format the contents of the Map in a human- readable format. |
protected void |
updateOnGet(Map.Entry entryReal)
Deprecated. as of Coherence 3.2 this method is never called |
protected void |
updateOnPut(Map.Entry entryReal)
Deprecated. as of Coherence 3.2 this method is never called |
Collection |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.util.AbstractMap |
---|
clone, isEmpty, putAll |
Methods inherited from interface java.util.Map |
---|
isEmpty, putAll |
Field Detail |
---|
protected static final Object NO_VALUE
protected MapListenerSupport m_listenerSupport
Constructor Detail |
---|
public ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheLoader loader)
ctxService
- the context provided by the CacheService
which is using this backing mapmapInternal
- the ObservableMap used to store the data
internally in this backing mapmapMisses
- the Map used to cache CacheLoader misses
(optional)loader
- the CacheLoader object to use (optional)public ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheStore store, boolean fReadOnly, int cWriteBehindSeconds)
ctxService
- the context provided by the CacheService
which is using this backing mapmapInternal
- the ObservableMap used to store the data
internally in this backing mapmapMisses
- the Map used to cache CacheStore misses
(optional)store
- the object responsible for the persistence
of the cached data (optional)fReadOnly
- pass true to use the CacheStore only for
read operations; changes to the cache will
not be persistedcWriteBehindSeconds
- number of seconds to write if there is a
CacheStore; zero disables write-behind
caching, which (combined with !fReadOnly)
implies write-throughpublic ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheStore store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor)
ctxService
- the context provided by the CacheService
which is using this backing mapmapInternal
- the ObservableMap used to store the data
internally in this backing mapmapMisses
- the Map used to cache CacheStore misses
(optional)store
- the object responsible for the persistence
of the cached data (optional)fReadOnly
- pass true to use the CacheStore only for
read operations; changes to the cache will
not be persistedcWriteBehindSeconds
- number of seconds to write if there is a
CacheStore; zero disables write-behind
caching, which (combined with !fReadOnly)
implies write-throughdflRefreshAheadFactor
- the interval before an entry expiration time
(expressed as a percentage of the internal
cache expiration interval) during which an
asynchronous load request for the
entry will be scheduled; zero disables
refresh-ahead; only applicable when
the mapInternal parameter is an
instance of LocalCache
Method Detail |
---|
public BackingMapManagerContext getContext()
public boolean isRethrowExceptions()
public void setRethrowExceptions(boolean fRethrow)
fRethrow
- true to indicate that exceptions should be rethrownpublic double getRefreshAheadFactor()
public void setRefreshAheadFactor(double dflRefreshAheadFactor)
dflRefreshAheadFactor
- the new refresh-ahead factorgetRefreshAheadFactor()
public boolean isReadOnly()
public boolean isRefreshAhead()
public double getWriteBatchFactor()
D' = (1.0 - F)*Dwhere:
D = write-behind delay F = write-batch factorConceptually, the write-behind thread uses the following logic when performing a batched update:
store()
(if there is only the single ripe
entry) or storeAll()
(if there are
multiple ripe/soft-ripe entries).storeAll()
method.
The value of this property is expressed as a percentage of the
write-behind
interval. Valid values are
doubles in the interval [0.0, 1.0].
public void setWriteBatchFactor(double dflWriteBatchFactor)
dflWriteBatchFactor
- the new write-batch factorgetWriteBatchFactor()
public boolean isWriteBehind()
public int getWriteBehindSeconds()
public void setWriteBehindSeconds(int cSecs)
cSecs
- the new write-behind delay in secondspublic int getWriteRequeueThreshold()
public void setWriteRequeueThreshold(int cThreshold)
cThreshold
- the new write-behind requeue thresholdpublic boolean isWriteThrough()
public void clear()
clear
in interface Map
clear
in class AbstractMap
public boolean containsKey(Object oKey)
containsKey
in interface Map
containsKey
in class AbstractMap
oKey
- the key to test for
public boolean containsValue(Object oValue)
containsValue
in interface Map
containsValue
in class AbstractMap
oValue
- the value to test for
public Object get(Object oKey)
get
in interface Map
get
in class AbstractMap
oKey
- the key object
public Object put(Object oKey, Object oValue)
put
in interface Map
put
in class AbstractMap
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key
public Object remove(Object oKey)
remove
in interface Map
remove
in class AbstractMap
oKey
- key whose mapping is to be removed from the map
public int size()
size
in interface Map
size
in class AbstractMap
public Set entrySet()
entrySet
in interface Map
entrySet
in class AbstractMap
public Set keySet()
keySet
in interface Map
keySet
in class AbstractMap
public Collection values()
values
in interface Map
values
in class AbstractMap
protected void updateOnGet(Map.Entry entryReal)
protected void updateOnPut(Map.Entry entryReal)
protected ReadWriteBackingMap.EntrySet instantiateEntrySet()
protected ReadWriteBackingMap.KeySet instantiateKeySet()
protected ReadWriteBackingMap.ValuesCollection instantiateValuesCollection()
public void addMapListener(MapListener listener)
addMapListener
in interface ObservableMap
listener
- the MapEvent
listener to addpublic void removeMapListener(MapListener listener)
removeMapListener
in interface ObservableMap
listener
- the listener to removepublic void addMapListener(MapListener listener, Object oKey, boolean fLite)
addMapListener
in interface ObservableMap
listener
- the 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)
addMapListener
in interface ObservableMap
listener
- the 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; 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
- a filter used to evaluate eventspublic boolean equals(Object o)
equals
in interface Map
equals
in class AbstractMap
o
- object to be compared for equality with this map
public int hashCode()
hashCode
in interface Map
hashCode
in class AbstractMap
public String toString()
toString
in class AbstractMap
public ObservableMap getInternalCache()
protected LocalCache getInternalLocalCache()
getInternalCache()
;
otherwise, it returns null.
protected void configureInternalCache(ObservableMap mapInternal)
public Map getMissesCache()
public ConcurrentMap getControlMap()
protected ConcurrentMap instantiateControlMap()
protected Map getSyntheticEventsMap()
protected MapListener getInternalListener()
protected MapListener instantiateInternalListener()
public void release()
public boolean isActive()
protected ReadWriteBackingMap.ReadLatch instantiateReadLatch(Object oKey)
public ReadWriteBackingMap.ReadQueue getReadQueue()
protected ReadWriteBackingMap.ReadQueue instantiateReadQueue()
public ReadWriteBackingMap.WriteQueue getWriteQueue()
public void flush()
protected void flush(ReadWriteBackingMap.WriteQueue queue, ReadWriteBackingMap.CacheStoreWrapper store)
queue
- the write-behind queue to flushstore
- the CacheStore to flush toprotected ReadWriteBackingMap.WriteQueue instantiateWriteQueue()
protected ReadWriteBackingMap.ReadThread getReadThread()
protected void configureReadThread(double dflRefreshAheadFactor)
getInternalLocalCache()
is null or
non-expiring.
dflRefreshAheadFactor
- the refresh-ahead factor expressed as a
percentage of the internal cache expiryprotected ReadWriteBackingMap.ReadThread instantiateReadThread()
protected void terminateReadThread()
protected ReadWriteBackingMap.WriteThread getWriteThread()
protected void configureWriteThread(int cWriteBehindSeconds)
isReadOnly()
returns true.
cWriteBehindSeconds
- write-behind delayprotected ReadWriteBackingMap.WriteThread instantiateWriteThread()
protected void terminateWriteThread()
public ReadWriteBackingMap.CacheStoreWrapper getCacheStore()
protected void configureCacheStore(CacheStore store, boolean fReadOnly)
store
- the CacheStore that this backing map will delegate
persistence responsibilities tofReadOnly
- pass true to prevent the usage of the CacheStore
write operationsprotected ReadWriteBackingMap.CacheStoreWrapper instantiateCacheStoreWrapper(CacheStore store)
store
- the CacheStore to wrap
protected ReadWriteBackingMap.CacheLoaderCacheStore instantiateCacheLoaderCacheStore(CacheLoader loader)
loader
- the CacheLoader to wrap
|
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 |