Apache Tomcat 6.0.53

org.apache.catalina.ha.session
Class DeltaManager

java.lang.Object
  extended by org.apache.catalina.session.ManagerBase
      extended by org.apache.catalina.ha.session.ClusterManagerBase
          extended by org.apache.catalina.ha.session.DeltaManager
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.management.MBeanRegistration, ClusterManager, 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() and stop() methods of this class at the correct times.

Author:
Filip Hanik, Craig R. McClanahan, Jean-Francois Arcand, Peter Rossbach

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.catalina.session.ManagerBase
ManagerBase.SessionTiming
 
Field Summary
protected  boolean defaultMode
           
protected  LifecycleSupport lifecycle
          The lifecycle event support for this component.
static Log log
           
protected static java.lang.String managerName
          The descriptive name of this Manager implementation (for logging).
protected  java.lang.String name
           
protected static StringManager sm
          The string manager for this package.
 
Fields inherited from class org.apache.catalina.session.ManagerBase
algorithm, container, DEFAULT_ALGORITHM, devRandomSource, digest, distributable, domain, duplicates, entropy, expiredSessions, initialized, maxActive, maxInactiveInterval, mserver, oname, processExpiresFrequency, random, randomClass, randomIS, sessionAverageAliveTime, sessionCounter, sessionCreationTiming, sessionExpirationTiming, sessionIdLength, sessionMaxAliveTime, sessions, support, TIMING_STATS_CACHE_SIZE
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Constructor Summary
DeltaManager()
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
          Add a lifecycle event listener to this component.
 void changeSessionId(Session session)
          Change the session ID of the current session to a new randomly generated session ID.
 void changeSessionId(Session session, boolean notify)
           
protected  boolean checkSenderDomain(SessionMessage msg, Member sender)
          Test that sender and local domain is the same
 ClusterManager cloneFromTemplate()
           
 Session createEmptySession()
          Create DeltaSession
 Session createSession(java.lang.String sessionId)
          Construct and return a new session object, based on the default settings specified by this Manager's properties.
 Session createSession(java.lang.String sessionId, boolean distribute)
          create new session with check maxActiveSessions and send session creation to other cluster nodes.
protected  DeltaRequest deserializeDeltaRequest(DeltaSession session, byte[] data)
          Load Deltarequest from external node Load the Class at container classloader
protected  java.lang.String deserializeSessionId(byte[] data)
          Load sessionID
protected  void deserializeSessions(byte[] data)
          Load sessions from other cluster node.
 boolean doDomainReplication()
           
 void expireAllLocalSessions()
          Expire all find sessions.
 LifecycleListener[] findLifecycleListeners()
          Get the lifecycle listeners associated with this lifecycle.
protected  Member findSessionMasterMember()
          Find the master of the session state
 void getAllClusterSessions()
          get from first session master the backup from all clustered sessions
 CatalinaCluster getCluster()
           
 int getCounterNoStateTransfered()
           
 long getCounterReceive_EVT_ALL_SESSION_DATA()
           
 long getCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER()
           
 int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE()
           
 long getCounterReceive_EVT_CHANGE_SESSION_ID()
           
 long getCounterReceive_EVT_GET_ALL_SESSIONS()
           
 long getCounterReceive_EVT_SESSION_ACCESSED()
           
 long getCounterReceive_EVT_SESSION_CREATED()
           
 long getCounterReceive_EVT_SESSION_DELTA()
           
 long getCounterReceive_EVT_SESSION_EXPIRED()
           
 long getCounterSend_EVT_ALL_SESSION_DATA()
           
 int getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE()
           
 long getCounterSend_EVT_CHANGE_SESSION_ID()
           
 long getCounterSend_EVT_GET_ALL_SESSIONS()
           
 long getCounterSend_EVT_SESSION_ACCESSED()
           
 long getCounterSend_EVT_SESSION_CREATED()
           
 long getCounterSend_EVT_SESSION_DELTA()
           
 long getCounterSend_EVT_SESSION_EXPIRED()
           
 java.lang.String getInfo()
          Return descriptive information about this Manager implementation and the corresponding version number, in the format <description>/<version>.
 java.lang.String[] getInvalidatedSessions()
          When the manager expires session not tied to a request.
 int getMaxActiveSessions()
          Return the maximum number of active Sessions allowed, or -1 for no limit.
 java.lang.String getName()
          Return the descriptive short name of this Manager implementation.
