CoherenceTM v3.1.3
Copyright© 2000-2006 by Tangosol, Inc.

com.tangosol.net.cache
Class VersionedBackingMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by com.tangosol.net.cache.ReadWriteBackingMap
          extended by com.tangosol.net.cache.VersionedBackingMap
All Implemented Interfaces:
ObservableMap, Map

public class VersionedBackingMap
extends ReadWriteBackingMap

Backing Map implementation that provides a size-limited cache of a persistent store and supports configurable write-behind caching. Additionally, this implementation supports a VersionedNearCache in front of the distributed cache, and manages version data caches to optimize the near cache without sacrificing data integrity.

This implementation does not support null keys or null values. The values stored in this Map must implement the Versionable interface.

Author:
cp 2002.10.20

Nested Class Summary
 class VersionedBackingMap.CacheStoreWrapper
          A wrapper around the original CacheStore to allow operations to be overridden and extended.
protected  class VersionedBackingMap.InternalMapListener
          A MapListener implementation that listens to the internal cache and routes those events to anyone listening to this VersionedBackingMap.
 
Nested classes/interfaces inherited from class com.tangosol.net.cache.ReadWriteBackingMap
ReadWriteBackingMap.CacheLoaderCacheStore, ReadWriteBackingMap.EntrySet, ReadWriteBackingMap.KeySet, ReadWriteBackingMap.ReadLatch, ReadWriteBackingMap.ReadQueue, ReadWriteBackingMap.ReadThread, ReadWriteBackingMap.ValuesCollection, ReadWriteBackingMap.WriteQueue, ReadWriteBackingMap.WriteThread
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry
 
Field Summary
static long MAX_LOCK_WAIT
          The length of time (in millis) to wait on a lock; keep this value low to avoid causing timing problems since some calls will be on the distributed cache thread.
 
Fields inherited from class com.tangosol.net.cache.ReadWriteBackingMap
m_listenerSupport, NO_VALUE
 
Constructor Summary
VersionedBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheLoader loader, NamedCache mapVersionTransient, NamedCache mapVersionPersist, boolean fManageTransient)
          Construct a VersionedBackingMap using a CacheLoader object.
VersionedBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheStore store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor, NamedCache mapVersionTransient, NamedCache mapVersionPersist, boolean fManageTransient)
          Construct a VersionedBackingMap using a CacheStore object.
VersionedBackingMap(BackingMapManagerContext ctxService, ObservableMap mapInternal, Map mapMisses, CacheStore store, boolean fReadOnly, int cWriteBehindSeconds, NamedCache mapVersionTransient, NamedCache mapVersionPersist, boolean fManageTransient)
          Construct a VersionedBackingMap using a CacheStore object.
 
Method Summary
 NamedCache getPersistentVersionCache()
          Get the cache of version info for the data stored in the persistent store behind this backing map (and other related backing maps if this is backing a distributed cache).
 NamedCache getTransientVersionCache()
          Get the cache of version info for the data maintained in this backing map (and other related backing maps if this is backing a distributed cache).
protected  ReadWriteBackingMap.CacheStoreWrapper instantiateCacheStoreWrapper(CacheStore store)
          Factory pattern: Instantiate a CacheStore wrapper around the passed CacheStore.
protected  MapListener instantiateInternalListener()
          Factory pattern: Create a MapListener that listens to the internal cache and routes those events to anyone listening to this VersionedBackingMap.
 boolean isManagingTransientVersion()
          Determine if this backing map is responsible for keeping the transient version cache in sync.
protected  void updateOnGet(Map.Entry entryReal)
          Update any relevant data based on the value that has just been loaded from the store as a result of the "get" operation.
protected  void updateOnPut(Map.Entry entryReal)
          Update any relevant data based on the value that is about to be written to the store or queued for write and owned by this context.
protected  void updatePersistentVersion(Object oKey, Comparable ver)
          Update the persistent version of the specified key.
protected  void updateTransientVersion(Object oKey, Comparable ver)
          Update the transient version of the specified key.
 
