com.sun.ejb.containers.util.cache
Class LruSessionCache

java.lang.Object
  extended by com.sun.ejb.containers.util.cache.BaseCache
      extended by com.sun.ejb.containers.util.cache.LruCache
          extended by com.sun.ejb.containers.util.cache.LruSessionCache
All Implemented Interfaces:
Cache, EJBCacheStatsProvider, StatsProvider
Direct Known Subclasses:
FIFOSessionCache, NRUSessionCache, UnBoundedSessionCache

public class LruSessionCache
extends LruCache
implements EJBCacheStatsProvider


Nested Class Summary
protected static class LruSessionCache.LruSessionCacheItem
           
 
Nested classes/interfaces inherited from class com.sun.ejb.containers.util.cache.LruCache
LruCache.LruCacheItem
 
Nested classes/interfaces inherited from class com.sun.ejb.containers.util.cache.BaseCache
BaseCache.CacheItem
 
Field Summary
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 numActivated
           
 int passivationCount
           
protected  Object passivationCountLock
           
protected  int removalTimeoutInSeconds
           
protected  boolean removeIfIdle
           
 
Fields inherited from class com.sun.ejb.containers.util.cache.LruCache
_logger, cacheName, head, listSize, NO_TIMEOUT, tail, timeout, trimCount
 
Fields inherited from class com.sun.ejb.containers.util.cache.BaseCache
_rb, addCount, addCountLk, bucketLocks, buckets, entryCount, entryCountLk, hitCount, hitCountLk, listeners, maxBuckets, missCount, missCountLk, overflowCount, overflowCountLk, refreshCount, refreshCountLk, refreshFlags, removalCount, removalCountLk, threshold
 
Constructor Summary
LruSessionCache(String cacheName, SFSBContainerCallback container, int cacheIdleTime, int removalTime)
           
 
Method Summary
 void appendStats(StringBuffer sbuf)
           
protected  BaseCache.CacheItem createItem(int hashCode, Object sessionKey, Object value, int size)
          create new item
 void 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 accessed
 StatefulEJBContext 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 listeners
 void 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 victims
 Iterator values()
          get an Iterator for the values stored in the cache
 
Methods inherited from class com.sun.ejb.containers.util.cache.LruCache
getStatByName, getStats, itemAdded, itemRefreshed, itemRemoved, setCacheName, trimExpiredEntries, trimLru
 
Methods inherited from class com.sun.ejb.containers.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numActivated

protected int numActivated

cacheIdleTimeoutInSeconds

protected int cacheIdleTimeoutInSeconds

removalTimeoutInSeconds

protected int removalTimeoutInSeconds

loadCountLock

protected Object loadCountLock

loadFromBackupCount

protected int loadFromBackupCount

removeIfIdle

protected boolean removeIfIdle

passivationCount

public int passivationCount

passivationCountLock

protected Object passivationCountLock

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.

Specified by:
destroy in interface Cache
Overrides:
destroy in class BaseCache

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

Overrides:
trimItem in class BaseCache
Parameters:
item - to be trimmed

itemAccessed

protected void itemAccessed(BaseCache.CacheItem item)
Description copied from class: LruCache
this item is accessed

Overrides:
itemAccessed in class LruCache
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.

Specified by:
remove in interface Cache
Overrides:
remove in class BaseCache
Parameters:
sessionKey - lookup key

remove

public Object remove(Object sessionKey,
                     boolean removeFromStore)

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

Specified by:
values in interface Cache
Overrides:
values in class BaseCache

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 class LruCache
Parameters:
hashCode - for the entry
sessionKey - Object key
value - Object value
size - 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(StringBuffer sbuf)
Specified by:
appendStats in interface StatsProvider

getCacheHits

public int getCacheHits()
Specified by:
getCacheHits in interface EJBCacheStatsProvider

getCacheMisses

public int getCacheMisses()
Specified by:
getCacheMisses in interface EJBCacheStatsProvider

getNumBeansInCache

public int getNumBeansInCache()
Specified by:
getNumBeansInCache in interface EJBCacheStatsProvider

getNumExpiredSessionsRemoved

public int getNumExpiredSessionsRemoved()
Specified by:
getNumExpiredSessionsRemoved in interface EJBCacheStatsProvider

getNumPassivationErrors

public int getNumPassivationErrors()
Specified by:
getNumPassivationErrors in interface EJBCacheStatsProvider

getNumPassivations

public int getNumPassivations()
Specified by:
getNumPassivations in interface EJBCacheStatsProvider

getNumPassivationSuccess

public int getNumPassivationSuccess()
Specified by:
getNumPassivationSuccess in interface EJBCacheStatsProvider

setMaxCacheSize

public void setMaxCacheSize(int val)

getMaxCacheSize

public int getMaxCacheSize()
Specified by:
getMaxCacheSize in interface EJBCacheStatsProvider


Copyright © 2012 GlassFish Community. All Rights Reserved.