protected  DeltaSession getNewDeltaSession()
          Get new session class to be used in the doLoad() method.
 long getProcessingTime()
           
 int getReceivedQueueSize()
           
 int getRejectedSessions()
          Number of session creations that failed due to maxActiveSessions
 int getSendAllSessionsSize()
           
 int getSendAllSessionsWaitTime()
           
 long getSessionReplaceCounter()
           
 boolean getStateTransfered()
          is session state transfered complete?
 int getStateTransferTimeout()
           
protected  void handleALL_SESSION_DATA(SessionMessage msg, Member sender)
          handle receive sessions from other not ( restart )
protected  void handleALL_SESSION_NOCONTEXTMANAGER(SessionMessage msg, Member sender)
          handle receive no context manager.
protected  void handleALL_SESSION_TRANSFERCOMPLETE(SessionMessage msg, Member sender)
          handle receive session state is complete transfered
protected  void handleCHANGE_SESSION_ID(SessionMessage msg, Member sender)
          handle receive change sessionID at other node
protected  void handleGET_ALL_SESSIONS(SessionMessage msg, Member sender)
          handle receive that other node want all sessions ( restart ) a) send all sessions with one message b) send session at blocks After sending send state is complete transfered
protected  void handleSESSION_ACCESSED(SessionMessage msg, Member sender)
          handle receive session is access at other node ( primary session is now false)
protected  void handleSESSION_CREATED(SessionMessage msg, Member sender)
          handle receive new session is created at other node (create backup - primary false)
protected  void handleSESSION_DELTA(SessionMessage msg, Member sender)
          handle receive session delta
