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.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private class | |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final Log | |
| protected int | maxIdleBackup
How long a session must be idle before it should be backed up. |
| protected int | maxIdleSwap
The maximum time in seconds a session may be idle before it is eligible to be swapped to disk due to inactivity. |
| protected int | minIdleSwap
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. |
| private static final String | name
The descriptive name of this Manager implementation (for logging).
|
| private static final String | PERSISTED_LAST_ACCESSED_TIME
Key of the note of a session in which the timestamp of last backup is stored. |
| protected boolean | saveOnRestart
Whether to save and reload sessions when the Manager |
| private final Map | sessionSwapInLocks
Sessions currently being swapped in and the associated locks |
| private final ThreadLocal | |
| protected Store | store
Store object which will manage the Session store. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public Session | findSession(String
The session id for the session to be returned id)Overrides org. Implements org. Return the active Session, associated with this Manager, with the
specified session id (if any); otherwise return |
| public int | getActiveSessionsFull()
Implements org. Returns the total session count for primary, backup and proxy. |
| public int | Returns: the timeout after which sessions are ripe for back upIndicates how many seconds old a session can get, after its last use in a request, before it should be backed up to the store. |
| public int | Returns: The maximum time in seconds a session may be idle before it is eligible to be swapped to disk due to inactivity. A value of-1 means sessions should not be swapped out just because of
inactivity.
|
| public int | Returns: 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. A value of-1 means sessions will not be
swapped out to keep the active session count down.
|
| public String | |
| public boolean | Returns: true, when sessions should be saved on restart, {code false} otherwiseIndicates whether sessions are saved when the Manager is shut down properly. |
| public Set | getSessionIdsFull()
Implements org. Returns the list of all sessions IDS (primary, backup and proxy). |
| public Store | Returns: the Store object which manages persistent Session storage for this Manager.Implements org.
|
| public boolean | |
| public void | load()
Implements org. Load all sessions found in the persistence mechanism, assuming they are marked as valid and have not passed their expiration limit. |
| private Session | |
| public void | processExpires()
Overrides org. Invalidate all sessions that have expired. |
| protected void | |
| protected void | |
| protected void | |
| public 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. |
| private void | |
| public void | remove(Session
Session to be removed session, boolean Should the expiration statistics be updated update)Overrides org. Implements org. Remove this Session from the active Sessions for this Manager. |
| protected void | removeSession(String
Session's id to be removed id)Remove this Session from the active Sessions for this Manager, and from the Store. |
| public void | removeSuper(Session
Session to be removed session)Implements org. Remove this Session from the active Sessions for this Manager, but not from the Store. |
| private Session | |
| public void | setMaxIdleBackup(int
The number of seconds after their last accessed time when they should be written to the Store. backup)Sets the option to back sessions up to the Store after they are used in a request. |
| public void | setMaxIdleSwap(int
time in seconds to wait for possible swap out max)Sets the maximum time in seconds a session may be idle before it is eligible to be swapped to disk due to inactivity. |
| public void | setMinIdleSwap(int
time in seconds before a possible swap out 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. |
| public void | setSaveOnRestart(boolean
true if sessions should be saved on restart, false if they should be
ignored.Set the option to save sessions to the Store when the Manager is shut down, then loaded when the Manager starts again. |
| public void | |
| protected void | startInternal()
Overrides org. Start this component and implement the requirements of
|
| protected void | stopInternal()
Overrides org. Stop this component and implement the requirements of
|
| protected Session | |
| protected void | |
| public void | unload()
Implements org. Save all currently active sessions in the appropriate persistence mechanism, if any. |
| protected void | writeSession(Session
The session that should be written session)Write the provided session to the Store without modifying the copy in memory or triggering passivation events. |
| log | back to summary |
|---|---|
| private final Log log | |
| maxIdleBackup | back to summary |
|---|---|
| protected int maxIdleBackup How long a session must be idle before it should be backed up. | |
| maxIdleSwap | back to summary |
|---|---|
| protected int maxIdleSwap The maximum time in seconds a session may be idle before it is eligible to be swapped to disk due to inactivity.
Setting this to | |
| minIdleSwap | back to summary |
|---|---|
| protected int minIdleSwap 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. Setting to | |
| name | back to summary |
|---|---|
| private static final String name Hides org. The descriptive name of this Manager implementation (for logging). | |
| PERSISTED_LAST_ACCESSED_TIME | back to summary |
|---|---|
| private static final String PERSISTED_LAST_ACCESSED_TIME Key of the note of a session in which the timestamp of last backup is stored. | |
| saveOnRestart | back to summary |
|---|---|
| protected boolean saveOnRestart Whether to save and reload sessions when the Manager | |
| sessionSwapInLocks | back to summary |
|---|---|
| private final Map<String, Object> sessionSwapInLocks Sessions currently being swapped in and the associated locks | |
| sessionToSwapIn | back to summary |
|---|---|
| private final ThreadLocal<Session> sessionToSwapIn | |
| store | back to summary |
|---|---|
| protected Store store Store object which will manage the Session store. | |
| PersistentManagerBase | back to summary |
|---|---|
| public PersistentManagerBase() | |
| clearStore | back to summary |
|---|---|
| public void clearStore() Clear all sessions from the Store. | |
| findSession | back to summary |
|---|---|
| public Session findSession(String id) throws IOException Overrides org. Implements org. Doc from org. Return the active Session, associated with this Manager, with the
specified session id (if any); otherwise return This method checks the persistence store if persistence is enabled, otherwise just uses the functionality from ManagerBase.
| |
| getActiveSessionsFull | back to summary |
|---|---|
| public int getActiveSessionsFull() Implements org. Doc from org. Returns the total session count for primary, backup and proxy.
| |
| getMaxIdleBackup | back to summary |
|---|---|
| public 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.
| |
| getMaxIdleSwap | back to summary |
|---|---|
public int getMaxIdleSwap()
| |
| getMinIdleSwap | back to summary |
|---|---|
public int getMinIdleSwap()
| |
| getName | back to summary |
|---|---|
| public String getName() Overrides org.
| |
| getSaveOnRestart | back to summary |
|---|---|
| public boolean getSaveOnRestart() Indicates whether sessions are saved when the Manager is shut down properly. This requires the
| |
| getSessionIdsFull | back to summary |
|---|---|
| public Set Implements org. Doc from org. Returns the list of all sessions IDS (primary, backup and proxy). | |
| getStore | back to summary |
|---|---|
| public Store getStore() Implements org. | |
| isLoaded | back to summary |
|---|---|
| public boolean isLoaded(String id) Check, whether a session is loaded in memory
| |
| load | back to summary |
|---|---|
| public void load() Implements org. Load all sessions found in the persistence mechanism, assuming they are marked as valid and have not passed their expiration limit. If persistence is not supported, this method returns without doing anything. 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.
| |
| loadSessionFromStore | back to summary |
|---|---|
| private Session loadSessionFromStore(String id) throws IOException | |
| processExpires | back to summary |
|---|---|
| public void processExpires() Overrides org. Doc from org. Invalidate all sessions that have expired. Direct call to processExpires and processPersistenceChecks
| |
| processMaxActiveSwaps | back to summary |
|---|---|
| protected void processMaxActiveSwaps() Swap idle sessions out to Store if too many are active | |
| processMaxIdleBackups | back to summary |
|---|---|
| protected void processMaxIdleBackups() Back up idle sessions. | |
| processMaxIdleSwaps | back to summary |
|---|---|
| protected void processMaxIdleSwaps() Swap idle sessions out to Store if they are idle too long. | |
| processPersistenceChecks | back to summary |
|---|---|
| public 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. | |
| reactivateLoadedSession | back to summary |
|---|---|
| private void reactivateLoadedSession(String id, Session session) | |
| remove | back to summary |
|---|---|
| public void remove(Session session, boolean update) Overrides org. Implements org. Doc from org. Remove this Session from the active Sessions for this Manager. Remove this Session from the Store. | |
| removeSession | back to summary |
|---|---|
| protected void removeSession(String id) Remove this Session from the active Sessions for this Manager, and from the Store.
| |
| removeSuper | back to summary |
|---|---|
| public void removeSuper(Session session) Implements org. Remove this Session from the active Sessions for this Manager, but not from the Store. (Used by the PersistentValve) | |
| securedStoreLoad | back to summary |
|---|---|
| private Session securedStoreLoad(String id) throws IOException, ClassNotFoundException | |
| setMaxIdleBackup | back to summary |
|---|---|
| public void setMaxIdleBackup(int backup) Sets the option to back sessions up to the Store after they are used in a request. Sessions remain available in
memory after being backed up, so they are not passivated as they are when swapped out. The value set indicates
how old a session may get (since its last use) before it must be backed up:
Note that this is not a hard limit: sessions are checked against this age limit periodically according to
So it is possible that a session may be idle for
| |
| setMaxIdleSwap | back to summary |
|---|---|
| public 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. Setting this to
| |
| setMinIdleSwap | back to summary |
|---|---|
| public 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. Setting to
| |
| setSaveOnRestart | back to summary |
|---|---|
| public 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. If set to false, any sessions found in the Store may still be picked up when the Manager is started again.
| |
| setStore | back to summary |
|---|---|
| public void setStore(Store store) Set the Store object which will manage persistent Session storage for this Manager.
| |
| startInternal | back to summary |
|---|---|
| protected void startInternal() throws LifecycleException Overrides org. Start this component and implement the requirements of
| |
| stopInternal | back to summary |
|---|---|
| protected void stopInternal() throws LifecycleException Overrides org. Stop this component and implement the requirements of
| |
| swapIn | back to summary |
|---|---|
| protected Session swapIn(String id) throws IOException Look for a session in the Store and, if found, restore it in the Manager's list of active sessions if appropriate. The session will be removed from the Store after swapping in, but will not be added to the active session list if it is invalid or past its expiration.
| |
| swapOut | back to summary |
|---|---|
| protected void swapOut(Session session) throws IOException Remove the session from the Manager's list of active sessions and write it out to the Store. If the session is past its expiration or invalid, this method does nothing.
| |
| unload | back to summary |
|---|---|
| public void unload() Implements org. Save all currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything. 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.
| |
| writeSession | back to summary |
|---|---|
| protected void writeSession(Session session) throws IOException Write the provided session to the Store without modifying the copy in memory or triggering passivation events. Does nothing if the session is invalid or past its expiration.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Void |
| PrivilegedStoreClear | back to summary |
|---|---|
| pack-priv PrivilegedStoreClear() | |
| run | back to summary |
|---|---|
| public Void run() throws Exception Implements java. Doc from java. Performs the computation. This method will be called by
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String[] |
| PrivilegedStoreKeys | back to summary |
|---|---|
| pack-priv PrivilegedStoreKeys() | |
| run | back to summary |
|---|---|
| public String[] run() throws Exception Implements java. Doc from java. Performs the computation. This method will be called by
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Session |
| id | back to summary |
|---|---|
| private String id | |
| PrivilegedStoreLoad | back to summary |
|---|---|
| pack-priv PrivilegedStoreLoad(String id) | |
| run | back to summary |
|---|---|
| public Session run() throws Exception Implements java. Doc from java. Performs the computation. This method will be called by
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Void |
| id | back to summary |
|---|---|
| private String id | |
| PrivilegedStoreRemove | back to summary |
|---|---|
| pack-priv PrivilegedStoreRemove(String id) | |
| run | back to summary |
|---|---|
| public Void run() throws Exception Implements java. Doc from java. Performs the computation. This method will be called by
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Void |
| session | back to summary |
|---|---|
| private Session session | |
| PrivilegedStoreSave | back to summary |
|---|---|
| pack-priv PrivilegedStoreSave(Session session) | |
| run | back to summary |
|---|---|
| public Void run() throws Exception Implements java. Doc from java. Performs the computation. This method will be called by
| |