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

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

Title: Tomcat Session Replication for Tomcat 4.0
Description: A very simple straight forward implementation of session replication of servers in a cluster.
This session replication is implemented "live". By live I mean, when a session attribute is added into a session on Node A a message is broadcasted to other messages and setAttribute is called on the replicated sessions.
A full description of this implementation can be found under Filip's Tomcat Page
Copyright: See apache license Company: www.filip.net
Field Summary
public static  Log log     
protected  String mChannelConfig     
protected  String mGroupName     
protected  boolean mChannelStarted     
protected  boolean mPrintToScreen     
protected  boolean defaultMode     
protected  boolean mManagerRunning     
protected  boolean synchronousReplication    Use synchronous rather than asynchronous replication. Every session modification (creation, change, removal etc) will be sent to all members. The call will then wait for max milliseconds, or forever (if timeout is 0) for all responses. 
protected  boolean mExpireSessionsOnShutdown    Set to true if we don't want the sessions to expire on shutdown 
protected  boolean useDirtyFlag     
protected  String name     
protected  boolean distributable     
protected  CatalinaCluster cluster     
protected  HashMap invalidatedSessions     
protected  boolean stateTransferred    Flag to keep track if the state has been transferred or not Assumes false. 
Fields inherited from org.apache.catalina.session.StandardManager:
info,  lifecycle,  maxActiveSessions,  name,  pathname,  started,  rejectedSessions,  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 SimpleTcpReplicationManager() 
Method from org.apache.catalina.cluster.session.SimpleTcpReplicationManager Summary:
createSession,   createSession,   getCluster,   getDistributable,   getExpireSessionsOnShutdown,   getInvalidatedSessions,   getName,   isDefaultMode,   isManagerRunning,   isNotifyListenersOnReplication,   isSendClusterDomainOnly,   isStateTransferred,   messageDataReceived,   messageReceived,   readSession,   requestCompleted,   sessionInvalidated,   setCluster,   setDefaultMode,   setDistributable,   setExpireSessionsOnShutdown,   setName,   setNotifyListenersOnReplication,   setPrintToScreen,   setSendClusterDomainOnly,   setSynchronousReplication,   setUseDirtyFlag,   start,   stop,   unload,   writeSession
Methods from org.apache.catalina.session.StandardManager:
addLifecycleListener,   createSession,   doLoad,   doUnload,   file,   findLifecycleListeners,   getInfo,   getMaxActiveSessions,   getName,   getPathname,   getRejectedSessions,   load,   propertyChange,   removeLifecycleListener,   setContainer,   setMaxActiveSessions,   setPathname,   setRejectedSessions,   start,   stop,   unload
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.SimpleTcpReplicationManager Detail:
 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.
 protected Session createSession(String sessionId,
    boolean notify,
    boolean setId) 
    Creates a HTTP session. Most of the code in here is copied from the StandardManager. This is not pretty, yeah I know, but it was necessary since the StandardManager had hard coded the session instantiation to the a StandardSession, when we actually want to instantiate a ReplicatedSession
    If the call comes from the Tomcat servlet engine, a SessionMessage goes out to the other nodes in the cluster that this session has been created.
 public CatalinaCluster getCluster() 
 public boolean getDistributable() 
 public boolean getExpireSessionsOnShutdown() 
 public String[] getInvalidatedSessions() 
 public String getName() 
 public boolean isDefaultMode() 
 public boolean isManagerRunning() 
 public boolean isNotifyListenersOnReplication() 
 public boolean isSendClusterDomainOnly() 
 public boolean isStateTransferred() 
 public  void messageDataReceived(ClusterMessage cmsg) 
 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 Session readSession(byte[] data,
    String sessionId) 
    Reinstantiates a serialized session from the data passed in. This will first call createSession() so that we get a fresh instance with all the managers set and all the transient fields validated. Then it calls Session.readObjectData(byte[]) to deserialize the object
 public ClusterMessage requestCompleted(String sessionId) 
 public  void sessionInvalidated(String sessionId) 
 public  void setCluster(CatalinaCluster cluster) 
 public  void setDefaultMode(boolean defaultMode) 
 public  void setDistributable(boolean dist) 
 public  void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown) 
 public  void setName(String name) 
 public  void setNotifyListenersOnReplication(boolean notifyListenersOnReplication) 
 public  void setPrintToScreen(boolean printtoscreen) 
 public  void setSendClusterDomainOnly(boolean sendClusterDomainOnly) 
 public  void setSynchronousReplication(boolean flag) 
 public  void setUseDirtyFlag(boolean usedirtyflag) 
 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.
    Starts the cluster communication channel, this will connect with the other nodes in the cluster, and request the current session state to be transferred to this node.
 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.
    This will disconnect the cluster communication channel and stop the listener thread.
 public  void unload() throws IOException 
    Override persistence since they don't go hand in hand with replication for now.
 protected byte[] writeSession(Session session) 
    Serialize a session into a byte array
    This method simple calls the writeObjectData method on the session and returns the byte data from that call