protected  void handleSESSION_EXPIRED(SessionMessage msg, Member sender)
          handle receive session is expire at other node ( expire session also here)
 boolean isDefaultMode()
           
 boolean isExpireSessionsOnShutdown()
           
 boolean isNoContextManagerReceived()
           
 boolean isNotifyContainerListenersOnReplication()
           
 boolean isNotifyListenersOnReplication()
           
 boolean isNotifySessionListenersOnReplication()
           
 boolean isSendAllSessions()
           
 boolean isStateTimestampDrop()
           
 void load()
          Load any currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any.
 void messageDataReceived(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  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.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Process property change events from our associated Context.
protected  void registerSessionAtReplicationValve(DeltaSession session)
          Register cross context session at replication valve thread local
 void removeLifecycleListener(LifecycleListener listener)
          Remove a lifecycle event listener from this component.
 ClusterMessage requestCompleted(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.
 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.
 void resetStatistics()
          Reset manager statistics
protected  void send(SessionMessage msg)
          Send messages to other backup member (domain or all)
protected  void sendCreateSession(java.lang.String sessionId, DeltaSession session)
          Send create session evt to all backup node
protected  void sendSessions(Member sender, Session[] currentSessions, long sendTimestamp)
          send a block of session to sender
protected  byte[] serializeDeltaRequest(DeltaSession session, DeltaRequest deltaRequest)
          serialize DeltaRequest
protected  byte[] serializeSessionId(java.lang.String sessionId)
          serialize sessionID
protected  byte[] serializeSessions(Session[] currentSessions)
          Save any currently active sessions in the appropriate persistence mechanism, if any.
protected  void sessionExpired(java.lang.String id)
          send session expired to other cluster nodes
 void setCluster(CatalinaCluster cluster)
           
 void setContainer(Container container)
          Set the Container with which this Manager has been associated.
 void setDefaultMode(boolean defaultMode)
           
 void setDomainReplication(boolean sendClusterDomainOnly)
           
 void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown)
           
 void setMaxActiveSessions(int max)
          Set the maximum number of actives Sessions allowed, or -1 for no limit.
 void setName(java.lang.String name)
          Set the name of the manager, at host /context name and at engine hostname+/context
 void setNoContextManagerReceived(boolean noContextManagerReceived)
           
 void setNotifyContainerListenersOnReplication(boolean notifyContainerListenersOnReplication)
           
 void setNotifyListenersOnReplication(boolean notifyListenersOnReplication)
           
 void setNotifySessionListenersOnReplication(boolean notifyListenersCreateSessionOnReplication)
           
 void setRejectedSessions(int rejectedSessions)
          Sets the number of sessions that were not created because the maximum number of active sessions was reached.
 void setSendAllSessions(boolean sendAllSessions)
           
 void setSendAllSessionsSize(int sendAllSessionsSize)
           
 void setSendAllSessionsWaitTime(int sendAllSessionsWaitTime)
           
 void setStateTimestampDrop(boolean isTimestampDrop)
           
 void setStateTransfered(boolean stateTransfered)
          set that state ist complete transfered
 void setStateTransferTimeout(int timeoutAllSession)
           
 void start()
          Prepare for the beginning of active use of the public methods of this component.
 void stop()
          Gracefully terminate the active use of the public methods of this component.
 void unload()
          Save any currently active sessions in the appropriate persistence mechanism, if any.
protected  void waitForSendAllSessions(long beforeSendTime)
          Wait that cluster session state is transfer or timeout after 60 Sec With stateTransferTimeout == -1 wait that backup is transfered (forever mode)
 
Methods inherited from class org.apache.catalina.ha.session.ClusterManagerBase
getClassLoaders, getClassLoaders, getReplicationStream, getReplicationStream, getSessionAttributeFilter, setSessionAttributeFilter, willAttributeDistribute
 
Methods inherited from class org.apache.catalina.session.ManagerBase
add, addPropertyChangeListener, backgroundProcess, createSession, destroy, expireSession, findSession, findSessions, generateSessionId, getActiveSessions, getAlgorithm, getClassName, getContainer, getCreationTime, getCreationTimestamp, getDigest, getDistributable, getDomain, getDuplicates, getEngine, getEntropy, getExpiredSessions, getJvmRoute, getLastAccessedTime, getLastAccessedTimestamp, getMaxActive, getMaxInactiveInterval, getNewSession, getObjectName, getProcessExpiresFrequency, getRandom, getRandomBytes, getRandomClass, getRandomFile, getSession, getSessionAttribute, getSessionAttributeNameFilter, getSessionAttributeNamePattern, getSessionAttributeValueClassNameFilter, getSessionAttributeValueClassNamePattern, getSessionAverageAliveTime, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdLength, getSessionMaxAliveTime, getWarnOnSessionAttributeFilterFailure, init, listSessionIds, postDeregister, postRegister, preDeregister, preRegister, processExpires, remove, removePropertyChangeListener, setAlgorithm, setDistributable, setDuplicates, setEntropy, setExpiredSessions, setMaxActive, setMaxInactiveInterval, setProcessExpiresFrequency, setProcessingTime, setRandomClass, setRandomFile, setSessionAttributeNameFilter, setSessionAttributeValueClassNameFilter, setSessionAverageAliveTime, setSessionCounter, setSessionIdLength, setSessionMaxAliveTime, setWarnOnSessionAttributeFilterFailure, willAttributeDistribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.catalina.Manager
add, addPropertyChangeListener, backgroundProcess, createSession, findSession, findSessions, getActiveSessions, getContainer, getDistributable, getExpiredSessions, getMaxActive, getMaxInactiveInterval, getSessionAverageAliveTime, getSessionCounter, getSessionIdLength, getSessionMaxAliveTime, remove, removePropertyChangeListener, setDistributable, setExpiredSessions, setMaxActive, setMaxInactiveInterval, setSessionAverageAliveTime, setSessionCounter, setSessionIdLength, setSessionMaxAliveTime, willAttributeDistribute
 

Field Detail

log

public static Log log

sm

protected static StringManager sm
The string manager for this package.


managerName

protected static java.lang.String managerName
The descriptive name of this Manager implementation (for logging).


name

protected java.lang.String name

defaultMode

protected boolean defaultMode

lifecycle

protected LifecycleSupport lifecycle
The lifecycle event support for this component.

Constructor Detail

DeltaManager

public DeltaManager()
Method Detail

getInfo

public java.lang.String getInfo()
Return descriptive information about this Manager implementation and the corresponding version number, in the format <description>/<version>.

Specified by:
getInfo in interface Manager
Overrides:
getInfo in class ManagerBase

setName

public void setName(java.lang.String name)
Description copied from interface: ClusterManager
Set the name of the manager, at host /context name and at engine hostname+/context


getName

public java.lang.String getName()
Return the descriptive short name of this Manager implementation.

Specified by:
getName in interface ClusterManager
Overrides:
getName in class ManagerBase
Returns:
The descriptive short name of this Manager implementation.

getCounterSend_EVT_GET_ALL_SESSIONS

public long getCounterSend_EVT_GET_ALL_SESSIONS()
Returns:
Returns the counterSend_EVT_GET_ALL_SESSIONS.

getCounterSend_EVT_SESSION_ACCESSED

public long getCounterSend_EVT_SESSION_ACCESSED()
Returns:
Returns the counterSend_EVT_SESSION_ACCESSED.

getCounterSend_EVT_SESSION_CREATED

public long getCounterSend_EVT_SESSION_CREATED()
Returns:
Returns the counterSend_EVT_SESSION_CREATED.

getCounterSend_EVT_SESSION_DELTA

public long getCounterSend_EVT_SESSION_DELTA()
Returns:
Returns the counterSend_EVT_SESSION_DELTA.

getCounterSend_EVT_SESSION_EXPIRED

public long getCounterSend_EVT_SESSION_EXPIRED()
Returns:
Returns the counterSend_EVT_SESSION_EXPIRED.

getCounterSend_EVT_ALL_SESSION_DATA

public long getCounterSend_EVT_ALL_SESSION_DATA()
Returns:
Returns the counterSend_EVT_ALL_SESSION_DATA.

getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE

public int getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE()
Returns:
Returns the counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE.

getCounterSend_EVT_CHANGE_SESSION_ID

public long getCounterSend_EVT_CHANGE_SESSION_ID()
Returns:
Returns the counterSend_EVT_CHANGE_SESSION_ID.

getCounterReceive_EVT_ALL_SESSION_DATA

public long getCounterReceive_EVT_ALL_SESSION_DATA()
Returns:
Returns the counterReceive_EVT_ALL_SESSION_DATA.

getCounterReceive_EVT_GET_ALL_SESSIONS

public long getCounterReceive_EVT_GET_ALL_SESSIONS()
Returns:
Returns the counterReceive_EVT_GET_ALL_SESSIONS.

getCounterReceive_EVT_SESSION_ACCESSED

public long getCounterReceive_EVT_SESSION_ACCESSED()
Returns:
Returns the counterReceive_EVT_SESSION_ACCESSED.

getCounterReceive_EVT_SESSION_CREATED

public long getCounterReceive_EVT_SESSION_CREATED()
Returns:
Returns the counterReceive_EVT_SESSION_CREATED.

getCounterReceive_EVT_SESSION_DELTA

public long getCounterReceive_EVT_SESSION_DELTA()
Returns:
Returns the counterReceive_EVT_SESSION_DELTA.

getCounterReceive_EVT_SESSION_EXPIRED

public long getCounterReceive_EVT_SESSION_EXPIRED()
Returns:
Returns the counterReceive_EVT_SESSION_EXPIRED.

getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE

public int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE()
Returns:
Returns the counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE.

getCounterReceive_EVT_CHANGE_SESSION_ID

public long getCounterReceive_EVT_CHANGE_SESSION_ID()
Returns:
Returns the counterReceive_EVT_CHANGE_SESSION_ID.

getCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER

public long getCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER()
Returns:
Returns the counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER.

getProcessingTime

public long getProcessingTime()
Overrides:
getProcessingTime in class ManagerBase
Returns:
Returns the processingTime.

getSessionReplaceCounter

public long getSessionReplaceCounter()
Returns:
Returns the sessionReplaceCounter.

getRejectedSessions

public int getRejectedSessions()
Number of session creations that failed due to maxActiveSessions

Returns:
The count

setRejectedSessions

public void setRejectedSessions(int rejectedSessions)
Description copied from interface: Manager
Sets the number of sessions that were not created because the maximum number of active sessions was reached.

Parameters:
rejectedSessions - Number of rejected sessions

getCounterNoStateTransfered

public int getCounterNoStateTransfered()
Returns:
Returns the counterNoStateTransfered.

getReceivedQueueSize

public int getReceivedQueueSize()

getStateTransferTimeout

public int getStateTransferTimeout()
Returns:
Returns the stateTransferTimeout.

setStateTransferTimeout

public void setStateTransferTimeout(int timeoutAllSession)
Parameters:
timeoutAllSession - The timeout

getStateTransfered

public boolean getStateTransfered()
is session state transfered complete?


setStateTransfered

public void setStateTransfered(boolean stateTransfered)
set that state ist complete transfered

Parameters:
stateTransfered -

isNoContextManagerReceived

public boolean isNoContextManagerReceived()

setNoContextManagerReceived

public void setNoContextManagerReceived(boolean noContextManagerReceived)

getSendAllSessionsWaitTime

public int getSendAllSessionsWaitTime()
Returns:
Returns the sendAllSessionsWaitTime in msec

setSendAllSessionsWaitTime

public void setSendAllSessionsWaitTime(int sendAllSessionsWaitTime)
Parameters:
sendAllSessionsWaitTime - The sendAllSessionsWaitTime to set at msec.

doDomainReplication

public boolean doDomainReplication()
Returns:
Returns the sendClusterDomainOnly.

setDomainReplication

public void setDomainReplication(boolean sendClusterDomainOnly)
Parameters:
sendClusterDomainOnly - The sendClusterDomainOnly to set.

isStateTimestampDrop

public boolean isStateTimestampDrop()
Returns:
Returns the stateTimestampDrop.

setStateTimestampDrop

public void setStateTimestampDrop(boolean isTimestampDrop)
Parameters:
isTimestampDrop - The new flag value

getMaxActiveSessions

public int getMaxActiveSessions()
Return the maximum number of active Sessions allowed, or -1 for no limit.


setMaxActiveSessions

public void setMaxActiveSessions(int max)
Set the maximum number of actives Sessions allowed, or -1 for no limit.

Parameters:
max - The new maximum number of sessions

isSendAllSessions

public boolean isSendAllSessions()
Returns:
Returns the sendAllSessions.

setSendAllSessions

public void setSendAllSessions(boolean sendAllSessions)
Parameters:
sendAllSessions - The sendAllSessions to set.

getSendAllSessionsSize

public int getSendAllSessionsSize()
Returns:
Returns the sendAllSessionsSize.

setSendAllSessionsSize

public void setSendAllSessionsSize(int sendAllSessionsSize)
Parameters:
sendAllSessionsSize - The sendAllSessionsSize to set.

isNotifySessionListenersOnReplication

public boolean isNotifySessionListenersOnReplication()
Returns:
Returns the notifySessionListenersOnReplication.

setNotifySessionListenersOnReplication

public void setNotifySessionListenersOnReplication(boolean notifyListenersCreateSessionOnReplication)
Parameters:
notifyListenersCreateSessionOnReplication - The notifySessionListenersOnReplication to set.

isExpireSessionsOnShutdown

public boolean isExpireSessionsOnShutdown()

setExpireSessionsOnShutdown

public void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown)

