|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
com.tangosol.net.cache.SimpleOverflowMap
public class SimpleOverflowMap
A non-observable Map implementation that wraps two maps - a front map (assumed to be fast but limited in its maximum size) and a back map (assumed to be slower but much less limited in its maximum size).
The SimpleOverflowMap is not observable, and as such it is assumed to be a passive data structure. In other words, it does not support item expiration or other types of "self-generating" events. As such, it may be more efficient for many common use cases that would benefit from the complete avoidance of event handling. As a second effect of being a passive data structure, the implementation is able to avoid tracking all of its entries; instead it tracks only entries that are in the front map and those that currently have a pending event or an in-flight operation occurring. This means that huge key sets are possible, since only keys in the front map will be managed in memory by the overflow map, but it means that some operations that would benefit from knowing the entire set of keys will be more expensive. Examples of operations that would be less efficient as a result includecontainsKey()
, size()
,
keySet().iterator()
, etc.
Nested Class Summary | |
---|---|
protected static class |
SimpleOverflowMap.FrontFilterConverter
A combination Filter and Converter used to iterate through the status map in order to iterate through the front keys. |
protected class |
SimpleOverflowMap.FrontMapListener
A listener for the front map that moves evictions to the back map. |
protected static class |
SimpleOverflowMap.HashcodeComparator
A stateless Comparator that compares Object.hashCode() values. |
protected class |
SimpleOverflowMap.KeyIterator
An Iterator implementation that attempts to provide the most resilient and most up-to-date view of the keys in the OverflowMap. |
protected static class |
SimpleOverflowMap.Status
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.AbstractKeyBasedMap |
---|
AbstractKeyBasedMap.EntrySet, AbstractKeyBasedMap.KeySet, AbstractKeyBasedMap.ValuesCollection |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry |
Field Summary | |
---|---|
static int |
ENTRY_DELETED
This event indicates that an entry has been removed from the map. |
static int |
ENTRY_INSERTED
This event indicates that an entry has been added to the map. |
static int |
ENTRY_UPDATED
This event indicates that an entry has been updated in the map. |
protected Map |
m_mapBack
The "back" map, which the front overflows to. |
protected ObservableMap |
m_mapFront
The "front" map, which is size-limited. |
protected Map |
m_mapMiss
The miss cache; may be null. |
protected SimpleCacheStatistics |
m_stats
The CacheStatistics object maintained by this cache. |
Constructor Summary | |
---|---|
SimpleOverflowMap(ObservableMap mapFront,
Map mapBack)
Construct a SimpleOverflowMap using two specified maps: FrontMap (aka "cache" or "shallow") and BackMap (aka "file" or "deep") |
|
SimpleOverflowMap(ObservableMap mapFront,
Map mapBack,
Map mapMiss)
Construct a SimpleOverflowMap using three specified maps: Front Map (aka "cache" or "shallow") and Back Map (aka "file" or "deep") Miss Cache |
Method Summary | |
---|---|
protected SimpleOverflowMap.Status[] |
beginBulkKeyProcess(Object[] aoKey)
Begin key-level procecessing for any number of keys. |
protected SimpleOverflowMap.Status |
beginKeyProcess(Object oKey)
Block until a key is available for processing, and return the Status object for that key. |
protected void |
beginMapProcess()
Block until this thread has exclusive access to perform operations against the OverflowMap. |
void |
clear()
Clear all key/value mappings. |
boolean |
containsKey(Object oKey)
Returns true if this map contains a mapping for the specified key. |
protected void |
endBulkKeyProcess(Object[] aoKey,
SimpleOverflowMap.Status[] aStatus)
Finish the processing of any number of keys. |
protected void |
endKeyProcess(Object oKey,
SimpleOverflowMap.Status status)
Finish the processing of a single key. |
protected void |
endMapProcess()
Release exclusive access for the OverflowMap. |
Object |
get(Object oKey)
Returns the value to which this map maps the specified key. |
Map |
getBackMap()
Returns the back Map. |
CacheStatistics |
getCacheStatistics()
Returns the CacheStatistics for this cache. |
protected List |
getDeferredList()
Obtain the List of keys that may have deferred events. |
ObservableMap |
getFrontMap()
Returns the front Map. |
protected MapListener |
getFrontMapListener()
Get the MapListener for the front map. |
Map |
getMissCache()
Returns the optional miss cache. |
protected Map |
getStatusMap()
Obtain the Map of Status objects for entries managed by this Overflow Map. |
protected ThreadGate |
getThreadGate()
Obtain the ThreadGate for managing key-level and Collection-level operations against the Map, versus Map-level operations themselves. |
protected MapListener |
instantiateFrontMapListener()
Factory pattern: Front Map Listener. |
protected SimpleOverflowMap.Status |
instantiateStatus()
Factory method: Instantiate a Status object. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
boolean |
isFrontPutBlind()
Determine if the front Map is more efficiently updated using putAll. |
boolean |
isNullValuesAllowed()
Determine if null values are permitted. |
protected Iterator |
iterateKeys()
Create an iterator over the keys in this 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 void |
processDeferredEvents()
Process deferred events, if there are any. |
protected void |
processFrontEvent(SimpleOverflowMap.Status status,
MapEvent evt)
Process an event. |
Object |
put(Object oKey,
Object oValue)
Associates the specified value with the specified key in this map. |
void |
putAll(Map map)
Copies all of the mappings from the specified map to this map. |
protected static void |
putOne(Map map,
Object oKey,
Object oValue,
boolean fPutBlind)
Helper to put a value into a map using either the put or putAll method. |
Object |
remove(Object oKey)
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 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. |
int |
size()
Returns the number of key-value mappings in this map. |
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. |
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap |
---|
clone, containsValue, entrySet, equals, getAll, hashCode, instantiateEntrySet, instantiateKeySet, instantiateValues, keySet, toString, values |
Field Detail |
---|
public static final int ENTRY_INSERTED
public static final int ENTRY_UPDATED
public static final int ENTRY_DELETED
protected ObservableMap m_mapFront
protected Map m_mapBack
protected Map m_mapMiss
protected SimpleCacheStatistics m_stats
Constructor Detail |
---|
public SimpleOverflowMap(ObservableMap mapFront, Map mapBack)
mapBack
- back mapmapFront
- front mappublic SimpleOverflowMap(ObservableMap mapFront, Map mapBack, Map mapMiss)
mapFront
- front mapmapBack
- back mapmapMiss
- an optional miss cacheMethod Detail |
---|
public void clear()
clear
in interface Map
clear
in class AbstractKeyBasedMap
public boolean containsKey(Object oKey)
containsKey
in interface Map
containsKey
in class AbstractKeyBasedMap
public Object get(Object oKey)
get
in interface Map
get
in class AbstractKeyBasedMap
oKey
- the key object
public boolean isEmpty()
isEmpty
in interface Map
isEmpty
in class AbstractKeyBasedMap
public Object put(Object oKey, Object oValue)
put
in interface Map
put
in class AbstractKeyBasedMap
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key
public void putAll(Map map)
put(java.lang.Object, java.lang.Object)
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.
putAll
in interface Map
putAll
in class AbstractKeyBasedMap
map
- the Map containing the key/value pairings to put into this
Mappublic Object remove(Object oKey)
remove
in interface Map
remove
in class AbstractKeyBasedMap
oKey
- key whose mapping is to be removed from the map
public int size()
size
in interface Map
size
in class AbstractKeyBasedMap
protected Iterator iterateKeys()
iterateKeys
in class AbstractKeyBasedMap
protected boolean removeBlind(Object oKey)
removeBlind
in class AbstractKeyBasedMap
oKey
- key whose mapping is to be removed from the map
public ObservableMap getFrontMap()
Warning: Direct modifications of the returned map may cause unpredictable behavior of the Overflow Map.
public Map getBackMap()
Warning: Direct modifications of the returned map may cause unpredictable behavior of the Overflow Map.
public Map getMissCache()
Warning: Direct modifications of the returned map may cause unpredictable behavior of the Overflow Map.
public CacheStatistics getCacheStatistics()
protected ThreadGate getThreadGate()
protected Map getStatusMap()
protected List getDeferredList()
public boolean isNullValuesAllowed()
public void setNullValuesAllowed(boolean fAllowNulls)
fAllowNulls
- pass true to allow null values; false to
disallowpublic boolean isFrontPutBlind()
public void setFrontPutBlind(boolean fUseFrontPutAll)
fUseFrontPutAll
- pass true to allow null values; false to
disallowprotected MapListener getFrontMapListener()
protected void setFrontMapListener(MapListener listener)
listener
- the MapListener for the front mapprotected MapListener instantiateFrontMapListener()
protected void onFrontEvent(MapEvent evt)
protected void processFrontEvent(SimpleOverflowMap.Status status, MapEvent evt)
evt
- the event to process; may be nullprotected SimpleOverflowMap.Status beginKeyProcess(Object oKey)
SimpleOverflowMap.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 call endKeyProcess(java.lang.Object, com.tangosol.net.cache.SimpleOverflowMap.Status)
passing the Status
object returned from this method.
oKey
- the key to process
protected void endKeyProcess(Object oKey, SimpleOverflowMap.Status status)
status
- the Status object returned from the call to
beginKeyProcess(java.lang.Object)
protected SimpleOverflowMap.Status[] beginBulkKeyProcess(Object[] aoKey)
aoKey
- an array of zero or more keys; note that this array may
be re-ordered by this method
beginKeyProcess(Object)
protected void endBulkKeyProcess(Object[] aoKey, SimpleOverflowMap.Status[] aStatus)
aoKey
- the same array of keys as were passed to
beginBulkKeyProcess(java.lang.Object[])
aStatus
- the array of Status objects returned from the call to
beginBulkKeyProcess(java.lang.Object[])
protected void beginMapProcess()
protected void endMapProcess()
protected void processDeferredEvents()
protected static void verifyNoNulls(Collection collection, String sAssert)
collection
- a CollectionsAssert
- the human-readable description of the error if any
nulls are found in the passed Collectionprotected static void putOne(Map map, Object oKey, Object oValue, boolean fPutBlind)
map
- the Map to put intooKey
- the key to putoValue
- the value to putfPutBlind
- true to use the putBlind optimizationprotected static void warnEventSequence(MapEvent evtOld, MapEvent evtNew)
evtOld
- the previous (potentially amalgamated) eventevtNew
- the new eventprotected SimpleOverflowMap.Status instantiateStatus()
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |