|
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.util.AbstractKeySetBasedMap
com.tangosol.net.cache.SerializationMap
com.tangosol.net.cache.AbstractSerializationCache
com.tangosol.net.cache.SerializationPagedCache
public class SerializationPagedCache
A version of SerializationMap that implements an LRU policy using
time-based paging of the cache. This implementation uses a
BinaryStoreManager
to create a current BinaryStore which is
used to store all objects being placed into the cache. Once the specified
"current" time period has elapsed, a new current BinaryStore is created,
and the previously current page is closed, which means that it will no
longer be used to store objects that are being placed into the cache.
This continues until the total number of pages (the one current plus all
of the previously current pages) exceeds the maximum number of pages
defined for the cache. When that happens, the oldest page is evicted,
triggering the related events, and the BinaryStore for that page is
destroyed. Note that cache items can be accessed out of and removed from
closed pages, but cache items are never written to closed pages.
To avoid a massive number of simultaneous events, the eviction of a closed page can be performed asynchronously on a daemon thread.
Nested Class Summary | |
---|---|
static class |
SerializationPagedCache.FakeBinaryStore
A lite BinaryStore implementation used when the real underlying BinaryStore gets destroyed. |
class |
SerializationPagedCache.PagedBinaryStore
A virtual BinaryStore implementation that aggregates a sequence (newest to oldest) of periodic BinaryStore objects. |
class |
SerializationPagedCache.WrapperBinaryStore
A wrapper BinaryStore implementation that keeps track of its size. |
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
AbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry |
Constructor Summary | |
---|---|
SerializationPagedCache(BinaryStoreManager storemgr,
int cPages,
int cPageSecs)
Construct a SerializationPagedCache on top of a BinaryStoreManager. |
|
SerializationPagedCache(BinaryStoreManager storemgr,
int cPages,
int cPageSecs,
boolean fBinaryMap,
boolean fPassive)
Construct a SerializationPagedCache on top of a BinaryStoreManager. |
|
SerializationPagedCache(BinaryStoreManager storemgr,
int cPages,
int cPageSecs,
ClassLoader loader)
Construct a SerializationPagedCache on top of a BinaryStoreManager. |
Method Summary | |
---|---|
protected void |
advancePage()
Advance to a new current page, and deactivate the oldest page is the maximum number of active pages has been reached. |
protected void |
checkPage()
Determine if the time has come to set up a new page for storing current cache data. |
void |
clear()
Clear all key/value mappings. |
protected BinaryStore |
createBinaryStore()
Create and register a new BinaryStore object, using this cache's BinaryStoreManager. |
protected void |
deactivatePage(SerializationPagedCache.WrapperBinaryStore store)
Deactivate a page that is no longer active. |
protected void |
destroyBinaryStore(BinaryStore store)
Destroy and unregister a BinaryStore object that was previously created using this cache's BinaryStoreManager by the createBinaryStore method. |
protected void |
eraseStore()
Erase all entries from the underlying store. |
void |
evict()
Flush items that have expired. |
Object |
get(Object oKey)
Returns the value to which this map maps the specified key. |
protected List |
getBinaryStoreList()
Get the list of registered BinaryStore objects. |
protected BinaryStoreManager |
getBinaryStoreManager()
Returns the BinaryStoreManager that provides BinaryStore objects this cache uses for its storage. |
XmlElement |
getConfig()
Determine the current configuration of the object. |
protected long |
getCurrentPageTime()
Determine the time that the current page was created. |
protected String |
getDescription()
Assemble a human-readable description. |
int |
getLockDelaySeconds()
Determine the number of seconds to wait for a lock in debug mode. |
protected ConcurrentMap |
getLockMap()
Obtain the map used for managing key- and map-level locks to ensure data consistency. |
int |
getMaximumPages()
Determine the maximum number of pages that the cache will manage, beyond which the oldest pages are destroyed. |
protected long |
getPageAdvanceTime()
Determine the time that the next page should be created. |
protected SerializationPagedCache.PagedBinaryStore |
getPagedBinaryStore()
Returns the BinaryStore that this map uses for its storage. |
long |
getPageDuration()
Determine the length of time that the most recently created page is kept as the current page. |
protected SerializationPagedCache.FakeBinaryStore |
instantiateFakeBinaryStore()
Factory method: Instantiate a FakeBinaryStore. |
protected SerializationPagedCache.PagedBinaryStore |
instantiatePagedStore(int cPages)
Factory method: Instantiate a PagedBinaryStore. |
protected SerializationPagedCache.WrapperBinaryStore |
instantiateWrapperStore(BinaryStore store)
Factory method: Instantiate a WrapperBinaryStore. |
boolean |
isAsynchronousPageDeactivation()
Determine if a daemon should evict the items from a deactivated page to avoid blocking other work from being done. |
static boolean |
isDebug()
Determine the status of the internal debug flag. |
boolean |
isPassivePagedBackup()
Determine if this is just a passive backup for a paged cache. |
boolean |
isVirtualErase()
Determine if BinaryStore erase commands will be done only in memory (to the cached list of keys) and not passsed to the underlying BinaryStore, thus improving performance and cutting I/O, but potentially wasting disk space (or whatever resource the paged data are stored on.) |
protected Iterator |
iterateBinaryStores()
Obtain an iterator of all registered (not destroyed) BinaryStore objects being used by this cache. |
protected void |
lockInternal(Object oKey)
Obtain a lock for the specified key. |
protected boolean |
lockInternalNoWait(Object oKey)
Obtain a lock for the specified key, but only if no other thread has the lock at the point in time that this method is invoked. |
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. |
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. This method exists to allow sub-classes to optmiize remove functionalitly for situations in which the original value is not required. |
protected void |
runTask(Runnable task)
Run the passed task on a separate thread. |
void |
setAsynchronousPageDeactivation(boolean fAsync)
Specify whether a daemon should evict the items from a deactivated page to avoid blocking other work from being done. |
protected void |
setBinaryStore(BinaryStore store)
Configures the BinaryStore that this map will use for its storage. |
void |
setConfig(XmlElement xml)
Specify the configuration for the object. |
static void |
setDebug(boolean fDebug)
Set the status of the internal debug flag. |
void |
setLockDelaySeconds(int cSecondsLockDelay)
Specify the number of seconds to wait for a lock in debug mode. |
protected void |
setPageDuration(long cPageMillis)
Specify the length of time that the most recently created page is kept as the current page. |
protected void |
setPassivePagedBackup(boolean fPassiveBackup)
Specify whether this is just a passive backup for a paged cache. |
protected void |
setVirtualErase(boolean fVirtualErase)
Specify whether BinaryStore erase commands will be done only in memory to the cached list of keys. |
String |
toString()
Returns a string representation of this Map. The string representation consists of a list of key-value mappings in the order returned by the Map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String.valueOf(Object). |
protected void |
unlockInternal(Object oKey)
Release the lock on the specified key. |
Methods inherited from class com.tangosol.net.cache.AbstractSerializationCache |
---|
addMapListener, addMapListener, addMapListener, dispatchEvent, dispatchPendingEvent, getMapListenerSupport, hasListeners, removeMapListener, removeMapListener, removeMapListener |
Methods inherited from class com.tangosol.net.cache.SerializationMap |
---|
containsValue, fromBinary, getBinaryStore, getCacheStatistics, getClassLoader, getInternalKeySet, getKeyMap, isBinaryMap, registerKey, setBinaryMap, setClassLoader, toBinary, unregisterKey |
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
containsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, isInternalKeySetIteratorMutable, iterateKeys, size |
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap |
---|
clone, entrySet, equals, getAll, hashCode, keySet, values |
Methods inherited from interface java.util.Map |
---|
containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, size, values |
Constructor Detail |
---|
public SerializationPagedCache(BinaryStoreManager storemgr, int cPages, int cPageSecs)
storemgr
- the BinaryStoreManager that provides BinaryStore
objects that the serialized objects are written tocPages
- the maximum number of pages to have active at a timecPageSecs
- the length of time, in seconds, that a 'page' is
currentpublic SerializationPagedCache(BinaryStoreManager storemgr, int cPages, int cPageSecs, ClassLoader loader)
storemgr
- the BinaryStoreManager that provides BinaryStore
objects that the serialized objects are written tocPages
- the maximum number of pages to have active at a timecPageSecs
- the length of time, in seconds, that a 'page' is
currentloader
- the ClassLoader to use for deserializationpublic SerializationPagedCache(BinaryStoreManager storemgr, int cPages, int cPageSecs, boolean fBinaryMap, boolean fPassive)
storemgr
- the BinaryStoreManager that provides BinaryStore
objects that the serialized objects are written tocPages
- the maximum number of pages to have active at a timecPageSecs
- the length of time, in seconds, that a 'page' is
currentfBinaryMap
- true indicates that this map will only manage
binary keys and valuesfPassive
- true indicates that this map is a passive cache,
which means that it is just a backup of the cache
and does not actively expire dataMethod Detail |
---|
public XmlElement getConfig()
public void setConfig(XmlElement xml)
xml
- the XML configuration for the object
IllegalStateException
- if the object is not in a state that
allows the configuration to be set; for example, if the
object has already been configured and cannot be reconfiguredpublic void clear()
clear
in interface Map
clear
in class AbstractSerializationCache
public Object get(Object oKey)
get
in interface Map
get
in class SerializationMap
oKey
- the key object
public Object put(Object oKey, Object oValue)
put
in interface Map
put
in class AbstractSerializationCache
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key
public void putAll(Map map)
putAll
in interface Map
putAll
in class AbstractSerializationCache
map
- map of entries to be stored in this mappublic Object remove(Object oKey)
remove
in interface Map
remove
in class AbstractSerializationCache
oKey
- key whose mapping is to be removed from the map
protected boolean removeBlind(Object oKey)
removeBlind
in class AbstractSerializationCache
oKey
- key whose mapping is to be removed from the map
protected void eraseStore()
eraseStore
in class SerializationMap
public void evict()
AsynchronousPageDeactivation
property.
evict
in class AbstractSerializationCache
public String toString()
toString
in class SerializationMap
protected String getDescription()
getDescription
in class AbstractSerializationCache
public boolean isVirtualErase()
protected void setVirtualErase(boolean fVirtualErase)
fVirtualErase
- true if the erase should not go to the underlying
store, but simply remove the key from the cached
list of keys managed by that store; false to pass
all erase requests down to the underlying storepublic int getLockDelaySeconds()
public void setLockDelaySeconds(int cSecondsLockDelay)
This will not take effect until the next lock is requested and unless debug mode is turned on.
cSecondsLockDelay
- the number of seconds to wait for a lockprotected ConcurrentMap getLockMap()
protected BinaryStoreManager getBinaryStoreManager()
This object is intended for use only by the createBinaryStore, and destroyBinaryStore methods.
protected void setBinaryStore(BinaryStore store)
setBinaryStore
in class SerializationMap
store
- the BinaryStore to useprotected SerializationPagedCache.PagedBinaryStore getPagedBinaryStore()
Note: This implementation assumes that the BinaryStore is only being modified by this Map instance. If you modify the BinaryStore contents, the behavior of this Map is undefined.
protected List getBinaryStoreList()
protected Iterator iterateBinaryStores()
public int getMaximumPages()
public long getPageDuration()
protected void setPageDuration(long cPageMillis)
cPageMillis
- the time in milliseconds that a page remains
currentprotected long getCurrentPageTime()
protected long getPageAdvanceTime()
public boolean isPassivePagedBackup()
protected void setPassivePagedBackup(boolean fPassiveBackup)
fPassiveBackup
- true if this cache is just a backup for a paged
cachepublic boolean isAsynchronousPageDeactivation()
public void setAsynchronousPageDeactivation(boolean fAsync)
This will not take effect until the next page is deactivated.
fAsync
- pass true to specify that a daemon should be used for
page deactivation, or false to block all other threads
while a page is fully deactivatedpublic static boolean isDebug()
public static void setDebug(boolean fDebug)
fDebug
- true to set the cache into debug mode, false to set it
into normal runtime modeprotected void lockInternal(Object oKey)
oKey
- the key to lockprotected boolean lockInternalNoWait(Object oKey)
oKey
- the key to lock
protected void unlockInternal(Object oKey)
oKey
- the key to unlockprotected BinaryStore createBinaryStore()
protected void destroyBinaryStore(BinaryStore store)
store
- a BinaryStore returned previously from createBinaryStoreprotected void checkPage()
protected void advancePage()
protected void runTask(Runnable task)
task
- the Runnable object to run on a separate threadprotected void deactivatePage(SerializationPagedCache.WrapperBinaryStore store)
store
- the "page" to deactivateprotected SerializationPagedCache.PagedBinaryStore instantiatePagedStore(int cPages)
cPages
- the maximum number of pages to have active at a time
protected SerializationPagedCache.WrapperBinaryStore instantiateWrapperStore(BinaryStore store)
store
- the BinaryStore to wrap
protected SerializationPagedCache.FakeBinaryStore instantiateFakeBinaryStore()
|
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 |