Class ReadWriteBackingMapScheme
- All Implemented Interfaces:
BackingMapManagerBuilder
,BuilderCustomization<ReadWriteBackingMap>
,MapBuilder
,NamedCacheBuilder
,ServiceBuilder
,CachingScheme
,ObservableCachingScheme
,Scheme
,ServiceScheme
RemoteCacheScheme
is responsible for creating a fully
configured ReadWriteBackingMap. The setters are annotated so that CODI
can automatically configure the builder After the builder is configured,
the realize method can be called to create either a custom ReadWriteBackingMap
or the internal Coherence ReadWriteBackingMap.- Since:
- Coherence 12.1.2
- Author:
- pfm 2011.11.30
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tangosol.coherence.config.builder.MapBuilder
MapBuilder.Dependencies
-
Field Summary
Fields inherited from class com.tangosol.coherence.config.scheme.AbstractServiceScheme
m_serviceDependencies
Fields inherited from interface com.tangosol.coherence.config.scheme.ServiceScheme
DELIM_APPLICATION_SCOPE, DELIM_DOMAIN_PARTITION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
establishMapListeners
(Map map, ParameterResolver resolver, MapBuilder.Dependencies dependencies) Establishes an appropriateMapListener
(provided by theObservableCachingScheme.getListenerBuilder()
) on theObservableMap
that was produced by theObservableCachingScheme
.Return theCacheStoreScheme
used to create a CacheStore or CacheLoader.getCacheStoreTimeout
(ParameterResolver resolver) Return the timeout interval to use for CacheStore read and write operations.Return the internal map which is set by the backing map manager when the partitioned flag is true.Return the scheme which the specifies the map used to cache entries.Return theScheme
for the cache used to maintain information on cache misses.double
getRefreshAheadFactor
(ParameterResolver resolver) Return refresh-ahead-factor used to calculate the "soft-expiration" time for cache entries.double
getWriteBatchFactor
(ParameterResolver resolver) Return the write-batch-factor element is used to calculate the "soft-ripe" time for write-behind queue entries.getWriteDelay
(ParameterResolver resolver) Return the time interval to defer asynchronous writes to the cache store for a write-behind queue.int
getWriteDelaySeconds
(ParameterResolver resolver) Return the write behind delay in seconds.int
getWriteMaxBatchSize
(ParameterResolver resolver) Return the maximum number of entries to write in a single storeAll operation.int
getWriteRequeueThreshold
(ParameterResolver resolver) Return the size of the write-behind queue at which additional actions could be taken.protected ReadWriteBackingMap
instantiateReadWriteBackingMap
(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, BinaryEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteBackingMap using the specified parameters.protected ReadWriteBackingMap
instantiateReadWriteBackingMap
(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, CacheLoader store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteBackingMap using the specified parameters.protected ReadWriteBackingMap
instantiateReadWriteBackingMap
(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, NonBlockingEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteBackingMap using the specified parameters.protected ReadWriteSplittingBackingMap
instantiateReadWriteSplittingBackingMap
(BackingMapManagerContext context, PartitionAwareBackingMap mapInternal, Map mapMisses, BinaryEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteSplittingBackingMap using the specified parameters.protected ReadWriteSplittingBackingMap
instantiateReadWriteSplittingBackingMap
(BackingMapManagerContext context, PartitionAwareBackingMap mapInternal, Map mapMisses, CacheLoader store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteSplittingBackingMap using the specified parameters.protected ReadWriteSplittingBackingMap
instantiateReadWriteSplittingBackingMap
(BackingMapManagerContext context, PartitionAwareBackingMap mapInternal, Map mapMisses, NonBlockingEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteSplittingBackingMap using the specified parameters.boolean
isReadOnly
(ParameterResolver resolver) Returns true if the cache is read only.boolean
Return true if exceptions caught during synchronous cachestore operations are rethrown to the calling thread (possibly over the network to a remote member).realizeMap
(ParameterResolver resolver, MapBuilder.Dependencies dependencies) Realize aMap
based on the state of theMapBuilder
, resolvable parameters and providedMapBuilder.Dependencies
.void
Set theCacheStoreScheme
builder.void
setCacheStoreTimeout
(Expression<Millis> expr) Set the timeout interval to use for CacheStore/CacheLoader read and write operations.void
Set the internal map.void
setInternalScheme
(CachingScheme scheme) Set the internal scheme.void
setMissCacheScheme
(LocalScheme scheme) Set the miss cacheScheme
.void
setReadOnly
(Expression<Boolean> expr) Set the read-only flag.void
Set the refresh ahead factor.void
Set the flag to indicate that cache store failures should be rolled back.void
setWriteBatchFactor
(Expression<Double> expr) Set the write batch factor.void
setWriteDelay
(Expression<Seconds> expr) Set the write behind delay.void
Set the write behind delay seconds.void
Set the write max batch size.void
Set the size of the write-behind queue at which additional actions could be taken.protected void
validate
(ParameterResolver resolver) Validate the properties.Methods inherited from class com.tangosol.coherence.config.scheme.AbstractLocalCachingScheme
getCustomBuilder, getEventInterceptorBuilders, getServiceType, isRunningClusterNeeded, setCustomBuilder
Methods inherited from class com.tangosol.coherence.config.scheme.AbstractCachingScheme
getDefaultParameterResolver, getListenerBuilder, realizeBackingMapManager, realizeCache, setListenerBuilder
Methods inherited from class com.tangosol.coherence.config.scheme.AbstractServiceScheme
ensureService, getDefaultServiceName, getScopedServiceName, getScopeName, getServiceBuilder, getServiceDependencies, getServiceName, getXml, injectScopeNameIntoService, isAutoStart, realizeService, setAutoStart, setScopeName, setServiceDependencies, setServiceName, setXml
Methods inherited from class com.tangosol.coherence.config.scheme.AbstractScheme
getSchemeName, isAnonymous, setSchemeName, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tangosol.coherence.config.scheme.Scheme
getSchemeName, isAnonymous
Methods inherited from interface com.tangosol.coherence.config.scheme.ServiceScheme
getScopedServiceName, getServiceBuilder, getServiceName, isAutoStart
-
Constructor Details
-
ReadWriteBackingMapScheme
public ReadWriteBackingMapScheme()
-
-
Method Details
-
realizeMap
public ReadWriteBackingMap realizeMap(ParameterResolver resolver, MapBuilder.Dependencies dependencies) Realize aMap
based on the state of theMapBuilder
, resolvable parameters and providedMapBuilder.Dependencies
.- Specified by:
realizeMap
in interfaceMapBuilder
- Overrides:
realizeMap
in classAbstractCachingScheme
- Parameters:
resolver
- theParameterResolver
dependencies
- theMapBuilder.Dependencies
for realizing theMap
- Returns:
- a
Map
-
establishMapListeners
public void establishMapListeners(Map map, ParameterResolver resolver, MapBuilder.Dependencies dependencies) Establishes an appropriateMapListener
(provided by theObservableCachingScheme.getListenerBuilder()
) on theObservableMap
that was produced by theObservableCachingScheme
.This method will automatically inject the following types and named values into realized classes that have been annotated with @Injectable.
-
BackingMapManagerContext
(optionally named "manager-context") -
ConfigurableCacheFactory
- Cache Name (as a
String
.class named "cache-name") - Context
ClassLoader
(optionally named "class-loader") -
ResourceRegistry
-
CacheConfig
- together with any other resource, named or otherwise, available
in the
ResourceRegistry
provided by theConfigurableCacheFactory
.
- Specified by:
establishMapListeners
in interfaceObservableCachingScheme
- Overrides:
establishMapListeners
in classAbstractCachingScheme
- Parameters:
map
- anObservableMap
to which to add aMapListener
(if the map is not observable, no listeners are added)resolver
- theParameterResolver
to use for resolving builder parametersdependencies
- theMapBuilder
dependencies from which to obtain builder information- See Also:
-
-
getCacheStoreScheme
Return theCacheStoreScheme
used to create a CacheStore or CacheLoader.- Returns:
- the builder
-
setCacheStoreScheme
Set theCacheStoreScheme
builder.- Parameters:
bldr
- the builder
-
getCacheStoreTimeout
Return the timeout interval to use for CacheStore read and write operations. If a CacheStore operation times out, the executing thread is interrupted and may ultimately lead to the termination of the cache service. Timeouts of asynchronous CacheStore operations (for example, refresh-ahead, write-behind) do not result in service termination.- Parameters:
resolver
- the ParameterResolver- Returns:
- the timeout
-
setCacheStoreTimeout
Set the timeout interval to use for CacheStore/CacheLoader read and write operations.- Parameters:
expr
- the timeout interval expression
-
getInternalScheme
Return the scheme which the specifies the map used to cache entries.- Returns:
- the scheme for the internal map
-
setInternalScheme
Set the internal scheme.- Parameters:
scheme
- the internal scheme
-
getInternalMap
Return the internal map which is set by the backing map manager when the partitioned flag is true. Otherwise the map will be null.- Returns:
- the internal map
-
setInternalMap
Set the internal map.- Parameters:
map
- the internal map
-
getMissCacheScheme
Return theScheme
for the cache used to maintain information on cache misses. The miss-cache is used track keys which were not found in the cache store. The knowledge that a key is not in the cache store allows some operations to perform faster, as they can avoid querying the potentially slow cache store. A size-limited scheme may be used to control how many misses are cached. If unspecified no cache-miss data is maintained.- Returns:
- the miss cache scheme
-
setMissCacheScheme
Set the miss cacheScheme
.- Parameters:
scheme
- the miss cache scheme
-
isReadOnly
Returns true if the cache is read only. A read-only cache loads data from cache store for read operations and does not perform any writing to the cache store when the cache is updated.- Parameters:
resolver
- the ParameterResolver- Returns:
- true if the cache is read only
-
setReadOnly
Set the read-only flag.- Parameters:
expr
- true if the cache is read-only
-
getRefreshAheadFactor
Return refresh-ahead-factor used to calculate the "soft-expiration" time for cache entries. Soft-expiration is the point in time before the actual expiration after which any access request for an entry schedules an asynchronous load request for the entry. This attribute is only applicable if the internal cache is a LocalCache, with a non-zero expiry delay. The value is expressed as a percentage of the internal LocalCache expiration interval. If zero, refresh-ahead scheduling is disabled. If 1.0, then any get operation immediately triggers an asynchronous reload. Legal values are nonnegative doubles less than or equal to 1.0.- Parameters:
resolver
- the ParameterResolver- Returns:
- the refresh-ahead factor
-
setRefreshAheadFactor
Set the refresh ahead factor.- Parameters:
expr
- the refresh ahead factor
-
isRollbackCacheStoreFailures
Return true if exceptions caught during synchronous cachestore operations are rethrown to the calling thread (possibly over the network to a remote member). Legal values are true or false. If the value of this element is false, an exception caught during a synchronous cachestore operation is logged locally and the internal cache is updated. If the value is true, the exception is rethrown to the calling thread and the internal cache is not changed. If the operation was called within a transactional context, this would have the effect of rolling back the current transaction.- Parameters:
resolver
- the ParameterResolver- Returns:
- the rollback cachestore failures flag
-
setRollbackCacheStoreFailures
@Injectable("rollback-cachestore-failures") public void setRollbackCacheStoreFailures(Expression<Boolean> expr) Set the flag to indicate that cache store failures should be rolled back.- Parameters:
expr
- true if failures should be rolled back
-
getWriteBatchFactor
Return the write-batch-factor element 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-delay interval. The "soft-ripe" time is the point in time before the actual ripe time after which an entry is included in a batched asynchronous write operation to the CacheStore (along with all other ripe and soft-ripe entries).- Parameters:
resolver
- the ParameterResolver- Returns:
- the write batch factor
-
setWriteBatchFactor
Set the write batch factor.- Parameters:
expr
- the write batch factor
-
getWriteDelay
Return the time interval to defer asynchronous writes to the cache store for a write-behind queue. If zero, synchronous writes to the cache store (without queuing) take place, otherwise the writes are asynchronous and deferred by specified time interval after the last update to the value in the cache.- Parameters:
resolver
- the ParameterResolver- Returns:
- the write behind delay
-
setWriteDelay
Set the write behind delay.- Parameters:
expr
- the write behind delay
-
getWriteDelaySeconds
Return the write behind delay in seconds.- Parameters:
resolver
- the ParameterResolver- Returns:
- the write behind delay in seconds
-
setWriteDelaySeconds
Set the write behind delay seconds.- Parameters:
expr
- the write behind delay in seconds
-
getWriteMaxBatchSize
Return the maximum number of entries to write in a single storeAll operation. Valid values are positive integers or zero. The default value is 128 entries. This value has no effect if write behind is disabled.- Parameters:
resolver
- the ParameterResolver- Returns:
- the write maximum batch size
-
setWriteMaxBatchSize
Set the write max batch size.- Parameters:
expr
- the write max batch size
-
getWriteRequeueThreshold
Return the size of the write-behind queue at which additional actions could be taken. If zero, write-behind re-queuing is disabled. Otherwise, this value controls the frequency of the corresponding log messages. For example, a value of 100 produces a log message every time the size of the write queue is a multiple of 100. Legal values are positive integers or zero.- Parameters:
resolver
- the ParameterResolver- Returns:
- the write re-queue threshold
-
setWriteRequeueThreshold
Set the size of the write-behind queue at which additional actions could be taken.- Parameters:
expr
- the write re-queue threshold
-
instantiateReadWriteBackingMap
protected ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, CacheLoader store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteBackingMap using the specified parameters.This method exposes a corresponding ReadWriteBackingMap
constructor
and is provided for the express purpose of allowing its override.- Parameters:
context
- 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)store
- the object 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 ofConfigurableCacheMap
- Returns:
- the instantiated
ReadWriteBackingMap
-
instantiateReadWriteBackingMap
protected ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, BinaryEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteBackingMap using the specified parameters.This method exposes a corresponding ReadWriteBackingMap
constructor
and is provided for the express purpose of allowing its override.- Parameters:
context
- 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 ofConfigurableCacheMap
- Returns:
- the instantiated
ReadWriteBackingMap
-
instantiateReadWriteBackingMap
protected ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, NonBlockingEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteBackingMap using the specified parameters.This method exposes a corresponding ReadWriteBackingMap
constructor
and is provided for the express purpose of allowing its override.- Parameters:
context
- 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 NonBlockingEntryStore 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 ofConfigurableCacheMap
- Returns:
- the instantiated
ReadWriteBackingMap
-
instantiateReadWriteSplittingBackingMap
protected ReadWriteSplittingBackingMap instantiateReadWriteSplittingBackingMap(BackingMapManagerContext context, PartitionAwareBackingMap mapInternal, Map mapMisses, CacheLoader store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteSplittingBackingMap using the specified parameters.This method exposes a corresponding ReadWriteSplittingBackingMap
constructor
and is provided for the express purpose of allowing its override.- Parameters:
context
- 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)store
- the object 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 ofConfigurableCacheMap
- Returns:
- the instantiated
ReadWriteSplittingBackingMap
-
instantiateReadWriteSplittingBackingMap
protected ReadWriteSplittingBackingMap instantiateReadWriteSplittingBackingMap(BackingMapManagerContext context, PartitionAwareBackingMap mapInternal, Map mapMisses, BinaryEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteSplittingBackingMap using the specified parameters.This method exposes a corresponding ReadWriteSplittingBackingMap
constructor
and is provided for the express purpose of allowing its override.- Parameters:
context
- 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 ofConfigurableCacheMap
- Returns:
- the instantiated
ReadWriteSplittingBackingMap
-
instantiateReadWriteSplittingBackingMap
protected ReadWriteSplittingBackingMap instantiateReadWriteSplittingBackingMap(BackingMapManagerContext context, PartitionAwareBackingMap mapInternal, Map mapMisses, NonBlockingEntryStore storeBinary, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor) Construct a ReadWriteSplittingBackingMap using the specified parameters.This method exposes a corresponding ReadWriteSplittingBackingMap
constructor
and is provided for the express purpose of allowing its override.- Parameters:
context
- 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 NonBlockingEntryStore 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 ofConfigurableCacheMap
- Returns:
- the instantiated
ReadWriteSplittingBackingMap
-
validate
Validate the properties.- Overrides:
validate
in classAbstractCachingScheme
- Parameters:
resolver
- the ParameterResolver needed to resolve expressions
-