EAF 7.6 Implementation

com.lutris.appserver.server.sessionEnhydra
Class DiskPagedSessionHome

java.lang.Object
  extended by com.lutris.appserver.server.sessionEnhydra.PagedSessionHome
      extended by com.lutris.appserver.server.sessionEnhydra.DiskPagedSessionHome
All Implemented Interfaces:
com.lutris.appserver.server.sessionEnhydra.StandardSessionHome

public class DiskPagedSessionHome
extends PagedSessionHome

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.

Version:
$Revision: 1.4 $
Author:
Kyle Clark
See Also:
StandardSession, StandardSessionManager

Field Summary
 
Fields inherited from class com.lutris.appserver.server.sessionEnhydra.PagedSessionHome
loader, sessionMgr
 
Constructor Summary
DiskPagedSessionHome(StandardSessionManager sessionMgr, com.lutris.util.Config config, java.lang.ClassLoader loader)
           
 
Method Summary
protected  boolean cleanupNewPagedSession()
          Removes a session that is new and paged.
protected  void deleteSession(java.lang.String sessionKey)
          Deletes a paged session.
protected  int getPagedSessionCount()
          Returns the number of paged sessions.
protected  java.util.Enumeration getPagedSessionKeys()
          Returns an enumeration of the keys of all the sessions that have been paged out to persistent storage.
protected  PagedSession newSession(StandardSessionManager mgr, java.lang.String sessionKey)
          Creates a new session object.
protected  boolean pagedSessionKeyExists(java.lang.String sessionKey)
          Returns true if the specified session key is in use by a session that has been paged out.
protected  PagedSession pageIn(java.lang.String sessionKey)
          Reads a paged session from disk.
protected  void pageOut(PagedSession s)
          Pages a session to disk.
 void shutdown()
          Shuts dows the session home.
 
Methods inherited from class com.lutris.appserver.server.sessionEnhydra.PagedSessionHome
containsKey, createSession, debug, debug, getSession, getSession, keys, pagedSize, passivateSession, removeSession, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskPagedSessionHome

public DiskPagedSessionHome(StandardSessionManager sessionMgr,
                            com.lutris.util.Config config,
                            java.lang.ClassLoader loader)
                     throws com.lutris.appserver.server.session.SessionException,
                            com.lutris.util.ConfigException
Parameters:
sessionMgr - The session manager associated with this session home.
config - Object parsed from configuration file. This should be for the section containing the standard session home configuration.
loader - The class load to use when load objects from persistent store.
Throws:
com.lutris.util.ConfigException - signifies a problem in the configuration file.
com.lutris.appserver.server.session.SessionException - if the initialization fails.
Method Detail

newSession

protected PagedSession newSession(StandardSessionManager mgr,
                                  java.lang.String sessionKey)
                           throws com.lutris.appserver.server.session.SessionException
Creates a new session object. This method is intended to be overriden by classes that extend PagedSessionHome.

Specified by:
newSession in class PagedSessionHome
Returns:
a new session.
Throws:
com.lutris.appserver.server.session.SessionException - if an error occurs.

deleteSession

protected void deleteSession(java.lang.String sessionKey)
                      throws com.lutris.appserver.server.session.SessionException
Deletes a paged session. If the session doesn't exist then this is a noop.

Specified by:
deleteSession in class PagedSessionHome
Parameters:
sessionKey - the key identifying the session that should be deleted.
Throws:
com.lutris.appserver.server.session.SessionException

pageOut

protected void pageOut(PagedSession s)
                throws com.lutris.appserver.server.session.SessionException
Pages a session to disk.

Specified by:
pageOut in class PagedSessionHome
Parameters:
session - the session to page.
Throws:
com.lutris.appserver.server.session.SessionException - if the paged session could not be paged out.

pageIn

protected PagedSession pageIn(java.lang.String sessionKey)
                       throws com.lutris.appserver.server.session.SessionException
Reads a paged session from disk.

Specified by:
pageIn in class PagedSessionHome
Parameters:
sessionKey - the key identifying the session that should be paged in.
Returns:
the paged session that was read in.
Throws:
com.lutris.appserver.server.session.SessionException - if the paged session could not be read in or does not exist.

getPagedSessionCount

protected int getPagedSessionCount()
                            throws com.lutris.appserver.server.session.SessionException
Returns the number of paged sessions.

Specified by:
getPagedSessionCount in class PagedSessionHome
Throws:
com.lutris.appserver.server.session.SessionException - if the paged session count cannot be retrieved.

pagedSessionKeyExists

protected boolean pagedSessionKeyExists(java.lang.String sessionKey)
                                 throws com.lutris.appserver.server.session.SessionException
Returns true if the specified session key is in use by a session that has been paged out.

Specified by:
pagedSessionKeyExists in class PagedSessionHome
Parameters:
sessionKey - the session key to test.
Returns:
true if the session key is in use by a paged session.
Throws:
com.lutris.appserver.server.session.SessionException - if an error occurs.

getPagedSessionKeys

protected java.util.Enumeration getPagedSessionKeys()
                                             throws com.lutris.appserver.server.session.SessionException
Returns an enumeration of the keys of all the sessions that have been paged out to persistent storage.

Specified by:
getPagedSessionKeys in class PagedSessionHome
Returns:
the session key enumeration.
Throws:
com.lutris.appserver.server.session.SessionException - if an error occurs.

cleanupNewPagedSession

protected boolean cleanupNewPagedSession()
                                  throws com.lutris.appserver.server.session.SessionException
Removes a session that is new and paged.

Specified by:
cleanupNewPagedSession in class PagedSessionHome
Returns:
true is a new session was found and deleted.
Throws:
com.lutris.appserver.server.session.SessionException - if an error occurs.

shutdown

public void shutdown()
Shuts dows the session home. Removes paged sessions from disk or page all sessions if key SaveOnRestart = true.

Specified by:
shutdown in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Overrides:
shutdown in class PagedSessionHome

EAF 7.6 Implementation