Home » apache-tomcat-6.0.26-src » org.apache » catalina » cluster » session » [javadoc | source]
org.apache.catalina.cluster.session
public class: DeltaManager [javadoc | source]
java.lang.Object
   org.apache.catalina.session.ManagerBase
      org.apache.catalina.cluster.session.DeltaManager

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

Direct Known Subclasses:
    MockDeltaManager

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
Constructor:
 public DeltaManager() 
Method from org.apache.catalina.cluster.session.DeltaManager Summary:
addLifecycleListener,   checkSenderDomain,   createEmptySession,   createSession,   createSession,   deserializeSessions,   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,   getStateTransferred,   handleALL_SESSION_DATA,   handleALL_SESSION_TRANSFERCOMPLETE,   handleGET_ALL_SESSIONS,   handleSESSION_ACCESSED,   handleSESSION_CREATED,   handleSESSION_DELTA,   handleSESSION_EXPIRRED,   isDefaultMode,   isExpireSessionsOnShutdown,   isNotifyListenersOnReplication,   isNotifySessionListenersOnReplication,   isSendAllSessions,   isSendClusterDomainOnly,   isStateTimestampDrop,   load,   loadDeltaRequest,   messageDataReceived,   messageReceived,   openDeserializeObjectStream,   propertyChange,   removeLifecycleListener,   requestCompleted,   resetStatistics,   send,   sendCreateSession,   sendSessions,   serializeSessions,   sessionExpired,   setCluster,   setContainer,   setDefaultMode,   setExpireSessionsOnShutdown,   setMaxActiveSessions,   setName,   setNotifyListenersOnReplication,   setNotifySessionListenersOnReplication,   setRejectedSessions,   setSendAllSessions,   setSendAllSessionsSize,   setSendAllSessionsWaitTime,   setSendClusterDomainOnly,   setStateTimestampDrop,   setStateTransferTimeout,   setStateTransferred,   start,   stop,   unload,   unloadDeltaRequest,   waitForSendAllSessions
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.cluster.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 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  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  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 getStateTransferred() 
 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_EXPIRRED(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 isSendClusterDomainOnly() 
 public boolean isStateTimestampDrop() 
 public  void load() 
 protected DeltaRequest loadDeltaRequest(DeltaSession session,
    byte[] data) throws ClassNotFoundException, IOException 
    Load Deltarequest from external node Load the Class at container classloader
 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.
 protected ObjectInputStream openDeserializeObjectStream(byte[] data) throws IOException 
    Open Stream and use correct ClassLoader (Container) Switch ThreadClassLoader
 public  void propertyChange(PropertyChangeEvent event) 
    Process property change events from our associated Context.
 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 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[] 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 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 setSendClusterDomainOnly(boolean sendClusterDomainOnly) 
 public  void setStateTimestampDrop(boolean isTimestampDrop) 
 public  void setStateTransferTimeout(int timeoutAllSession) 
 public  void setStateTransferred(boolean stateTransferred) 
 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 byte[] unloadDeltaRequest(DeltaRequest deltaRequest) throws IOException 
    serialize DeltaRequest
 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)