|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> [ session overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.appserver.server.session
Class PagedSessionHome

java.lang.Objectcom.lutris.appserver.server.session.PagedSessionHome
- All Implemented Interfaces:
- StandardSessionHome
- Direct Known Subclasses:
- DiskPagedSessionHome
- public abstract class PagedSessionHome
- extends java.lang.Object
- implements StandardSessionHome
- extends java.lang.Object
The StandardSessionManager uses PagedSessionHome to manage a collection of sessions that can be paged to disk.
PagedSessionHome will page sessions to disk as soon as a pre-configured threshold of sessions has been reached. Only sessions in the 'passive' state will be paged to disk. If all sessions are in the 'active' state and the threshold has been reached, then a request to create a new session will block until one of the 'active' sessions goes into the 'passive' state. At this point the session that just became 'passive' is paged to disk and a new session is created.
Sessions are paged to disk by serializing the all data (excluding the session manager) that is associated with a session. This requires that the session data and user associated with a session are serializable.
The following parameters can be used to configure
the PagedSessionHome. They should be grouped together in a section,
normally SessionManager.SessionHome, which is specified to
the constructor.
PageThreshold: {int}Specifies the maximum number of session that may reside in memory simultaneously. If set to zero the the paged session home acts as a write through cache. If set to -1, then the page threshold is assumed to be infinite and paging will never take place. If not set, defaults to -1.
PageTimeThreshold: {long}Specifies the amount of time a session may remain in memory before it is paged out to disk. If this parameter is not set, or, it is set to -1, then the session will not be paged out unless the PageThreshold is reached.
PageWait: {int}Specifies the maximum time (in milliseconds) that a thread will wait for a session to be created or retrieved. If the page threshold has been reached, then a thread has to wait for an existing session to be paged before a new session can be created or a pre-existing session (that has been paged to disk) can be activated. If not set, defaults to 1 minute. If this time is exceeded then an exception is thrown - this prevents a possible deadlock situation.
PageDir: {String}The directory where sessions will be paged. This setting is required.
MaxSessions: {int}Specifies the maximum number of in use concurrent sessions. If this value is exceeded then CreateSession() will throw a CreateSessionException. -1 indicates unlimited session. If MaxSessions is not set in the application's configuration then MaxSessions defaults to unlimited sessions.
- Version:
- $Revision: 1.5.14.1 $
| Field Summary | |
private java.util.Hashtable |
activeCache
The active cache contains sessions that are actively in use (associated with) by a request. |
private java.util.Hashtable |
activeThreadCache
The active thread cache holds all the association between active sessions and the threads that have checked them out. |
private com.lutris.util.Config |
config
Config options for paged session home. |
protected java.lang.ClassLoader |
loader
The class loader to use when reading in paged data. |
private java.lang.String |
MAX_SESSIONS_KEY
Configuration keys. |
private long |
maxSessions
Maximum number of allowed sessions. |
private java.lang.String |
PAGE_THRESHOLD_KEY
|
private java.lang.String |
PAGE_TIME_THRESHOLD_KEY
|
private java.lang.String |
PAGE_WAIT_KEY
|
private long |
pageThreshold
The threshold where paging beings. |
private long |
pageTimeThreshold
The amount of time a session may remain in memory unused before it is paged out. |
private long |
pageWait
If a thread has to wait for a session to be paged before it can retrieve (get) or create a session then pageWait specifies that maximum amount of time that the thread will wait before an exception is thrown. |
private java.util.Hashtable |
passiveCache
The passive cache contains sessions that aren't currently associated with a request. |
protected StandardSessionManager |
sessionMgr
The session manager associated with the session home. |
private PagedSessionThresholdTimer |
thresholdTimer
The pageTimeThreshold timer. |
private long |
UNDEFINED_MAX_SESSIONS
|
| Constructor Summary | |
PagedSessionHome(StandardSessionManager sessionMgr,
com.lutris.util.Config config,
java.lang.ClassLoader loader)
|
|
| Method Summary | |
private PagedSession |
activateSession(java.lang.String sessionKey)
Puts a session into the 'active' state. |
(package private) long |
checkPassiveSessions()
Pages out any sessions that are passive and have exceeded the page time threshold. |
private long |
checkPassiveSessions(long threshold)
Pages out any sessions that are passive and have exceeded the page time threshold. |
protected abstract boolean |
cleanupNewPagedSession()
Removes a session that is new and paged. |
private void |
cleanupNewSession()
Cleans up (removes) the oldest unused (new) session from the passive cache. |
boolean |
containsKey(java.lang.String sessionKey)
Specifies if a key is currently in use. |
StandardSession |
createSession(java.lang.String sessionKey)
Creates a new session instance in the cache. |
protected void |
debug(int level,
java.lang.String msg)
Prints debug information under Logger.DEBUG. |
protected void |
debug(java.lang.String msg)
Prints debug information under Logger.DEBUG. |
protected abstract void |
deleteSession(java.lang.String sessionKey)
Deletes a paged session. |
private void |
ensureNewSession()
Ensures that a new session can be put into the list in-core sessions that are being managed. |
protected abstract int |
getPagedSessionCount()
Returns the number of paged sessions. |
protected abstract java.util.Enumeration |
getPagedSessionKeys()
Returns an enumeration of the keys of all the sessions that have been paged out to persistent storage. |
StandardSession |
getSession(java.lang.String sessionKey)
Returns the session associated with the session key. |
StandardSession |
getSession(java.lang.Thread thread,
java.lang.String sessionKey)
Returns the session associated with the session key. |
private boolean |
isWriteThroughCache()
Returns true if the current configuration is for a write trhough cache. |
java.util.Enumeration |
keys()
Returns an enumeration of keys for the cached sessions. |
protected abstract PagedSession |
newSession(StandardSessionManager mgr,
java.lang.String sessionKey)
Creates a new session object. |
protected abstract boolean |
pagedSessionKeyExists(java.lang.String sessionKey)
Returns true if the specified session key is in use by a session that has been paged out. |
int |
pagedSize()
Returns the current number of sessions that are paged to persistent store. |
protected abstract PagedSession |
pageIn(java.lang.String sessionKey)
Reads a paged session from disk. |
protected abstract void |
pageOut(PagedSession s)
Pages a session to disk. |
void |
passivateSession(java.lang.Thread thread,
java.lang.String sessionKey)
Puts an 'active' session into the 'passive' state. |
void |
removeSession(java.lang.String sessionKey)
Removes the session associated with the session key. |
void |
shutdown()
Shuts down the session home. |
int |
size()
Returns the current number of sessions. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
activeCache
private java.util.Hashtable activeCache
- The active cache contains sessions that are
actively in use (associated with) by a request.
activeThreadCache
private java.util.Hashtable activeThreadCache
- The active thread cache holds all the association
between active sessions and the threads that have
checked them out.
passiveCache
private java.util.Hashtable passiveCache
- The passive cache contains sessions that
aren't currently associated with a request.
config
private com.lutris.util.Config config
- Config options for paged session home.
maxSessions
private long maxSessions
- Maximum number of allowed sessions.
pageThreshold
private long pageThreshold
- The threshold where paging beings.
pageTimeThreshold
private long pageTimeThreshold
- The amount of time a session may remain in memory
unused before it is paged out. In seconds.
thresholdTimer
private PagedSessionThresholdTimer thresholdTimer
- The pageTimeThreshold timer.
pageWait
private long pageWait
- If a thread has to wait for a session to be paged
before it can retrieve (get) or create a session then
pageWait specifies that maximum amount of time
that the thread will wait before an exception is
thrown.
MAX_SESSIONS_KEY
private final java.lang.String MAX_SESSIONS_KEY
- Configuration keys.
- See Also:
- Constant Field Values
PAGE_THRESHOLD_KEY
private final java.lang.String PAGE_THRESHOLD_KEY
- See Also:
- Constant Field Values
PAGE_TIME_THRESHOLD_KEY
private final java.lang.String PAGE_TIME_THRESHOLD_KEY
- See Also:
- Constant Field Values
PAGE_WAIT_KEY
private final java.lang.String PAGE_WAIT_KEY
- See Also:
- Constant Field Values
UNDEFINED_MAX_SESSIONS
private final long UNDEFINED_MAX_SESSIONS
- See Also:
- Constant Field Values
loader
protected java.lang.ClassLoader loader
- The class loader to use when reading in paged data.
sessionMgr
protected StandardSessionManager sessionMgr
- The session manager associated with the session home.
| Constructor Detail |
PagedSessionHome
public PagedSessionHome(StandardSessionManager sessionMgr, com.lutris.util.Config config, java.lang.ClassLoader loader) throws SessionException, com.lutris.util.ConfigException
| Method Detail |
createSession
public StandardSession createSession(java.lang.String sessionKey) throws CreateSessionException, DuplicateKeyException, SessionException
- Creates a new session instance in the cache. The
session is associated with the session key and the
current thread.
- Specified by:
createSessionin interfaceStandardSessionHome
newSession
protected abstract PagedSession newSession(StandardSessionManager mgr, java.lang.String sessionKey) throws SessionException
- Creates a new session object. This method is intended to be
overriden by classes that extend PagedSessionHome.
deleteSession
protected abstract void deleteSession(java.lang.String sessionKey) throws SessionException
- Deletes a paged session. If the session doesn't exist then this
is a noop.
getSession
public StandardSession getSession(java.lang.String sessionKey) throws SessionException
- Returns the session associated with the session key.
The session must already be associated with the current thread
otherwize null is returned.
- Specified by:
getSessionin interfaceStandardSessionHome
getSession
public StandardSession getSession(java.lang.Thread thread, java.lang.String sessionKey) throws SessionException
- Returns the session associated with the session key.
The session is associated with the specified thread.
The session is put into the 'active' state.
- Specified by:
getSessionin interfaceStandardSessionHome
removeSession
public void removeSession(java.lang.String sessionKey) throws SessionException
- Removes the session associated with the session key.
- Specified by:
removeSessionin interfaceStandardSessionHome
passivateSession
public void passivateSession(java.lang.Thread thread, java.lang.String sessionKey) throws SessionException
- Puts an 'active' session into the 'passive' state.
- Specified by:
passivateSessionin interfaceStandardSessionHome
pageOut
protected abstract void pageOut(PagedSession s) throws SessionException
- Pages a session to disk.
pageIn
protected abstract PagedSession pageIn(java.lang.String sessionKey) throws SessionException
- Reads a paged session from disk.
getPagedSessionCount
protected abstract int getPagedSessionCount()
throws SessionException
- Returns the number of paged sessions.
activateSession
private PagedSession activateSession(java.lang.String sessionKey) throws SessionException
- Puts a session into the 'active' state. Reads paged version
if necessary.
containsKey
public boolean containsKey(java.lang.String sessionKey) throws SessionException
- Specifies if a key is currently in use.
- Specified by:
containsKeyin interfaceStandardSessionHome
pagedSessionKeyExists
protected abstract boolean pagedSessionKeyExists(java.lang.String sessionKey) throws SessionException
- Returns true if the specified session key is in use
by a session that has been paged out.
size
public int size()
throws SessionException
- Returns the current number of sessions.
- Specified by:
sizein interfaceStandardSessionHome
pagedSize
public int pagedSize()
throws SessionException
- Returns the current number of sessions that are paged to
persistent store.
- Specified by:
pagedSizein interfaceStandardSessionHome
keys
public java.util.Enumeration keys() throws SessionException
- Returns an enumeration of keys for the cached sessions.
- Specified by:
keysin interfaceStandardSessionHome
getPagedSessionKeys
protected abstract java.util.Enumeration getPagedSessionKeys() throws SessionException
- Returns an enumeration of the keys of all the sessions that have
been paged out to persistent storage.
cleanupNewSession
private void cleanupNewSession()
throws SessionException
- Cleans up (removes) the oldest unused (new) session from the
passive cache.
checkPassiveSessions
long checkPassiveSessions()
throws SessionException
- Pages out any sessions that are passive and have exceeded
the page time threshold.
checkPassiveSessions
private long checkPassiveSessions(long threshold)
throws SessionException
- Pages out any sessions that are passive and have exceeded
the page time threshold.
cleanupNewPagedSession
protected abstract boolean cleanupNewPagedSession()
throws SessionException
- Removes a session that is new and paged.
ensureNewSession
private void ensureNewSession()
throws SessionException
- Ensures that a new session can be put into the list
in-core sessions that are being managed.
If necessary, this method will page a passive session disk in
in order to guarantee that another session can be
read into memory (or created). This method may block
if a session first needs to be paged to disk.
shutdown
public void shutdown()
- Shuts down the session home. Pages out all active sessions.
- Specified by:
shutdownin interfaceStandardSessionHome
isWriteThroughCache
private boolean isWriteThroughCache()
- Returns true if the current configuration is for
a write trhough cache.
debug
protected void debug(java.lang.String msg)
- Prints debug information under Logger.DEBUG.
debug
protected void debug(int level,
java.lang.String msg)
- Prints debug information under Logger.DEBUG.
|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> [ session overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lutris.appserver.server.session.PagedSessionHome