public class ObservableSplittingBackingCache extends ObservableSplittingBackingMap implements ConfigurableCacheMap
LocalCache
, but it internally
partitions its data across any number of caches that implement the
ConfigurableCacheMap interface. Note that the underlying backing maps must
implement the ConfigurableCacheMap interface or a runtime exception will
occur.Modifier and Type | Class and Description |
---|---|
protected static class |
ObservableSplittingBackingCache.CapacityAwareMap
A subclass of PartitionSplittingBackingMap which allows an injected instance
of
ObservableSplittingBackingMap to be called immediately before
inserting a value(s) in a partition map. |
class |
ObservableSplittingBackingCache.EntrySet
A set of ConfigurableCacheMap entries backed by this map.
|
WrapperObservableMap.InternalListener
AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection
AbstractKeyBasedMap.DeferredCacheEvent<K,V>
Base.LoggingWriter, Base.StackFrame
ConfigurableCacheMap.Entry, ConfigurableCacheMap.EvictionApprover, ConfigurableCacheMap.EvictionPolicy, ConfigurableCacheMap.UnitCalculator
Modifier and Type | Field and Description |
---|---|
protected ConfigurableCacheMap[] |
m_acache
A cached array of the backing ConfigurableCacheMap instances.
|
protected ConfigurableCacheMap.EvictionApprover |
m_apprvrEvict
An optional EvictionApprover registered with this cache.
|
protected ConfigurableCacheMap.UnitCalculator |
m_calculator
The unit calculator.
|
protected int |
m_cExpiryDelayMillis
The expiry delay.
|
protected int |
m_cHighUnitFairShare
The fair share of high units for each partition map.
|
protected int |
m_cHighUnits
High units is the number of units that triggers eviction.
|
protected int |
m_cHighUnitsCalibrated
The high units adjusted based on the
partition unit factor . |
protected int |
m_cLowUnitFairShare
The fair share of low units for each partition map.
|
protected int |
m_cLowUnits
Low units is the number of units to evict down to.
|
protected int |
m_cLowUnitsCalibrated
The low units adjusted based on the
partition unit factor . |
protected Class |
m_clzPartitionMap |
protected int |
m_nUnitFactor
The unit factor.
|
protected ConfigurableCacheMap.EvictionPolicy |
m_policy
The eviction policy.
|
protected static int |
MAX_PARTITION_MAP_UNIT_FACTOR
The maximum unit factor for partition maps.
|
m_fDeferredEvent, m_fTranslateEvents, m_listenerInternal, m_listenerSupport, m_map, m_stats
LOG_ALWAYS, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
EXPIRY_DEFAULT, EXPIRY_NEVER
Constructor and Description |
---|
ObservableSplittingBackingCache(BackingMapManager bmm,
String sName)
Create a ObservableSplittingBackingCache that adds ConfigurableCacheMap
functionality to an ObservableSplittingBackingMap.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adjustUnits(int cUnits)
Adjust the number of units for each map with the pool of units provided.
|
protected int |
calcUnitFairShare(int cUnits)
Return the fair share of units for each child maps.
|
protected void |
claimAll(ConfigurableCacheMap mapRequestor)
Claim the full entitlement of units for mapRequestor.
|
protected void |
claimUnused(ConfigurableCacheMap mapRequestor)
Claim as many units as possible from existing maps without causing
over-allocated maps to evict.
|
void |
createPartition(int nPid)
Add a partition to the PartitionAwareBackingMap.
|
void |
destroyPartition(int nPid)
Remove a partition from the PartitionAwareBackingMap.
|
void |
evict()
Evict all entries from the cache that are no longer valid, and
potentially prune the cache size if the cache is size-limited
and its size is above the caching low water mark.
|
void |
evict(Object oKey)
Evict a specified key from the cache, as if it had expired from the
cache.
|
void |
evictAll(Collection colKeys)
Evict the specified keys from the cache, as if they had each expired
from the cache.
|
ConfigurableCacheMap.Entry |
getCacheEntry(Object oKey)
Locate a cache Entry in the cache based on its key.
|
protected int |
getCalibratedHighUnits()
Determine the high units adjusted based on the
partition unit factor . |
protected int |
getCalibratedLowUnits()
Determine the low units adjusted based on the
partition unit factor . |
ConfigurableCacheMap.EvictionApprover |
getEvictionApprover()
Obtain the registered EvictionApprover.
|
ConfigurableCacheMap.EvictionPolicy |
getEvictionPolicy()
Obtain the current EvictionPolicy used by the cache.
|
int |
getExpiryDelay()
Determine the default "time to live" for each individual cache entry.
|
protected int |
getHighUnitFairShare()
Return the fair share of high-units per partition map.
|
int |
getHighUnits()
Determine the limit of the cache size in units.
|
protected int |
getLowUnitFairShare()
Return the fair share of low-units per partition map.
|
int |
getLowUnits()
Determine the point to which the cache will shrink when it prunes.
|
long |
getNextExpiryTime()
Determine the next expiry time for the cache entries.
|
protected ConfigurableCacheMap |
getPartitionCache(Object oKey)
Obtain the backing cache for a particular key.
|
protected ConfigurableCacheMap[] |
getPartitionCacheArray()
Obtain the array of backing caches.
|
Class |
getPartitionMapType()
Return the uniform type used by each partition map.
|
protected int |
getPartitionUnitFactor()
Determine the unit factor for individual partition maps.
|
ConfigurableCacheMap.UnitCalculator |
getUnitCalculator()
Obtain the current UnitCalculator used by the cache.
|
int |
getUnitFactor()
Determine the factor by which the Units, LowUnits and HighUnits
properties are adjusted.
|
int |
getUnits()
Determine the number of units that the cache currently stores.
|
protected void |
initializeConfiguredProperties()
Initialize the configurable properties of this cache-map.
|
protected Set |
instantiateEntrySet()
Factory pattern: Create a Set that represents the entries in the Map.
|
protected void |
prepareUpdate(Map mapPartition,
Map mapUpdate)
Prepare mapPart, a map representing a partition, for the impending changes
in which all of the mappings from mapUpdate will be copied to mapPart.
|
void |
setEvictionApprover(ConfigurableCacheMap.EvictionApprover approver)
Set the EvictionApprover for this ConfigurableCacheMap.
|
void |
setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
Set the EvictionPolicy for the cache to use.
|
void |
setExpiryDelay(int cMillis)
Specify the default "time to live" for cache entries.
|
void |
setHighUnits(int cMax)
Update the maximum size of the cache in units.
|
void |
setLowUnits(int cUnits)
Specify the point to which the cache will shrink when it prunes.
|
void |
setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
Set the UnitCalculator for the cache to use.
|
void |
setUnitFactor(int nFactor)
Determine the factor by which the Units, LowUnits and HighUnits
properties are adjusted.
|
addMapListener, addMapListener, dispose, getBackingMapManager, getCacheStatistics, getName, getPartitionMap, getPartitionMap, getPartitionSplittingBackingMap, isCollectStats, isEventFabricator, put, removeMapListener, removeMapListener, setTranslateEvents, toString
addMapListener, clear, containsValue, dispatchEvent, dispatchPendingEvent, ensureInternalListener, ensureMapListenerSupport, equals, get, getDescription, getInternalKeySet, getMap, getMapListenerSupport, hashCode, hasListeners, instantiateInternalListener, isInternalKeySetIteratorMutable, isSynthetic, isTranslateEvents, put, putAll, remove, removeBlind, removeMapListener, setCollectStats
containsKey, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, size
clone, entrySet, getAll, keySet, values
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, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, 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
finalize, getClass, notify, notifyAll, wait, wait, wait
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
protected static final int MAX_PARTITION_MAP_UNIT_FACTOR
protected int m_cHighUnits
protected int m_cLowUnits
protected int m_cHighUnitsCalibrated
partition unit factor
.protected int m_cLowUnitsCalibrated
partition unit factor
.protected int m_nUnitFactor
protected int m_cExpiryDelayMillis
protected int m_cHighUnitFairShare
protected int m_cLowUnitFairShare
protected ConfigurableCacheMap.EvictionPolicy m_policy
protected ConfigurableCacheMap.UnitCalculator m_calculator
protected ConfigurableCacheMap[] m_acache
protected ConfigurableCacheMap.EvictionApprover m_apprvrEvict
protected Class m_clzPartitionMap
public ObservableSplittingBackingCache(BackingMapManager bmm, String sName)
bmm
- a callback that knows how to create and release the
backing maps that this ObservableSplittingBackingCache is
responsible forsName
- the cache name for which this backing map existspublic void createPartition(int nPid)
createPartition
in interface PartitionAwareBackingMap
createPartition
in class ObservableSplittingBackingMap
nPid
- the partition id that the PartitionAwareBackingMap will be
responsible for, starting at this instantpublic void destroyPartition(int nPid)
destroyPartition
in interface PartitionAwareBackingMap
destroyPartition
in class ObservableSplittingBackingMap
nPid
- the partition id that the PartitionAwareBackingMap will no
longer be responsible for, starting at this instantpublic int getUnits()
Note: It is expected that the return type will be widened to a long in Coherence 4.
getUnits
in interface ConfigurableCacheMap
public int getHighUnits()
Note: It is expected that the return type will be widened to a long in Coherence 4.
getHighUnits
in interface ConfigurableCacheMap
public void setHighUnits(int cMax)
Note: It is expected that the parameter will be widened to a long in Coherence 4.
setHighUnits
in interface ConfigurableCacheMap
cMax
- the new maximum size of the cache, in unitspublic int getLowUnits()
Note: It is expected that the parameter will be widened to a long in Coherence 4.
getLowUnits
in interface ConfigurableCacheMap
public void setLowUnits(int cUnits)
Note: It is expected that the parameter will be widened to a long in Coherence 4.
setLowUnits
in interface ConfigurableCacheMap
cUnits
- the number of units that the cache prunes topublic int getUnitFactor()
Note: This property exists only to avoid changing the type of the units, low units and high units properties from 32-bit values to 64-bit values. It is expected that the parameter will be dropped in Coherence 4.
getUnitFactor
in interface ConfigurableCacheMap
public void setUnitFactor(int nFactor)
Note: This property exists only to avoid changing the type of the units, low units and high units properties from 32-bit values to 64-bit values. It is expected that the parameter will be dropped in Coherence 4.
setUnitFactor
in interface ConfigurableCacheMap
nFactor
- the units factor; the default is 1public ConfigurableCacheMap.EvictionPolicy getEvictionPolicy()
getEvictionPolicy
in interface ConfigurableCacheMap
public void setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
setEvictionPolicy
in interface ConfigurableCacheMap
policy
- an EvictionPolicypublic void evict(Object oKey)
evict
in interface ConfigurableCacheMap
oKey
- the key to evict from the cachepublic void evictAll(Collection colKeys)
The result of this method is defined to be semantically the same as the following implementation:
for (Iterator iter = colKeys.iterator(); iter.hasNext(); ) { Object oKey = iter.next(); evict(oKey); }
evictAll
in interface ConfigurableCacheMap
colKeys
- a collection of keys to evict from the cachepublic void evict()
evict
in interface ConfigurableCacheMap
public ConfigurableCacheMap.EvictionApprover getEvictionApprover()
getEvictionApprover
in interface ConfigurableCacheMap
public void setEvictionApprover(ConfigurableCacheMap.EvictionApprover approver)
setEvictionApprover
in interface ConfigurableCacheMap
approver
- the EvictionApproverpublic int getExpiryDelay()
getExpiryDelay
in interface ConfigurableCacheMap
public void setExpiryDelay(int cMillis)
setExpiryDelay
in interface ConfigurableCacheMap
cMillis
- the number of milliseconds that cache entries will
live, or zero to disable automatic expirypublic long getNextExpiryTime()
getNextExpiryTime
in interface ConfigurableCacheMap
SafeClock
) that one
or more cache entries will expire or zero if the cache is empty,
its entries never expire or the implementation chooses to
avoid the pro-active evictionpublic ConfigurableCacheMap.Entry getCacheEntry(Object oKey)
getCacheEntry
in interface ConfigurableCacheMap
oKey
- the key object to search forpublic ConfigurableCacheMap.UnitCalculator getUnitCalculator()
getUnitCalculator
in interface ConfigurableCacheMap
public void setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
setUnitCalculator
in interface ConfigurableCacheMap
calculator
- a UnitCalculatorpublic Class getPartitionMapType()
protected void prepareUpdate(Map mapPartition, Map mapUpdate)
This implementation will check if mapPart is under-allocated for high units. If this is the case, demand the entitled unit amount from other maps.
prepareUpdate
in class ObservableSplittingBackingMap
mapPartition
- the map to be mutated with the contents of mapUpdatemapUpdate
- the map of changes to be appliedprotected void claimUnused(ConfigurableCacheMap mapRequestor)
mapRequestor
- the map requesting its fair share of unitsprotected void claimAll(ConfigurableCacheMap mapRequestor)
mapRequestor
- the map demanding its entitled fair shareprotected void adjustUnits(int cUnits)
The provided units may be positive or negative, with the latter suggesting that this number of units should be retrieved, thus decremented, from child maps. If the provided units is positive, maps that are over-allocated may consumer the provided amount. If the provided units is negative maintain a positive delta between the fair share and their current high units may consume the minimum between what is available from the provided units and the determined delta. If the provided units is negative, those maps whose current high unit allocation is more than the fair share will have this delta decremented until the debt (cUnits) is reclaimed.
cUnits
- the number of units to either disseminate (positive unit value)
or retract across the mapsprotected void initializeConfiguredProperties()
protected ConfigurableCacheMap getPartitionCache(Object oKey)
oKey
- the key of the desired entryprotected ConfigurableCacheMap[] getPartitionCacheArray()
protected int getCalibratedHighUnits()
partition unit factor
.protected int getCalibratedLowUnits()
partition unit factor
.protected int getPartitionUnitFactor()
protected int getLowUnitFairShare()
protected int getHighUnitFairShare()
protected int calcUnitFairShare(int cUnits)
cUnits
- the units to distribute across all child mapsprotected Set instantiateEntrySet()
instantiateEntrySet
in class AbstractKeySetBasedMap