Tomcat Native Clustering has been created by Jason Warner (Sep 11, 2008).

Content:

Introduction

The tomcat web container provides a native clustering solution that can be configured through geronimo using gbean definitions within config.xml. This document will go through the available gbeans and how to configure them for clustering in a geronimo server with a tomcat web container. Details about each component of the cluster and configuration options can be found in the tomcat documentation here http://tomcat.apache.org/tomcat-6.0-doc/config/cluster.html

Cluster Configuration Elements

  • Cluster
    • ClusterListenerChain
    • TomcatValveChain
    • Channel
      • Membership
      • Receiver
      • Sender
      • ChannelInterceptor
        • StaticMember
    • ClusterManager

Sample Clustering Configuration

The following is a clustering example that uses a unicast configuration. Two static members are defined. To convert this example to a multicast configuration the DisableMCastInterceptor, StaticMemberInterceptor, and StaticMember definitions need to be removed. Also, the value for the "address" attribute for the TomcatReceiver definition should be changed to "auto".

<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=Cluster,name=TomcatCluster" 
       gbeanInfo="org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean">
    <attribute name="className">org.apache.catalina.ha.tcp.SimpleTcpCluster</attribute>
    <attribute name="initParams"/>
    <reference name="ClusterListenerChain">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>TomcatClusterListenerChain</name>
        </pattern>
    </reference>
    <reference name="TomcatValveChain">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>ReplicationValve</name>
        </pattern>
    </reference>
    <reference name="Channel">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>TomcatChannel</name>
        </pattern>
    </reference>
    <reference name="ClusterManager">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>TomcatClusterManager</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ClusterListener,name=TomcatClusterListenerChain"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ClusterListenerGBean">
    <attribute name="className">org.apache.catalina.ha.session.ClusterSessionListener</attribute>
    <attribute name="initParams"/>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=TomcatValve,name=ReplicationValve"
       gbeanInfo="org.apache.geronimo.tomcat.ValveGBean">
    <attribute name="className">org.apache.catalina.ha.tcp.ReplicationValve</attribute>
    <attribute name="initParams">.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;</attribute>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ClusterManager,name=TomcatClusterManager"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ClusterManagerGBean">
    <attribute name="className">org.apache.catalina.ha.session.DeltaManager</attribute>
    <attribute name="initParams">name=${clusterName}
        channelSendOptions=6
        expireSessionsOnShutdown=false
        notifyListenersOnReplication=true
        mapSendOptions=6</attribute>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=Channel,name=TomcatChannel"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelGBean">
    <attribute name="className">org.apache.catalina.tribes.group.GroupChannel</attribute>
    <attribute name="initParams"/>
    <reference name="Membership">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>ClusterMembership</name>
        </pattern>
    </reference>
    <reference name="Receiver">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>ClusterReceiver</name>
        </pattern>
    </reference>
    <reference name="Sender">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>ClusterSender</name>
        </pattern>
    </reference>
    <reference name="ChannelInterceptor">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>DisableMcastInterceptor</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=MembershipService,name=ClusterMembership"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.MembershipServiceGBean">
    <attribute name="className">org.apache.catalina.tribes.membership.McastService</attribute>
    <attribute name="initParams">address=228.0.0.4
        port=45564
        frequency=500
        dropTime=3000</attribute>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=Receiver,name=ClusterReceiver"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ReceiverGBean">
    <attribute name="className">org.apache.catalina.tribes.transport.nio.NioReceiver</attribute>
    <attribute name="initParams">address=localhost
        port=5000
        selectorTimeout=100
        maxThreads=6</attribute>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=Sender,name=ClusterSender"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.SenderGBean">
    <attribute name="className">org.apache.catalina.tribes.transport.ReplicationTransmitter</attribute>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ChannelInterceptor,name=DisableMcastInterceptor"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean">
    <attribute name="className">org.apache.geronimo.tomcat.interceptor.DisableMcastInterceptor</attribute>
    <attribute name="initParams"/>
    <reference name="NextInterceptor">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>TcpPingInterceptor</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ChannelInterceptor,name=TcpPingInterceptor"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean">
    <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor</attribute>
    <attribute name="initParams">Interval=60</attribute>
    <reference name="NextInterceptor">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>TcpFailureDetector</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ChannelInterceptor,name=TcpFailureDetector"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean">
    <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpFailureDetector</attribute>
    <attribute name="initParams"/>
    <reference name="NextInterceptor">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>StaticMember1Interceptor</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ChannelInterceptor,name=StaticMember1Interceptor"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean">
    <attribute name="className">org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor</attribute>
    <attribute name="initParams"/>
    <reference name="StaticMember">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>StaticMember1</name>
        </pattern>
    </reference>
    <reference name="NextInterceptor">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>MessageDispatch15Interceptor</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ChannelInterceptor,name=MessageDispatch15Interceptor"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean">
    <attribute name="className">org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor</attribute>
    <attribute name="initParams"/>
    <reference name="NextInterceptor">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>ThroughputInterceptor</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=ChannelInterceptor,name=ThroughputInterceptor"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean">
    <attribute name="className">org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor</attribute>
    <attribute name="initParams"/>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=StaticMember,name=StaticMember1"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.StaticMemberGBean">
    <attribute name="className">org.apache.catalina.tribes.membership.StaticMember</attribute>
    <attribute name="initParams">port=5001
        securePort=-1
        host=localhost
        domain=test-domain
        UniqueId={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}</attribute>
    <reference name="NextStaticMember">
        <pattern>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>tomcat6</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>car</type>
            <name>StaticMember2</name>
        </pattern>
    </reference>
</gbean>
<gbean name="org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2-SNAPSHOT/car,j2eeType=StaticMember,name=StaticMember2"
       gbeanInfo="org.apache.geronimo.tomcat.cluster.StaticMemberGBean">
    <attribute name="className">org.apache.catalina.tribes.membership.StaticMember</attribute>
    <attribute name="initParams">port=5002
        securePort=-1
        host=localhost
        domain=test-domain
        UniqueId={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}</attribute>
</gbean>

Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences