Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.net.cache
Class ReadWriteBackingMap.StoreWrapper

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.cache.ReadWriteBackingMap.StoreWrapper

Direct Known Subclasses:
ReadWriteBackingMap.BinaryEntryStoreWrapper, ReadWriteBackingMap.CacheStoreWrapper
Enclosing class:
ReadWriteBackingMap

public abstract class ReadWriteBackingMap.StoreWrapper
extends Base

Abstract wrapper around a cache store to allow operations to be overridden and extended.

Author:
cp 2002.06.04, tb 2011.01.11

Field Summary
protected  long m_cEraseFailures
          The number of Erase failures.
protected  long m_cEraseMillis
          The cummulative time spent on Erase operations.
protected  long m_cEraseOps
          The number of Erase operations.
protected  long m_cLoadFailures
          The number of Load failures.
protected  long m_cLoadMillis
          The cummulative time spent on Load operations.
protected  long m_cLoadOps
          The number of Load operations.
protected  long m_cStoreEntries
          The total number of entries written in Store operations.
protected  long m_cStoreFailures
          The number of Store failures.
protected  long m_cStoreMillis
          The cummulative time spent on Store operations.
protected  long m_cStoreOps
          The number of Store operations.
protected  AbstractBundler m_eraseBundler
          The bundler for erase() operations.
protected  boolean m_fEraseAllSupported
          Flag that determines wether or not EraseAll operations are supported by the wrapped store.
protected  boolean m_fEraseSupported
          Flag that determines wether or not Erase operations are supported by the wrapped store.
protected  boolean m_fStoreAllSupported
          Flag that determines wether or not StoreAll operations are supported by the wrapped store.
protected  boolean m_fStoreSupported
          Flag that determines wether or not Store operations are supported by the wrapped store.
protected  AbstractBundler m_loadBundler
          The bundler for load() operations.
protected  AbstractBundler m_storeBundler
          The bundler for store() operations.

 

Constructor Summary
ReadWriteBackingMap.StoreWrapper()
           

 

Method Summary
protected  long calculateRequeueDelay(ReadWriteBackingMap.WriteQueue queue)
          Calculate the requeue delay after a store operation failed.
 AbstractBundler ensureEraseBundler(int cBundleThreshold)
          Configure the bundler for the "erase" operations.
 AbstractBundler ensureLoadBundler(int cBundleThreshold)
          Configure the bundler for the "load" operations.
 AbstractBundler 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 eraseAll(java.util.Set setBinEntries)
          Remove the specified entries from the underlying store.