isNotifyListenersOnReplication

public boolean isNotifyListenersOnReplication()

setNotifyListenersOnReplication

public void setNotifyListenersOnReplication(boolean notifyListenersOnReplication)

isNotifyContainerListenersOnReplication

public boolean isNotifyContainerListenersOnReplication()

setNotifyContainerListenersOnReplication

public void setNotifyContainerListenersOnReplication(boolean notifyContainerListenersOnReplication)

isDefaultMode

public boolean isDefaultMode()
Returns:
Returns the defaultMode.

setDefaultMode

public void setDefaultMode(boolean defaultMode)
Parameters:
defaultMode - The defaultMode to set.

getCluster

public CatalinaCluster getCluster()

setCluster

public void setCluster(CatalinaCluster cluster)

setContainer

public void setContainer(Container container)
Set the Container with which this Manager has been associated. If it is a Context (the usual case), listen for changes to the session timeout property.

Specified by:
setContainer in interface Manager
Overrides:
setContainer in class ManagerBase
Parameters:
container - The associated Container

createSession

public Session createSession(java.lang.String sessionId)
Construct and return a new session object, based on the default settings specified by this Manager's properties. The session id will be assigned by this method, and available via the getId() method of the returned session. If a new session cannot be created for any reason, return null.

Specified by:
createSession in interface Manager
Overrides:
createSession in class ManagerBase
Parameters:
sessionId - The session id which should be used to create the new session; if null, a new session id will be generated
Throws:
java.lang.IllegalStateException - if a new session cannot be instantiated for any reason Construct and return a new session object, based on the default settings specified by this Manager's properties. The session id will be assigned by this method, and available via the getId() method of the returned session. If a new session cannot be created for any reason, return null.
java.lang.IllegalStateException - if a new session cannot be instantiated for any reason

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:
distribute -
Returns:
The session

