public abstract class PersistentManagerBase extends ManagerBase implements DistributedManager
ManagerBase class to implement most of the
 functionality required by a Manager which supports any kind of
 persistence, even if only for  restarts.
 
 IMPLEMENTATION NOTE:  Correct behavior of session storing and
 reloading depends upon external calls to the Lifecycle.start()
 and Lifecycle.stop() methods of this class
 at the correct times.
ManagerBase.SessionTimingLifecycle.SingleUse| Modifier and Type | Field and Description | 
|---|---|
| protected int | maxIdleBackupHow long a session must be idle before it should be backed up. | 
| protected int | maxIdleSwapThe maximum time in seconds a session may be idle before it is eligible
 to be swapped to disk due to inactivity. | 
| protected int | minIdleSwapThe minimum time in seconds a session must be idle before it is eligible
 to be swapped to disk to keep the active session count below
 maxActiveSessions. | 
| protected boolean | saveOnRestartWhether to save and reload sessions when the Manager  unloadandloadmethods are called. | 
| protected Store | storeStore object which will manage the Session store. | 
container, distributable, duplicates, expiredSessions, maxActive, maxActiveSessions, maxInactiveInterval, processExpiresFrequency, processingTime, rejectedSessions, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, SESSION_ID_LENGTH_UNSET, sessionCounter, sessionCreationTiming, sessionExpirationTiming, sessionIdGenerator, sessionIdGeneratorClass, sessionIdLength, sessionMaxAliveTime, sessions, sm, support, TIMING_STATS_CACHE_SIZEmserverAFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT| Constructor and Description | 
|---|
| PersistentManagerBase() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | clearStore()Clear all sessions from the Store. | 
| Session | findSession(String id)Return the active Session, associated with this Manager, with the
 specified session id (if any); otherwise return  null. | 
| int | getActiveSessionsFull()Returns the total session count for primary, backup and proxy. | 
| String | getInfo() | 
| int | getMaxIdleBackup()Indicates how many seconds old a session can get, after its last use in a
 request, before it should be backed up to the store. | 
| int | getMaxIdleSwap() | 
| int | getMinIdleSwap() | 
| String | getName() | 
| boolean | getSaveOnRestart()Indicates whether sessions are saved when the Manager is shut down
 properly. | 
| Set<String> | getSessionIdsFull()Returns the list of all sessions IDS (primary, backup and proxy). | 
| Store | getStore() | 
| boolean | isLoaded(String id)Check, whether a session is loaded in memory | 
| void | load()Load all sessions found in the persistence mechanism, assuming
 they are marked as valid and have not passed their expiration
 limit. | 
| void | processExpires()Invalidate all sessions that have expired. | 
| protected void | processMaxActiveSwaps()Swap idle sessions out to Store if too many are active | 
| protected void | processMaxIdleBackups()Back up idle sessions. | 
| protected void | processMaxIdleSwaps()Swap idle sessions out to Store if they are idle too long. | 
| void | processPersistenceChecks()Called by the background thread after active sessions have been checked
 for expiration, to allow sessions to be swapped out, backed up, etc. | 
| void | remove(Session session,
      boolean update)Remove this Session from the active Sessions for this Manager. | 
| protected void | removeSession(String id)Remove this Session from the active Sessions for this Manager,
 and from the Store. | 
| void | removeSuper(Session session)Remove this Session from the active Sessions for this Manager,
 but not from the Store. | 
| void | setMaxIdleBackup(int backup)Sets the option to back sessions up to the Store after they
 are used in a request. | 
| void | setMaxIdleSwap(int max)Sets the maximum time in seconds a session may be idle before it is
 eligible to be swapped to disk due to inactivity. | 
| void | setMinIdleSwap(int min)Sets the minimum time in seconds a session must be idle before it is
 eligible to be swapped to disk to keep the active session count below
 maxActiveSessions. | 
| void | setSaveOnRestart(boolean saveOnRestart)Set the option to save sessions to the Store when the Manager is
 shut down, then loaded when the Manager starts again. | 
| void | setStore(Store store)Set the Store object which will manage persistent Session
 storage for this Manager. | 
| protected void | startInternal()Start this component and implement the requirements
 of  LifecycleBase.startInternal(). | 
| protected void | stopInternal()Stop this component and implement the requirements
 of  LifecycleBase.stopInternal(). | 
| protected Session | swapIn(String id)Look for a session in the Store and, if found, restore
 it in the Manager's list of active sessions if appropriate. | 
| protected void | swapOut(Session session)Remove the session from the Manager's list of active
 sessions and write it out to the Store. | 
| void | unload()Save all currently active sessions in the appropriate persistence
 mechanism, if any. | 
| protected void | writeSession(Session session)Write the provided session to the Store without modifying
 the copy in memory or triggering passivation events. | 
