public class DistributableSessionManager<O extends OutgoingDistributableSessionData> extends AbstractSessionManager implements LocalDistributableSessionManager, ClusteredSessionManager<O>, DistributableSessionManagerMBean, org.apache.catalina.LifecycleListener
averageAliveTime, createdCounter, duplicates, expiredCounter, lifecycle, localActiveCounter, maxActiveAllowed, maxActiveCounter, maxAliveTime, maxLocalActiveCounter, processingTime, rejectedCounter, started, timeSinceLastReset
container, distributable, domain, expiredSessions, initialized, log, maxActive, maxInactiveInterval, mserver, oname, processExpiresFrequency, sessionAverageAliveTime, sessionCounter, sessionIdLength, sessionMaxAliveTime, sessions, sm, support
Constructor and Description |
---|
DistributableSessionManager(DistributedCacheManagerFactory factory,
org.apache.catalina.Context context,
org.jboss.metadata.web.jboss.JBossWebMetaData metaData,
org.jboss.marshalling.ClassResolver resolver) |
Modifier and Type | Method and Description |
---|---|
void |
add(org.apache.catalina.Session session) |
protected boolean |
appendJVMRoute() |
protected ClusteredSessionNotificationPolicy |
createClusteredSessionNotificationPolicy() |
ClusteredSession<O> |
createEmptySession() |
org.apache.catalina.Session |
createSession(String sessionId,
Random random) |
String |
createSessionId(String realId,
String jvmRoute) |
protected SnapshotManager |
createSnapshotManager() |
ClusteredSession<O> |
findSession(String id) |
org.apache.catalina.Session[] |
findSessions() |
org.jboss.marshalling.ClassResolver |
getApplicationClassResolver()
Get the classloader able to load application classes.
|
String |
getCacheConfigName()
Gets the cache config name used to get the underlying cache from a cache manager.
|
String |
getContextName() |
DistributedCacheManager<O> |
getDistributedCacheManager()
Gets the
DistributedCacheManager through which we interact with the distributed cache. |
String |
getEngineName()
Returns the name of the session manager's engine.
|
String |
getHostName() |
String |
getInfo() |
long |
getMaxPassivatedSessionCount()
Gets the highest number of passivated sessions seen.
|
int |
getMaxUnreplicatedInterval()
Get the maximum interval between requests, in seconds, after which a request will trigger replication of the session's
metadata regardless of whether the request has otherwise made the session dirty.
|
String |
getName()
Returns the unique name of this session manager.
|
ClusteredSessionNotificationPolicy |
getNotificationPolicy()
Gets the policy for determining whether the servlet spec notifications related to session events are allowed to be
emitted on the local cluster node.
|
long |
getPassivatedSessionCount()
Gets the number of passivated sessions
|
long |
getPassivationMaxIdleTime()
Elapsed time after which an inactive session will be passivated to persistent storage if
passivation is enabled . |
long |
getPassivationMinIdleTime()
Elapsed time after which an inactive session will be passivated to persistent storage if
passivation is enabled and the manager needs to passivate sessions early in order to comply with a
SessionManagerMBean.getMaxActiveAllowed() setting. |
org.jboss.metadata.web.jboss.ReplicationConfig |
getReplicationConfig()
Gets the web application metadata.
|
org.jboss.metadata.web.jboss.ReplicationGranularity |
getReplicationGranularity()
Gets the replication granularity.
|
org.jboss.metadata.web.jboss.ReplicationTrigger |
getReplicationTrigger()
Gets the policy controlling whether session attribute reads and writes mark the session/attribute as needing replication.
|
int |
getSnapshotInterval()
Gets the number of milliseconds between replications if "interval" mode is used.
|
org.jboss.metadata.web.jboss.SnapshotMode |
getSnapshotMode()
Gets the snapshot mode.
|
protected int |
getTotalActiveSessions()
Get the total number of active sessions
|
boolean |
getUseJK()
Gets whether JK is being used and special handling of a jvmRoute portion of session ids is needed.
|
protected void |
initializeUnloadedSessions()
Gets the ids of all sessions in the distributed cache and adds them to the unloaded sessions map, along with their
lastAccessedTime and their maxInactiveInterval.
|
protected void |
installValves()
Instantiate a SnapshotManager and ClusteredSessionValve and add the valve to our parent Context's pipeline.
|
boolean |
isPassivationEnabled()
Gets whether the webapp is configured for passivation.
|
void |
lifecycleEvent(org.apache.catalina.LifecycleEvent event) |
String |
listLocalSessionIds()
Lists all session ids known to this manager, excluding those in the distributed store that have not been accessed on this
node.
|
String |
locate(String sessionId)
Locate the most appropriate jvm route for the specified sessionId
|
void |
notifyLocalAttributeModification(String realId)
Callback from the distributed cache notifying of a local modification to a session's attributes.
|
void |
notifyRemoteInvalidation(String realId)
Notifies the manager that a session in the distributed cache has been invalidated
|
Map.Entry<String,String> |
parse(String sessionId) |
protected void |
processExpirationPassivation() |
void |
remove(org.apache.catalina.Session s) |
void |
removeLocal(org.apache.catalina.Session s)
Remove the active session locally from the manager without replicating to the cluster.
|
void |
sessionActivated()
Notification that a previously passivated session has been activated.
|
boolean |
sessionChangedInDistributedCache(String realId,
String dataOwner,
int distributedVersion,
long timestamp,
DistributableSessionMetadata metadata)
Callback from the distributed cache to notify us that a session has been modified remotely.
|
void |
setMaxUnreplicatedInterval(int maxUnreplicatedInterval)
Sets the maximum interval between requests, in seconds, after which a request will trigger replication of the session's
metadata regardless of whether the request has otherwise made the session dirty.
|
void |
start() |
void |
stop() |
boolean |
storeSession(org.apache.catalina.Session s)
Store the modified session.
|
addLifecycleListener, calcActiveSessions, findLifecycleListeners, getActiveSessionCount, getCreatedSessionCount, getExpiredSessionCount, getLocalActiveSessionCount, getMaxActiveAllowed, getMaxActiveSessionCount, getMaxActiveSessions, getMaxLocalActiveSessionCount, getRejectedSessionCount, getRejectedSessions, getReplicationStatistics, getTimeSinceLastReset, load, processExpires, removeLifecycleListener, resetStats, sessionExpired, setMaxActiveAllowed, setNewSessionCookie, setRejectedSessions, unload
addPropertyChangeListener, backgroundProcess, changeSessionId, destroy, encode, expireSession, generateSessionId, getActiveSessions, getClassName, getContainer, getCreationTime, getDistributable, getDomain, getDuplicates, getEngine, getExpiredSessions, getJvmRoute, getLastAccessedTime, getMaxActive, getMaxInactiveInterval, getNewSession, getObjectName, getProcessExpiresFrequency, getProcessingTime, getSession, getSessionAttribute, getSessionAverageAliveTime, getSessionCounter, getSessionIdLength, getSessionMaxAliveTime, init, listSessionIds, postDeregister, postRegister, preDeregister, preRegister, removePropertyChangeListener, setContainer, setDistributable, setDuplicates, setExpiredSessions, setMaxActive, setMaxInactiveInterval, setProcessExpiresFrequency, setProcessingTime, setSessionAverageAliveTime, setSessionCounter, setSessionIdLength, setSessionMaxAliveTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getJvmRoute
getJvmRoute, setNewSessionCookie
addPropertyChangeListener, backgroundProcess, changeSessionId, getActiveSessions, getContainer, getDistributable, getExpiredSessions, getMaxActive, getMaxInactiveInterval, getRejectedSessions, getSessionAverageAliveTime, getSessionCounter, getSessionIdLength, getSessionMaxAliveTime, load, removePropertyChangeListener, setContainer, setDistributable, setExpiredSessions, setMaxActive, setMaxInactiveInterval, setRejectedSessions, setSessionAverageAliveTime, setSessionCounter, setSessionIdLength, setSessionMaxAliveTime, unload
expireSession, getCreationTime, getDuplicates, getLastAccessedTime, getSessionAttribute, listSessionIds, setDuplicates
getActiveSessionCount, getActiveSessions, getClassName, getCreatedSessionCount, getDistributable, getExpiredSessionCount, getExpiredSessions, getLocalActiveSessionCount, getMaxActive, getMaxActiveAllowed, getMaxActiveSessionCount, getMaxActiveSessions, getMaxInactiveInterval, getMaxLocalActiveSessionCount, getProcessExpiresFrequency, getProcessingTime, getRejectedSessionCount, getRejectedSessions, getReplicationStatistics, getSessionAverageAliveTime, getSessionCounter, getSessionIdLength, getSessionMaxAliveTime, getTimeSinceLastReset, resetStats, setDistributable, setMaxActive, setMaxActiveAllowed, setMaxInactiveInterval, setProcessExpiresFrequency, setProcessingTime, setSessionCounter, setSessionMaxAliveTime
public DistributableSessionManager(DistributedCacheManagerFactory factory, org.apache.catalina.Context context, org.jboss.metadata.web.jboss.JBossWebMetaData metaData, org.jboss.marshalling.ClassResolver resolver) throws ClusteringNotSupportedException
ClusteringNotSupportedException
public String getHostName()
getHostName
in interface LocalDistributableSessionManager
public String getContextName()
getContextName
in interface LocalDistributableSessionManager
public String getName()
LocalDistributableSessionManager
getName
in interface LocalDistributableSessionManager
getName
in interface SessionManagerMBean
getName
in class org.apache.catalina.session.ManagerBase
public void start() throws org.apache.catalina.LifecycleException
start
in interface org.apache.catalina.Lifecycle
start
in class AbstractSessionManager
org.apache.catalina.LifecycleException
protected void installValves()
protected SnapshotManager createSnapshotManager()
protected void initializeUnloadedSessions()
protected ClusteredSessionNotificationPolicy createClusteredSessionNotificationPolicy()
public void stop() throws org.apache.catalina.LifecycleException
stop
in interface org.apache.catalina.Lifecycle
stop
in class AbstractSessionManager
org.apache.catalina.LifecycleException
public org.apache.catalina.Session createSession(String sessionId, Random random)
createSession
in interface org.apache.catalina.Manager
createSession
in class org.apache.catalina.session.ManagerBase
protected boolean appendJVMRoute()
appendJVMRoute
in class org.apache.catalina.session.ManagerBase
public ClusteredSession<O> createEmptySession()
createEmptySession
in interface org.apache.catalina.Manager
createEmptySession
in class org.apache.catalina.session.ManagerBase
public ClusteredSession<O> findSession(String id)
findSession
in interface org.apache.catalina.Manager
findSession
in class org.apache.catalina.session.ManagerBase
public org.apache.catalina.Session[] findSessions()
findSessions
in interface org.apache.catalina.Manager
findSessions
in class org.apache.catalina.session.ManagerBase
public void remove(org.apache.catalina.Session s)
remove
in interface org.apache.catalina.Manager
remove
in class org.apache.catalina.session.ManagerBase
public void lifecycleEvent(org.apache.catalina.LifecycleEvent event)
lifecycleEvent
in interface org.apache.catalina.LifecycleListener
public String locate(String sessionId)
SessionManager
locate
in interface SessionManager
sessionId
- a session identifierpublic void removeLocal(org.apache.catalina.Session s)
SessionManager
removeLocal
in interface SessionManager
public boolean storeSession(org.apache.catalina.Session s)
SessionManager
storeSession
in interface SessionManager
public String getInfo()
getInfo
in interface org.apache.catalina.Manager
getInfo
in class org.apache.catalina.session.ManagerBase
public void add(org.apache.catalina.Session session)
add
in interface org.apache.catalina.Manager
add
in class org.apache.catalina.session.ManagerBase
public String getCacheConfigName()
DistributableSessionManagerMBean
getCacheConfigName
in interface DistributableSessionManagerMBean
null
if this has not yet been configured or the cache was directly injected.public org.jboss.metadata.web.jboss.ReplicationGranularity getReplicationGranularity()
DistributableSessionManagerMBean
getReplicationGranularity
in interface DistributableSessionManagerMBean
null
if this has not yet been configured.public org.jboss.metadata.web.jboss.SnapshotMode getSnapshotMode()
DistributableSessionManagerMBean
getSnapshotMode
in interface DistributableSessionManagerMBean
public int getSnapshotInterval()
DistributableSessionManagerMBean
getSnapshotInterval
in interface DistributableSessionManagerMBean
public void setMaxUnreplicatedInterval(int maxUnreplicatedInterval)
DistributableSessionManagerMBean
setMaxUnreplicatedInterval
in interface DistributableSessionManagerMBean
maxUnreplicatedInterval
- the maximum interval since last replication after which a request will trigger session
metadata replication. A value of 0
means replicate metadata on every request; a value of
-1
means never replicate metadata unless the session is otherwise dirty.public String listLocalSessionIds()
DistributableSessionManagerMBean
listLocalSessionIds
in interface DistributableSessionManagerMBean
public long getPassivatedSessionCount()
DistributableSessionManagerMBean
getPassivatedSessionCount
in interface DistributableSessionManagerMBean
public long getMaxPassivatedSessionCount()
DistributableSessionManagerMBean
getMaxPassivatedSessionCount
in interface DistributableSessionManagerMBean
public long getPassivationMaxIdleTime()
DistributableSessionManagerMBean
passivation is enabled
.getPassivationMaxIdleTime
in interface DistributableSessionManagerMBean
public long getPassivationMinIdleTime()
DistributableSessionManagerMBean
passivation is enabled
and the manager needs to passivate sessions early in order to comply with a
SessionManagerMBean.getMaxActiveAllowed()
setting.getPassivationMinIdleTime
in interface DistributableSessionManagerMBean
public int getMaxUnreplicatedInterval()
ClusteredSessionManager
-1
.
The cost of the metadata replication depends on the configured replication granularity
. With SESSION
, the sesssion's attribute map is replicated along with the metadata,
so it can be fairly costly. With other granularities, the metadata object is replicated separately from the attributes
and only contains a String, and a few longs, ints and booleans.getMaxUnreplicatedInterval
in interface ClusteredSessionManager<O extends OutgoingDistributableSessionData>
getMaxUnreplicatedInterval
in interface DistributableSessionManagerMBean
0
means replicate metadata on every request; a value of -1
means never
replicate metadata unless the session is otherwise dirty.public ClusteredSessionNotificationPolicy getNotificationPolicy()
ClusteredSessionManager
getNotificationPolicy
in interface ClusteredSessionManager<O extends OutgoingDistributableSessionData>
public org.jboss.metadata.web.jboss.ReplicationTrigger getReplicationTrigger()
ClusteredSessionManager
getReplicationTrigger
in interface ClusteredSessionManager<O extends OutgoingDistributableSessionData>
getReplicationTrigger
in interface DistributableSessionManagerMBean
null
if this has not yet been configured.public boolean getUseJK()
DistributableSessionManagerMBean
getUseJK
in interface DistributableSessionManagerMBean
public DistributedCacheManager<O> getDistributedCacheManager()
ClusteredSessionManager
DistributedCacheManager
through which we interact with the distributed cache.getDistributedCacheManager
in interface ClusteredSessionManager<O extends OutgoingDistributableSessionData>
public boolean isPassivationEnabled()
LocalDistributableSessionManager
isPassivationEnabled
in interface LocalDistributableSessionManager
isPassivationEnabled
in interface DistributableSessionManagerMBean
true
if passivation is enabledpublic String getEngineName()
LocalDistributableSessionManager
getEngineName
in interface LocalDistributableSessionManager
public org.jboss.marshalling.ClassResolver getApplicationClassResolver()
LocalDistributableSessionManager
getApplicationClassResolver
in interface LocalDistributableSessionManager
null
public org.jboss.metadata.web.jboss.ReplicationConfig getReplicationConfig()
LocalDistributableSessionManager
getReplicationConfig
in interface LocalDistributableSessionManager
null
public void notifyRemoteInvalidation(String realId)
LocalDistributableSessionManager
notifyRemoteInvalidation
in interface LocalDistributableSessionManager
realId
- the session id excluding any jvmRoutepublic void notifyLocalAttributeModification(String realId)
LocalDistributableSessionManager
notifyLocalAttributeModification
in interface LocalDistributableSessionManager
realId
- the session id excluding any jvmRoutepublic void sessionActivated()
LocalDistributableSessionManager
sessionActivated
in interface LocalDistributableSessionManager
public boolean sessionChangedInDistributedCache(String realId, String dataOwner, int distributedVersion, long timestamp, DistributableSessionMetadata metadata)
LocalDistributableSessionManager
sessionChangedInDistributedCache
in interface LocalDistributableSessionManager
realId
- the session id, without any trailing jvmRoutedataOwner
- the owner of the session. Can be null
if the owner is unknown.distributedVersion
- the session's version per the distributed cachetimestamp
- the session's timestamp per the distributed cachemetadata
- the session's metadata per the distributed cacheprotected void processExpirationPassivation()
processExpirationPassivation
in class AbstractSessionManager
public Map.Entry<String,String> parse(String sessionId)
parse
in interface SessionManager
parse
in class AbstractSessionManager
public String createSessionId(String realId, String jvmRoute)
createSessionId
in interface SessionManager
createSessionId
in class AbstractSessionManager
protected int getTotalActiveSessions()
AbstractSessionManager
getTotalActiveSessions
in class AbstractSessionManager
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.