sendCreateSession

protected void sendCreateSession(java.lang.String sessionId,
                                 DeltaSession session)
Send create session evt to all backup node

Parameters:
sessionId -
session -

send

protected void send(SessionMessage msg)
Send messages to other backup member (domain or all)

Parameters:
msg - Session message

createEmptySession

public Session createEmptySession()
Create DeltaSession

Specified by:
createEmptySession in interface Manager
Overrides:
createEmptySession in class ManagerBase
See Also:
Manager.createEmptySession()

getNewDeltaSession

protected DeltaSession getNewDeltaSession()
Get new session class to be used in the doLoad() method.


changeSessionId

public void changeSessionId(Session session)
Change the session ID of the current session to a new randomly generated session ID.

Specified by:
changeSessionId in interface Manager
Overrides:
changeSessionId in class ManagerBase
Parameters:
session - The session to change the session ID for

changeSessionId

public void changeSessionId(Session session,
                            boolean notify)

serializeSessionId

protected byte[] serializeSessionId(java.lang.String sessionId)
                             throws java.io.IOException
serialize sessionID

Throws:
java.io.IOException - if an input/output error occurs

deserializeSessionId

protected java.lang.String deserializeSessionId(byte[] data)
                                         throws java.io.IOException
Load sessionID

Throws:
java.io.IOException - if an input/output error occurs

