Home » apache-tomcat-6.0.26-src » org.apache » catalina » ha » session » [javadoc | source]
public class: DeltaManager [javadoc | source]

All Implemented Interfaces:
    ClusterManager, PropertyChangeListener, Lifecycle, Manager, MBeanRegistration

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.
Field Summary
public static  Log log     
protected static  StringManager sm    The string manager for this package. 
protected static  String managerName    The descriptive name of this Manager implementation (for logging). 
protected  String name     
protected  boolean defaultMode     
protected  LifecycleSupport lifecycle    The lifecycle event support for this component. 
 int rejectedSessions     
 long processingTime     
Fields inherited from org.apache.catalina.session.ManagerBase:
log,  randomIS,  devRandomSource,  DEFAULT_ALGORITHM,  algorithm,  container,  digest,  distributable,  entropy,  maxInactiveInterval,  sessionIdLength,  name,  random,  randomClass,  sessionMaxAliveTime,  sessionAverageAliveTime,  expiredSessions,  sessions,  sessionCounter,  maxActive,  duplicates,  initialized,  processingTime,  processExpiresFrequency,  sm,  support,  domain,  oname,  mserver
 public DeltaManager() 
Method from org.apache.catalina.ha.session.DeltaManager Summary:
addLifecycleListener,   checkSenderDomain,   cloneFromTemplate,   createEmptySession,   createSession,   createSession,   deserializeDeltaRequest,   deserializeSessions,   doDomainReplication,   expireAllLocalSessions,   findLifecycleListeners,   findSessionMasterMember,   getAllClusterSessions,   getCluster,   getCounterNoStateTransfered,   getCounterReceive_EVT_ALL_SESSION_DATA,   getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE,   getCounterReceive_EVT_GET_ALL_SESSIONS,   getCounterReceive_EVT_SESSION_ACCESSED,   getCounterReceive_EVT_SESSION_CREATED,   getCounterReceive_EVT_SESSION_DELTA,   getCounterReceive_EVT_SESSION_EXPIRED,   getCounterSend_EVT_ALL_SESSION_DATA,   getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE,   getCounterSend_EVT_GET_ALL_SESSIONS,   getCounterSend_EVT_SESSION_ACCESSED,   getCounterSend_EVT_SESSION_CREATED,   getCounterSend_EVT_SESSION_DELTA,   getCounterSend_EVT_SESSION_EXPIRED,   getInfo,   getInvalidatedSessions,   getMaxActiveSessions,   getName,   getNewDeltaSession,   getProcessingTime,   getReceivedQueueSize,   getRejectedSessions,   getSendAllSessionsSize,   getSendAllSessionsWaitTime,   getSessionReplaceCounter,   getStateTransferTimeout,   getStateTransfered,   handleALL_SESSION_DATA,   handleALL_SESSION_TRANSFERCOMPLETE,   handleGET_ALL_SESSIONS,   handleSESSION_ACCESSED,   handleSESSION_CREATED,   handleSESSION_DELTA,   handleSESSION_EXPIRED,   isDefaultMode,   isExpireSessionsOnShutdown,   isNotifyListenersOnReplication,   isNotifySessionListenersOnReplication,   isSendAllSessions,   isStateTimestampDrop,   load,   messageDataReceived,   messageReceived,   propertyChange,   registerSessionAtReplicationValve,   removeLifecycleListener,   requestCompleted,   requestCompleted,   resetStatistics,   send,   sendCreateSession,   sendSessions,   serializeDeltaRequest,   serializeSessions,   sessionExpired,   setCluster,   setContainer,   setDefaultMode,   setDomainReplication,   setExpireSessionsOnShutdown,   setMaxActiveSessions,   setName,   setNotifyListenersOnReplication,   setNotifySessionListenersOnReplication,   setRejectedSessions,   setSendAllSessions,   setSendAllSessionsSize,   setSendAllSessionsWaitTime,   setStateTimestampDrop,   setStateTransferTimeout,   setStateTransfered,   start,   stop,   unload,   waitForSendAllSessions
Methods from org.apache.catalina.ha.session.ClusterManagerBase:
getClassLoaders,   getClassLoaders,   getReplicationStream,   getReplicationStream
Methods from org.apache.catalina.session.ManagerBase:
add,   addPropertyChangeListener,   backgroundProcess,   changeSessionId,   createEmptySession,   createSession,   createSession,   destroy,   expireSession,   findSession,   findSessions,   generateSessionId,   getActiveSessions,   getAlgorithm,   getClassName,   getContainer,   getCreationTime,   getCreationTimestamp,   getDigest,   getDistributable,   getDomain,   getDuplicates,   getEngine,   getEntropy,   getExpiredSessions,   getInfo,   getJvmRoute,   getLastAccessedTime,   getLastAccessedTimestamp,   getMaxActive,   getMaxInactiveInterval,   getName,   getNewSession,   getObjectName,   getProcessExpiresFrequency,   getProcessingTime,   getRandom,   getRandomBytes,   getRandomClass,   getRandomFile,   getSession,   getSessionAttribute,   getSessionAverageAliveTime,   getSessionCounter,   getSessionIdLength,   getSessionMaxAliveTime,   init,   listSessionIds,   postDeregister,   postRegister,   preDeregister,   preRegister,   processExpires,   remove,   removePropertyChangeListener,   setAlgorithm,   setContainer,   setDistributable,   setDuplicates,   setEntropy,   setExpiredSessions,   setMaxActive,   setMaxInactiveInterval,   setProcessExpiresFrequency,   setProcessingTime,   setRandomClass,   setRandomFile,   setSessionAverageAliveTime,   setSessionCounter,   setSessionIdLength,   setSessionMaxAliveTime
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.catalina.ha.session.DeltaManager Detail:
 public  void addLifecycleListener(LifecycleListener listener) 
    Add a lifecycle event listener to this component.
 protected boolean checkSenderDomain(SessionMessage msg,
    Member sender) 
    Test that sender and local domain is the same
 public ClusterManager cloneFromTemplate() 
 public Session createEmptySession() 
    Create DeltaSession
 public Session createSession(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.
 public Session createSession(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) throws ClassNotFoundException, IOException 
    Load Deltarequest from external node Load the Class at container classloader
 protected  void deserializeSessions(byte[] data) throws ClassNotFoundException, 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!
 public boolean doDomainReplication() 
 public  void expireAllLocalSessions() 
    Exipre all find sessions.
 public LifecycleListener[] findLifecycleListeners() 
    Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.
 protected Member findSessionMasterMember() 
    Find the master of the session state
 public synchronized  void getAllClusterSessions() 
    get from first session master the backup from all clustered sessions
 public CatalinaCluster getCluster() 
 public int getCounterNoStateTransfered() 
 public long getCounterReceive_EVT_ALL_SESSION_DATA() 
 public int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE() 
 public long getCounterReceive_EVT_GET_ALL_SESSIONS() 
 public long getCounterReceive_EVT_SESSION_ACCESSED() 
 public long getCounterReceive_EVT_SESSION_CREATED() 
 public long getCounterReceive_EVT_SESSION_DELTA() 
 public long getCounterReceive_EVT_SESSION_EXPIRED() 
 public long getCounterSend_EVT_ALL_SESSION_DATA() 
 public int getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE() 
 public long getCounterSend_EVT_GET_ALL_SESSIONS() 
 public long getCounterSend_EVT_SESSION_ACCESSED() 
 public long getCounterSend_EVT_SESSION_CREATED() 
 public long getCounterSend_EVT_SESSION_DELTA() 
 public long getCounterSend_EVT_SESSION_EXPIRED() 
 public String getInfo() 
    Return descriptive information about this Manager implementation and the corresponding version number, in the format <description>/<version>.
 public 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.
 public int getMaxActiveSessions() 
    Return the maximum number of active Sessions allowed, or -1 for no limit.
 public 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.
 public long getProcessingTime() 
 public int getReceivedQueueSize() 
 public int getRejectedSessions() 
    Number of session creations that failed due to maxActiveSessions
 public int getSendAllSessionsSize() 
 public int getSendAllSessionsWaitTime() 
 public long getSessionReplaceCounter() 
 public int getStateTransferTimeout() 
 public boolean getStateTransfered() 
    is session state transfered complete?
 protected  void handleALL_SESSION_DATA(SessionMessage msg,
    Member sender) throws ClassNotFoundException, IOException 
    handle receive sessions from other not ( restart )
 protected  void handleALL_SESSION_TRANSFERCOMPLETE(SessionMessage msg,
    Member sender) 
    handle receive session state is complete transfered
 protected  void handleGET_ALL_SESSIONS(SessionMessage msg,
    Member sender) throws 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
 protected  void handleSESSION_ACCESSED(SessionMessage msg,
    Member sender) throws IOException 
    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) throws IOException, ClassNotFoundException 
    handle receive session delta
 protected  void handleSESSION_EXPIRED(SessionMessage msg,
    Member sender) throws IOException 
    handle receive session is expire at other node ( expire session also here)
 public boolean isDefaultMode() 
 public boolean isExpireSessionsOnShutdown() 
 public boolean isNotifyListenersOnReplication() 
 public boolean isNotifySessionListenersOnReplication() 
 public boolean isSendAllSessions() 
 public boolean isStateTimestampDrop() 
 public  void load() 
 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.
 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.
 public  void propertyChange(PropertyChangeEvent event) 
    Process property change events from our associated Context.
 protected  void registerSessionAtReplicationValve(DeltaSession session) 
    Register cross context session at replication valve thread local
 public  void removeLifecycleListener(LifecycleListener listener) 
    Remove a lifecycle event listener from this component.
 public ClusterMessage requestCompleted(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.
 public ClusterMessage requestCompleted(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.
 public synchronized  void resetStatistics() 
    Reset manager statistics
 protected  void send(SessionMessage msg) 
    Send messages to other backup member (domain or all)
 protected  void sendCreateSession(String sessionId,
    DeltaSession session) 
    Send create session evt to all backup node
 protected  void sendSessions(Member sender,
    Session[] currentSessions,
    long sendTimestamp) throws IOException 
    send a block of session to sender
 protected byte[] serializeDeltaRequest(DeltaSession session,
    DeltaRequest deltaRequest) throws IOException 
    serialize DeltaRequest
 protected byte[] serializeSessions(Session[] currentSessions) throws IOException 
    Save any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.
 protected  void sessionExpired(String id) 
    send session expired to other cluster nodes
 public  void setCluster(CatalinaCluster cluster) 
 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.
 public  void setDefaultMode(boolean defaultMode) 
 public  void setDomainReplication(boolean sendClusterDomainOnly) 
 public  void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown) 
 public  void setMaxActiveSessions(int max) 
    Set the maximum number of actives Sessions allowed, or -1 for no limit.
 public  void setName(String name) 
 public  void setNotifyListenersOnReplication(boolean notifyListenersOnReplication) 
 public  void setNotifySessionListenersOnReplication(boolean notifyListenersCreateSessionOnReplication) 
 public  void setRejectedSessions(int rejectedSessions) 
 public  void setSendAllSessions(boolean sendAllSessions) 
 public  void setSendAllSessionsSize(int sendAllSessionsSize) 
 public  void setSendAllSessionsWaitTime(int sendAllSessionsWaitTime) 
 public  void setStateTimestampDrop(boolean isTimestampDrop) 
 public  void setStateTransferTimeout(int timeoutAllSession) 
 public  void setStateTransfered(boolean stateTransfered) 
    set that state ist complete transfered
 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.
 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.
 public  void unload() 
 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)