Package org.apache.catalina.ha.session
Class DeltaManager
- java.lang.Object
-
- org.apache.catalina.util.LifecycleBase
-
- org.apache.catalina.util.LifecycleMBeanBase
-
- org.apache.catalina.session.ManagerBase
-
- org.apache.catalina.ha.session.ClusterManagerBase
-
- org.apache.catalina.ha.session.DeltaManager
-
- All Implemented Interfaces:
javax.management.MBeanRegistration,ClusterManager,JmxEnabled,Lifecycle,Manager
public class DeltaManager extends ClusterManagerBase
The DeltaManager manages replicated sessions by only replicating the deltas in data. For applications written to handle this, the DeltaManager is the optimal way of replicating data.This code is almost identical to StandardManager with a difference in how it persists sessions and some modifications to it.
IMPLEMENTATION NOTE : Correct behavior of session storing and reloading depends upon external calls to the
start()andstop()methods of this class at the correct times.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.catalina.session.ManagerBase
ManagerBase.SessionTiming
-
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse
-
-
Field Summary
Fields Modifier and Type Field Description LoglogThe log instance for this class.protected java.lang.StringnameThe name of this manager.protected static StringManagersmThe string manager for this package.-
Fields inherited from class org.apache.catalina.ha.session.ClusterManagerBase
cluster
-
Fields inherited from class org.apache.catalina.session.ManagerBase
duplicates, expiredSessions, maxActive, maxActiveSessions, processExpiresFrequency, processingTime, rejectedSessions, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, sessionCounter, sessionCreationTiming, sessionExpirationTiming, sessionIdGenerator, sessionIdGeneratorClass, sessionMaxAliveTime, sessions, support, TIMING_STATS_CACHE_SIZE
-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_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 Summary
Constructors Constructor Description DeltaManager()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeSessionId(Session session, java.lang.String newId)Change the session ID of the current session to a specified session ID.protected voidchangeSessionId(Session session, java.lang.String newId, boolean notify)Change the session ID and optionally notify cluster members.ClusterManagercloneFromTemplate()Creates a clone of this manager from a template configuration.SessioncreateEmptySession()Get a session from the recycled ones or create a new empty one.SessioncreateSession(java.lang.String sessionId)Construct and return a new session object, based on the default settings specified by this Manager's properties.SessioncreateSession(java.lang.String sessionId, boolean distribute)Create new session with check maxActiveSessions and send session creation to other cluster nodes.protected java.lang.StringdeserializeSessionId(byte[] data)Load sessionIDprotected voiddeserializeSessions(byte[] data)Load sessions from other cluster node.voidexpireAllLocalSessions()Expire all find sessions.protected MemberfindSessionMasterMember()Find the master of the session statevoidgetAllClusterSessions()get from first session master the backup from all clustered sessionsintgetCounterNoStateTransferred()Get the counter for sessions where no state was transferred.longgetCounterReceive_EVT_ALL_SESSION_DATA()Get the receive counter for EVT_ALL_SESSION_DATA events.longgetCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER()Get the receive counter for EVT_ALL_SESSION_NOCONTEXTMANAGER events.intgetCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE()Get the receive counter for EVT_ALL_SESSION_TRANSFERCOMPLETE events.longgetCounterReceive_EVT_CHANGE_SESSION_ID()Get the receive counter for EVT_CHANGE_SESSION_ID events.longgetCounterReceive_EVT_GET_ALL_SESSIONS()Get the receive counter for EVT_GET_ALL_SESSIONS events.longgetCounterReceive_EVT_SESSION_ACCESSED()Get the receive counter for EVT_SESSION_ACCESSED events.longgetCounterReceive_EVT_SESSION_CREATED()Get the receive counter for EVT_SESSION_CREATED events.longgetCounterReceive_EVT_SESSION_DELTA()Get the receive counter for EVT_SESSION_DELTA events.longgetCounterReceive_EVT_SESSION_EXPIRED()Get the receive counter for EVT_SESSION_EXPIRED events.longgetCounterSend_EVT_ALL_SESSION_DATA()Get the send counter for EVT_ALL_SESSION_DATA events.intgetCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE()Get the send counter for EVT_ALL_SESSION_TRANSFERCOMPLETE events.longgetCounterSend_EVT_CHANGE_SESSION_ID()Get the send counter for EVT_CHANGE_SESSION_ID events.longgetCounterSend_EVT_GET_ALL_SESSIONS()Get the send counter for EVT_GET_ALL_SESSIONS events.longgetCounterSend_EVT_SESSION_ACCESSED()Get the send counter for EVT_SESSION_ACCESSED events.longgetCounterSend_EVT_SESSION_CREATED()Get the send counter for EVT_SESSION_CREATED events.longgetCounterSend_EVT_SESSION_DELTA()Get the send counter for EVT_SESSION_DELTA events.longgetCounterSend_EVT_SESSION_EXPIRED()Get the send counter for EVT_SESSION_EXPIRED events.booleangetEnableStatistics()Check if statistics collection is enabled.java.lang.String[]getInvalidatedSessions()When the manager expires session not tied to a request.java.lang.StringgetName()Returns the descriptive short name of this Manager implementation.intgetReceivedQueueSize()Get the current size of the received message queue.intgetSendAllSessionsSize()Get the batch size for sending all sessions.intgetSendAllSessionsWaitTime()Get the wait time for sending all sessions.longgetSessionReplaceCounter()Get the session replace counter.booleangetStateTransferred()Check if the state transfer is complete.intgetStateTransferTimeout()Get the state transfer timeout value.protected voidhandleALL_SESSION_DATA(SessionMessage msg, Member sender)handle receive sessions from other not ( restart )protected voidhandleALL_SESSION_NOCONTEXTMANAGER(SessionMessage msg, Member sender)handle receive no context manager.protected voidhandleALL_SESSION_TRANSFERCOMPLETE(SessionMessage msg, Member sender)handle receive session state is complete transferredprotected voidhandleCHANGE_SESSION_ID(SessionMessage msg, Member sender)handle receive change sessionID at other nodeprotected voidhandleGET_ALL_SESSIONS(SessionMessage msg, Member sender)Handle a get all sessions message from another node.protected voidhandleSESSION_ACCESSED(SessionMessage msg, Member sender)handle receive session is access at other node ( primary session is now false)protected voidhandleSESSION_CREATED(SessionMessage msg, Member sender)handle receive new session is created at other node (create backup - primary false)protected voidhandleSESSION_DELTA(SessionMessage msg, Member sender)handle receive session deltaprotected voidhandleSESSION_EXPIRED(SessionMessage msg, Member sender)handle receive session is expired at other node ( expire session also here)booleanisExpireSessionsOnShutdown()Check if sessions should be expired on shutdown.booleanisNoContextManagerReceived()Check if a no-context-manager signal has been received.booleanisNotifyContainerListenersOnReplication()Check if container listeners are notified on replication.booleanisNotifySessionListenersOnReplication()Check if session listeners are notified on replication.booleanisSendAllSessions()Check if sending all sessions is enabled.booleanisStateTimestampDrop()Check if state timestamp drop is enabled.voidmessageDataReceived(ClusterMessage cmsg)A message was received from another node, this is the callback method to implement if you are interested in receiving replication messages.protected voidmessageReceived(SessionMessage msg, Member sender)This method is called by the received thread when a SessionMessage has been received from one of the other nodes in the cluster.ClusterMessagerequestCompleted(java.lang.String sessionId)When the request has been completed, the replication valve will notify the manager, and the manager will decide whether any replication is needed or not.ClusterMessagerequestCompleted(java.lang.String sessionId, boolean expires)When the request has been completed, the replication valve will notify the manager, and the manager will decide whether any replication is needed or not.voidresetStatistics()Reset manager statisticsjava.lang.StringrotateSessionId(Session session)Change the session ID of the current session to a new randomly generated session ID.protected java.lang.StringrotateSessionId(Session session, boolean notify)Rotate the session ID and optionally notify cluster members.protected voidsend(SessionMessage msg)Send messages to other backup member (domain or all)protected voidsendChangeSessionId(java.lang.String newSessionID, java.lang.String orgSessionID)Send a session ID change notification to cluster members.protected voidsendCreateSession(java.lang.String sessionId, DeltaSession session)Send create session event to all backup nodeprotected voidsendSessions(Member sender, Session[] currentSessions, long sendTimestamp)send a block of session to senderprotected byte[]serializeSessionId(java.lang.String sessionId)serialize sessionIDprotected byte[]serializeSessions(Session[] currentSessions)Save any currently active sessions in the appropriate persistence mechanism, if any.protected voidsessionExpired(java.lang.String id)send session expired to other cluster nodesvoidsetEnableStatistics(boolean enableStatistics)Set whether statistics collection is enabled.voidsetExpireSessionsOnShutdown(boolean expireSessionsOnShutdown)Set whether to expire sessions on shutdown.voidsetName(java.lang.String name)Set the name of the manager, at host /context name and at engine hostname+/contextvoidsetNoContextManagerReceived(boolean noContextManagerReceived)Set whether a no-context-manager signal has been received.voidsetNotifyContainerListenersOnReplication(boolean notifyContainerListenersOnReplication)Set whether to notify container listeners on replication.voidsetNotifySessionListenersOnReplication(boolean notifyListenersCreateSessionOnReplication)Set whether to notify session listeners on replication.voidsetSendAllSessions(boolean sendAllSessions)Set whether to send all sessions during replication.voidsetSendAllSessionsSize(int sendAllSessionsSize)Set the batch size for sending all sessions.voidsetSendAllSessionsWaitTime(int sendAllSessionsWaitTime)Set the wait time for sending all sessions.voidsetStateTimestampDrop(boolean isTimestampDrop)Set the state timestamp drop flag.voidsetStateTransferred(boolean stateTransferred)Set that state transferred is completevoidsetStateTransferTimeout(int timeoutAllSession)Set the state transfer timeout.protected voidstartInternal()Start this component and implement the requirements ofLifecycleBase.startInternal().protected voidstopInternal()Stop this component and implement the requirements ofLifecycleBase.stopInternal().protected voidwaitForSendAllSessions(long beforeSendTime)Wait that cluster session state is transferred or timeout after 60 Sec With stateTransferTimeout == -1 wait that backup is transferred (forever mode)-
Methods inherited from class org.apache.catalina.ha.session.ClusterManagerBase
clone, getClassLoaders, getClassLoaders, getCluster, getDeltaRequestPool, getReplicationStream, getReplicationStream, isNotifyListenersOnReplication, isRecordAllActions, load, registerSessionAtReplicationValve, setCluster, setNotifyListenersOnReplication, setRecordAllActions, unload
-
Methods inherited from class org.apache.catalina.session.ManagerBase
add, addPropertyChangeListener, backgroundProcess, changeSessionId, expireSession, findSession, findSessions, generateSessionId, getActiveSessions, getClassName, getContext, getCreationTime, getCreationTimestamp, getDomainInternal, getDuplicates, getEngine, getExpiredSessions, getJvmRoute, getLastAccessedTime, getLastAccessedTimestamp, getMaxActive, getMaxActiveSessions, getNewSession, getNotifyAttributeListenerOnUnchangedValue, getNotifyBindingListenerOnUnchangedValue, getObjectNameKeyProperties, getPersistAuthentication, getProcessExpiresFrequency, getProcessingTime, getRejectedSessions, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, getSession, getSessionActivityCheck, getSessionAttribute, getSessionAttributeNameFilter, getSessionAttributeNamePattern, getSessionAttributeValueClassNameFilter, getSessionAttributeValueClassNamePattern, getSessionAverageAliveTime, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionLastAccessAtStart, getSessionMaxAliveTime, getThisAccessedTime, getThisAccessedTimestamp, getWarnOnSessionAttributeFilterFailure, initInternal, listSessionIds, processExpires, remove, remove, removePropertyChangeListener, setContext, setDuplicates, setExpiredSessions, setMaxActive, setMaxActiveSessions, setNotifyAttributeListenerOnUnchangedValue, setNotifyBindingListenerOnUnchangedValue, setPersistAuthentication, setProcessExpiresFrequency, setProcessingTime, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSessionActivityCheck, setSessionAttributeNameFilter, setSessionAttributeValueClassNameFilter, setSessionCounter, setSessionIdGenerator, setSessionLastAccessAtStart, setSessionMaxAliveTime, setWarnOnSessionAttributeFilterFailure, toString, updateSessionMaxAliveTime, willAttributeDistribute
-
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
-
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.catalina.Manager
add, addPropertyChangeListener, backgroundProcess, findSession, findSessions, getActiveSessions, getContext, getExpiredSessions, getMaxActive, getNotifyAttributeListenerOnUnchangedValue, getNotifyBindingListenerOnUnchangedValue, getRejectedSessions, getSessionActivityCheck, getSessionAverageAliveTime, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionLastAccessAtStart, getSessionMaxAliveTime, remove, remove, removePropertyChangeListener, setContext, setExpiredSessions, setMaxActive, setNotifyAttributeListenerOnUnchangedValue, setNotifyBindingListenerOnUnchangedValue, setSessionActivityCheck, setSessionCounter, setSessionIdGenerator, setSessionLastAccessAtStart, setSessionMaxAliveTime, willAttributeDistribute
-
-
-
-
Field Detail
-
log
public final Log log
The log instance for this class.
-
sm
protected static final StringManager sm
The string manager for this package.
-
name
protected java.lang.String name
The name of this manager.
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
Description copied from interface:ClusterManagerSet the name of the manager, at host /context name and at engine hostname+/context- Parameters:
name- The manager name
-
getName
public java.lang.String getName()
Description copied from class:ManagerBaseReturns the descriptive short name of this Manager implementation.- Specified by:
getNamein interfaceClusterManager- Overrides:
getNamein classManagerBase- Returns:
- The descriptive short name of this Manager implementation.
-
getCounterSend_EVT_GET_ALL_SESSIONS
public long getCounterSend_EVT_GET_ALL_SESSIONS()
Get the send counter for EVT_GET_ALL_SESSIONS events.- Returns:
- the counterSend_EVT_GET_ALL_SESSIONS value.
-
getCounterSend_EVT_SESSION_ACCESSED
public long getCounterSend_EVT_SESSION_ACCESSED()
Get the send counter for EVT_SESSION_ACCESSED events.- Returns:
- the counterSend_EVT_SESSION_ACCESSED value.
-
getCounterSend_EVT_SESSION_CREATED
public long getCounterSend_EVT_SESSION_CREATED()
Get the send counter for EVT_SESSION_CREATED events.- Returns:
- the counterSend_EVT_SESSION_CREATED value.
-
getCounterSend_EVT_SESSION_DELTA
public long getCounterSend_EVT_SESSION_DELTA()
Get the send counter for EVT_SESSION_DELTA events.- Returns:
- the counterSend_EVT_SESSION_DELTA value.
-
getCounterSend_EVT_SESSION_EXPIRED
public long getCounterSend_EVT_SESSION_EXPIRED()
Get the send counter for EVT_SESSION_EXPIRED events.- Returns:
- the counterSend_EVT_SESSION_EXPIRED value.
-
getCounterSend_EVT_ALL_SESSION_DATA
public long getCounterSend_EVT_ALL_SESSION_DATA()
Get the send counter for EVT_ALL_SESSION_DATA events.- Returns:
- the counterSend_EVT_ALL_SESSION_DATA value.
-
getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE
public int getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE()
Get the send counter for EVT_ALL_SESSION_TRANSFERCOMPLETE events.- Returns:
- the counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE value.
-
getCounterSend_EVT_CHANGE_SESSION_ID
public long getCounterSend_EVT_CHANGE_SESSION_ID()
Get the send counter for EVT_CHANGE_SESSION_ID events.- Returns:
- the counterSend_EVT_CHANGE_SESSION_ID value.
-
getCounterReceive_EVT_ALL_SESSION_DATA
public long getCounterReceive_EVT_ALL_SESSION_DATA()
Get the receive counter for EVT_ALL_SESSION_DATA events.- Returns:
- the counterReceive_EVT_ALL_SESSION_DATA value.
-
getCounterReceive_EVT_GET_ALL_SESSIONS
public long getCounterReceive_EVT_GET_ALL_SESSIONS()
Get the receive counter for EVT_GET_ALL_SESSIONS events.- Returns:
- the counterReceive_EVT_GET_ALL_SESSIONS value.
-
getCounterReceive_EVT_SESSION_ACCESSED
public long getCounterReceive_EVT_SESSION_ACCESSED()
Get the receive counter for EVT_SESSION_ACCESSED events.- Returns:
- the counterReceive_EVT_SESSION_ACCESSED value.
-
getCounterReceive_EVT_SESSION_CREATED
public long getCounterReceive_EVT_SESSION_CREATED()
Get the receive counter for EVT_SESSION_CREATED events.- Returns:
- the counterReceive_EVT_SESSION_CREATED value.
-
getCounterReceive_EVT_SESSION_DELTA
public long getCounterReceive_EVT_SESSION_DELTA()
Get the receive counter for EVT_SESSION_DELTA events.- Returns:
- the counterReceive_EVT_SESSION_DELTA value.
-
getCounterReceive_EVT_SESSION_EXPIRED
public long getCounterReceive_EVT_SESSION_EXPIRED()
Get the receive counter for EVT_SESSION_EXPIRED events.- Returns:
- the counterReceive_EVT_SESSION_EXPIRED value.
-
getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE
public int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE()
Get the receive counter for EVT_ALL_SESSION_TRANSFERCOMPLETE events.- Returns:
- the counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE value.
-
getCounterReceive_EVT_CHANGE_SESSION_ID
public long getCounterReceive_EVT_CHANGE_SESSION_ID()
Get the receive counter for EVT_CHANGE_SESSION_ID events.- Returns:
- the counterReceive_EVT_CHANGE_SESSION_ID value.
-
getCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER
public long getCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER()
Get the receive counter for EVT_ALL_SESSION_NOCONTEXTMANAGER events.- Returns:
- the counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER value.
-
getSessionReplaceCounter
public long getSessionReplaceCounter()
Get the session replace counter.- Returns:
- the sessionReplaceCounter value.
-
getCounterNoStateTransferred
public int getCounterNoStateTransferred()
Get the counter for sessions where no state was transferred.- Returns:
- the counterNoStateTransferred value.
-
getReceivedQueueSize
public int getReceivedQueueSize()
Get the current size of the received message queue.- Returns:
- the queue size
-
getStateTransferTimeout
public int getStateTransferTimeout()
Get the state transfer timeout value.- Returns:
- the stateTransferTimeout value.
-
setStateTransferTimeout
public void setStateTransferTimeout(int timeoutAllSession)
Set the state transfer timeout.- Parameters:
timeoutAllSession- The timeout value
-
getStateTransferred
public boolean getStateTransferred()
Check if the state transfer is complete.- Returns:
trueif the state transfer is complete.
-
setStateTransferred
public void setStateTransferred(boolean stateTransferred)
Set that state transferred is complete- Parameters:
stateTransferred- Flag value
-
isNoContextManagerReceived
public boolean isNoContextManagerReceived()
Check if a no-context-manager signal has been received.- Returns:
- true if no context manager received
-
setNoContextManagerReceived
public void setNoContextManagerReceived(boolean noContextManagerReceived)
Set whether a no-context-manager signal has been received.- Parameters:
noContextManagerReceived- The flag value
-
getSendAllSessionsWaitTime
public int getSendAllSessionsWaitTime()
Get the wait time for sending all sessions.- Returns:
- the sendAllSessionsWaitTime in milliseconds
-
setSendAllSessionsWaitTime
public void setSendAllSessionsWaitTime(int sendAllSessionsWaitTime)
Set the wait time for sending all sessions.- Parameters:
sendAllSessionsWaitTime- The wait time in milliseconds
-
isStateTimestampDrop
public boolean isStateTimestampDrop()
Check if state timestamp drop is enabled.- Returns:
- the stateTimestampDrop flag
-
setStateTimestampDrop
public void setStateTimestampDrop(boolean isTimestampDrop)
Set the state timestamp drop flag.- Parameters:
isTimestampDrop- The new flag value
-
isSendAllSessions
public boolean isSendAllSessions()
Check if sending all sessions is enabled.- Returns:
- the sendAllSessions flag
-
setSendAllSessions
public void setSendAllSessions(boolean sendAllSessions)
Set whether to send all sessions during replication.- Parameters:
sendAllSessions- The flag value
-
getSendAllSessionsSize
public int getSendAllSessionsSize()
Get the batch size for sending all sessions.- Returns:
- the sendAllSessionsSize value
-
setSendAllSessionsSize
public void setSendAllSessionsSize(int sendAllSessionsSize)
Set the batch size for sending all sessions.- Parameters:
sendAllSessionsSize- The batch size value
-
isNotifySessionListenersOnReplication
public boolean isNotifySessionListenersOnReplication()
Check if session listeners are notified on replication.- Returns:
- the notifySessionListenersOnReplication flag
-
setNotifySessionListenersOnReplication
public void setNotifySessionListenersOnReplication(boolean notifyListenersCreateSessionOnReplication)
Set whether to notify session listeners on replication.- Parameters:
notifyListenersCreateSessionOnReplication- The flag value
-
isExpireSessionsOnShutdown
public boolean isExpireSessionsOnShutdown()
Check if sessions should be expired on shutdown.- Returns:
- true if sessions are expired on shutdown
-
setExpireSessionsOnShutdown
public void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown)
Set whether to expire sessions on shutdown.- Parameters:
expireSessionsOnShutdown- The flag value
-
isNotifyContainerListenersOnReplication
public boolean isNotifyContainerListenersOnReplication()
Check if container listeners are notified on replication.- Returns:
- true if container listeners are notified on replication
-
setNotifyContainerListenersOnReplication
public void setNotifyContainerListenersOnReplication(boolean notifyContainerListenersOnReplication)
Set whether to notify container listeners on replication.- Parameters:
notifyContainerListenersOnReplication- The flag value
-
getEnableStatistics
public boolean getEnableStatistics()
Check if statistics collection is enabled.- Returns:
- the enableStatistics flag
-
setEnableStatistics
public void setEnableStatistics(boolean enableStatistics)
Set whether statistics collection is enabled.- Parameters:
enableStatistics- The flag value
-
createSession
public Session createSession(java.lang.String sessionId)
Description copied from interface:ManagerConstruct and return a new session object, based on the default settings specified by this Manager's properties. The session id specified will be used as the session id. If a new session cannot be created for any reason, returnnull.- Specified by:
createSessionin interfaceManager- Overrides:
createSessionin classManagerBase- Parameters:
sessionId- The session id which should be used to create the new session; ifnull, the session id will be assigned by this method, and available via the getId() method of the returned session.- Returns:
- An empty Session object with the given ID or a newly created session ID if none was specified
-
createSession
public Session createSession(java.lang.String sessionId, boolean distribute)
Create new session with check maxActiveSessions and send session creation to other cluster nodes.- Parameters:
sessionId- The session id that should be used for the sessiondistribute-trueto replicate the new session- Returns:
- The session
-
sendCreateSession
protected void sendCreateSession(java.lang.String sessionId, DeltaSession session)Send create session event to all backup node- Parameters:
sessionId- The session id of the sessionsession- The session object
-
send
protected void send(SessionMessage msg)
Send messages to other backup member (domain or all)- Parameters:
msg- Session message
-
createEmptySession
public Session createEmptySession()
Get a session from the recycled ones or create a new empty one. The PersistentManager manager does not need to create session data because it reads it from the Store.Creates new DeltaSession instance.
- Specified by:
createEmptySessionin interfaceManager- Overrides:
createEmptySessionin classManagerBase- Returns:
- An empty Session object
-
rotateSessionId
public java.lang.String rotateSessionId(Session session)
Description copied from interface:ManagerChange the session ID of the current session to a new randomly generated session ID.- Specified by:
rotateSessionIdin interfaceManager- Overrides:
rotateSessionIdin classManagerBase- Parameters:
session- The session to change the session ID for- Returns:
- The new session ID
-
changeSessionId
public void changeSessionId(Session session, java.lang.String newId)
Description copied from interface:ManagerChange the session ID of the current session to a specified session ID.- Specified by:
changeSessionIdin interfaceManager- Overrides:
changeSessionIdin classManagerBase- Parameters:
session- The session to change the session ID fornewId- new session ID
-
rotateSessionId
protected java.lang.String rotateSessionId(Session session, boolean notify)
Rotate the session ID and optionally notify cluster members.- Parameters:
session- The session whose ID should be rotatednotify- Whether to notify cluster members of the change- Returns:
- the new session ID
-
changeSessionId
protected void changeSessionId(Session session, java.lang.String newId, boolean notify)
Change the session ID and optionally notify cluster members.- Parameters:
session- The session whose ID should be changednewId- The new session IDnotify- Whether to notify cluster members of the change
-
sendChangeSessionId
protected void sendChangeSessionId(java.lang.String newSessionID, java.lang.String orgSessionID)Send a session ID change notification to cluster members.- Parameters:
newSessionID- The new session IDorgSessionID- The original session ID
-
serializeSessionId
protected byte[] serializeSessionId(java.lang.String sessionId) throws java.io.IOExceptionserialize sessionID- Parameters:
sessionId- Session id to serialize- Returns:
- byte array with serialized session id
- Throws:
java.io.IOException- if an input/output error occurs
-
deserializeSessionId
protected java.lang.String deserializeSessionId(byte[] data) throws java.io.IOExceptionLoad sessionID- Parameters:
data- serialized session id- Returns:
- session id
- Throws:
java.io.IOException- if an input/output error occurs
-
deserializeSessions
protected void deserializeSessions(byte[] data) throws java.lang.ClassNotFoundException, java.io.IOExceptionLoad sessions from other cluster node.FIXME replace currently sessions with same id without notification.
FIXME SSO handling is not really correct with the session replacement!
- Parameters:
data- Serialized data- Throws:
java.lang.ClassNotFoundException- if a serialized class cannot be found during the reloadjava.io.IOException- if an input/output error occurs
-
serializeSessions
protected byte[] serializeSessions(Session[] currentSessions) throws java.io.IOException
Save any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.- Parameters:
currentSessions- Sessions to serialize- Returns:
- serialized data
- Throws:
java.io.IOException- if an input/output error occurs
-
startInternal
protected void startInternal() throws LifecycleExceptionStart this component and implement the requirements ofLifecycleBase.startInternal().- Overrides:
startInternalin classClusterManagerBase- Throws:
LifecycleException- if this component detects a fatal error that prevents this component from being used
-
getAllClusterSessions
public void getAllClusterSessions()
get from first session master the backup from all clustered sessions- See Also:
findSessionMasterMember()
-
findSessionMasterMember
protected Member findSessionMasterMember()
Find the master of the session state- Returns:
- master member of sessions
-
waitForSendAllSessions
protected void waitForSendAllSessions(long beforeSendTime)
Wait that cluster session state is transferred or timeout after 60 Sec With stateTransferTimeout == -1 wait that backup is transferred (forever mode)- Parameters:
beforeSendTime- Start instant of the operation
-
stopInternal
protected void stopInternal() throws LifecycleExceptionStop this component and implement the requirements ofLifecycleBase.stopInternal().- Overrides:
stopInternalin classClusterManagerBase- Throws:
LifecycleException- if this component detects a fatal error that prevents this component from being used
-
messageDataReceived
public void messageDataReceived(ClusterMessage cmsg)
Description copied from interface:ClusterManagerA message was received from another node, this is the callback method to implement if you are interested in receiving replication messages.- Parameters:
cmsg- - the message received.
-
requestCompleted
public ClusterMessage requestCompleted(java.lang.String sessionId)
Description copied from interface:ClusterManagerWhen the request has been completed, the replication valve will notify the manager, and the manager will decide whether any replication is needed or not. If there is a need for replication, the manager will create a session message and that will be replicated. The cluster determines where it gets sent.- Parameters:
sessionId- - the sessionId that just completed.- Returns:
- a SessionMessage to be sent.
-
requestCompleted
public ClusterMessage requestCompleted(java.lang.String sessionId, boolean expires)
When the request has been completed, the replication valve will notify the manager, and the manager will decide whether any replication is needed or not. If there is a need for replication, the manager will create a session message and that will be replicated. The cluster determines where it gets sent. Session expiration also calls this method, but with expires == true.- Parameters:
sessionId- - the sessionId that just completed.expires- - whether this method has been called during session expiration- Returns:
- a SessionMessage to be sent,
-
resetStatistics
public void resetStatistics()
Reset manager statistics
-
sessionExpired
protected void sessionExpired(java.lang.String id)
send session expired to other cluster nodes- Parameters:
id- session id
-
expireAllLocalSessions
public void expireAllLocalSessions()
Expire all find sessions.
-
getInvalidatedSessions
public java.lang.String[] getInvalidatedSessions()
Description copied from interface:ClusterManagerWhen the manager expires session not tied to a request. The cluster will periodically ask for a list of sessions that should expire and that should be sent across the wire.- Returns:
- String[] The invalidated sessions
-
messageReceived
protected void messageReceived(SessionMessage msg, Member sender)
This method is called by the received thread when a SessionMessage has been received from one of the other nodes in the cluster.- Parameters:
msg- - the message receivedsender- - the sender of the message, this is used if we receive a EVT_GET_ALL_SESSION message, so that we only reply to the requesting node
-
handleALL_SESSION_TRANSFERCOMPLETE
protected void handleALL_SESSION_TRANSFERCOMPLETE(SessionMessage msg, Member sender)
handle receive session state is complete transferred- Parameters:
msg- Session messagesender- Member which sent the message
-
handleSESSION_DELTA
protected void handleSESSION_DELTA(SessionMessage msg, Member sender) throws java.io.IOException, java.lang.ClassNotFoundException
handle receive session delta- Parameters:
msg- Session messagesender- Member which sent the message- Throws:
java.io.IOException- IO error with serializationjava.lang.ClassNotFoundException- Serialization error
-
handleSESSION_ACCESSED
protected void handleSESSION_ACCESSED(SessionMessage msg, Member sender) throws java.io.IOException
handle receive session is access at other node ( primary session is now false)- Parameters:
msg- Session messagesender- Member which sent the message- Throws:
java.io.IOException- Propagated IO error
-
handleSESSION_EXPIRED
protected void handleSESSION_EXPIRED(SessionMessage msg, Member sender) throws java.io.IOException
handle receive session is expired at other node ( expire session also here)- Parameters:
msg- Session messagesender- Member which sent the message- Throws:
java.io.IOException- Propagated IO error
-
handleSESSION_CREATED
protected void handleSESSION_CREATED(SessionMessage msg, Member sender)
handle receive new session is created at other node (create backup - primary false)- Parameters:
msg- Session messagesender- Member which sent the message
-
handleALL_SESSION_DATA
protected void handleALL_SESSION_DATA(SessionMessage msg, Member sender) throws java.lang.ClassNotFoundException, java.io.IOException
handle receive sessions from other not ( restart )- Parameters:
msg- Session messagesender- Member which sent the message- Throws:
java.lang.ClassNotFoundException- Serialization errorjava.io.IOException- IO error with serialization
-
handleGET_ALL_SESSIONS
protected void handleGET_ALL_SESSIONS(SessionMessage msg, Member sender) throws java.io.IOException
Handle a get all sessions message from another node. Depending onsendAllSessions, sessions are either sent in a single message or in batches. Sending is complete when this method exits.- Parameters:
msg- Session messagesender- Member which sent the message- Throws:
java.io.IOException- IO error sending messages
-
handleCHANGE_SESSION_ID
protected void handleCHANGE_SESSION_ID(SessionMessage msg, Member sender) throws java.io.IOException
handle receive change sessionID at other node- Parameters:
msg- Session messagesender- Member which sent the message- Throws:
java.io.IOException- IO error with serialization
-
handleALL_SESSION_NOCONTEXTMANAGER
protected void handleALL_SESSION_NOCONTEXTMANAGER(SessionMessage msg, Member sender)
handle receive no context manager.- Parameters:
msg- Session messagesender- Member which sent the message
-
sendSessions
protected void sendSessions(Member sender, Session[] currentSessions, long sendTimestamp) throws java.io.IOException
send a block of session to sender- Parameters:
sender- Sender membercurrentSessions- Sessions to sendsendTimestamp- Timestamp- Throws:
java.io.IOException- IO error sending messages
-
cloneFromTemplate
public ClusterManager cloneFromTemplate()
Description copied from interface:ClusterManagerCreates a clone of this manager from a template configuration.- Returns:
- a clone of a template manager configuration
-
-