deserializeDeltaRequest

protected DeltaRequest deserializeDeltaRequest(DeltaSession session,
                                               byte[] data)
                                        throws java.lang.ClassNotFoundException,
                                               java.io.IOException
Load Deltarequest from external node Load the Class at container classloader

Parameters:
session -
data - message data
Returns:
The request
Throws:
java.lang.ClassNotFoundException
java.io.IOException
See Also:
DeltaRequest.readExternal(java.io.ObjectInput)

serializeDeltaRequest

protected byte[] serializeDeltaRequest(DeltaSession session,
                                       DeltaRequest deltaRequest)
                                throws java.io.IOException
serialize DeltaRequest

Parameters:
deltaRequest -
Returns:
serialized delta request
Throws:
java.io.IOException
See Also:
DeltaRequest.writeExternal(java.io.ObjectOutput)

deserializeSessions

protected void deserializeSessions(byte[] data)
                            throws java.lang.ClassNotFoundException,
                                   java.io.IOException
Load sessions from other cluster node. FIXME replace currently sessions with same id without notifcation. FIXME SSO handling is not really correct with the session replacement!

Throws:
java.lang.ClassNotFoundException - if a serialized class cannot be found during the reload
java.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.

Throws:
java.io.IOException - if an input/output error occurs

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.