Methods inherited from class com.tangosol.net.cache.ReadWriteBackingMap
addMapListener, addMapListener, addMapListener, clear, configureCacheStore, configureInternalCache, configureReadThread, configureWriteThread, containsKey, containsValue, entrySet, equals, flush, flush, get, getCacheStore, getContext, getControlMap, getInternalCache, getInternalListener, getInternalLocalCache, getMissesCache, getReadQueue, getReadThread, getRefreshAheadFactor, getSyntheticEventsMap, getWriteBatchFactor, getWriteBehindSeconds, getWriteQueue, getWriteRequeueThreshold, getWriteThread, hashCode, instantiateCacheLoaderCacheStore, instantiateControlMap, instantiateEntrySet, instantiateKeySet, instantiateReadLatch, instantiateReadQueue, instantiateReadThread, instantiateValuesCollection, instantiateWriteQueue, instantiateWriteThread, isActive, isReadOnly, isRefreshAhead, isRethrowExceptions, isWriteBehind, isWriteThrough, keySet, log, log, log, log, put, release, remove, removeMapListener, removeMapListener, removeMapListener, setRefreshAheadFactor, setRethrowExceptions, setWriteBatchFactor, setWriteBehindSeconds, setWriteRequeueThreshold, size, terminateReadThread, terminateWriteThread, toString, updateWriteQueueDelay, values
 
Methods inherited from class java.util.AbstractMap
clone, isEmpty, putAll
 
Methods inherited from interface java.util.Map
isEmpty, putAll
 

Field Detail

MAX_LOCK_WAIT

public static final long MAX_LOCK_WAIT
The length of time (in millis) to wait on a lock; keep this value low to avoid causing timing problems since some calls will be on the distributed cache thread.

See Also:
Constant Field Values
Constructor Detail

VersionedBackingMap

public VersionedBackingMap(BackingMapManagerContext ctxService,
                           ObservableMap mapInternal,
                           Map mapMisses,
                           CacheLoader loader,
                           NamedCache mapVersionTransient,
                           NamedCache mapVersionPersist,
                           boolean fManageTransient)
Construct a VersionedBackingMap using a CacheLoader object.

Parameters:
ctxService - the context provided by the CacheService which is using this backing map
mapInternal - the ObservableMap used to store the data internally in this backing map
mapMisses - the Map used to cache CacheLoader misses (optional)
loader - the object responsible for loading the cached data (optional)
mapVersionTransient - (optional) a replicated cache of versions of the cached data as it is in memory
mapVersionPersist - (optional) a replicated cache of versions of the cached data as it was written to the CacheStore
fManageTransient - if true, the backing map is responsible for keeping the transient version cache up to date; if false (as is the case when using the VersionedNearCache implementation), the backing map manages the transient version cache only for operations for which no other party is aware (such as entry expiry)

VersionedBackingMap

public VersionedBackingMap(BackingMapManagerContext ctxService,
                           ObservableMap mapInternal,
                           Map mapMisses,
                           CacheStore store,
                           boolean fReadOnly,
                           int cWriteBehindSeconds,
                           NamedCache mapVersionTransient,
                           NamedCache mapVersionPersist,
                           boolean fManageTransient)
Construct a VersionedBackingMap using a CacheStore object.

Parameters:
ctxService - the context provided by the CacheService which is using this backing map
mapInternal - the ObservableMap used to store the data internally in this backing map
mapMisses - the Map used to cache CacheStore misses (optional)
store - the object responsible for the persistence of the cached data (optional)
fReadOnly - pass true to use the CacheStore only for read operations
cWriteBehindSeconds - number of seconds to write if there is a CacheStore; zero disables write-behind caching (optional)
mapVersionTransient - (optional) a replicated cache of versions of the cached data as it is in memory
mapVersionPersist - (optional) a replicated cache of versions of the cached data as it was written to the CacheStore
fManageTransient - if true, the backing map is responsible for keeping the transient version cache up to date; if false (as is the case when using the VersionedNearCache implementation), the backing map manages the transient version cache only for operations for which no other party is aware (such as entry expiry)

VersionedBackingMap

