public class InfinispanSessionManager extends AbstractSessionManager
Key: is the id of the session + the context path + the vhost for the context Value: is the data of the sessionThe key is necessarily complex because the same session id can be in-use by more than one context. In this case, the contents of the session will strictly be different for each context, although the id will be the same. Sessions are also kept in local memory when they are used by this session manager. This allows multiple different request threads in the same context to call Request.getSession() and obtain the same object. This session manager support scavenging, which is only done over the set of sessions in its local memory. This can result in some sessions being "stranded" in the cluster cache if no session manager is currently managing it (eg the node managing the session crashed and it was never requested on another node).
| Modifier and Type | Class and Description |
|---|---|
protected class |
InfinispanSessionManager.Scavenger
Scavenger
|
class |
InfinispanSessionManager.SerializableSessionData |
class |
InfinispanSessionManager.Session
Session
Representation of a session in local memory.
|
AbstractSessionManager.CookieConfig, AbstractSessionManager.SessionIfAbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.Listener| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_ownScheduler |
protected long |
_scavengeIntervalMs |
protected InfinispanSessionManager.Scavenger |
_scavenger |
protected Scheduler |
_scheduler |
protected Scheduler.Task |
_task |
__defaultSessionTrackingModes, __distantFuture, _checkingRemoteSessionIdEncoding, _context, _dftMaxIdleSecs, _httpOnly, _loader, _maxCookieAge, _nodeIdInSessionId, _refreshCookieAge, _secureCookies, _secureRequestOnly, _sessionAttributeListeners, _sessionComment, _sessionCookie, _sessionDomain, _sessionHandler, _sessionIdListeners, _sessionIdManager, _sessionIdPathParameterName, _sessionIdPathParameterNamePrefix, _sessionListeners, _sessionPath, _sessionsStats, _sessionTimeStats, _sessionTrackingModesFAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty| Constructor and Description |
|---|
InfinispanSessionManager() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addSession(AbstractSession session)
Add a new session for the context related to this session manager
|
protected void |
delete(InfinispanSessionManager.Session session)
Remove the session from the cluster cache.
|
void |
doStart()
Start the session manager.
|
void |
doStop()
Stop the session manager.
|
org.infinispan.commons.api.BasicCache<String,Object> |
getCache()
Get the clustered cache instance.
|
long |
getScavengeInterval() |
AbstractSession |
getSession(String idInCluster)
Ask the cluster for the session.
|
long |
getStaleIntervalSec() |
void |
invalidateSession(String idInCluster)
Invalidate a session for this context with the given id
|
protected InfinispanSessionManager.Session |
load(String key)
Load a session from the clustered cache.
|
protected AbstractSession |
newSession(javax.servlet.http.HttpServletRequest request)
Create a new session instance
|
protected boolean |
removeSession(String idInCluster)
Remove a session from local memory, and delete it from
the cluster cache.
|
void |
renewSessionId(String oldClusterId,
String oldNodeId,
String newClusterId,
String newNodeId)
Tell the HttpSessionIdListeners the id changed.
|
protected void |
save(InfinispanSessionManager.Session session)
Save or update the session to the cluster cache
|
void |
scavenge() |
void |
setCache(org.infinispan.commons.api.BasicCache<String,Object> cache)
Set the clustered cache instance.
|
void |
setScavengeInterval(long sec)
Set the interval between runs of the scavenger.
|
void |
setStaleIntervalSec(long staleIntervalSec) |
protected void |
shutdownSessions()
The session manager is stopping.
|
access, addEventListener, addSession, clearEventListeners, complete, doSessionAttributeListeners, getClusterId, getContext, getContextHandler, getDefaultSessionTrackingModes, getEffectiveSessionTrackingModes, getHttpOnly, getHttpSession, getMaxCookieAge, getMaxInactiveInterval, getMetaManager, getNodeId, getRefreshCookieAge, getSecureCookies, getSessionCookie, getSessionCookie, getSessionCookieConfig, getSessionDomain, getSessionHandler, getSessionIdManager, getSessionIdPathParameterName, getSessionIdPathParameterNamePrefix, getSessionPath, getSessions, getSessionsMax, getSessionsTotal, getSessionTimeMax, getSessionTimeMean, getSessionTimeStdDev, getSessionTimeTotal, isCheckingRemoteSessionIdEncoding, isNodeIdInSessionId, isSecureRequestOnly, isUsingCookies, isUsingURLs, isValid, newHttpSession, removeEventListener, removeSession, removeSession, setCheckingRemoteSessionIdEncoding, setHttpOnly, setMaxInactiveInterval, setNodeIdInSessionId, setRefreshCookieAge, setSecureRequestOnly, setSessionCookie, setSessionHandler, setSessionIdManager, setSessionIdPathParameterName, setSessionTrackingModes, setUsingCookies, statsResetaddBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopprotected Scheduler.Task _task
protected Scheduler _scheduler
protected InfinispanSessionManager.Scavenger _scavenger
protected long _scavengeIntervalMs
protected boolean _ownScheduler
public void doStart()
throws Exception
doStart in class AbstractSessionManagerExceptionAbstractSessionManager.doStart()public void doStop()
throws Exception
doStop in class AbstractSessionManagerExceptionAbstractSessionManager.doStop()public void scavenge()
public long getScavengeInterval()
public void setScavengeInterval(long sec)
sec - scavenge interval in secondspublic org.infinispan.commons.api.BasicCache<String,Object> getCache()
public void setCache(org.infinispan.commons.api.BasicCache<String,Object> cache)
cache - the cachepublic long getStaleIntervalSec()
public void setStaleIntervalSec(long staleIntervalSec)
protected void addSession(AbstractSession session)
addSession in class AbstractSessionManagerAbstractSessionManager.addSession(org.eclipse.jetty.server.session.AbstractSession)public AbstractSession getSession(String idInCluster)
getSession in class AbstractSessionManageridInCluster - The session ID in the cluster, stripped of any worker name.AbstractSessionManager.getSession(java.lang.String)protected void shutdownSessions()
throws Exception
shutdownSessions in class AbstractSessionManagerException - if unable to shutdown sesssionsAbstractSessionManager.shutdownSessions()protected AbstractSession newSession(javax.servlet.http.HttpServletRequest request)
AbstractSessionManagernewSession in class AbstractSessionManagerrequest - the request to build the session fromprotected boolean removeSession(String idInCluster)
removeSession in class AbstractSessionManagerAbstractSessionManager.removeSession(java.lang.String)public void renewSessionId(String oldClusterId, String oldNodeId, String newClusterId, String newNodeId)
AbstractSessionManagerrenewSessionId in interface SessionManagerrenewSessionId in class AbstractSessionManageroldClusterId - the old cluster idoldNodeId - the old node idnewClusterId - the new cluster idnewNodeId - the new node idSessionManager.renewSessionId(java.lang.String, java.lang.String, java.lang.String, java.lang.String)protected InfinispanSessionManager.Session load(String key)
key - the session keyprotected void save(InfinispanSessionManager.Session session) throws Exception
session - the sessionException - if unable to saveprotected void delete(InfinispanSessionManager.Session session)
session - the sessionpublic void invalidateSession(String idInCluster)
idInCluster - session id in clusterCopyright © 1995–2016 Mort Bay Consulting. All rights reserved.