Parameters:
listener - The listener to add

findLifecycleListeners

public LifecycleListener[] findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.


removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.

Parameters:
listener - The listener to remove

start

public void start()
           throws LifecycleException
Prepare for the beginning of active use of the public methods of this component. This method should be called after configure(), and before any of the public methods of the component are utilized.

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()

registerSessionAtReplicationValve

protected void registerSessionAtReplicationValve(DeltaSession session)
Register cross context session at replication valve thread local

Parameters:
session - cross context session

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 transfer or timeout after 60 Sec With stateTransferTimeout == -1 wait that backup is transfered (forever mode)


stop

public void stop()
          throws LifecycleException
Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.

Throws:
LifecycleException - if this component detects a fatal error that needs to be reported

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Process property change events from our associated Context.

Parameters:
event - The property change event that has occurred

messageDataReceived

public void messageDataReceived(ClusterMessage cmsg)
A 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)
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.

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


load

public void load()
Description copied from interface: Manager
Load any currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.


unload

public void unload()
Description copied from interface: Manager
Save any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.


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()
When 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:
The invalidated sessions array

checkSenderDomain

protected boolean checkSenderDomain(SessionMessage msg,
                                    Member sender)
Test that sender and local domain is the same


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 received
sender - - 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 transfered

Parameters:
msg -
sender -

handleSESSION_DELTA

protected void handleSESSION_DELTA(SessionMessage msg,
                                   Member sender)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
handle receive session delta

Parameters:
msg -
sender -
Throws:
java.io.IOException
java.lang.ClassNotFoundException

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 -
sender -
Throws:
java.io.IOException

handleSESSION_EXPIRED

protected void handleSESSION_EXPIRED(SessionMessage msg,
                                     Member sender)
                              throws java.io.IOException
handle receive session is expire at other node ( expire session also here)

Parameters:
msg -
sender -
Throws:
java.io.IOException

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 -
sender -

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 -
sender -
Throws:
java.lang.ClassNotFoundException
java.io.IOException

handleGET_ALL_SESSIONS

protected void handleGET_ALL_SESSIONS(SessionMessage msg,
                                      Member sender)
                               throws java.io.IOException
handle receive that other node want all sessions ( restart ) a) send all sessions with one message b) send session at blocks After sending send state is complete transfered

Parameters:
msg -
sender -
Throws:
java.io.IOException

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 -
sender -
Throws:
java.io.IOException

handleALL_SESSION_NOCONTEXTMANAGER

protected void handleALL_SESSION_NOCONTEXTMANAGER(SessionMessage msg,
                                                  Member sender)
handle receive no context manager.

Parameters:
msg -
sender -

sendSessions

protected void sendSessions(Member sender,
                            Session[] currentSessions,
                            long sendTimestamp)
                     throws java.io.IOException
send a block of session to sender

Parameters:
sender -
currentSessions -
sendTimestamp -
Throws:
java.io.IOException

cloneFromTemplate

public ClusterManager cloneFromTemplate()

Apache Tomcat 6.0.53

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.