Class LruSessionCache
- java.lang.Object
-
- com.sun.appserv.util.cache.BaseCache
-
- com.sun.appserv.util.cache.LruCache
-
- com.sun.ejb.containers.util.cache.LruEJBCache
-
- com.sun.ejb.containers.util.cache.LruSessionCache
-
- All Implemented Interfaces:
Cache
,EjbCacheStatsProviderDelegate
,StatsProvider
- Direct Known Subclasses:
FIFOSessionCache
,NRUSessionCache
,UnBoundedSessionCache
public class LruSessionCache extends LruEJBCache implements EjbCacheStatsProviderDelegate
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
LruSessionCache.LruSessionCacheItem
-
Nested classes/interfaces inherited from class com.sun.appserv.util.cache.LruCache
LruCache.LruCacheItem
-
Nested classes/interfaces inherited from class com.sun.appserv.util.cache.BaseCache
BaseCache.CacheItem
-
-
Field Summary
Fields Modifier and Type Field Description protected org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata>
backingStore
protected int
cacheIdleTimeoutInSeconds
protected String
configData
protected int
confMaxCacheSize
protected SFSBContainerCallback
container
protected Object
loadCountLock
protected int
loadFromBackupCount
protected int
removalTimeoutInSeconds
protected boolean
removeIfIdle
-
Fields inherited from class com.sun.ejb.containers.util.cache.LruEJBCache
_logger, cacheName
-
Fields inherited from class com.sun.appserv.util.cache.LruCache
defaultMaxEntries, head, isUnbounded, listSize, NO_TIMEOUT, tail, timeout, trimCount
-
Fields inherited from class com.sun.appserv.util.cache.BaseCache
bucketLocks, buckets, entryCount, hitCount, listeners, maxBuckets, maxEntries, missCount, refreshFlags, removalCount, threshold
-
-
Constructor Summary
Constructors Constructor Description LruSessionCache(String cacheName, SFSBContainerCallback container, int cacheIdleTime, int removalTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendStats(StringBuilder sbuf)
protected BaseCache.CacheItem
createItem(int hashCode, Object sessionKey, Object value, int size)
create new itemvoid
destroy()
Destroys all references.boolean
eligibleForRemovalFromCache(StatefulEJBContext ctx, Serializable sessionKey)
Called by StatefulSessionContainer before passivation to determine whether or not removal-timeout has elapsed for a cache item.int
getCacheHits()
int
getCacheMisses()
int
getLoadFromBackupCount()
int
getMaxCacheSize()
int
getNumBeansInCache()
int
getNumExpiredSessionsRemoved()
int
getNumPassivationErrors()
int
getNumPassivations()
int
getNumPassivationSuccess()
int
getNumVictimsAccessed()
protected void
incrementLoadFromBackupCount()
protected void
itemAccessed(BaseCache.CacheItem item)
this item is accessedStatefulEJBContext
lookupEJB(Serializable sessionKey, SFSBContainerCallback container, Object cookie)
boolean
passivateEJB(StatefulEJBContext ctx, Serializable sessionKey)
Object
remove(Object sessionKey)
remove the item stored at the key.Object
remove(Object sessionKey, boolean removeFromStore)
void
setBackingStore(org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata> store)
void
setConfigData(String configData)
void
setMaxCacheSize(int val)
void
setShutdownState()
void
setStatefulSessionStoreMonitor(StatefulSessionStoreMonitor storeMonitor)
void
setUndeployedState()
void
shutdown()
protected void
trimItem(BaseCache.CacheItem item)
trim the item from the cache and notify listenersvoid
trimTimedoutItems(int maxTrimCount)
trim the timedOut entries from the cache.void
trimUnSortedTimedoutItems(int maxCount)
This method picks idle items from a cache which does not have a sorted LRU list NRU cache at light loads and FIFO caches do not maintain a LRU list and hence they have to scan the entire cache and select victimsIterator
values()
get an Iterator for the values stored in the cache-
Methods inherited from class com.sun.ejb.containers.util.cache.LruEJBCache
itemAdded, setCacheName, trimLru
-
Methods inherited from class com.sun.appserv.util.cache.LruCache
getStatByName, getStats, init, itemRefreshed, itemRemoved, setTimeout, trimExpiredEntries
-
Methods inherited from class com.sun.appserv.util.cache.BaseCache
_put, _remove, _removeItem, add, add, addCacheListener, clear, clearStats, contains, decrementEntryCount, elements, eq, get, get, getAll, getEntryCount, getIndex, getIndex, handleOverflow, hash, incrementAddCount, incrementEntryCount, incrementHitCount, incrementMissCount, incrementOverflowCount, incrementRefreshCount, incrementRemovalCount, init, init, isEmpty, isThresholdReached, keys, loadValue, notifyRefresh, put, put, remove, remove, removeAll, waitRefresh
-
-
-
-
Field Detail
-
cacheIdleTimeoutInSeconds
protected int cacheIdleTimeoutInSeconds
-
removalTimeoutInSeconds
protected int removalTimeoutInSeconds
-
loadCountLock
protected Object loadCountLock
-
loadFromBackupCount
protected int loadFromBackupCount
-
removeIfIdle
protected boolean removeIfIdle
-
container
protected SFSBContainerCallback container
-
backingStore
protected org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata> backingStore
-
configData
protected String configData
-
confMaxCacheSize
protected int confMaxCacheSize
-
-
Constructor Detail
-
LruSessionCache
public LruSessionCache(String cacheName, SFSBContainerCallback container, int cacheIdleTime, int removalTime)
-
-
Method Detail
-
destroy
public void destroy()
Destroys all references. This is the last method call of this object's life cycle. This method is called during undeploy of ejb container.
-
setBackingStore
public void setBackingStore(org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata> store)
-
setStatefulSessionStoreMonitor
public void setStatefulSessionStoreMonitor(StatefulSessionStoreMonitor storeMonitor)
-
trimItem
protected void trimItem(BaseCache.CacheItem item)
trim the item from the cache and notify listeners
-
itemAccessed
protected void itemAccessed(BaseCache.CacheItem item)
Description copied from class:LruCache
this item is accessed- Overrides:
itemAccessed
in classLruCache
- Parameters:
item
-CacheItem
accessed Cache bucket is already synchronized by the caller
-
getLoadFromBackupCount
public int getLoadFromBackupCount()
-
incrementLoadFromBackupCount
protected void incrementLoadFromBackupCount()
-
lookupEJB
public StatefulEJBContext lookupEJB(Serializable sessionKey, SFSBContainerCallback container, Object cookie)
-
remove
public Object remove(Object sessionKey)
Description copied from class:BaseCache
remove the item stored at the key.
-
eligibleForRemovalFromCache
public boolean eligibleForRemovalFromCache(StatefulEJBContext ctx, Serializable sessionKey)
Called by StatefulSessionContainer before passivation to determine whether or not removal-timeout has elapsed for a cache item. If so, it will be directly removed instead of passivated. See issue 16188.
-
passivateEJB
public boolean passivateEJB(StatefulEJBContext ctx, Serializable sessionKey) throws NotSerializableException
- Throws:
NotSerializableException
-
setShutdownState
public void setShutdownState()
-
setUndeployedState
public void setUndeployedState()
-
values
public Iterator values()
get an Iterator for the values stored in the cache
-
shutdown
public void shutdown()
-
trimTimedoutItems
public void trimTimedoutItems(int maxTrimCount)
trim the timedOut entries from the cache. This call is to be scheduled by a thread managed by the container. In this case a sorted LRU list exists based on access time and this list is scanned
-
trimUnSortedTimedoutItems
public void trimUnSortedTimedoutItems(int maxCount)
This method picks idle items from a cache which does not have a sorted LRU list NRU cache at light loads and FIFO caches do not maintain a LRU list and hence they have to scan the entire cache and select victims
-
getNumVictimsAccessed
public int getNumVictimsAccessed()
-
createItem
protected BaseCache.CacheItem createItem(int hashCode, Object sessionKey, Object value, int size)
Description copied from class:LruCache
create new item- Overrides:
createItem
in classLruCache
- Parameters:
hashCode
- for the entrysessionKey
-Object
keyvalue
-Object
valuesize
- size in bytes of the item subclasses may override to provide their own CacheItem extensions e.g. one that permits persistence.
-
setConfigData
public void setConfigData(String configData)
-
appendStats
public void appendStats(StringBuilder sbuf)
- Specified by:
appendStats
in interfaceStatsProvider
-
getCacheHits
public int getCacheHits()
- Specified by:
getCacheHits
in interfaceEjbCacheStatsProviderDelegate
-
getCacheMisses
public int getCacheMisses()
- Specified by:
getCacheMisses
in interfaceEjbCacheStatsProviderDelegate
-
getNumBeansInCache
public int getNumBeansInCache()
- Specified by:
getNumBeansInCache
in interfaceEjbCacheStatsProviderDelegate
-
getNumExpiredSessionsRemoved
public int getNumExpiredSessionsRemoved()
- Specified by:
getNumExpiredSessionsRemoved
in interfaceEjbCacheStatsProviderDelegate
-
getNumPassivationErrors
public int getNumPassivationErrors()
- Specified by:
getNumPassivationErrors
in interfaceEjbCacheStatsProviderDelegate
-
getNumPassivations
public int getNumPassivations()
- Specified by:
getNumPassivations
in interfaceEjbCacheStatsProviderDelegate
-
getNumPassivationSuccess
public int getNumPassivationSuccess()
- Specified by:
getNumPassivationSuccess
in interfaceEjbCacheStatsProviderDelegate
-
setMaxCacheSize
public void setMaxCacheSize(int val)
-
getMaxCacheSize
public int getMaxCacheSize()
- Specified by:
getMaxCacheSize
in interfaceEjbCacheStatsProviderDelegate
-
-