|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.server.session.AbstractSessionManager
org.eclipse.jetty.server.session.JDBCSessionManager
public class JDBCSessionManager
JDBCSessionManager SessionManager that persists sessions to a database to enable clustering. Session data is persisted to the JettySessions table: rowId (unique in cluster: webapp name/path + virtualhost + sessionId) contextPath (of the context owning the session) sessionId (unique in a context) lastNode (name of node last handled session) accessTime (time in ms session was accessed) lastAccessTime (previous time in ms session was accessed) createTime (time in ms session created) cookieTime (time in ms session cookie created) lastSavedTime (last time in ms session access times were saved) expiryTime (time in ms that the session is due to expire) map (attribute map) As an optimisation, to prevent thrashing the database, we do not persist the accessTime and lastAccessTime every time the session is accessed. Rather, we write it out every so often. The frequency is controlled by the saveIntervalSec field.
Nested Class Summary | |
---|---|
protected class |
JDBCSessionManager.ClassLoadingObjectInputStream
ClassLoadingObjectInputStream |
class |
JDBCSessionManager.Session
Session Session instance in memory of this node. |
class |
JDBCSessionManager.SessionData
SessionData Persistable data about a session. |
Nested classes/interfaces inherited from class org.eclipse.jetty.server.session.AbstractSessionManager |
---|
AbstractSessionManager.NullSessionContext, AbstractSessionManager.SessionIf |
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
protected java.lang.String |
__deleteSession
|
protected java.lang.String |
__insertSession
|
protected java.lang.String |
__selectSession
|
protected java.lang.String |
__updateSession
|
protected java.lang.String |
__updateSessionAccessTime
|
protected java.lang.String |
__updateSessionNode
|
protected long |
_saveIntervalSec
|
Fields inherited from class org.eclipse.jetty.server.session.AbstractSessionManager |
---|
__distantFuture, _context, _dftMaxIdleSecs, _httpOnly, _loader, _maxCookieAge, _maxSessions, _minSessions, _nodeIdInSessionId, _refreshCookieAge, _secureCookies, _sessionAttributeListeners, _sessionCookie, _sessionDomain, _sessionHandler, _sessionIdManager, _sessionIdPathParameterName, _sessionIdPathParameterNamePrefix, _sessionListeners, _sessionPath |
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING |
Fields inherited from interface org.eclipse.jetty.server.SessionManager |
---|
__DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty |
Constructor Summary | |
---|---|
JDBCSessionManager()
|
Method Summary | |
---|---|
protected void |
addSession(AbstractSessionManager.Session session)
Add a newly created session to our in-memory list for this node and persist it. |
protected void |
deleteSession(JDBCSessionManager.SessionData data)
Delete a session from the database. |
void |
doStart()
Start the session manager. |
void |
doStop()
Stop the session manager. |
protected void |
expire(java.util.List sessionIds)
Expire any Sessions we have in memory matching the list of expired Session ids. |
long |
getSaveInterval()
|
JDBCSessionManager.Session |
getSession(java.lang.String idInCluster)
A session has been requested by it's id on this node. |
java.util.Map |
getSessionMap()
Get all the sessions as a map of id to Session. |
int |
getSessions()
Get the number of sessions. |
protected void |
invalidateSession(java.lang.String idInCluster)
Invalidate a session. |
protected void |
invalidateSessions()
|
protected JDBCSessionManager.SessionData |
loadSession(java.lang.String id,
java.lang.String canonicalContextPath,
java.lang.String vhost)
Load a session from the database |
protected AbstractSessionManager.Session |
newSession(javax.servlet.http.HttpServletRequest request)
Make a new Session. |
protected void |
prepareTables()
|
void |
removeSession(AbstractSessionManager.Session session,
boolean invalidate)
Remove session from manager |
protected void |
removeSession(java.lang.String idInCluster)
Delete an existing session, both from the in-memory map and the database. |
void |
setSaveInterval(long sec)
Set the time in seconds which is the interval between saving the session access time to the database. |
protected void |
storeSession(JDBCSessionManager.SessionData data)
Insert a session into the database. |
protected void |
updateSession(JDBCSessionManager.SessionData data)
Update data on an existing persisted session. |
protected void |
updateSessionNode(JDBCSessionManager.SessionData data)
Update the node on which the session was last seen to be my node. |
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Field Detail |
---|
protected java.lang.String __insertSession
protected java.lang.String __deleteSession
protected java.lang.String __selectSession
protected java.lang.String __updateSession
protected java.lang.String __updateSessionNode
protected java.lang.String __updateSessionAccessTime
protected long _saveIntervalSec
Constructor Detail |
---|
public JDBCSessionManager()
Method Detail |
---|
public void setSaveInterval(long sec)
sec
- public long getSaveInterval()
public JDBCSessionManager.Session getSession(java.lang.String idInCluster)
getSession
in class AbstractSessionManager
idInCluster
- The session ID in the cluster, stripped of any worker name.
AbstractSessionManager.getSession(java.lang.String)
public java.util.Map getSessionMap()
getSessionMap
in class AbstractSessionManager
AbstractSessionManager.getSessionMap()
public int getSessions()
getSessions
in class AbstractSessionManager
AbstractSessionManager.getSessions()
public void doStart() throws java.lang.Exception
doStart
in class AbstractSessionManager
java.lang.Exception
AbstractSessionManager.doStart()
public void doStop() throws java.lang.Exception
doStop
in class AbstractSessionManager
java.lang.Exception
AbstractSessionManager.doStop()
protected void invalidateSessions()
invalidateSessions
in class AbstractSessionManager
protected void invalidateSession(java.lang.String idInCluster)
idInCluster
- protected void removeSession(java.lang.String idInCluster)
removeSession
in class AbstractSessionManager
AbstractSessionManager.removeSession(java.lang.String)
protected void addSession(AbstractSessionManager.Session session)
addSession
in class AbstractSessionManager
AbstractSessionManager.addSession(org.eclipse.jetty.server.session.AbstractSessionManager.Session)
protected AbstractSessionManager.Session newSession(javax.servlet.http.HttpServletRequest request)
newSession
in class AbstractSessionManager
AbstractSessionManager.newSession(javax.servlet.http.HttpServletRequest)
public void removeSession(AbstractSessionManager.Session session, boolean invalidate)
removeSession
in class AbstractSessionManager
session
- The session to removeinvalidate
- True if HttpSessionListener.sessionDestroyed(HttpSessionEvent)
and
SessionIdManager.invalidateAll(String)
should be called.protected void expire(java.util.List sessionIds)
sessionIds
- protected void prepareTables()
protected JDBCSessionManager.SessionData loadSession(java.lang.String id, java.lang.String canonicalContextPath, java.lang.String vhost) throws java.lang.Exception
id
-
java.lang.Exception
protected void storeSession(JDBCSessionManager.SessionData data) throws java.lang.Exception
data
-
java.lang.Exception
protected void updateSession(JDBCSessionManager.SessionData data) throws java.lang.Exception
data
-
java.lang.Exception
protected void updateSessionNode(JDBCSessionManager.SessionData data) throws java.lang.Exception
data
-
java.lang.Exception
protected void deleteSession(JDBCSessionManager.SessionData data) throws java.lang.Exception
data
-
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |