Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » catalina » cluster » tcp » [javadoc | source]
org.apache.catalina.cluster.tcp
public class: SimpleTcpCluster [javadoc | source]
java.lang.Object
   org.apache.catalina.cluster.tcp.SimpleTcpCluster

All Implemented Interfaces:
    IDynamicProperty, CatalinaCluster, LifecycleListener, MembershipListener, Lifecycle

Direct Known Subclasses:
    MockCluster

A Cluster implementation using simple multicast. Responsible for setting up a cluster and provides callers with a valid multicast receiver/sender. FIXME remove install/remove/start/stop context dummys FIXME wrote testcases
Field Summary
public static  Log log     
protected static final  String info    Descriptive information about this component implementation. 
public static final  String BEFORE_MEMBERREGISTER_EVENT     
public static final  String AFTER_MEMBERREGISTER_EVENT     
public static final  String BEFORE_MANAGERREGISTER_EVENT     
public static final  String AFTER_MANAGERREGISTER_EVENT     
public static final  String BEFORE_MANAGERUNREGISTER_EVENT     
public static final  String AFTER_MANAGERUNREGISTER_EVENT     
public static final  String BEFORE_MEMBERUNREGISTER_EVENT     
public static final  String AFTER_MEMBERUNREGISTER_EVENT     
public static final  String SEND_MESSAGE_FAILURE_EVENT     
public static final  String RECEIVE_MESSAGE_FAILURE_EVENT     
protected  MembershipService membershipService    the service that provides the membership 
protected  String clusterImpName    Name for logging purpose 
protected  StringManager sm    The string manager for this package. 
protected  String clusterName    The cluster name to join 
protected  Container container    The Container associated with this Cluster. 
protected  LifecycleSupport lifecycle    The lifecycle event support for this component. 
protected  boolean started    Has this component been started? 
protected  PropertyChangeSupport support    The property change support for this component. 
protected  Map managers    The context name <->manager association for distributed contexts. 
protected  SimpleTcpCluster.MemberComparator memberComparator     
protected  List clusterListeners    Listeners of messages 
Constructor:
 public SimpleTcpCluster() 
Method from org.apache.catalina.cluster.tcp.SimpleTcpCluster Summary:
addClusterListener,   addLifecycleListener,   addManager,   addValve,   backgroundProcess,   createDefaultClusterListener,   createDefaultClusterReceiver,   createDefaultClusterSender,   createDefaultClusterValves,   createDefaultMembershipService,   createManager,   findClusterListeners,   findLifecycleListeners,   getClusterDeployer,   getClusterLog,   getClusterLogName,   getClusterName,   getClusterReceiver,   getClusterSender,   getContainer,   getInfo,   getLocalMember,   getLogger,   getMBeanServer,   getManagedBean,   getManager,   getManagerClassName,   getManagers,   getMembers,   getMembershipService,   getObjectName,   getProperty,   getPropertyNames,   getProtocol,   getValves,   installContext,   isDefaultMode,   isDoClusterLog,   isNotifyLifecycleListenerOnFailure,   lifecycleEvent,   logReceiveMessage,   logSendMessage,   memberAdded,   memberDisappeared,   receive,   registerClusterValve,   registerMBeans,   removeClusterListener,   removeLifecycleListener,   removeManager,   removeProperty,   send,   send,   sendClusterDomain,   sendToMember,   setClusterDeployer,   setClusterLogName,   setClusterName,   setClusterReceiver,   setClusterSender,   setContainer,   setDefaultMode,   setDoClusterLog,   setManagerClassName,   setMembershipService,   setNotifyLifecycleListenerOnFailure,   setObjectName,   setProperty,   setProperty,   setProtocol,   start,   startContext,   stop,   stop,   transferProperty,   unregisterClusterValve,   unregisterMBeans
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.catalina.cluster.tcp.SimpleTcpCluster Detail:
 public  void addClusterListener(MessageListener listener) 
    add cluster message listener and register cluster to this listener
 public  void addLifecycleListener(LifecycleListener listener) 
    Add a lifecycle event listener to this component.
 public  void addManager(String name,
    Manager manager) 
    add an application to cluster replication bus
 public  void addValve(Valve valve) 
    Add cluster valve Cluster Valves are only add to container when cluster is started!
 public  void backgroundProcess() 
    Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.
 protected  void createDefaultClusterListener() 
    Create default session cluster listener:
    <ClusterListener
    className="org.apache.catalina.cluster.session.ClusterSessionListener" />
    
 protected  void createDefaultClusterReceiver() 
    Create default receiver:
    <Receiver
    className="org.apache.catalina.cluster.tcp.SocketReplicationListener"
    tcpListenAddress="auto"
    tcpListenPort="8015"
    tcpListenMaxPort="8019"
    doReceivedProcessingStats="true"
    />
    
 protected  void createDefaultClusterSender() 
    Create default cluster sender
    <Sender
    className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
    replicationMode="fastasyncqueue"
    doTransmitterProcessingStats="true"
    doProcessingStats="true"/>
    
 protected  void createDefaultClusterValves() 
    Create default ReplicationValve
    <Valve
    className="org.apache.catalina.cluster.tcp.ReplicationValve"
    filter=".*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"
    primaryIndicator="true" />
    
 protected  void createDefaultMembershipService() 
    Create default membership service:
    <Membership
    className="org.apache.catalina.cluster.mcast.McastService"
    mcastAddr="228.0.0.4"
    mcastPort="8012"
    mcastFrequency="1000"
    mcastDropTime="30000"/>
    
 public synchronized Manager createManager(String name) 
    Create new Manager without add to cluster (comes with start the manager)
 public MessageListener[] findClusterListeners() 
    Get the cluster listeners associated with this cluster. If this Array has no listeners registered, a zero-length array is returned.
 public LifecycleListener[] findLifecycleListeners() 
    Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.
 public ClusterDeployer getClusterDeployer() 
 public Log getClusterLog() 
 public String getClusterLogName() 
 public String getClusterName() 
    Return the name of the cluster that this Server is currently configured to operate within.
 public ClusterReceiver getClusterReceiver() 
 public ClusterSender getClusterSender() 
 public Container getContainer() 
    Get the Container associated with our Cluster
 public String getInfo() 
    Return descriptive information about this Cluster implementation and the corresponding version number, in the format <description>/<version>.
 public Member getLocalMember() 
    Return the member that represents this node.
 public Log getLogger() 
 public MBeanServer getMBeanServer() throws Exception 
    Get current Catalina MBean Server and load mbean registry
 public ModelMBean getManagedBean(Object object) throws Exception 
    Returns the ModelMBean
 public Manager getManager(String name) 
 public String getManagerClassName() 
 public Map getManagers() 
 public Member[] getMembers() 
    Get all current cluster members
 public MembershipService getMembershipService() 
 public ObjectName getObjectName() 
 public Object getProperty(String key) 
    get current config
 public Iterator getPropertyNames() 
    Get all properties keys
 public String getProtocol() 
 public Valve[] getValves() 
    get all cluster valves
 public  void installContext(String contextPath,
    URL war) 
 public boolean isDefaultMode() 
 public boolean isDoClusterLog() 
 public boolean isNotifyLifecycleListenerOnFailure() 
 public  void lifecycleEvent(LifecycleEvent lifecycleEvent) 
    Use as base to handle start/stop/periodic Events from host. Currently only log the messages as trace level.
 protected  void logReceiveMessage(ClusterMessage message,
    long start,
    boolean accepted) 
    log received message to cluster transfer log
 protected  void logSendMessage(ClusterMessage message,
    long start,
    Member dest) 
    log sended message to cluster transfer log
 public  void memberAdded(Member member) 
    New cluster member is registered
 public  void memberDisappeared(Member member) 
    Cluster member is gone
 public  void receive(ClusterMessage message) 
    notify all listeners from receiving a new message is not ClusterMessage emitt Failure Event to LifecylceListener
 protected  void registerClusterValve() throws Exception 
    register all cluster valve to host or engine
 protected  void registerMBeans() 
    register Means at cluster.
 public  void removeClusterListener(MessageListener listener) 
    remove message listener and deregister Cluster from listener
 public  void removeLifecycleListener(LifecycleListener listener) 
    Remove a lifecycle event listener from this component.
 public  void removeManager(String name,
    Manager manager) 
    remove an application form cluster replication bus
 public  void removeProperty(String key) 
    remove a configured property.
 public  void send(ClusterMessage msg) 
    send message to all cluster members
 public  void send(ClusterMessage msg,
    Member dest) 
    send a cluster message to one member
 public  void sendClusterDomain(ClusterMessage msg) 
    send message to all cluster members same cluster domain
 public  void sendToMember(ClusterMessage msg,
    String dest) 
    send a cluster message to one member (very usefull JMX method for remote scripting)
 public  void setClusterDeployer(ClusterDeployer clusterDeployer) 
 public  void setClusterLogName(String clusterLogName) 
 public  void setClusterName(String clusterName) 
    Set the name of the cluster to join, if no cluster with this name is present create one.
 public  void setClusterReceiver(ClusterReceiver clusterReceiver) 
 public  void setClusterSender(ClusterSender clusterSender) 
 public  void setContainer(Container container) 
    Set the Container associated with our Cluster
 public  void setDefaultMode(boolean defaultMode) 
 public  void setDoClusterLog(boolean doClusterLog) 
 public  void setManagerClassName(String managerClassName) 
 public  void setMembershipService(MembershipService membershipService) 
 public  void setNotifyLifecycleListenerOnFailure(boolean notifyListenerOnFailure) 
 public  void setObjectName(ObjectName name) 
 public  void setProperty(String name,
    String value) 
    JMX hack to direct use at jconsole
 public  void setProperty(String name,
    Object value) 
    set config attributes with reflect and propagate to all managers
 public  void setProtocol(String protocol) 
 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 startContext(String contextPath) throws IOException 
 public  void stop() throws LifecycleException 
    Gracefully terminate the active cluster component.
    This will disconnect the cluster communication channel, stop the listener and deregister the valves from host or engine.

    Note:
    The sub elements receiver, sender, membership, listener or valves are not removed. You can easily start the cluster again.
 public  void stop(String contextPath) throws IOException 
 protected  void transferProperty(String prefix,
    Object bean) 
    transfer properties from cluster configuration to subelement bean.
 protected  void unregisterClusterValve() throws Exception 
    unregister all cluster valve to host or engine
 protected  void unregisterMBeans()