Class ReadWriteBackingMap.StoreWrapper
- Direct Known Subclasses:
ReadWriteBackingMap.BinaryEntryStoreWrapper
,ReadWriteBackingMap.CacheStoreWrapper
,ReadWriteBackingMap.NonBlockingEntryStoreWrapper
- Enclosing class:
ReadWriteBackingMap
- Author:
- cp 2002.06.04, tb 2011.01.11
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AtomicLong
The number of Load failures.protected final AtomicLong
The cumulative time spent on Load operations.protected final AtomicLong
The number of Load operations.protected final AtomicLong
The number of pending non-blocking store operations.protected final AtomicLong
The total number of entries written in Store operations.protected final AtomicLong
The number of Store failures.protected final AtomicLong
The cumulative time spent on Store operations.protected final AtomicLong
The number of Store operations.protected long
The number of Erase failures.protected long
The cumulative time spent on Erase operations.protected long
The number of Erase operations.protected AbstractBundler
The bundler for erase() operations.protected boolean
Flag that determines whether or not EraseAll operations are supported by the wrapped store.protected boolean
Flag that determines whether or not Erase operations are supported by the wrapped store.protected boolean
Flag that determines whether or not StoreAll operations are supported by the wrapped store.protected boolean
Flag that determines whether or not Store operations are supported by the wrapped store.protected AbstractBundler
The bundler for load() operations.protected AbstractBundler
The bundler for store() operations. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected long
Calculate the requeue delay after a store operation failed.ensureEraseBundler
(int cBundleThreshold) Configure the bundler for the "erase" operations.ensureLoadBundler
(int cBundleThreshold) Configure the bundler for the "load" operations.ensureStoreBundler
(int cBundleThreshold) Configure the bundler for the "store" operations.protected void
erase
(ReadWriteBackingMap.Entry binEntry) Remove the specified entry from the underlying store.protected void
Remove the specified entries from the underlying store.protected abstract void
eraseAllInternal
(Set setBinEntries) Remove the specified entries from the underlying store.protected abstract void
eraseInternal
(ReadWriteBackingMap.Entry binEntry) Remove the specified entry from the underlying store.protected String
formatKeys
(Set setBinEntries, String sHeader) Generate a log message containing the keys from the specified set of entries.long
Determine the average number of entries stored per store() operation.long
Determine the average time spent per erase() operation.long
Determine the average time spent per load() operation.long
Determine the average time spent per store() operation.Obtain the bundler for the "erase" operations.long
Determine the number of erase() failures.long
Determine the cumulative time spent on erase() operations.long
Determine the number of erase() operations.Obtain the bundler for the "load" operations.long
Determine the number of load() failures.long
Determine the cumulative time spent on load() operations.long
Determine the number of load() operations.long
Determine the number of pending non-blocking store operations.abstract Object
getStore()
Return the cache store object to which this wrapper delegates.Obtain the bundler for the "store" operations.long
Determine the number of store() failures.long
Determine the cumulative time spent on store() operations.long
Determine the number of store() operations.protected abstract AbstractBundler
Create the bundler for the erase operations.protected abstract AbstractBundler
Create the bundler for the load operations.protected abstract AbstractBundler
Create the bundler for the store operations.boolean
Determine if the wrapped store implements blocking operations.boolean
Determine if the wrapped store supports eraseAll() operations.boolean
Determine if the wrapped store supports erase() operations.boolean
Determine if the wrapped store supports storeAll() operations.boolean
Determine if the wrapped store supports store() operations.protected ReadWriteBackingMap.Entry
Return the entry associated with the specified key, or null if the key does not have an associated value in the underlying store.protected Set
Return the entry set associated with the specified keys in the passed collection.protected abstract Set
loadAllInternal
(Set setBinKey) Load the entries associated with each of the specified binary keys from the underlying store.protected abstract ReadWriteBackingMap.Entry
loadInternal
(Object binKey) Load the entry associated with the specified key from the underlying store.protected void
onEraseAllFailure
(Set setBinEntries, Exception e) Logs a store eraseAll() failure.protected void
onEraseFailure
(Object oKeyReal, Exception e) Logs a store erase() failure.protected void
onLoadAllFailure
(Collection colKeys, Exception e) Logs a store loadAll() failure.protected void
onLoadAllFailure
(Collection colKeys, Exception e, boolean fThrow) Logs a store loadAll() failure.protected void
onLoadFailure
(Object oKeyReal, Exception e) Logs a store load() failure.protected void
onLoadFailure
(Object oKeyReal, Exception e, boolean fThrow) Logs a store load() failure.protected void
onStoreAllFailure
(Set setBinEntries, Exception e) Logs a store storeAll() failure.protected void
onStoreAllFailure
(Set setBinEntries, Exception e, boolean fThrow) Logs a store storeAll() failure.protected void
onStoreFailure
(ReadWriteBackingMap.Entry entry, Exception e) Logs a store store() failure.protected void
onStoreFailure
(ReadWriteBackingMap.Entry entry, Exception e, boolean fThrow) Logs a store store() failure.protected void
replace
(ReadWriteBackingMap.Entry entry) Replace the value in the internal cache for the specified entry.protected void
reportUnsupported
(String sOp) Log the info about an unsupported operation.protected boolean
requeue
(ReadWriteBackingMap.WriteQueue queue, int cThreshold, ReadWriteBackingMap.Entry entry) Requeue the specified entry.void
Reset the CacheStore statistics.void
setEraseAllSupported
(boolean fSupported) Set the flag that determines whether or not the wrapped store supports eraseAll() operations.void
setEraseSupported
(boolean fSupported) Set the flag that determines whether or not the wrapped store supports erase() operations.void
setStoreAllSupported
(boolean fSupported) Set the flag that determines whether or not the wrapped store supports storeAll() operations.void
setStoreSupported
(boolean fSupported) Set the flag that determines whether or not the wrapped store supports store() operations.protected void
store
(ReadWriteBackingMap.Entry binEntry, boolean fAllowChange) Store the specified entry in the underlying store.protected void
Store the entries in the specified set in the underlying store.protected abstract void
storeAllInternal
(Set setBinEntries) Store the entries in the specified set in the underlying store.protected abstract void
storeInternal
(ReadWriteBackingMap.Entry binEntry) Store the specified entry in the underlying store.Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Field Details
-
f_cLoadOps
The number of Load operations. -
f_cLoadFailures
The number of Load failures. -
f_cLoadMillis
The cumulative time spent on Load operations. -
f_cStoreOps
The number of Store operations. -
f_cStoreEntries
The total number of entries written in Store operations. -
f_cStoreFailures
The number of Store failures. -
f_cStoreMillis
The cumulative time spent on Store operations. -
f_cPendingAsyncStoreOps
The number of pending non-blocking store operations. -
m_cEraseOps
protected volatile long m_cEraseOpsThe number of Erase operations. -
m_cEraseFailures
protected volatile long m_cEraseFailuresThe number of Erase failures. -
m_cEraseMillis
protected volatile long m_cEraseMillisThe cumulative time spent on Erase operations. -
m_fStoreSupported
protected boolean m_fStoreSupportedFlag that determines whether or not Store operations are supported by the wrapped store. -
m_fStoreAllSupported
protected boolean m_fStoreAllSupportedFlag that determines whether or not StoreAll operations are supported by the wrapped store. -
m_fEraseSupported
protected boolean m_fEraseSupportedFlag that determines whether or not Erase operations are supported by the wrapped store. -
m_fEraseAllSupported
protected boolean m_fEraseAllSupportedFlag that determines whether or not EraseAll operations are supported by the wrapped store. -
m_loadBundler
The bundler for load() operations. -
m_storeBundler
The bundler for store() operations. -
m_eraseBundler
The bundler for erase() operations.
-
-
Constructor Details
-
StoreWrapper
public StoreWrapper()
-
-
Method Details
-
ensureLoadBundler
Configure the bundler for the "load" operations. If the bundler does not exist and bundling is enabled, it will be instantiated.- Parameters:
cBundleThreshold
- the bundle size threshold; pass zero to disable "load" operation bundling- Returns:
- the "load" bundler or null if bundling is disabled
-
ensureStoreBundler
Configure the bundler for the "store" operations. If the bundler does not exist and bundling is enabled, it will be instantiated.- Parameters:
cBundleThreshold
- the bundle size threshold; pass zero to disable "store" operation bundling- Returns:
- the "store" bundler or null if bundling is disabled
-
ensureEraseBundler
Configure the bundler for the "erase" operations. If the bundler does not exist and bundling is enabled, it will be instantiated.- Parameters:
cBundleThreshold
- the bundle size threshold; pass zero to disable "erase" operation bundling- Returns:
- the "erase" bundler or null if bundling is disabled
-
getLoadOps
public long getLoadOps()Determine the number of load() operations.- Returns:
- the number of load() operations
-
getLoadFailures
public long getLoadFailures()Determine the number of load() failures.- Returns:
- the number of load() failures
-
getLoadMillis
public long getLoadMillis()Determine the cumulative time spent on load() operations.- Returns:
- the cumulative time spent on load() operations
-
getStoreOps
public long getStoreOps()Determine the number of store() operations.- Returns:
- the number of store() operations
-
getStoreFailures
public long getStoreFailures()Determine the number of store() failures.- Returns:
- the number of store() failures
-
getStoreMillis
public long getStoreMillis()Determine the cumulative time spent on store() operations.- Returns:
- the cumulative time spent on store() operations
-
getEraseOps
public long getEraseOps()Determine the number of erase() operations.- Returns:
- the number of erase() operations
-
getEraseFailures
public long getEraseFailures()Determine the number of erase() failures.- Returns:
- the number of erase() failures
-
getEraseMillis
public long getEraseMillis()Determine the cumulative time spent on erase() operations.- Returns:
- the cumulative time spent on erase() operations
-
getAverageBatchSize
public long getAverageBatchSize()Determine the average number of entries stored per store() operation.- Returns:
- the average number of entries stored per store() operation
-
getAverageLoadMillis
public long getAverageLoadMillis()Determine the average time spent per load() operation.- Returns:
- the average time spent per load() operation
-
getAverageStoreMillis
public long getAverageStoreMillis()Determine the average time spent per store() operation.- Returns:
- the average time spent per store() operation
-
getAverageEraseMillis
public long getAverageEraseMillis()Determine the average time spent per erase() operation.- Returns:
- the average time spent per erase() operation
-
getPendingAsyncStoreOps
public long getPendingAsyncStoreOps()Determine the number of pending non-blocking store operations.- Returns:
- the number of pending non-blocking store operations
-
resetStatistics
public void resetStatistics()Reset the CacheStore statistics. -
getLoadBundler
Obtain the bundler for the "load" operations.- Returns:
- the "load" bundler
-
getStoreBundler
Obtain the bundler for the "store" operations.- Returns:
- the "store" bundler
-
getEraseBundler
Obtain the bundler for the "erase" operations.- Returns:
- the "erase" bundler
-
isStoreSupported
public boolean isStoreSupported()Determine if the wrapped store supports store() operations.- Returns:
- true if the wrapped store supports store() operations
-
setStoreSupported
public void setStoreSupported(boolean fSupported) Set the flag that determines whether or not the wrapped store supports store() operations.- Parameters:
fSupported
- the new value of the flag
-
isStoreAllSupported
public boolean isStoreAllSupported()Determine if the wrapped store supports storeAll() operations.- Returns:
- true if the wrapped store supports storeAll() operations
-
setStoreAllSupported
public void setStoreAllSupported(boolean fSupported) Set the flag that determines whether or not the wrapped store supports storeAll() operations.- Parameters:
fSupported
- the new value of the flag
-
isEraseSupported
public boolean isEraseSupported()Determine if the wrapped store supports erase() operations.- Returns:
- true if the wrapped store supports erase() operations
-
setEraseSupported
public void setEraseSupported(boolean fSupported) Set the flag that determines whether or not the wrapped store supports erase() operations.- Parameters:
fSupported
- the new value of the flag
-
isEraseAllSupported
public boolean isEraseAllSupported()Determine if the wrapped store supports eraseAll() operations.- Returns:
- true if the wrapped store supports eraseAll() operations
-
setEraseAllSupported
public void setEraseAllSupported(boolean fSupported) Set the flag that determines whether or not the wrapped store supports eraseAll() operations.- Parameters:
fSupported
- the new value of the flag
-
isBlocking
public boolean isBlocking()Determine if the wrapped store implements blocking operations.- Returns:
- true if the operations are blocking
-
load
Return the entry associated with the specified key, or null if the key does not have an associated value in the underlying store.Same as
CacheLoader.load(K)
, but the key and the value are in the internal format.- Parameters:
binKey
- binary key whose associated entry is to be returned- Returns:
- the entry associated with the specified binary key, or null if no value is available for that key
-
loadAll
Return the entry set associated with the specified keys in the passed collection. If a key does not have an associated value in the underlying store, then the return set will not have an entry for that key.Same as
CacheLoader.loadAll(java.util.Collection<? extends K>)
, but the keys are in the internal format.- Parameters:
setBinKey
- a set of keys to load- Returns:
- a Set of entries for the specified keys
-
store
Store the specified entry in the underlying store.- Parameters:
binEntry
- the entryfAllowChange
- if true, any changes made to the entry by the store operation should be applied to the internal cache; otherwise they will be dealt with by the caller
-
storeAll
Store the entries in the specified set in the underlying store.- Parameters:
setBinEntries
- the set of binary entries
-
erase
Remove the specified entry from the underlying store.- Parameters:
binEntry
- the entry
-
eraseAll
Remove the specified entries from the underlying store.- Parameters:
setBinEntries
- the set of entries
-
replace
Replace the value in the internal cache for the specified entry.For write-behind, we should replace (and undecorate) the value *only* if the internal cache still holds the value it contained when the entry was de-queued for store operations.
Note: for write-through RWBM, this method is only called while the entry is locked
- Parameters:
entry
- the entry that holds the binary value to replace
-
onLoadFailure
Logs a store load() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
oKeyReal
- the keye
- the exception
-
onLoadFailure
Logs a store load() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
oKeyReal
- the keye
- the exceptionfThrow
- the caller can bubble up exceptions
-
onLoadAllFailure
Logs a store loadAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
colKeys
- colKeys a collection of keys in external form to loade
- the exception
-
onLoadAllFailure
Logs a store loadAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
colKeys
- colKeys a collection of keys in external form to loade
- the exceptionfThrow
- the caller can bubble up exceptions
-
onStoreFailure
Logs a store store() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
entry
- the entrye
- the exception
-
onStoreFailure
Logs a store store() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
entry
- the entrye
- the exceptionfThrow
- whether the store mode supports exceptions
-
onStoreAllFailure
Logs a store storeAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
setBinEntries
- set ofEntries
e
- the exception
-
onStoreAllFailure
Logs a store storeAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
setBinEntries
- set ofEntries
e
- the exceptionfThrow
- whether the store mode supports exceptions
-
requeue
protected boolean requeue(ReadWriteBackingMap.WriteQueue queue, int cThreshold, ReadWriteBackingMap.Entry entry) Requeue the specified entry.Note: Subclasses could override this method and perform some type of the "last recovery attempt" operation if the super.requeue(...) call returns false. Note 2: Starting with Coherence 3.6 a positive threshold value ensures that entries are never dropped. The signature of the method did not change to maintain backward compatibility.
- Parameters:
queue
- the queue (never null)cThreshold
- the queue size thresholdentry
- the entry to requeue- Returns:
- starting with Coherence 3.6 this method always returns true
-
calculateRequeueDelay
Calculate the requeue delay after a store operation failed. The default implementations delays the entry by at least a minute or by the two times the write-behind delay.- Parameters:
queue
- the write-behind queue- Returns:
- the number of milliseconds until another attempt should be made to persist the specified value
-
onEraseFailure
Logs a store erase() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
oKeyReal
- the keye
- the exception
-
onEraseAllFailure
Logs a store eraseAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.- Parameters:
setBinEntries
- set ofEntries
e
- the exception
-
reportUnsupported
Log the info about an unsupported operation.- Parameters:
sOp
- the unsupported operation
-
formatKeys
Generate a log message containing the keys from the specified set of entries.- Parameters:
setBinEntries
- set ofEntries
sHeader
- message header- Returns:
- the formatted message
-
getStore
Return the cache store object to which this wrapper delegates.- Returns:
- the cache store object to which this wrapper delegates
-
instantiateLoadBundler
Create the bundler for the load operations.- Returns:
- the "load" bundler
-
instantiateStoreBundler
Create the bundler for the store operations.- Returns:
- the "store" bundler
-
instantiateEraseBundler
Create the bundler for the erase operations.- Returns:
- the "erase" bundler
-
loadInternal
Load the entry associated with the specified key from the underlying store.- Parameters:
binKey
- binary key whose associated value is to be loaded- Returns:
- the entry associated with the specified key, or null if no value is available for that key
-
loadAllInternal
Load the entries associated with each of the specified binary keys from the underlying store.- Parameters:
setBinKey
- a set of binary keys to load- Returns:
- a Set of entries for the specified keys
-
storeInternal
Store the specified entry in the underlying store.- Parameters:
binEntry
- the entry to be stored
-
storeAllInternal
Store the entries in the specified set in the underlying store.- Parameters:
setBinEntries
- the set of entries to be stored
-
eraseInternal
Remove the specified entry from the underlying store.- Parameters:
binEntry
- the entry to be removed from the store
-
eraseAllInternal
Remove the specified entries from the underlying store.- Parameters:
setBinEntries
- the set entries to be removed from the store
-