Class OverflowMap
- All Implemented Interfaces:
CacheMap
,ObservableMap
,Map
The OverflowMap is observable, and as such it is allowed to be an active
data structure. In other words, it supports item expiration, eviction, and
other types of "self-generating" events. (The SimpleOverflowMap
) is
an alternative that may be more efficient if the overflow map is passive.)
As a consequence of the requirements for managing the overflow map as an
active data structure, the OverflowMap maintains information about each
entry in the map; in practice, this will limit the size of the OverflowMap
since all keys and some additional information for each key will be
maintained in memory. On the other hand, by maintaining this information
in memory, certain operations will be more efficient, such as the methods
containsKey()
, size()
,
keySet().iterator()
, etc.
(Again, for an alternative, see SimpleOverflowMap
, which does not
maintain the entire set of keys in memory.)
The primary reason why OverflowMap is based on the AbstractKeySetBasedMap
is that the set of keys within the OverflowMap is considered to be "known",
although not altogether stable due to concurrency issues (the OverflowMap
is designed to support a high level of concurrency). AbstractKeySetBasedMap
conceptually delegates many operations down to its key Set, which the
OverflowMap implementation reverses (by having the implementations on the
OverflowMap itself). However, the key and entry Sets and the values
Collection benefit significantly in terms of their ability to optimize
the Collection.iterator()
and Collection.toArray()
methods.
Further, as a result (and sometimes as a consequence) of its observability, the OverflowMap supports (and has to support) a number of capabilities that the SimpleOverflowMap does not:
- Expiry - the entries in the OverflowMap can each have their own expiry, which is respected regardless of whether the entry is being managed in the front and/or back map.
- Reentrancy - since an event listener on the OverflowMap can respond to an event in an unpredictable manner, including by attempting to undo or compensate for or react to the event, the OverflowMap is forced to support reentrancy.
- Since:
- Coherence 2.2
- Author:
- cp 2003.05.24, cp 2005.08.11 re-architected and split out SimpleOverflowMap
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
A listener for the back map.class
A set of entries backed by this map.protected static class
The ExpirableStatus adds expiry to the base Status object.protected class
A listener for the front map that moves evictions to the back map.protected static class
A CacheEvent that carries a recent value (to avoid it being lost during eviction).protected class
A read-only set of keys backed by this map.protected static class
The Status object is used to manage concurrency at the key level for the key-level operations against the Map, to track all the items in the front Map, to manage the state transition for operations occurring against the Map, and to coordinate events across multiple threads.Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap
AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeyBasedMap
AbstractKeyBasedMap.DeferredCacheEvent<K,
V> Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
This event indicates that an entry has been removed from the map.static final int
This event indicates that an entry has been added to the map.static final int
This event indicates that an entry has been updated in the map.Fields inherited from class com.tangosol.util.Base
LOG_ALWAYS, LOG_CONFIG, 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
Fields inherited from interface com.tangosol.net.cache.CacheMap
EXPIRY_DEFAULT, EXPIRY_NEVER
-
Constructor Summary
ConstructorDescriptionOverflowMap
(ObservableMap mapFront, Map mapBack) Construct a OverflowMap using two specified maps: FrontMap (aka "cache" or "shallow") and BackMap (aka "file" or "deep") If the BackMap implements the ObservableMap interface a listener will be added to the BackMap to invalidate items updated [externally] in the back map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapListener
(MapListener listener) Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included.void
addMapListener
(MapListener listener, Filter filter, boolean fLite) Add a map listener that receives events based on a filter evaluation.void
addMapListener
(MapListener listener, Object oKey, boolean fLite) Add a map listener for a specific key.protected void
adjustSize
(int cItems) Adjust the number of entries in the OverflowMap.protected OverflowMap.Status
beginKeyProcess
(Object oKey) Block until a key is available for processing, and return the Status object for that key.protected void
Block until this thread has exclusive access to perform operations against the OverflowMap.void
clear()
Clear all key/value mappings.protected void
closeStatus
(OverflowMap.Status status) Helper method to close a Status, processing any pending events as part of the process.boolean
containsKey
(Object oKey) Returns true if this map contains a mapping for the specified key.protected void
dispatchEvent
(OverflowMap.Status status, int nId, Object oKey, Object oValueOld, Object oValueNew, boolean fSynthetic) Dispatch an event containing the passed event information.protected void
dispatchEvent
(OverflowMap.Status status, MapEvent evt) Dispatch the passed event.protected void
endKeyProcess
(Object oKey, OverflowMap.Status status) Finish the processing of a single key.protected void
Release exclusive access for the OverflowMap.void
evict()
Flush items that have expired.protected static void
If the passed Map supports it, evict its expired data.Returns the value to which this map maps the specified key.getAll
(Collection colKeys) Get all the specified keys, if they are in the Map.Returns the back Map.protected MapListener
Get the MapListener for the back map.Returns the CacheStatistics for this cache.protected List
Obtain the List of keys that may have deferred events.protected LongArray
Obtain the array of keys that have an expiration, indexed by expiration times.int
Determine the "time to live" for each individual cache entry.Returns the front Map.protected MapListener
Get the MapListener for the front map.protected Gate
getGate()
Obtain the Gate for managing key-level and Collection-level operations against the Map, versus Map-level operations themselves.protected Object
getInternal
(Object oKey, boolean fStats, Map mapResult) A combined implementation ofget(java.lang.Object)
andgetAll(java.util.Collection)
that eliminates duplicate (and very complex) code.protected Set
Obtain a set of keys that are represented by this Map.protected static Object
Obtain the latest old value from the passed event.protected MapListenerSupport
Accessor for the MapListenerSupport for sub-classes.protected int
getSize()
Obtain the number of entries in the OverflowMap.protected Map
Obtain the Map of Status objects for entries managed by this Overflow Map.protected boolean
Determine if the OverflowMap has any listeners at all.protected MapListener
Factory pattern: Back Map Listener.protected Set
Factory pattern: Create a Set that represents the entries in the Map.protected MapListener
Factory pattern: Front Map Listener.protected Set
Factory pattern: Create a read-only Set of keys in the Overflow Mapprotected OverflowMap.Status
Factory method: Instantiate a Status object.boolean
isEmpty()
Returns true if this map contains no key-value mappings.boolean
Determine if this OverflowMap supports entry expiry.boolean
Determine if the front Map is more efficiently updated using putAll.protected boolean
Determine if this Iterator should remove an iterated item by calling remove on the internal key Set Iterator, or by calling removeBlind on the map itself.boolean
Determine if null values are permitted.protected static boolean
isSynthetic
(MapEvent evt) Helper method to determine if an event is synthetic.protected static MapEvent
mergeEvents
(MapEvent evtOld, MapEvent evtNew) Merge two events that have been raised in sequence from a given map.protected void
onBackEvent
(MapEvent evtBack) Handle an event occuring against the "back" map.protected void
onFrontEvent
(MapEvent evt) Either handle an event by turning it over to another thread that is processing the key specified by the event, or take responsibility on this thread for deferring the event and registering its immediate side-effects.protected boolean
prepareStatus
(Object oKey, OverflowMap.Status status) Validate the status and process any deferred events or pending expiry.protected void
processBackEvent
(OverflowMap.Status status, MapEvent evtBack) Process an event.protected void
processDeferredEvents
(boolean fProcessAll) Process deferred events, if there are any.protected void
processEvent
(OverflowMap.Status status, MapEvent evt) Process an arbitrary event that has occurred against either the front or back map.protected void
processFrontEvent
(OverflowMap.Status status, MapEvent evtFront) Process an event.Associates the specified value with the specified key in this map.Associates the specified value with the specified key in this cache.void
Copies all of the mappings from the specified map to this map.protected Object
putInternal
(Object oKey, Object oValue, boolean fStoreOnly, long cMillis) A combined implementation ofput(Object, Object)
and "void put(Object, Object)" that eliminates duplicate (and muchos complex) code between theput(java.lang.Object, java.lang.Object)
andputAll(java.util.Map)
methods.protected static void
Helper to put a value into a map using either the put or putAll method.protected void
registerExpiry
(Object oKey, long ldtExpire) Register an expiry for the specified key.protected void
releaseClosedStatus
(Object oKey) Helper method to encapsulate the release of a Status object on which closeProcessing() has already been called.Removes the mapping for this key from this map if present.protected boolean
removeBlind
(Object oKey) Removes the mapping for this key from this map if present.protected Object
removeInternal
(Object oKey, boolean fCheckRemovedOnly, boolean fEviction) A combined implementation of remove() and removeBlind() that eliminates duplicate (and muchos complex) codevoid
removeMapListener
(MapListener listener) Remove a standard map listener that previously signed up for all events.void
removeMapListener
(MapListener listener, Filter filter) Remove a map listener that previously signed up for events based on a filter evaluation.void
removeMapListener
(MapListener listener, Object oKey) Remove a map listener that previously signed up for events about a specific key.protected void
setBackMapListener
(MapListener listener) Specify the MapListener for the back map.protected void
setExpiryArray
(LongArray laExpiry) Specify the array of keys that have an expiration, indexed by expiration times.void
setExpiryDelay
(int cMillis) Specify the "time to live" for cache entries.void
setExpiryEnabled
(boolean fEnableExpiry) Specify whether or not entry expiry is supported.protected void
setFrontMapListener
(MapListener listener) Specify the MapListener for the front map.void
setFrontPutBlind
(boolean fUseFrontPutAll) Specify whether the front Map is more efficiently updated using putAll.void
setNullValuesAllowed
(boolean fAllowNulls) Specify whether null values are permitted.protected void
setSize
(int cItems) Update the number of entries in the OverflowMap.int
size()
Returns the number of key-value mappings in this map.protected void
unregisterExpiry
(Object oKey, long ldtExpire) Unregister the specified key expiry that is registered to expire at the specified time.protected static void
verifyNoNulls
(Collection collection, String sAssert) Check the passed collection for nulls, and fail if it contains any.protected static void
warnEventSequence
(MapEvent evtOld, MapEvent evtNew) Issue a one-time warning that events are being received in an order than cannot be explained by normal operation according to the contracts expected by this OverflowMap.protected void
warnMissingEvent
(Object oKey, int nId, boolean fFront) An expected event did not get raised.protected void
warnUnfathomable
(MapEvent evt) Something totally inexplicable has occurred.Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap
instantiateKeyIterator, instantiateKeySet, instantiateValues, iterateKeys
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap
clone, containsValue, entrySet, equals, hashCode, keySet, toString, values
Methods inherited from class com.tangosol.util.Base
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, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, 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
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, values
-
Field Details
-
ENTRY_INSERTED
public static final int ENTRY_INSERTEDThis event indicates that an entry has been added to the map.- See Also:
-
ENTRY_UPDATED
public static final int ENTRY_UPDATEDThis event indicates that an entry has been updated in the map.- See Also:
-
ENTRY_DELETED
public static final int ENTRY_DELETEDThis event indicates that an entry has been removed from the map.- See Also:
-
-
Constructor Details
-
OverflowMap
Construct a OverflowMap using two specified maps:- FrontMap (aka "cache" or "shallow") and
- BackMap (aka "file" or "deep")
- Parameters:
mapFront
- front mapmapBack
- back map
-
-
Method Details
-
clear
public void clear()Clear all key/value mappings.- Specified by:
clear
in interfaceMap
- Overrides:
clear
in classAbstractKeyBasedMap
-
containsKey
Returns true if this map contains a mapping for the specified key.- Specified by:
containsKey
in interfaceMap
- Overrides:
containsKey
in classAbstractKeySetBasedMap
- Returns:
- true if this map contains a mapping for the specified key, false otherwise.
-
get
Returns the value to which this map maps the specified key.- Specified by:
get
in interfaceMap
- Specified by:
get
in classAbstractKeyBasedMap
- Parameters:
oKey
- the key object- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key
-
isEmpty
public boolean isEmpty()Returns true if this map contains no key-value mappings.- Specified by:
isEmpty
in interfaceMap
- Overrides:
isEmpty
in classAbstractKeySetBasedMap
- Returns:
- true if this map contains no key-value mappings
-
put
Associates the specified value with the specified key in this map.- Specified by:
put
in interfaceCacheMap
- Specified by:
put
in interfaceMap
- Overrides:
put
in classAbstractKeyBasedMap
- Parameters:
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key- Returns:
- previous value associated with specified key, or null if there was no mapping for key
-
putAll
Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of callingAbstractKeyBasedMap.put(K, V)
on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.- Specified by:
putAll
in interfaceMap
- Overrides:
putAll
in classAbstractKeyBasedMap
- Parameters:
map
- the Map containing the key/value pairings to put into this Map
-
remove
Removes the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.- Specified by:
remove
in interfaceMap
- Overrides:
remove
in classAbstractKeyBasedMap
- Parameters:
oKey
- key whose mapping is to be removed from the map- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
-
size
public int size()Returns the number of key-value mappings in this map.- Specified by:
size
in interfaceMap
- Overrides:
size
in classAbstractKeySetBasedMap
- Returns:
- the number of key-value mappings in this map
-
put
Associates the specified value with the specified key in this cache. If the cache previously contained a mapping for this key, the old value is replaced. This variation of theCacheMap.put(Object oKey, Object oValue)
method allows the caller to specify an expiry (or "time to live") for the cache entry.- Specified by:
put
in interfaceCacheMap
- Parameters:
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keycMillis
- the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; passCacheMap.EXPIRY_DEFAULT
to use the cache's default time-to-live setting; passCacheMap.EXPIRY_NEVER
to indicate that the cache entry should never expire; this milliseconds value is not a date/time value, such as is returned from System.currentTimeMillis()- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
-
getAll
Get all the specified keys, if they are in the Map. For each key that is in the cache, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the cache, which may imply (for caches that can load behind the scenes) that the requested data could not be loaded.- Specified by:
getAll
in interfaceCacheMap
- Overrides:
getAll
in classAbstractKeyBasedMap
- Parameters:
colKeys
- a collection of keys that may be in the named cache- Returns:
- a Map of keys to values for the specified keys passed in colKeys
-
addMapListener
Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included. This has the same result as the following call:addMapListener(listener, (Filter) null, false);
- Specified by:
addMapListener
in interfaceObservableMap
- Parameters:
listener
- theMapEvent
listener to add
-
removeMapListener
Remove a standard map listener that previously signed up for all events. This has the same result as the following call:removeMapListener(listener, (Filter) null);
- Specified by:
removeMapListener
in interfaceObservableMap
- Parameters:
listener
- the listener to remove
-
addMapListener
Add a map listener for a specific key.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the
ObservableMap.removeMapListener(MapListener, Object)
method.- Specified by:
addMapListener
in interfaceObservableMap
- Parameters:
listener
- theMapEvent
listener to addoKey
- the key that identifies the entry for which to raise eventsfLite
- true to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
Remove a map listener that previously signed up for events about a specific key.- Specified by:
removeMapListener
in interfaceObservableMap
- Parameters:
listener
- the listener to removeoKey
- the key that identifies the entry for which to raise events
-
addMapListener
Add a map listener that receives events based on a filter evaluation.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the
ObservableMap.removeMapListener(MapListener, Filter)
method.- Specified by:
addMapListener
in interfaceObservableMap
- Parameters:
listener
- theMapEvent
listener to addfilter
- a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent (seeMapEventFilter
); null is equivalent to a filter that alway returns truefLite
- true to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
Remove a map listener that previously signed up for events based on a filter evaluation.- Specified by:
removeMapListener
in interfaceObservableMap
- Parameters:
listener
- the listener to removefilter
- the filter that was passed into the corresponding addMapListener() call
-
removeBlind
Removes the mapping for this key from this map if present. This method exists to allow sub-classes to optimize remove functionality for situations in which the original value is not required.- Overrides:
removeBlind
in classAbstractKeyBasedMap
- Parameters:
oKey
- key whose mapping is to be removed from the map- Returns:
- true iff the Map changed as the result of this operation
-
getInternalKeySet
Obtain a set of keys that are represented by this Map.The AbstractKeySetBasedMap only utilizes the internal key set as a read-only resource.
- Specified by:
getInternalKeySet
in classAbstractKeySetBasedMap
- Returns:
- an internal Set of keys that are contained by this Map
-
isInternalKeySetIteratorMutable
protected boolean isInternalKeySetIteratorMutable()Determine if this Iterator should remove an iterated item by calling remove on the internal key Set Iterator, or by calling removeBlind on the map itself.- Overrides:
isInternalKeySetIteratorMutable
in classAbstractKeySetBasedMap
- Returns:
- true to remove using the internal key Set Iterator or false to
use the
AbstractKeyBasedMap.removeBlind(Object)
method
-
getInternal
A combined implementation ofget(java.lang.Object)
andgetAll(java.util.Collection)
that eliminates duplicate (and very complex) code.- Parameters:
oKey
- the key to accessfStats
- pass true to update statisticsmapResult
- pass a map into which the key and its value will be put iff the key is contained within the overflow map- Returns:
- the value (which may be null) is returned from the entry if it exists, otherwise null is returned
-
putInternal
A combined implementation ofput(Object, Object)
and "void put(Object, Object)" that eliminates duplicate (and muchos complex) code between theput(java.lang.Object, java.lang.Object)
andputAll(java.util.Map)
methods. Additionally implements the put-with-expiry option.- Parameters:
oKey
- the key to storeoValue
- the value to storefStoreOnly
- pass true to simply store the new value, or false to both store the new value and return the previous valuecMillis
- the time-to-live for the entry as defined byCacheMap.put(Object, Object, long)
- Returns:
- the previous value if fStoreOnly is false and the entry existed in the overflow map, otherwise undefined
-
removeInternal
A combined implementation of remove() and removeBlind() that eliminates duplicate (and muchos complex) code- Parameters:
oKey
- the key to removefCheckRemovedOnly
- pass true to only check for entry existencefEviction
- pass true if the removal is an eviction and if the status is already owned by this thread- Returns:
- if only checking for existence, then a Boolean value is returned, otherwise the value (which may be null) is returned from the entry if it exists, otherwise null is returned
-
getFrontMap
Returns the front Map.Warning: Direct modifications of the returned map may cause unpredictable behavior of the Overflow Map.
- Returns:
- the front Map
-
getBackMap
Returns the back Map.Warning: Direct modifications of the returned map may cause unpredictable behavior of the Overflow Map.
- Returns:
- the back Map
-
getExpiryDelay
public int getExpiryDelay()Determine the "time to live" for each individual cache entry.- Returns:
- the number of milliseconds that a cache entry value will live,
or
EXPIRY_NEVER
if the entries never expire by default
-
setExpiryDelay
public void setExpiryDelay(int cMillis) Specify the "time to live" for cache entries. This does not affect the already-scheduled expiry of existing entries.- Parameters:
cMillis
- the number of milliseconds to specify that cache entries subsequently added without an expiry will live,EXPIRY_DEFAULT
to indicate that the OverflowMap's default expiry be used (which is to never automatically expire values), orEXPIRY_NEVER
to specify that cache entries subsequently added without an expiry will never expire
-
getSize
protected int getSize()Obtain the number of entries in the OverflowMap.- Returns:
- the cached size of the OverflowMap
-
setSize
protected void setSize(int cItems) Update the number of entries in the OverflowMap.- Parameters:
cItems
- the cached size of the OverflowMap
-
adjustSize
protected void adjustSize(int cItems) Adjust the number of entries in the OverflowMap.- Parameters:
cItems
- the number of items to adjust the cached size of the OverflowMap by, for example +1 or -1
-
getCacheStatistics
Returns the CacheStatistics for this cache.- Returns:
- a CacheStatistics object
-
getGate
Obtain the Gate for managing key-level and Collection-level operations against the Map, versus Map-level operations themselves.- Returns:
- the Gate for the OverflowMap
-
getStatusMap
Obtain the Map of Status objects for entries managed by this Overflow Map. There will be a Status object for each entry in the front map, and a Status object for each key that has a current operation underway.- Returns:
- the Map of Status objects
-
getExpiryArray
Obtain the array of keys that have an expiration, indexed by expiration times.- Returns:
- a sparse LongArray keyed by expiry time with a corresponding value of a set of keys that expire at that time
-
setExpiryArray
Specify the array of keys that have an expiration, indexed by expiration times.- Parameters:
laExpiry
- a LongArray to use to keep track of what expires when
-
getFrontMapListener
Get the MapListener for the front map.- Returns:
- the MapListener for the front map
-
setFrontMapListener
Specify the MapListener for the front map.The caller is required to manage all of the thread concurrency issues associated with modifying the listener.
- Parameters:
listener
- the MapListener for the front map
-
getBackMapListener
Get the MapListener for the back map.- Returns:
- the MapListener for the back map
-
setBackMapListener
Specify the MapListener for the back map.The caller is required to manage all of the thread concurrency issues associated with modifying the listener.
- Parameters:
listener
- the MapListener for the back map
-
getDeferredList
Obtain the List of keys that may have deferred events.- Returns:
- the List of keys of deferred-event Status objects
-
isNullValuesAllowed
public boolean isNullValuesAllowed()Determine if null values are permitted. By default, they are not.- Returns:
- true iff null values are permitted
-
setNullValuesAllowed
public void setNullValuesAllowed(boolean fAllowNulls) Specify whether null values are permitted.- Parameters:
fAllowNulls
- pass true to allow null values; false to disallow
-
isExpiryEnabled
public boolean isExpiryEnabled()Determine if this OverflowMap supports entry expiry.- Returns:
- true iff the entry expiry feature is supported
-
setExpiryEnabled
public void setExpiryEnabled(boolean fEnableExpiry) Specify whether or not entry expiry is supported. Since there is a per-entry (memory) cost just to support the expiry feature, and since there is additional memory cost (and a small performance cost) to keep track of entries that are set to expire, this feature is made optional.Note that this feature must be enabled before populating the cache.
- Parameters:
fEnableExpiry
- pass true to enable entry expiry, false to disable it
-
isFrontPutBlind
public boolean isFrontPutBlind()Determine if the front Map is more efficiently updated using putAll. (The use of putAll instead of put is called put-blind because it does not return a value.)- Returns:
- true iff the use of the put method should be avoided when updating the front Map, and putAll should be used instead
-
setFrontPutBlind
public void setFrontPutBlind(boolean fUseFrontPutAll) Specify whether the front Map is more efficiently updated using putAll.- Parameters:
fUseFrontPutAll
- pass true to allow null values; false to disallow
-
beginKeyProcess
Block until a key is available for processing, and return the Status object for that key. The caller is then expected to perform its processing, during which time events against the Map Entry may occur. Note that those events can occur on threads other than the current thread; when this current thread can no longer handle events from other threads, it must callOverflowMap.Status.closeProcessing()
and then perform its final adjustments to the Status data structure, handling any events that were queued in the meantime on the Status. After completing the processing during this "quiet period" in which all other threads are prevented from accessing this entry or handling events for this entry, then the caller must callendKeyProcess(java.lang.Object, com.tangosol.net.cache.OverflowMap.Status)
passing the Status object returned from this method.- Parameters:
oKey
- the key to process- Returns:
- the Status object for the specified key
-
endKeyProcess
Finish the processing of a single key.- Parameters:
oKey
- the keystatus
- the Status object returned from the call tobeginKeyProcess(java.lang.Object)
-
beginMapProcess
protected void beginMapProcess()Block until this thread has exclusive access to perform operations against the OverflowMap. -
endMapProcess
protected void endMapProcess()Release exclusive access for the OverflowMap. -
prepareStatus
Validate the status and process any deferred events or pending expiry.- Parameters:
oKey
- the entry keystatus
- the Status object for the entry- Returns:
- true iff the Status is in the processing state and oready to be used
-
onFrontEvent
Either handle an event by turning it over to another thread that is processing the key specified by the event, or take responsibility on this thread for deferring the event and registering its immediate side-effects.- Parameters:
evt
- the event
-
onBackEvent
Handle an event occuring against the "back" map.- Parameters:
evtBack
- an event from the back map
-
mergeEvents
Merge two events that have been raised in sequence from a given map.- Parameters:
evtOld
- the first eventevtNew
- the second event- Returns:
- the merged event
-
getLatestOldValue
Obtain the latest old value from the passed event. The latest old value is the value that must be retained upon the eviction of data from the front map.- Parameters:
evt
- an event (which may be a HistoricCacheEvent)- Returns:
- the latest old value from the event
-
processEvent
Process an arbitrary event that has occurred against either the front or back map.- Parameters:
status
- the Status object representing the Overflow Map's entry against which the event was raisedevt
- the MapEvent to process
-
processFrontEvent
Process an event. The Status must already be owned by this thread and in the processing or committing state.- Parameters:
status
- the statusevtFront
- the event to process; may be null
-
processBackEvent
Process an event. The Status must already be owned by this thread and in the processing or committing state.- Parameters:
status
- the statusevtBack
- the event to process; may be null
-
processDeferredEvents
protected void processDeferredEvents(boolean fProcessAll) Process deferred events, if there are any.- Parameters:
fProcessAll
- pass true to process all pending events, false to process just a fair portion of them
-
closeStatus
Helper method to close a Status, processing any pending events as part of the process.- Parameters:
status
- the Status object to close
-
releaseClosedStatus
Helper method to encapsulate the release of a Status object on which closeProcessing() has already been called.- Parameters:
oKey
- the entry key
-
getMapListenerSupport
Accessor for the MapListenerSupport for sub-classes.- Returns:
- the MapListenerSupport, or null if there are no listeners
-
hasListeners
protected boolean hasListeners()Determine if the OverflowMap has any listeners at all.- Returns:
- true iff this OverflowMap has at least one MapListener
-
dispatchEvent
protected void dispatchEvent(OverflowMap.Status status, int nId, Object oKey, Object oValueOld, Object oValueNew, boolean fSynthetic) Dispatch an event containing the passed event information.- Parameters:
status
- the Status for the entrynId
- this event's idoKey
- the key into the mapoValueOld
- the old valueoValueNew
- the new valuefSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loading
-
dispatchEvent
Dispatch the passed event.- Parameters:
status
- the Status for the entryevt
- a MapEvent object
-
isSynthetic
Helper method to determine if an event is synthetic.- Parameters:
evt
- a Map Event- Returns:
- true if the event is a synthetic cache event
-
registerExpiry
Register an expiry for the specified key.- Parameters:
oKey
- the key of the entry to expireldtExpire
- the time to expire the entry
-
unregisterExpiry
Unregister the specified key expiry that is registered to expire at the specified time.- Parameters:
oKey
- the key that is set to expireldtExpire
- the time that the key is set to expire
-
verifyNoNulls
Check the passed collection for nulls, and fail if it contains any.- Parameters:
collection
- a CollectionsAssert
- the human-readable description of the error if any nulls are found in the passed Collection
-
putOne
Helper to put a value into a map using either the put or putAll method.- Parameters:
map
- the Map to put intooKey
- the key to putoValue
- the value to putfPutBlind
- true to use the putBlind optimization
-
evict
public void evict()Flush items that have expired.- Since:
- Coherence 3.2
-
evict
If the passed Map supports it, evict its expired data.- Parameters:
map
- a Map that may or may not support the requesting of an eviction of expired data- Since:
- Coherence 3.2
-
warnMissingEvent
An expected event did not get raised. Try to report it to the log.- Parameters:
oKey
- the key for which an event is missingnId
- the event type that is missingfFront
- true if the event was expected to come from the front map, false if from the back map
-
warnUnfathomable
Something totally inexplicable has occurred. Try to report it to the log.- Parameters:
evt
- the event that cannot be explained
-
warnEventSequence
Issue a one-time warning that events are being received in an order than cannot be explained by normal operation according to the contracts expected by this OverflowMap.- Parameters:
evtOld
- the previous (potentially amalgamated) eventevtNew
- the new event
-
instantiateEntrySet
Factory pattern: Create a Set that represents the entries in the Map.- Overrides:
instantiateEntrySet
in classAbstractKeySetBasedMap
- Returns:
- a new instance of Set that represents the entries in the Map
-
instantiateInternalKeySet
Factory pattern: Create a read-only Set of keys in the Overflow Map- Returns:
- a new instance of Set that represents the keys in the Map
-
instantiateStatus
Factory method: Instantiate a Status object.- Returns:
- a new Status object
-
instantiateFrontMapListener
Factory pattern: Front Map Listener.- Returns:
- a new instance of the listener for the front map
-
instantiateBackMapListener
Factory pattern: Back Map Listener.- Returns:
- a new instance of the listener for the back map
-