protected abstract  void eraseAllInternal(java.util.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  java.lang.String formatKeys(java.util.Set setBinEntries, java.lang.String sHeader)
          Generate a log message containing the keys from the specified set of entries.
 long getAverageBatchSize()
          Determine the average number of entries stored per store() operation.
 long getAverageEraseMillis()
          Determine the average time spent per erase() operation.
 long getAverageLoadMillis()
          Determine the average time spent per load() operation.
 long getAverageStoreMillis()
          Determine the average time spent per store() operation.
 AbstractBundler getEraseBundler()
          Obtain the bundler for the "erase" operations.
 long getEraseFailures()
          Determine the number of erase() failures.
 long getEraseMillis()
          Determine the cummulative time spent on erase() operations.
 long getEraseOps()
          Determine the number of erase() operations.
 AbstractBundler getLoadBundler()
          Obtain the bundler for the "load" operations.
 long getLoadFailures()
          Determine the number of load() failures.
 long getLoadMillis()
          Determine the cummulative time spent on load() operations.
 long getLoadOps()
          Determine the number of load() operations.
abstract  java.lang.Object getStore()
          Return the cache store object to which this wrapper delegates.
 AbstractBundler getStoreBundler()
          Obtain the bundler for the "store" operations.
 long getStoreFailures()
          Determine the number of store() failures.
 long getStoreMillis()
          Determine the cummulative time spent on store() operations.
 long getStoreOps()
          Determine the number of store() operations.
protected abstract  AbstractBundler instantiateEraseBundler()
          Create the bundler for the erase operations.
protected abstract  AbstractBundler instantiateLoadBundler()
          Create the bundler for the load operations.
protected abstract  AbstractBundler instantiateStoreBundler()
          Create the bundler for the store operations.
 boolean isEraseAllSupported()
          Determine if the wrapped store supports eraseAll() operations.
 boolean isEraseSupported()
          Determine if the wrapped store supports erase() operations.
 boolean isStoreAllSupported()
          Determine if the wrapped store supports storeAll() operations.
 boolean isStoreSupported()
          Determine if the wrapped store supports store() operations.
protected  java.lang.Object load(java.lang.Object binKey)
          Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.
protected  java.util.Map loadAll(java.util.Set setBinKey)
          Return the values associated with each the specified keys in the passed collection.
protected abstract  java.util.Map loadAllInternal(java.util.Set setBinKey)
          Load the values associated with each of the specified binary keys from the underlying store.
protected abstract  java.lang.Object loadInternal(java.lang.Object binKey)
          Load the value associated with the specified key from the underlying store.
protected  void onEraseAllFailure(java.util.Set setBinEntries, java.lang.Exception e)
          Logs a store eraseAll() failure.
protected  void onEraseFailure(java.lang.Object oKeyReal, java.lang.Exception e)
          Logs a store erase() failure.
protected  void onLoadAllFailure(java.util.Collection colKeys, java.lang.Exception e)
          Logs a store loadAll() failure.
protected  void onLoadFailure(java.lang.Object oKeyReal, java.lang.Exception e)
          Logs a store load() failure.
protected  void onStoreAllFailure(java.util.Set setBinEntries, java.lang.Exception e)
          Logs a store storeAll() failure.
protected  void onStoreFailure(ReadWriteBackingMap.Entry entry, java.lang.Exception e)
          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(java.lang.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 resetStatistics()
          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 storeAll(java.util.Set setBinEntries)
          Store the entries in the specified set in the underlying store.
protected abstract  void storeAllInternal(java.util.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.

 

Field Detail

m_cLoadOps

protected volatile long m_cLoadOps
The number of Load operations.

m_cLoadFailures

protected volatile long m_cLoadFailures
The number of Load failures.

m_cLoadMillis

protected volatile long m_cLoadMillis
The cummulative time spent on Load operations.

m_cStoreOps

protected volatile long m_cStoreOps
The number of Store operations.

m_cStoreEntries

protected volatile long m_cStoreEntries
The total number of entries written in Store operations.

m_cStoreFailures

protected volatile long m_cStoreFailures
The number of Store failures.

m_cStoreMillis

protected volatile long m_cStoreMillis
The cummulative time spent on Store operations.

m_cEraseOps

protected volatile long m_cEraseOps
The number of Erase operations.

m_cEraseFailures

protected volatile long m_cEraseFailures
The number of Erase failures.

m_cEraseMillis

protected volatile long m_cEraseMillis
The cummulative time spent on Erase operations.

m_fStoreSupported

protected boolean m_fStoreSupported
Flag that determines wether or not Store operations are supported by the wrapped store.

m_fStoreAllSupported

protected boolean m_fStoreAllSupported
Flag that determines wether or not StoreAll operations are supported by the wrapped store.

m_fEraseSupported

protected boolean m_fEraseSupported
Flag that determines wether or not Erase operations are supported by the wrapped store.

m_fEraseAllSupported

protected boolean m_fEraseAllSupported
Flag that determines wether or not EraseAll operations are supported by the wrapped store.

m_loadBundler

protected AbstractBundler m_loadBundler
The bundler for load() operations.

m_storeBundler

protected AbstractBundler m_storeBundler
The bundler for store() operations.

m_eraseBundler

protected AbstractBundler m_eraseBundler
The bundler for erase() operations.

Constructor Detail

ReadWriteBackingMap.StoreWrapper

public ReadWriteBackingMap.StoreWrapper()

Method Detail

ensureLoadBundler

public AbstractBundler ensureLoadBundler(int cBundleThreshold)
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

public AbstractBundler ensureStoreBundler(int cBundleThreshold)
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

public AbstractBundler ensureEraseBundler(int cBundleThreshold)
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 cummulative time spent on load() operations.
Returns:
the cummulative 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 cummulative time spent on store() operations.
Returns:
the cummulative 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 cummulative time spent on erase() operations.
Returns:
the cummulative 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

resetStatistics

public void resetStatistics()
Reset the CacheStore statistics.

getLoadBundler

public AbstractBundler getLoadBundler()
Obtain the bundler for the "load" operations.
Returns:
the "load" bundler

getStoreBundler

public AbstractBundler getStoreBundler()
Obtain the bundler for the "store" operations.
Returns:
the "store" bundler

getEraseBundler

public AbstractBundler 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

load

protected java.lang.Object load(java.lang.Object binKey)
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.

Same as CacheLoader.load(java.lang.Object), but the key and the returned value are in the internal format.

Parameters:
binKey - binary key whose associated value is to be returned
Returns:
the value associated with the specified binary key, or null if no value is available for that key

loadAll

protected java.util.Map loadAll(java.util.Set setBinKey)
Return the values associated with each the specified keys in the passed collection. If a key does not have an associated value in the underlying store, then the return map will not have an entry for that key.

Same as CacheLoader.loadAll(java.util.Collection), but the keys are in the internal format.

Parameters:
setBinKey - a set of keys to load
Returns:
a Map of keys to associated values for the specified keys

store

protected void store(ReadWriteBackingMap.Entry binEntry,
                     boolean fAllowChange)
Store the specified entry in the underlying store.
Parameters:
binEntry - the entry
fAllowChange - 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

protected void storeAll(java.util.Set setBinEntries)
Store the entries in the specified set in the underlying store.
Parameters:
setBinEntries - the set of binary entries

erase

protected void erase(ReadWriteBackingMap.Entry binEntry)
Remove the specified entry from the underlying store.
Parameters:
binEntry - the entry

eraseAll

protected void eraseAll(java.util.Set setBinEntries)
Remove the specified entries from the underlying store.
Parameters:
setBinEntries - the set of entries

replace

protected void replace(ReadWriteBackingMap.Entry entry)
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

protected void onLoadFailure(java.lang.Object oKeyReal,
                             java.lang.Exception e)
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 key
e - the exception

onLoadAllFailure

protected void onLoadAllFailure(java.util.Collection colKeys,
                                java.lang.Exception e)
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 load
e - the exception

onStoreFailure

protected void onStoreFailure(ReadWriteBackingMap.Entry entry,
                              java.lang.Exception e)
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 entry
e - the exception

onStoreAllFailure

protected void onStoreAllFailure(java.util.Set setBinEntries,
                                 java.lang.Exception e)
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 of Entries
e - the exception

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 threshold
entry - the entry to reqeue
Returns:
starting with Coherence 3.6 this method always returns true

calculateRequeueDelay

protected long calculateRequeueDelay(ReadWriteBackingMap.WriteQueue queue)
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

protected void onEraseFailure(java.lang.Object oKeyReal,
                              java.lang.Exception e)
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 key
e - the exception

onEraseAllFailure

protected void onEraseAllFailure(java.util.Set setBinEntries,
                                 java.lang.Exception e)
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 of Entries
e - the exception

reportUnsupported

protected void reportUnsupported(java.lang.String sOp)
Log the info about an unsupported operation.
Parameters:
sOp - the unsupported operation

formatKeys

protected java.lang.String formatKeys(java.util.Set setBinEntries,
                                      java.lang.String sHeader)
Generate a log message containing the keys from the specified set of entries.
Parameters:
setBinEntries - set of Entries
sHeader - message header
Returns:
the formatted message

getStore

public abstract java.lang.Object getStore()
Return the cache store object to which this wrapper delegates.
Returns:
the cache store object to which this wrapper delegates

instantiateLoadBundler

protected abstract AbstractBundler instantiateLoadBundler()
Create the bundler for the load operations.
Returns:
the "load" bundler

instantiateStoreBundler

protected abstract AbstractBundler instantiateStoreBundler()
Create the bundler for the store operations.
Returns:
the "store" bundler

instantiateEraseBundler

protected abstract AbstractBundler instantiateEraseBundler()
Create the bundler for the erase operations.
Returns:
the "erase" bundler

loadInternal

protected abstract java.lang.Object loadInternal(java.lang.Object binKey)
Load the value associated with the specified key from the underlying store.
Parameters:
binKey - binary key whose associated value is to be loaded
Returns:
the value associated with the specified key, or null if no value is available for that key

loadAllInternal

protected abstract java.util.Map loadAllInternal(java.util.Set setBinKey)
Load the values associated with each of the specified binary keys from the underlying store.
Parameters:
setBinKey - a set of binary keys to load
Returns:
a Map of keys to associated values for the specified keys

storeInternal

protected abstract void storeInternal(ReadWriteBackingMap.Entry binEntry)
Store the specified entry in the underlying store.
Parameters:
binEntry - the entry to be stored

storeAllInternal

protected abstract void storeAllInternal(java.util.Set setBinEntries)
Store the entries in the specified set in the underlying store.
Parameters:
setBinEntries - the set of entries to be stored

eraseInternal

protected abstract void eraseInternal(ReadWriteBackingMap.Entry binEntry)
Remove the specified entry from the underlying store.
Parameters:
binEntry - the entry to be removed from the store

eraseAllInternal

protected abstract void eraseAllInternal(java.util.Set setBinEntries)
Remove the specified entries from the underlying store.
Parameters:
setBinEntries - the set entries to be removed from the store

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


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