add, addPropertyChangeListener, backgroundProcess, changeSessionId, changeSessionId, createEmptySession, createSession, expireSession, findSessions, generateSessionId, getActiveSessions, getClassName, getContainer, getCreationTime, getCreationTimestamp, getDistributable, getDomainInternal, getDuplicates, getEngine, getExpiredSessions, getJvmRoute, getLastAccessedTime, getLastAccessedTimestamp, getMaxActive, getMaxActiveSessions, getMaxInactiveInterval, getNewSession, getObjectNameKeyProperties, getPersistAuthentication, getProcessExpiresFrequency, getProcessingTime, getRejectedSessions, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, getSession, getSessionAttribute, getSessionAttributeNameFilter, getSessionAttributeNamePattern, getSessionAttributeValueClassNameFilter, getSessionAttributeValueClassNamePattern, getSessionAverageAliveTime, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionIdLength, getSessionMaxAliveTime, getThisAccessedTime, getThisAccessedTimestamp, getWarnOnSessionAttributeFilterFailure, initInternal, listSessionIds, remove, removePropertyChangeListener, rotateSessionId, setContainer, setDistributable, setDuplicates, setExpiredSessions, setMaxActive, setMaxActiveSessions, setMaxInactiveInterval, setPersistAuthentication, setProcessExpiresFrequency, setProcessingTime, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSessionAttributeNameFilter, setSessionAttributeValueClassNameFilter, setSessionCounter, setSessionIdGenerator, setSessionIdLength, setSessionMaxAliveTime, setWarnOnSessionAttributeFilterFailure, toString, updateSessionMaxAliveTime, willAttributeDistributedestroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregisteraddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stopprotected Store store
protected boolean saveOnRestart
unload
 and load methods are called.protected int maxIdleBackup
-1 means sessions won't be backed up.protected int minIdleSwap
-1 means sessions will not be
 swapped out to keep the active session count down.protected int maxIdleSwap
-1 means
 sessions should not be swapped out just because of inactivity.public int getMaxIdleBackup()
-1 means sessions
 are not backed up.public void setMaxIdleBackup(int backup)
-1
 means sessions are not backed up.
 
 Note that this is not a hard limit: sessions are checked
 against this age limit periodically according to processExpiresFrequency.
 This value should be considered to indicate when a session is
 ripe for backing up.
 
 So it is possible that a session may be idle for maxIdleBackup +
 processExpiresFrequency * engine.backgroundProcessorDelay seconds, plus the time it takes to handle other
 session expiration, swapping, etc. tasks.
backup - The number of seconds after their last accessed
 time when they should be written to the Store.public int getMaxIdleSwap()
-1
 means sessions should not be swapped out just because of inactivity.public void setMaxIdleSwap(int max)
-1 means sessions should not be swapped out just because of
 inactivity.max - time in seconds to wait for possible swap outpublic int getMinIdleSwap()
-1 means sessions will not be
 swapped out to keep the active session count down.public void setMinIdleSwap(int min)
-1 means sessions will not be
 swapped out to keep the active session count down.min - time in seconds before a possible swap outpublic String getInfo()
getInfo in interface ManagergetInfo in class ManagerBase<description>/<version>.public boolean isLoaded(String id)
id - The session id for the session to be searched fortrue, if the session id is loaded in memory
 otherwise false is returnedpublic String getName()
getName in class ManagerBasepublic void setStore(Store store)
store - the associated Storepublic Store getStore()
public boolean getSaveOnRestart()
unload() method to be called.true, when sessions should be saved on restart,
 {code false} otherwisepublic void setSaveOnRestart(boolean saveOnRestart)
saveOnRestart - true if sessions should be saved on restart, false if
     they should be ignored.public void clearStore()
public void processExpires()
Direct call to processExpires and processPersistenceChecks
processExpires in class ManagerBasepublic void processPersistenceChecks()
public Session findSession(String id) throws IOException
null.
 This method checks the persistence store if persistence is enabled, otherwise just uses the functionality from ManagerBase.
findSession in interface ManagerfindSession in class ManagerBaseid - The session id for the session to be returnednull if a session with the
         requested ID could not be foundIOException - if an input/output error occurs while
  processing this requestpublic void removeSuper(Session session)
session - Session to be removedpublic void load()
Note that by default, this method is not called by the MiddleManager class. In order to use it, a subclass must specifically call it, for example in the start() and/or processPersistenceChecks() methods.
public void remove(Session session, boolean update)
Remove this Session from the Store.
remove in interface Managerremove in class ManagerBasesession - Session to be removedupdate - Should the expiration statistics be updatedprotected void removeSession(String id)
id - Session's id to be removedpublic void unload()
Note that by default, this method is not called by the MiddleManager class. In order to use it, a subclass must specifically call it, for example in the stop() and/or processPersistenceChecks() methods.
public int getActiveSessionsFull()
DistributedManagergetActiveSessionsFull in interface DistributedManagerpublic Set<String> getSessionIdsFull()
DistributedManagergetSessionIdsFull in interface DistributedManagerprotected Session swapIn(String id) throws IOException
null, if none is foundIOExceptionprotected void swapOut(Session session) throws IOException
session - The Session to write out.IOExceptionprotected void writeSession(Session session) throws IOException
IOExceptionprotected void startInternal()
                      throws LifecycleException
LifecycleBase.startInternal().startInternal in class ManagerBaseLifecycleException - if this component detects a fatal error
  that prevents this component from being usedprotected void stopInternal()
                     throws LifecycleException
LifecycleBase.stopInternal().stopInternal in class ManagerBaseLifecycleException - if this component detects a fatal error
  that prevents this component from being usedprotected void processMaxIdleSwaps()
protected void processMaxActiveSwaps()
protected void processMaxIdleBackups()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.