public VersionedBackingMap(BackingMapManagerContext ctxService,
                           ObservableMap mapInternal,
                           Map mapMisses,
                           CacheStore store,
                           boolean fReadOnly,
                           int cWriteBehindSeconds,
                           double dflRefreshAheadFactor,
                           NamedCache mapVersionTransient,
                           NamedCache mapVersionPersist,
                           boolean fManageTransient)
Construct a VersionedBackingMap using a CacheStore object.

Parameters:
ctxService - the context provided by the CacheService which is using this backing map
mapInternal - the ObservableMap used to store the data internally in this backing map
mapMisses - the Map used to cache CacheStore misses (optional)
store - the object responsible for the persistence of the cached data (optional)
fReadOnly - pass true to use the CacheStore only for read operations
cWriteBehindSeconds - number of seconds to write if there is a CacheStore; zero disables write-behind caching (optional)
dflRefreshAheadFactor - the interval before an entry expiration time (expressed as a percentage of the internal cache expiration interval) during which an asynchronous load request for the entry will be scheduled; zero disables refresh-ahead; only applicable when the mapInternal parameter is an instance of LocalCache (optional)
mapVersionTransient - (optional) a replicated cache of versions of the cached data as it is in memory
mapVersionPersist - (optional) a replicated cache of versions of the cached data as it was written to the CacheStore
fManageTransient - if true, the backing map is responsible for keeping the transient version cache up to date; if false (as is the case when using the VersionedNearCache implementation), the backing map manages the transient version cache only for operations for which no other party is aware (such as entry expiry)
Method Detail

updateOnGet

protected void updateOnGet(Map.Entry entryReal)
Update any relevant data based on the value that has just been loaded from the store as a result of the "get" operation. This method is called while the entry is locked and intended to be overriden by subclasses.

Overrides:
updateOnGet in class ReadWriteBackingMap

updateOnPut

protected void updateOnPut(Map.Entry entryReal)
Update any relevant data based on the value that is about to be written to the store or queued for write and owned by this context. This method is called while the entry is locked and intended to be overriden by subclasses.

Overrides:
updateOnPut in class ReadWriteBackingMap

instantiateInternalListener

protected MapListener instantiateInternalListener()
Factory pattern: Create a MapListener that listens to the internal cache and routes those events to anyone listening to this VersionedBackingMap.

Overrides:
instantiateInternalListener in class ReadWriteBackingMap
Returns:
a new routing MapListener

instantiateCacheStoreWrapper

protected ReadWriteBackingMap.CacheStoreWrapper instantiateCacheStoreWrapper(CacheStore store)
Factory pattern: Instantiate a CacheStore wrapper around the passed CacheStore. (Supports CacheStore extension by delegation pattern.)

Overrides:
instantiateCacheStoreWrapper in class ReadWriteBackingMap
Parameters:
store - the CacheStore to wrap
Returns:
the CacheStoreWrapper that can supplement and override the operations of the supplied CacheStore

getPersistentVersionCache

public NamedCache getPersistentVersionCache()
Get the cache of version info for the data stored in the persistent store behind this backing map (and other related backing maps if this is backing a distributed cache).

Returns:
the NamedCache object that has a "last written" version entry for each key maintained in memory by this cache, or null if the version cache is not used

updatePersistentVersion

protected void updatePersistentVersion(Object oKey,
                                       Comparable ver)
Update the persistent version of the specified key.

Parameters:
oKey - the key in its external ("real") format
ver - the new version to store; null implies remove

getTransientVersionCache

public NamedCache getTransientVersionCache()
Get the cache of version info for the data maintained in this backing map (and other related backing maps if this is backing a distributed cache).

Returns:
the NamedCache object that has a version entry for each key maintained in memory by this cache, or null if the version cache is not used

updateTransientVersion

protected void updateTransientVersion(Object oKey,
                                      Comparable ver)
Update the transient version of the specified key.

Parameters:
oKey - the key in its external ("real") format
ver - the new version to store; null implies remove

isManagingTransientVersion

public boolean isManagingTransientVersion()
Determine if this backing map is responsible for keeping the transient version cache in sync.

Returns:
true if the backing map is the object that is maintaining the transient version cache; false if it is not (e.g. if the VersionedNearCache is being used)

CoherenceTM v3.1.3
Copyright© 2000-2006 by Tangosol, Inc.