Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


com.tangosol.net.cache
Class ReadWriteBackingMap.CacheStoreWrapper

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

Direct Known Subclasses:
VersionedBackingMap.CacheStoreWrapper
Enclosing class:
ReadWriteBackingMap

public class ReadWriteBackingMap.CacheStoreWrapper
extends Base

A wrapper around the original CacheStore to allow operations to be overridden and extended.

Author:
cp 2002.06.04

Nested Class Summary
protected  class ReadWriteBackingMap.CacheStoreWrapper.EraseBundler
           
protected  class ReadWriteBackingMap.CacheStoreWrapper.LoadBundler
           
protected  class ReadWriteBackingMap.CacheStoreWrapper.StoreBundler
           

 

Constructor Summary
ReadWriteBackingMap.CacheStoreWrapper(BinaryEntryStore store)
          Construct a CacheStoreWrapper.
ReadWriteBackingMap.CacheStoreWrapper(CacheStore store)
          Construct a CacheStoreWrapper.

 

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.
 void erase(Object oKey)
          
 void eraseAll(Collection colKeys)
          
protected  void eraseAllInternal(Set setBinEntries)
          Same as eraseAll(java.util.Collection), but the keys is in the internal format.
protected  void eraseInternal(ReadWriteBackingMap.Entry binEntry)
          Same as erase(java.lang.Object), but the key is in the internal format.
protected  long extractExpiry(Object o)
          Return the expiration decoration for the given object or -1 if the given object does not have an expiration decoration.
protected  String formatKeys(Set setBinEntries, 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.
 BinaryEntryStore getBinaryEntryStore()
          The wrapped BinaryEntryStore.
 CacheStore getCacheStore()
          The wrapped CacheStore.
 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.
 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.
 boolean isBinaryEntryStore()
           
 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.
 Object load(Object oKey)
          
 Map loadAll(Collection colKeys)
          
protected  Map loadAllInternal(Set setBinKeys)
          Same as loadAll(java.util.Collection), but the keys are in the internal format.
protected  Object loadInternal(Object binKey)
          Same as load(java.lang.Object), but the key and the returned value are in the internal format.
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 onLoadFailure(Object oKeyReal, Exception e)
          Logs a store load() failure.
protected  void onStoreAllFailure(Set setBinEntries, Exception e)
          Logs a store storeAll() failure.
protected  void onStoreFailure(ReadWriteBackingMap.Entry entry, Exception e)
          Logs a store store() failure.
protected  void replaceInternal(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 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.
 void store(Object oKey, Object oValue)
          
 void storeAll(Map mapEntries)
          
protected  void storeAllInternal(Set setBinEntries)
          Same as storeAll(java.util.Map), but the entries are in the internal format.
protected  void storeInternal(ReadWriteBackingMap.Entry binEntry, boolean fAllowChange)
          Same as store(java.lang.Object, java.lang.Object), but the based on the backing map entry.
 String toString()
          Return a String representation of the CacheStoreWrapper object that will be used as a part of the write-behind thread name.

 

Constructor Detail

ReadWriteBackingMap.CacheStoreWrapper

public ReadWriteBackingMap.CacheStoreWrapper(CacheStore store)
Construct a CacheStoreWrapper.
Parameters:
store - the CacheStore to wrap

ReadWriteBackingMap.CacheStoreWrapper

public ReadWriteBackingMap.CacheStoreWrapper(BinaryEntryStore store)
Construct a CacheStoreWrapper.
Parameters:
store - the BinaryEntryStore to wrap

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

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

loadInternal

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

loadAllInternal

protected Map loadAllInternal(Set setBinKeys)
Same as loadAll(java.util.Collection), but the keys are in the internal format. Note: this method is currently not used.

storeInternal

protected void storeInternal(ReadWriteBackingMap.Entry binEntry,
                             boolean fAllowChange)
Same as store(java.lang.Object, java.lang.Object), but the based on the backing map entry.
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

storeAllInternal

protected void storeAllInternal(Set setBinEntries)
Same as storeAll(java.util.Map), but the entries are in the internal format.

eraseInternal

protected void eraseInternal(ReadWriteBackingMap.Entry binEntry)
Same as erase(java.lang.Object), but the key is in the internal format.

eraseAllInternal

protected void eraseAllInternal(Set setBinEntries)
Same as eraseAll(java.util.Collection), but the keys is in the internal format. Note: this method is currently not used.

replaceInternal

protected void replaceInternal(ReadWriteBackingMap.Entry entry)
Replace the value in the internal cache for the specified entry. <p/> 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. <p/> Note: for write-through RWBM, this method is onlly called while the entry is locked
Parameters:
entry - the entry that holds the binary value to replace

load

public Object load(Object oKey)

loadAll

public Map loadAll(Collection colKeys)

store

public void store(Object oKey,
                  Object oValue)

storeAll

public void storeAll(Map mapEntries)

erase

public void erase(Object oKey)

eraseAll

public void eraseAll(Collection colKeys)

extractExpiry

protected long extractExpiry(Object o)
Return the expiration decoration for the given object or -1 if the given object does not have an expiration decoration.
Parameters:
o - the decorated object
Returns:
the expiration decoration or -1

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.

getCacheStore

public CacheStore getCacheStore()
The wrapped CacheStore. If not null, the getBinaryEntryStore()
Returns:
the underlying CacheStore this CacheStoreWrapper wraps

getBinaryEntryStore

public BinaryEntryStore getBinaryEntryStore()
The wrapped BinaryEntryStore.
Returns:
the underlying BinaryEntryStore this CacheStoreWrapper wraps

isBinaryEntryStore

public boolean isBinaryEntryStore()

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

onLoadFailure

protected void onLoadFailure(Object oKeyReal,
                             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(Collection colKeys,
                                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,
                              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 -
e - the exception

onStoreAllFailure

protected void onStoreAllFailure(Set setBinEntries,
                                 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. <p/> 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(Object oKeyReal,
                              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(Set setBinEntries,
                                 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(String sOp)
Log the info about an unsupported operation.

formatKeys

protected String formatKeys(Set setBinEntries,
                            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

toString

public String toString()
Return a String representation of the CacheStoreWrapper object that will be used as a part of the write-behind thread name.
Returns:
a String representation of the CacheStoreWrapper object

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


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