public class ReadWriteBackingMap extends AbstractMap implements CacheMap
Modifier and Type | Class and Description |
---|---|
class |
ReadWriteBackingMap.BinaryEntryStoreWrapper
A wrapper around the original BinaryEntryStore to allow operations to be
overridden and extended.
|
static 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.
|
class |
ReadWriteBackingMap.Entry
A queue entry that is scheduled to come out of the front of the
queue no earlier than some specific point in time.
|
protected class |
ReadWriteBackingMap.EntrySet
A set of entries corresponding to this backing map.
|
static class |
ReadWriteBackingMap.EvictingBackupMap
A Map implementation used for a backup map that evicts all data that
has been successfully written.
|
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 static 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. |
class |
ReadWriteBackingMap.StoreWrapper
Abstract wrapper around a cache store to allow operations to be
overridden and extended.
|
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.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
static Binary |
BIN_ERASE_PENDING
Binary representation of a decorated null for write-behind remove.
|
protected static Binary |
BIN_STORE_PENDING
The binary form of the decoration indicating that the CacheStore
on the primary member has not yet written the value.
|
protected static float |
GUARD_RECOVERY
The recovery threshold to use for guarded execution of
write-behind/refresh-ahead threads.
|
protected MapListenerSupport |
m_listenerSupport
MapListenerSupport object.
|
static long |
MIN_REQUEUE_DELAY
The minimum "retry after requeue" time interval.
|
static String |
PROP_WB_REMOVE_DEFAULT
A Boolean system property to control whether write behind remove is enabled.
|
protected static Binary |
REMOVED
Marker object used by
ReadWriteBackingMap.Entry to indicate remove was called on the Entry. |
static boolean |
RWBM_WB_REMOVE_DEFAULT
The default write behind remove behavior.
|
EXPIRY_DEFAULT, EXPIRY_NEVER
Constructor and Description |
---|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
BinaryEntryStore storeBinary,
boolean fReadOnly,
int cWriteBehindSeconds,
double dflRefreshAheadFactor)
Construct a ReadWriteBackingMap based on a BinaryEntryStore.
|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
BinaryEntryStore storeBinary,
boolean fReadOnly,
int cWriteBehindSeconds,
double dflRefreshAheadFactor,
boolean fWriteBehindRemove)
Construct a ReadWriteBackingMap based on a BinaryEntryStore.
|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
CacheLoader loader)
Construct a ReadWriteBackingMap based on a CacheLoader (CacheStore).
|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
CacheLoader loader,
boolean fReadOnly,
int cWriteBehindSeconds,
double dflRefreshAheadFactor)
Construct a ReadWriteBackingMap based on a CacheLoader (CacheStore).
|
ReadWriteBackingMap(BackingMapManagerContext ctxService,
ObservableMap mapInternal,
Map mapMisses,
CacheLoader loader,
boolean fReadOnly,
int cWriteBehindSeconds,
double dflRefreshAheadFactor,
boolean fWriteBehindRemove)
Construct a ReadWriteBackingMap based on a CacheLoader (CacheStore).
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
cancelOutstandingReads(Object oKey)
Cancel any outstanding asynchronous reads for a key.
|
void |
clear()
Remove everything from the Map.
|
protected void |
configureCacheStore(ReadWriteBackingMap.StoreWrapper store,
boolean fReadOnly,
boolean fWBRemove)
Set up the StoreWrapper 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.
|
protected long |
extractExpiry(ReadWriteBackingMap.Entry entry)
Return the expiration value for the given entry.
|
void |
flush()
Flush the write-behind queue, writing everything immediately.
|
protected void |
flush(ReadWriteBackingMap.WriteQueue queue,
ReadWriteBackingMap.StoreWrapper store)
Flush the write-behind queue, writing everything immediately.
|
Object |
get(Object oKey)
Returns the value to which this map maps the specified key.
|
Map |
getAll(Collection colKeys)
Retrieve values for all the specified keys.
|
protected Object |
getCachedOrPending(Object oKey)
Get a value from the internal cache in a way that respects a potentially
pending write-behind operation.
|
CacheService |
getCacheService()
Return the CacheService.
|
ReadWriteBackingMap.StoreWrapper |
getCacheStore()
Get the representative of the "persistent" storage for this backing
map.
|
long |
getCacheStoreTimeoutMillis()
Return the timeout used for CacheStore operations, or 0 if no timeout is
specified.
|
BackingMapManagerContext |
getContext()
Get the context information provided by the CacheService.
|
ConcurrentMap |
getControlMap()
Get the concurrency control map for this backing map.
|
protected Object |
getFromInternalCache(Object oKey)
Get the the value for a given key.
|
ObservableMap |
getInternalCache()
Get the representative of the "in-memory" storage for this backing map.
|
protected ConfigurableCacheMap |
getInternalConfigurableCache()
Get the map that provides internal 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.
|
Map |
getMissesCache()
Get the optional map used to cache CacheLoader (or CacheStore) misses.
|
Set |
getPendingRemoves()
Get the pending removes key set for the CacheStore used by this
backing map.
|
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.
|
long |
getWriteBehindMillis()
Return the number of milliseconds between write-behind writes to the
CacheStore or 0 if write-behind is not enabled.
|
int |
getWriteBehindSeconds()
Return the number of seconds between write-behind writes to the
CacheStore or 0 if write-behind is not enabled.
|
int |
getWriteMaxBatchSize()
Get the maximum size of the write-behind batch.
|
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 void |
heartbeat()
Issue a service guardian "heartbeat" for the current thread.
|
protected CacheStore |
instantiateCacheLoaderCacheStore(CacheLoader loader)
Factory pattern: Instantiate a CacheLoaderCacheStore wrapper around a
passed CacheLoader.
|
protected ReadWriteBackingMap.StoreWrapper |
instantiateCacheStoreWrapper(BinaryEntryStore store)
Factory pattern: Instantiate a StoreWrapper wrapper around the
passed BinaryEntryStore.
|
protected ReadWriteBackingMap.StoreWrapper |
instantiateCacheStoreWrapper(CacheStore store)
Factory pattern: Instantiate a StoreWrapper wrapper around the
passed CacheStore.
|
protected ConcurrentMap |
instantiateControlMap()
Factory pattern: Create the concurrency control map for this backing map.
|
protected ReadWriteBackingMap.Entry |
instantiateEntry(Object oKey,
Object oValue,
Object oValueOrig)
Factory pattern: instantiate a queue entry.
|
protected ReadWriteBackingMap.Entry |
instantiateEntry(Object oKey,
Object oValue,
Object oValueOrig,
long cExpiry)
Factory pattern: instantiate a queue entry.
|
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 |
isWriteBehindRemove()
Determine if the backing map should apply write-behind delay to
remove from 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.
|
Object |
put(Object oKey,
Object oValue,
long cMillis)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map map)
Associates the specified values with the respective keys in this map.
|
protected Object |
putInternal(Object oKey,
Object oValue,
long cMillis)
An actual implementation for the extended put() method.
|
protected void |
putToInternalCache(Object oKey,
Object oVal)
Add the key and value pair to the internal cache in such a way that the
resulting map event would be marked as "synthetic".
|
protected void |
putToInternalCache(Object oKey,
Object oVal,
long cMillis)
Add the key and value pair to the internal cache in such a way that the
resulting map event would be marked as "synthetic".
|
protected void |
putToInternalCache(ReadWriteBackingMap.Entry entry)
Add the key and value pair to the internal cache in such a way that the
resulting map event would be marked as "synthetic".
|
protected Object |
putToInternalMap(Object binKey,
Object binValue,
long cExpiry)
Put the specified key in internal format and value in
internal format into the internal backing 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.
|
protected ReadWriteBackingMap.Entry |
removeFromWriteQueue(Object binKey)
Remove the specified entry from the WriteQueue.
|
protected Object |
removeInternal(Object oKey,
boolean fBlind)
Implementation of the remove() API.
|
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 |
setCacheName(String sCacheName)
Set the cache name for ReadThread and WriteThread if not already set.
|
void |
setCacheStoreTimeoutMillis(long cStoreTimeoutMillis)
Set the timeout used for CacheStore operations.
|
void |
setRefreshAheadFactor(double dflRefreshAheadFactor)
Set the refresh-ahead factor, expressed as a percentage of the internal
cache 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 |
setWriteBehindMillis(long cMillis)
Set the number of milliseconds between write-behind writes to the CacheStore.
|
void |
setWriteBehindSeconds(int cSecs)
Set the number of seconds between write-behind writes to the CacheStore.
|
void |
setWriteMaxBatchSize(int cWriteMaxBatchSize)
Set the maximum size of a batch.
|
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 |
updateThreadName(Daemon daemon,
String sName)
Append the provided name to the Daemon's thread name if not already appended.
|
Collection |
values()
Returns a collection view of the values contained in this map.
|
protected boolean |
waitFor(Object o,
long cMillis)
Wait for notification on the specified object for no longer than
the specified wait time.
|
clone, isEmpty
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll
protected static final Binary REMOVED
ReadWriteBackingMap.Entry
to indicate remove
was called on the Entry.protected static final Binary BIN_STORE_PENDING
protected static final float GUARD_RECOVERY
public static final long MIN_REQUEUE_DELAY
coherence.rwbm.requeue.delay
public static final Binary BIN_ERASE_PENDING
public static final String PROP_WB_REMOVE_DEFAULT
public static final boolean RWBM_WB_REMOVE_DEFAULT
coherence.rwbm.writebehind.remove.default
protected MapListenerSupport m_listenerSupport
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 responsible for the persistence of
the cached data (optional)public ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheLoader loader, 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)loader
- the CacheLoader responsible for the
persistence of the cached data (optional)fReadOnly
- pass true is the specified loader is in fact
a CacheStore that needs to be used 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 ConfigurableCacheMap
public ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheLoader loader, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor, boolean fWriteBehindRemove)
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)loader
- the CacheLoader responsible for the
persistence of the cached data (optional)fReadOnly
- pass true is the specified loader is in fact
a CacheStore that needs to be used 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 ConfigurableCacheMap
fWriteBehindRemove
- pass true if the specified loader is in fact a
CacheStore that needs to apply write-behind to removepublic ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, BinaryEntryStore storeBinary, 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)storeBinary
- the BinaryEntryStore responsible for the
persistence of the cached data (optional)fReadOnly
- pass true is the specified loader is in fact
a CacheStore that needs to be used 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 ConfigurableCacheMap
public ReadWriteBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, BinaryEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor, boolean fWriteBehindRemove)
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)storeBinary
- the BinaryEntryStore responsible for the
persistence of the cached data (optional)fReadOnly
- pass true is the specified loader is in fact
a CacheStore that needs to be used 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 ConfigurableCacheMap
fWriteBehindRemove
- pass true if the specified loader is in fact
a CacheStore that needs to apply write-behind to removepublic BackingMapManagerContext getContext()
public CacheService getCacheService()
public boolean isRethrowExceptions()
public void setRethrowExceptions(boolean fRethrow)
fRethrow
- true to indicate that exceptions should be rethrownpublic double getRefreshAheadFactor()
The refresh-ahead factor is used to calculate the "soft-expiration" time for cache entries. Soft-expiration is the point in time prior to the actual expiration after which any access request for an entry will schedule an asynchronous load request for the entry.
The value of this property is expressed as a percentage of the internal cache expiration interval. If zero, refresh-ahead scheduling is disabled.
public void setRefreshAheadFactor(double dflRefreshAheadFactor)
This method has no effect if refresh-ahead is disabled.
dflRefreshAheadFactor
- the new refresh-ahead factorgetRefreshAheadFactor()
public boolean isReadOnly()
public boolean isRefreshAhead()
public int getWriteMaxBatchSize()
public void setWriteMaxBatchSize(int cWriteMaxBatchSize)
This method has no effect if write-behind is disabled.
cWriteMaxBatchSize
- the maximum batch sizepublic double getWriteBatchFactor()
The write-batch factor is used to calculate the "soft-ripe" time for write-behind queue entries. A queue entry is considered to be "ripe" for a write operation if it has been in the write-behind queue for no less than the write-behind interval. The "soft-ripe" time is the point in time prior to the actual ripe time after which an entry will be included in a batched asynchronous write operation to the CacheStore (along with all other ripe and soft-ripe entries). In other words, a soft-ripe entry is an entry that has been in the write-behind queue for at least the following duration:
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).
This property is only applicable if asynchronous writes are enabled and
the CacheStore implements the 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)
This method has no effect if write-behind is disabled.
dflWriteBatchFactor
- the new write-batch factorgetWriteBatchFactor()
public boolean isWriteBehind()
public int getWriteBehindSeconds()
public void setWriteBehindSeconds(int cSecs)
This method has not effect if write-behind is not enabled.
cSecs
- the new write-behind delay in secondspublic long getWriteBehindMillis()
public void setWriteBehindMillis(long cMillis)
This method has not effect if write-behind is not enabled.
cMillis
- the new write-behind delay in millisecondspublic int getWriteRequeueThreshold()
public void setWriteRequeueThreshold(int cThreshold)
This method has not effect if write-behind is not enabled.
cThreshold
- the new write-behind requeue thresholdpublic boolean isWriteThrough()
public long getCacheStoreTimeoutMillis()
public void setCacheStoreTimeoutMillis(long cStoreTimeoutMillis)
cStoreTimeoutMillis
- the CacheStore timeout, or 0 for the default
guardian timeoutpublic void setCacheName(String sCacheName)
sCacheName
- the name of the cachepublic boolean isWriteBehindRemove()
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 forpublic boolean containsValue(Object oValue)
containsValue
in interface Map
containsValue
in class AbstractMap
oValue
- the value to test forpublic Object get(Object oKey)
get
in interface Map
get
in class AbstractMap
oKey
- the key objectpublic Object put(Object oKey, Object oValue)
put
in interface CacheMap
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 keypublic Object remove(Object oKey)
remove
in interface Map
remove
in class AbstractMap
oKey
- key whose mapping is to be removed from the mappublic void putAll(Map map)
putAll
in interface Map
putAll
in class AbstractMap
map
- keys and values which are to be associated in this mapprotected Object putToInternalMap(Object binKey, Object binValue, long cExpiry)
CacheMap
then an exception will be thrown.binKey
- the key in internal formatbinValue
- the value in internal format; null if the value should be
cached as "missing"cExpiry
- the cache entry expiry valueUnsupportedOperationException
- if the value of cExpiry is
greater than CacheMap.EXPIRY_DEFAULT and the internal map
is not an instance of CacheMap
.protected Object removeInternal(Object oKey, boolean fBlind)
oKey
- key whose mapping is to be removed from the mapfBlind
- if true, the return value will be ignoredpublic 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
public Object put(Object oKey, Object oValue, long cMillis)
put
in interface CacheMap
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 entry will expire;
pass zero to use the cache's default ExpiryDelay settings;
pass -1 to indicate that the entry should never expirepublic Map getAll(Collection colKeys)
protected void putToInternalCache(Object oKey, Object oVal)
oKey
- the key in internal formatoVal
- the value in internal format; null if the value should be
cached as "missing"protected void putToInternalCache(ReadWriteBackingMap.Entry entry)
entry
- cache entryprotected void putToInternalCache(Object oKey, Object oVal, long cMillis)
oKey
- the key in internal formatoVal
- the value in internal format; null if the value should be
cached as "missing"cMillis
- the cache entry expiry valueprotected void cancelOutstandingReads(Object oKey)
oKey
- the key in internal formatprotected Object getFromInternalCache(Object oKey)
oKey
- the key in internal formatprotected Object getCachedOrPending(Object oKey)
oKey
- the keyprotected Object putInternal(Object oKey, Object oValue, long cMillis)
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 entry will expireprotected boolean waitFor(Object o, long cMillis)
Note: the caller must hold synchronization on the object being waited on.
o
- the object to wait for notification oncMillis
- the maximum time in milliseconds to wait;
pass 0 for foreverprotected void heartbeat()
protected long extractExpiry(ReadWriteBackingMap.Entry entry)
entry
- the entryprotected void updateThreadName(Daemon daemon, String sName)
daemon
- the Daemon to be modifiedsName
- the name to append to the Daemon's thread nameprotected ReadWriteBackingMap.EntrySet instantiateEntrySet()
protected ReadWriteBackingMap.KeySet instantiateKeySet()
protected ReadWriteBackingMap.ValuesCollection instantiateValuesCollection()
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 boolean equals(Object o)
equals
in interface Map
equals
in class AbstractMap
o
- object to be compared for equality with this mappublic int hashCode()
hashCode
in interface Map
hashCode
in class AbstractMap
public String toString()
toString
in class AbstractMap
public ObservableMap getInternalCache()
protected ConfigurableCacheMap getInternalConfigurableCache()
getInternalCache()
; otherwise it returns null.
The refresh-ahead implementation relies on the internal storage
providing the ConfigurableCacheMap interface, so this method will
always return a non-null value if refresh-ahead is enabled.protected void configureInternalCache(ObservableMap mapInternal)
mapInternal
- the internal mappublic Map getMissesCache()
public Set getPendingRemoves()
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)
oKey
- the keypublic ReadWriteBackingMap.ReadQueue getReadQueue()
protected ReadWriteBackingMap.ReadQueue instantiateReadQueue()
public ReadWriteBackingMap.WriteQueue getWriteQueue()
public void flush()
protected void flush(ReadWriteBackingMap.WriteQueue queue, ReadWriteBackingMap.StoreWrapper store)
queue
- the write-behind queue to flushstore
- the CacheStore to flush toprotected ReadWriteBackingMap.Entry removeFromWriteQueue(Object binKey)
binKey
- the keyprotected ReadWriteBackingMap.Entry instantiateEntry(Object oKey, Object oValue, Object oValueOrig)
oKey
- the key for the new entryoValue
- the entry's value; could be null representing a
non-existing or removed entryoValueOrig
- the entry's original value; could be null representing
a non-existing entryprotected ReadWriteBackingMap.Entry instantiateEntry(Object oKey, Object oValue, Object oValueOrig, long cExpiry)
oKey
- the key for the new entryoValue
- the entry's value; could be null representing a
non-existing or removed entryoValueOrig
- the entry's original value; could be null representing
a non-existing entrycExpiry
- the expiry delay, or CacheMap.EXPIRY_NEVER
or
CacheMap.EXPIRY_DEFAULT
protected ReadWriteBackingMap.WriteQueue instantiateWriteQueue()
protected ReadWriteBackingMap.ReadThread getReadThread()
protected void configureReadThread(double dflRefreshAheadFactor)
This method has no effect if the given refresh-ahead factor is zero or
the cache returned by getInternalConfigurableCache()
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)
This method has no effect if the given write-behind delay is zero or
isReadOnly()
returns true.
cWriteBehindSeconds
- write-behind delayprotected ReadWriteBackingMap.WriteThread instantiateWriteThread()
protected void terminateWriteThread()
public ReadWriteBackingMap.StoreWrapper getCacheStore()
protected void configureCacheStore(ReadWriteBackingMap.StoreWrapper store, boolean fReadOnly, boolean fWBRemove)
store
- the StoreWrapper that this backing map will
delegate persistence responsibilities tofReadOnly
- pass true to prevent the usage of the cache store
write operationsfWBRemove
- pass true to apply write-behind to removeprotected ReadWriteBackingMap.StoreWrapper instantiateCacheStoreWrapper(CacheStore store)
store
- the CacheStore to wrapprotected ReadWriteBackingMap.StoreWrapper instantiateCacheStoreWrapper(BinaryEntryStore store)
store
- the BinaryEntryStore to wrapprotected CacheStore instantiateCacheLoaderCacheStore(CacheLoader loader)
loader
- the CacheLoader to wrap; never null