...
- Ensure that every object placed in the HTTP session implements java.io.Serializable. The clustering feature serializes the objects when it distributes them to the other nodes in the cluster.
- The deployment descriptor for your Web application, that is the
web.xml
file in the Web archive, must indicate that your Web application is distributable. To do this, insert the distributable element in the deployment descriptor.Code Block XML XML borderStyle solid title Excerpt from web.xml borderStyle solid <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name> ... </display-name> <description> ... </description> <distributable> <distributable/> ... </web-app>
...
For every node in the cluster, update config.xml as follows after the server is stopped
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
<gbean name="TomcatEngine"> <attribute name="initParams"> name=geronimo jvmRoute=nodeId </attribute> </gbean> |
...
- Sample geronimo-web.xml for geronimo 2.1.4 and below
Code Block XML XML borderStylesolid title geronimo-web.xml borderStyle solid <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0.1" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"> <dep:environment> <dep:moduleId> <dep:groupId>org.mygroup</dep:groupId> <dep:artifactId>web-cluster-server1</dep:artifactId> <dep:version>2.1.1.2</dep:version> <dep:type>war</dep:type> </dep:moduleId> <dep:dependencies/> <dep:hidden-classes/> <dep:non-overridable-classes/> </dep:environment> <context-root>/servlet-examples-cluster</context-root> <security-realm-name>geronimo-properties-realm</security-realm-name> <security> <default-principal> <principal name="anonymous" class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"/> </default-principal> <role-mappings> <role role-name="tomcat"> <principal name="admin" class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"/> </role> </role-mappings> </security> <cluster>TomcatCluster</cluster> <gbean class="org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean" name="TomcatCluster"> <attribute name="className">org.apache.catalina.ha.tcp.SimpleTcpCluster</attribute> <attribute name="initParams"> managerClassName=org.apache.catalina.ha.session.DeltaManager expireSessionsOnShutdown=false useDirtyFlag=true notifyListenersOnReplication=true </attribute> <reference name="TomcatValveChain"> <name>ReplicationValve</name> </reference> <reference name="ClusterListenerChain"> <name>ClusterSessionListener</name> </reference> <reference name="Channel"> <name>TomcatGroupChannel</name> </reference> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ChannelGBean" name="TomcatGroupChannel"> <attribute name="className">org.apache.catalina.tribes.group.GroupChannel</attribute> <attribute name="initParams"/> <reference name="Membership"> <name>TomcatMembership</name> </reference> <reference name="Receiver"> <name>TomcatReceiver</name> </reference> <reference name="Sender"> <name>TomcatSender</name> </reference> <reference name="ChannelInterceptor"> <name>TomcatChannelInterceptor</name> </reference> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.MembershipServiceGBean" name="TomcatMembership"> <attribute name="className">org.apache.catalina.tribes.membership.McastService</attribute> <attribute name="initParams"> mcastAddr=228.0.0.4 mcastPort=45564 mcastFrequency=500 mcastDropTime=3000 </attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ReceiverGBean" name="TomcatReceiver"> <attribute name="className">org.apache.catalina.tribes.transport.nio.NioReceiver</attribute> <attribute name="initParams"> tcpListenAddress=IPAddressIn tcpListenPort=4001 tcpSelectorTimeout=100 tcpThreadCount=6 </attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.SenderGBean" name="TomcatSender"> <attribute name="className">org.apache.catalina.tribes.transport.ReplicationTransmitter</attribute> <attribute name="initParams"> replicationMode=pooled waitForAck=true </attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.ValveGBean" name="ReplicationValve"> <attribute name="className">org.apache.catalina.ha.tcp.ReplicationValve</attribute> <attribute name="initParams">filter=.*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;</attribute> <reference name="NextValve"> <name>JvmRouteBinderValve</name> </reference> </gbean> <gbean class="org.apache.geronimo.tomcat.ValveGBean" name="JvmRouteBinderValve"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <attribute name="initParams">enabled=true</attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ClusterListenerGBean" name="ClusterSessionListener"> <attribute name="className">org.apache.catalina.ha.session.ClusterSessionListener</attribute> <reference name="NextListener"> <name>JvmRouteSessionIDBinderListener</name> </reference> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ClusterListenerGBean" name="JvmRouteSessionIDBinderListener"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener</attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean" name="TomcatChannelInterceptor"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpFailureDetector</attribute> </gbean> </web-app>
- Sample geronimo-web.xml for geronimo versions above 2.1.4. This does not include g 2.2
After applying fix to 2.1 through GERONIMO-4187 there are some modifications which needs to picked up by your configuration through geronimo-web.xml
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0.1" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"> <dep:environment> <dep:moduleId> <dep:groupId>org.mygroup</dep:groupId> <dep:artifactId>web-cluster-server1</dep:artifactId> <dep:version>2.1.1.2</dep:version> <dep:type>war</dep:type> </dep:moduleId> <dep:dependencies/> <dep:hidden-classes/> <dep:non-overridable-classes/> </dep:environment> <context-root>/servlet-examples-cluster</context-root> <security-realm-name>geronimo-properties-realm</security-realm-name> <security> <default-principal> <principal name="anonymous" class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"/> </default-principal> <role-mappings> <role role-name="tomcat"> <principal name="admin" class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"/> </role> </role-mappings> </security> <cluster>TomcatCluster</cluster> <gbean class="org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean" name="TomcatCluster"> <attribute name="className">org.apache.catalina.ha.tcp.SimpleTcpCluster</attribute> <attribute name="initParams"/> <reference name="TomcatValveChain"> <name>ReplicationValve</name> </reference> <reference name="ClusterListenerChain"> <name>ClusterSessionListener</name> </reference> <reference name="Channel"> <name>TomcatGroupChannel</name> </reference> <reference name="ClusterManager"> <name>TomcatClusterManager</name> </reference> </gbean> <gbean name="TomcatClusterManager" class="org.apache.geronimo.tomcat.cluster.ClusterManagerGBean"> <attribute name="className">org.apache.catalina.ha.session.DeltaManager</attribute> <attribute classname="org.apache.geronimo.tomcat.cluster.ClusterManagerGBean">initParams">name=somename <attribute expireSessionsOnShutdown=false name="className">org.apache.catalina.ha.session.DeltaManager</attribute> <attribute name="initParams">name=somename useDirtyFlag=true expireSessionsOnShutdown=false notifyListenersOnReplication=true useDirtyFlag=true </attribute> notifyListenersOnReplication=true </gbean> </attribute> <gbean class="org.apache.geronimo.tomcat.cluster.ChannelGBean" name="TomcatGroupChannel"> <attribute name="className">org.apache.catalina.tribes.group.GroupChannel</attribute> <attribute name="initParams"/> <reference name="Membership"> <name>TomcatMembership</name> </reference> <reference name="Receiver"> <name>TomcatReceiver</name> </gbean>reference> <reference name="Sender"> <name>TomcatSender</name> </reference> <reference name="ChannelInterceptor"> <name>TomcatChannelInterceptor</name> </reference> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ChannelGBeanMembershipServiceGBean" name="TomcatGroupChannelTomcatMembership"> <attribute name="className">org.apache.catalina.tribes.groupmembership.GroupChannel<McastService</attribute> <attribute name="initParams"/> <reference name="Membership">mcastAddr=228.0.0.4 <name>TomcatMembership</name>mcastPort=45564 </reference> <reference name="Receiver">mcastFrequency=500 <name>TomcatReceiver</name>mcastDropTime=3000 </reference>attribute> </gbean> <reference<gbean class="org.apache.geronimo.tomcat.cluster.ReceiverGBean" name="SenderTomcatReceiver"> <name>TomcatSender</name><attribute name="className">org.apache.catalina.tribes.transport.nio.NioReceiver</attribute> </reference> <reference<attribute name="ChannelInterceptorinitParams"> <name>TomcatChannelInterceptor</name>tcpListenAddress=IPAddressIn tcpListenPort=4001 tcpSelectorTimeout=100 tcpThreadCount=6 </reference>attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.MembershipServiceGBeanSenderGBean" name="TomcatMembershipTomcatSender"> <attribute name="className">org.apache.catalina.tribes.membershiptransport.McastService<ReplicationTransmitter</attribute> <attribute name="initParams"> mcastAddr=228.0.0.4replicationMode=pooled mcastPortwaitForAck=45564true mcastFrequency=500 mcastDropTime=3000 </attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ReceiverGBeanValveGBean" name="TomcatReceiverReplicationValve"> <attribute name="className">org.apache.catalina.tribesha.transporttcp.nio.NioReceiver<ReplicationValve</attribute> <attribute name="initParams">>filter=.*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;</attribute> <reference tcpListenAddress=IPAddressInname="NextValve"> tcpListenPort=4001<name>JvmRouteBinderValve</name> </reference> tcpSelectorTimeout=100</gbean> tcpThreadCount=6 <gbean class="org.apache.geronimo.tomcat.ValveGBean" name="JvmRouteBinderValve"> < <attribute name="className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <attribute name="initParams">enabled=true</attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.SenderGBeanClusterListenerGBean" name="TomcatSenderClusterSessionListener"> <attribute name="className">org.apache.catalina.tribesha.transportsession.ReplicationTransmitter<ClusterSessionListener</attribute> <attribute<reference name="initParamsNextListener"> replicationMode=pooled <name>JvmRouteSessionIDBinderListener</name> waitForAck=true </attribute>reference> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ValveGBeanClusterListenerGBean" name="ReplicationValveJvmRouteSessionIDBinderListener"> <attribute name="className">org.apache.catalina.ha.tcpsession.ReplicationValve<JvmRouteSessionIDBinderListener</attribute> </gbean> <attribute<gbean nameclass="initParams">filter=.*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;</attribute> <reference name="NextValveorg.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean" name="TomcatChannelInterceptor"> <name>JvmRouteBinderValve</name> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpFailureDetector</attribute> </reference>gbean> </gbean> <gbean class="org.apache.geronimo.tomcat.ValveGBean" name="JvmRouteBinderValve"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <attribute name="initParams">enabled=true</attribute> </gbean> <gbean class="web-app> |
where
- web-cluster-server1 should match the WAR file name. It can be different for each node in the cluster.
On each node, deploy your Web application, either via admin console or deploy command, following this syntax:
Panel | ||
---|---|---|
| ||
|
where
- name is replaced with a user name authorized to manage the server. If you omit this option, you will be prompted to enter a user name.
- word is replaced with the password used to authenticate the user. If you omit this option, you will be prompted to enter a password.
- archive is replaced with a file specification to your Web application WAR file.
- plan is replaced with a file specification to your deployment plan.
Note: After server installation, the default user name is initially system, and the default password is manager.
Sample Tomcat clustering with unicast configuration
Static members in a cluster are defined using org.apache.geronimo.tomcat.cluster.StaticMemberGBean
in the deployment plan. You have to specify all static members within the deployment plan to make sure the application is clustered successfully. Refer to the sample code below for an application-scoped unicast clustering configuration on one node. The sample assumes there are only two static members in a cluster environment.
A few notes for better understanding of the sample deployment plan:
- Use
ReceiverGBean
to specify the information of the current node and port number used for communication. - Use
ChannelInterceptorGBeans
to disable the multicast cluster configurations, and specify how the static member are chained together as you can see the configurations ofStaticMember1Interceptor
andStaticMember2Interceptor
. - Use
StaticMemberGBean
to specify the information of the second static member and port number used for communication. - Use
TcpPingInterceptor
to send a ping to another member periodically. You can manage ping interval by setting the interval attibute forTcpPingInterceptor
. It is a good practice to set interval to 240.
To convert this example to a multicast configuration, the DisableMCastInterceptor
, StaticMemberInterceptor
, and StaticMember
definitions should be removed. Also, the value for the address attribute for the ReceiverGBean
definition should be changed to auto.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
... <cluster>TomcatCluster</cluster> <gbean name="TomcatCluster"ClusterListenerGBean" name="ClusterSessionListener"> <attribute name="className">org.apache.catalina.ha.session.ClusterSessionListener</attribute> <reference name="NextListener"> <name>JvmRouteSessionIDBinderListener</name> </reference> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ClusterListenerGBean" name="JvmRouteSessionIDBinderListener"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener</attribute> </gbean> <gbean class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean" name="TomcatChannelInterceptor"CatalinaClusterGBean"> <attribute name="className">org.apache.catalina.tribesha.grouptcp.interceptors.TcpFailureDetector<SimpleTcpCluster</attribute> </gbean> </web-app> |
where
- web-cluster-server1 should match the WAR file name. It can be different for each node in the cluster.
On each node, deploy your Web application, either via admin console or deploy command, following this syntax:
Panel | ||
---|---|---|
| ||
|
where
- name is replaced with a user name authorized to manage the server. If you omit this option, you will be prompted to enter a user name.
- word is replaced with the password used to authenticate the user. If you omit this option, you will be prompted to enter a password.
- archive is replaced with a file specification to your Web application WAR file.
- plan is replaced with a file specification to your deployment plan.
Note: After server installation, the default user name is initially system, and the default password is manager.
Sample Tomcat clustering with unicast configuration
Static members in a cluster are defined using org.apache.geronimo.tomcat.cluster.StaticMemberGBean in the deployment plan. You have to specify all static members within the deployment plan to make sure the application is clustered successfully. Refer to the sample code below for a application-scoped unicast clustering configuration on one node. The sample assumes there are only two static members in a cluster environment.
A few notes for better understanding of the sample deployment plan:
- Use ReceiverGBean to specify the information of the current node and port number used for communication.
- Use ChannelInterceptorGBeans to disable the multicast cluster configurations and specify how the static member are chained together as you can see the configurations of StaticMember1Interceptor and StaticMember2Interceptor.
- Use StaticMemberGBean to specify the information of the second static member and port number used for communication.
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.
Code Block | |
---|---|
XML | XML |
borderStyle | solid |
title | excerpt from geronimo-web.xml | ... <cluster>TomcatCluster</cluster> <attribute name="initParams"/> <reference name="ClusterListenerChain"> <name>TomcatClusterListenerChain</name> </reference> <reference name="TomcatValveChain"> <name>ReplicationValve</name> </reference> <reference name="Channel"> <name>TomcatChannel</name> </reference> <reference name="ClusterManager"> <name>TomcatClusterManager</name> </reference> </gbean> <gbean name="TomcatClusterListenerChain" class="org.apache.geronimo.tomcat.cluster.ClusterListenerGBean"> <attribute name="className">org.apache.catalina.ha.session.ClusterSessionListener</attribute> <attribute name="initParams"/> </gbean> <gbean name="ReplicationValve" class="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<reference name="TomcatCluster" class="org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean"NextValve"> <type>TomcatValve</type> <attribute name="className">org.apache.catalina.ha.tcp.SimpleTcpCluster</attribute> <attribute name="initParams"/> <reference name="ClusterListenerChain"> <name>JvmRouteBinderValve</name> </reference> <name>TomcatClusterListenerChain<</name>gbean> <gbean </reference>name="JvmRouteBinderValve" class="org.apache.geronimo.tomcat.ValveGBean"> <reference<attribute name="TomcatValveChain">className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <name>ReplicationValve</name> <attribute name="initParams">enabled=true</attribute> </reference>gbean> <reference<gbean name="ChannelTomcatClusterManager"> class="org.apache.geronimo.tomcat.cluster.ClusterManagerGBean"> <attribute name="className">org.apache.catalina.ha.session.DeltaManager</attribute> <name>TomcatChannel</name> <attribute name="initParams">name=${clusterName} </reference> <reference name="ClusterManager"> <name>TomcatClusterManager</name>channelSendOptions=6 </reference> </gbean> <gbean name="TomcatClusterListenerChain" class="org.apache.geronimo.tomcat.cluster.ClusterListenerGBean"> expireSessionsOnShutdown=false <attribute name="className">org.apache.catalina.ha.session.ClusterSessionListener</attribute> notifyListenersOnReplication=true <attribute name="initParams"/> mapSendOptions=6 </attribute> </gbean> <gbean name="ReplicationValveTomcatChannel" class="org.apache.geronimo.tomcat.ValveGBeancluster.ChannelGBean"> <attribute name="className">org.apache.catalina.hatribes.tcpgroup.ReplicationValve<GroupChannel</attribute> <attribute name="initParams">.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;</attribute>/> <reference name="NextValveMembership"> <type>TomcatValve</type> <name>JvmRouteBinderValve<<name>ClusterMembership</name> </reference> </gbean> <gbean<reference name="JvmRouteBinderValve" class="org.apache.geronimo.tomcat.ValveGBeanReceiver"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <attribute name="initParams">enabled=true</attribute> <name>ClusterReceiver</name> </gbean> <gbean name="TomcatClusterManager" class="org.apache.geronimo.tomcat.cluster.ClusterManagerGBean"> <attribute name="className">org.apache.catalina.ha.session.DeltaManager</attribute></reference> <attribute<reference name="initParams">name=${clusterName} Sender"> <name>ClusterSender</name> channelSendOptions=6 </reference> expireSessionsOnShutdown=false<reference name="ChannelInterceptor"> notifyListenersOnReplication=true <name>DisableMcastInterceptor</name> mapSendOptions=6 </attribute>reference> </gbean> <gbean name="TomcatChannelClusterMembership" class="org.apache.geronimo.tomcat.cluster.ChannelGBeanMembershipServiceGBean"> <attribute name="className">org.apache.catalina.tribes.groupmembership.GroupChannel<McastService</attribute> <attribute name="initParams"/>>address=228.0.0.4 <reference name="Membership"> <name>ClusterMembership</name> port=45564 </reference> <reference name="Receiver"> <name>ClusterReceiver</name> frequency=500 </reference> <reference name="Sender"> dropTime=3000 </attribute> </gbean> <gbean name="ClusterReceiver" class="org.apache.geronimo.tomcat.cluster.ReceiverGBean"> <name>ClusterSender</name> </reference><attribute name="className">org.apache.catalina.tribes.transport.nio.NioReceiver</attribute> <reference<attribute name="ChannelInterceptorinitParams">>address=IPAddress1 <name>DisableMcastInterceptor</name> </reference>port=TCP_port1 </gbean> <gbean name="ClusterMembership" class="org.apache.geronimo.tomcat.cluster.MembershipServiceGBean"> <attribute name="className">org.apache.catalina.tribes.membership.McastService</attribute> <attribute name="initParams">address=228.0.0.4selectorTimeout=100 portmaxThreads=455646 </attribute> </gbean> <gbean frequency=500name="ClusterSender" class="org.apache.geronimo.tomcat.cluster.SenderGBean"> dropTime=3000 <<attribute name="className">org.apache.catalina.tribes.transport.ReplicationTransmitter</attribute> </gbean> <gbean name="ClusterReceiverDisableMcastInterceptor" class="org.apache.geronimo.tomcat.cluster.ReceiverGBeanChannelInterceptorGBean"> <attribute name="className">org.apache.catalinageronimo.tribestomcat.transportinterceptor.nio.NioReceiver<DisableMcastInterceptor</attribute> <attribute name="initParams">address=IPAddress1/> <reference name="NextInterceptor"> <name>TcpPingInterceptor</name> port=TCP_port1 </reference> </gbean> <gbean selectorTimeout=100name="TcpPingInterceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor</attribute> <attribute name="initParams">Interval=240</attribute> <reference maxThreads=6name="NextInterceptor"> </attribute> </gbean> <name>TcpFailureDetector</name> <gbean name="ClusterSender" class="org.apache.geronimo.tomcat.cluster.SenderGBean"> <attribute name="className">org.apache.catalina.tribes.transport.ReplicationTransmitter</attribute> </reference> </gbean> <gbean name="DisableMcastInterceptorTcpFailureDetector" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.geronimotribes.tomcatgroup.interceptorinterceptors.DisableMcastInterceptor<TcpFailureDetector</attribute> <attribute name="initParams"/> <reference name="NextInterceptor"> <name>TcpPingInterceptor<<name>StaticMember1Interceptor</name> </reference> </gbean> <gbean name="TcpPingInterceptorStaticMember1Interceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor<StaticMembershipInterceptor</attribute> <attribute name="initParams">Interval=240</attribute>> <reference name="NextInterceptorStaticMember"> <name>TcpFailureDetector<<name>StaticMember2</name> </reference> </gbean> <reference name="NextInterceptor"> <gbean name="TcpFailureDetector" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name <name>MessageDispatch15Interceptor</name> </reference> </gbean> <gbean name="MessageDispatch15Interceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpFailureDetector<MessageDispatch15Interceptor</attribute> <attribute name="initParams"/> <reference name="NextInterceptor"> <name>StaticMember1Interceptor<<name>ThroughputInterceptor</name> </reference> </gbean> <gbean name="StaticMember1InterceptorThroughputInterceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor<ThroughputInterceptor</attribute> <attribute name="initParams"/> </gbean> <reference <gbean name="StaticMember"StaticMember2" class="org.apache.geronimo.tomcat.cluster.StaticMemberGBean"> <attribute name="className">org.apache.catalina.tribes.membership.StaticMember</attribute> <name>StaticMember2</name><attribute name="initParams">port=TCP_port2 </reference> <reference name="NextInterceptor">securePort=-1 <name>MessageDispatch15Interceptor</name> host=IPAddress2 </reference> </gbean> <gbean name="MessageDispatch15Interceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor</attribute> domain=test-domain <attribute name="initParams"/> <reference name="NextInterceptor"> UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} <name>ThroughputInterceptor</name> </attribute> </reference> </gbean> <gbean name="ThroughputInterceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor</attribute> <attribute name="initParams"/> </gbean> <gbean name="StaticMember2</gbean> ... |
Where
- IPAddress1 is the IP address or host name of current static member.
- TCP_port1 is the TCP port on the current node to listen for session replication data from other static members.
- IPAddress2 is the IP address or host name of the second static member.
- TCP_port2 is the TCP port on the second static member to listen for session replication data from other static members.
Configuration of unicast clustering with more than two nodes
To set up an application-scoped unicast clustering with more than two nodes, make sure you have defined all the static members in the deployment plan for each server node.
Interceptors can perform actions when a message is sent or received. Use a reference NextInterceptor
in interceptor configurations to chain interceptors together. You can control how the client requests are processed by arranging the order of the interceptor chain. In the following sample code, when the TcpFailureDetector
intercepter catches errors, it calls the next interceptor StaticMember1Interceptor
. The static member referenced inside StaticMember1Interceptor
, static member 2 in this example, will immediately take over the work of the first static member.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
... <gbean name="TcpFailureDetector" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpFailureDetector</attribute> <attribute name="initParams"/> <reference name="NextInterceptor"> <name>StaticMember1Interceptor</name> </reference> </gbean> <gbean name="StaticMember1Interceptor" class="org.apache.geronimo.tomcat.cluster.StaticMemberGBeanChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.membershipgroup.interceptors.StaticMember<StaticMembershipInterceptor</attribute> <attribute name="initParams">port=TCP_port2/> <reference name="StaticMember"> <name>StaticMember2</name> </reference> securePort=-1 <reference name="NextInterceptor"> <name>MessageDispatch15Interceptor</name> host=IPAddress2 domain=test-domain UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} </attribute> </gbean> ... |
Where
- IPAddress1 is the IP address or host name of current static member.
- TCP_port1 is the TCP port on the current node to listen for session replication data from other static members.
- IPAddress2 is the IP address or host name of the second static member.
- TCP_port2 is the TCP port on the second static member to listen for session replication data from other static members
Configuration for unicast clustering with more than two nodes
To set up an application-scoped unicast clustering with more than two nodes, make sure you have defined all the static members in the deployment plan for each server node.
Interceptors can perform actions when a message is sent or received. Use a reference NextInterceptor in interceptor configurations to chain interceptors together. You can control how the client requests are processed by arranging the order of the interceptor chain. In the following sample code, when the TcpFailureDetector intercepter catches errors, it calls the next interceptor StaticMember1Interceptor. The static member referenced inside StaticMember1Interceptor, static member 2 in this example, will immediately take over the work of the first static member.
</reference>
</gbean>
...
|
All the static members involved should be defined in the deployment plan as well as the relationship between these static members. Use a reference NextStaticMember
in the definition of each static member, except for the last one, to chain static members together. When static member 2 in this example fails to take over the work, static member 3 will immediately take over the work. It is the same for longer static member chain. When a static member fails to take over the work of the previous static member, it calls the next static member in the chain. The request is passed along until a static member can handle the work or it gets to the end.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Code Block | ||||||||
XML | XML | |||||||
borderStyle | solid | |||||||
title | interceptor chain | ... <gbean name="TcpFailureDetectorStaticMember2" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBeanStaticMemberGBean"> <attribute name="className">org.apache.catalina.tribes.groupmembership.interceptors.TcpFailureDetector<StaticMember</attribute> <attribute name="initParams"/> >port=TCP_port2 <reference name="NextInterceptor"> <name>StaticMember1Interceptor</name> </reference> </gbean> <gbean name="StaticMember1Interceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor</attribute> <attribute name="initParams"/> <reference name="StaticMember"> <name>StaticMember2</name> </reference> <reference name="NextInterceptor"> <name>MessageDispatch15Interceptor</name> </reference> </gbean> ... securePort=-1 host=IPAddress2 domain=test-domain UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} </attribute> <reference name="NextStaticMember"> <name>StaticMember3</name> </reference> </gbean> ... |
See the following deployment plan snippet as a complete example of setting up application-scoped unicast clustering with more than two nodesAll the static members involved should be defined in the deployment plan as well as the relationship between these static members. Use a reference NextStaticMember in the definition of each static member, except for the last one, to chain static members together. When static member 2 in this example fails to take over the work, static member 3 will immediately take over the work. It is the same for longer static member chain. When a static member fails to take over the work of the previous static member, it calls the next static member in the chain, until a static member can handle the work or it gets to the end.
Code Block | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
... <cluster>TomcatCluster</cluster> <gbean name="TomcatCluster" class="org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean"> <attribute name="className">org.apache.catalina.ha.tcp.SimpleTcpCluster</attribute> <attribute name="initParams">managerClassName=org.apache.catalina.ha.session.DeltaManager expireSessionsOnShutdown=false useDirtyFlag=true notifyListenersOnReplication=true </attribute> <reference name="ClusterListenerChain"> <name>TomcatClusterListenerChain</name> </reference> <reference name="TomcatValveChain"> <name>ReplicationValve</name> </reference> <reference name="Channel"> <name>TomcatChannel</name> </reference> </gbean> <gbean name="TomcatClusterListenerChain ... <gbean name="StaticMember2" class="org.apache.geronimo.tomcat.cluster.StaticMemberGBeanClusterListenerGBean"> <attribute name="className">org.apache.catalina.tribesha.membershipsession.StaticMember<ClusterSessionListener</attribute> <attribute name="initParams">port=TCP_port2 /> securePort=-1 </gbean> host=IPAddress2 <gbean domain=test-domain UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} </attribute> name="ReplicationValve" class="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> <reference name="NextStaticMemberNextValve"> <type>TomcatValve</type> <name>StaticMember3</name> <name>JvmRouteBinderValve</name> </reference> </gbean> <gbean name="JvmRouteBinderValve" class="org.apache.geronimo.tomcat. |
See the following deployment plan snippet as an complete example of setting up application-scoped unicast clustering with more than two nodes.
Code Block | |
---|---|
XML | XML |
borderStyle | solid |
title | excerpt from geronimo-web.xml | ... <cluster>TomcatCluster</cluster>ValveGBean"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <attribute name="initParams">enabled=true</attribute> </gbean> <gbean name="TomcatClusterTomcatChannel" class="org.apache.geronimo.tomcat.cluster.CatalinaClusterGBeanChannelGBean"> <attribute name="className">org.apache.catalina.hatribes.tcpgroup.SimpleTcpCluster<GroupChannel</attribute> <attribute name="initParams">managerClassName=org.apache.catalina.ha.session.DeltaManager/> <reference expireSessionsOnShutdown=falsename="Membership"> useDirtyFlag=true <name>ClusterMembership</name> notifyListenersOnReplication=true </attribute>reference> <reference name="ClusterListenerChainReceiver"> <name>TomcatClusterListenerChain< <name>ClusterReceiver</name> </reference> <reference name="TomcatValveChainSender"> <name>ReplicationValve< <name>ClusterSender</name> </reference> <reference name="ChannelChannelInterceptor"> <name>TomcatChannel< <name>DisableMcastInterceptor</name> </reference> </gbean> <gbean name="TomcatClusterListenerChainClusterMembership" class="org.apache.geronimo.tomcat.cluster.ClusterListenerGBeanMembershipServiceGBean"> <attribute name="className">org.apache.catalina.hatribes.sessionmembership.ClusterSessionListener<McastService</attribute> <attribute name="initParams"/> </gbean> <gbean name="ReplicationValve" class="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> <reference name="NextValve"> <type>TomcatValve</type> <name>JvmRouteBinderValve</name> </reference> </gbean> <gbean name="JvmRouteBinderValve" class="org.apache.geronimo.tomcat.ValveGBean"> <attribute name="className">org.apache.catalina.ha.session.JvmRouteBinderValve</attribute> <attribute name="initParams">enabled=true<>address=228.0.0.4 port=45564 frequency=500 dropTime=3000 </attribute> </gbean> <gbean name="TomcatChannelClusterReceiver" class="org.apache.geronimo.tomcat.cluster.ChannelGBeanReceiverGBean"> <attribute name="className">org.apache.catalina.tribes.transport.groupnio.GroupChannel<NioReceiver</attribute> <attribute name="initParams"/>>address=IPAddress1 <reference name="Membership"> <name>ClusterMembership</name> </reference> <reference name="Receiver"> <name>ClusterReceiver</name> </reference> <reference name="Sender"> <name>ClusterSender</name> </reference> <reference name="ChannelInterceptor"> <name>DisableMcastInterceptor</name> </reference> port=TCP_port1 selectorTimeout=100 maxThreads=6 </attribute> </gbean> <gbean name="ClusterMembershipClusterSender" class="org.apache.geronimo.tomcat.cluster.MembershipServiceGBeanSenderGBean"> <attribute name="className">org.apache.catalina.tribes.membershiptransport.McastService<ReplicationTransmitter</attribute> <attribute name="initParams">address=228.0.0.4 port=45564 frequency=500 dropTime=3000 </attribute> </gbean> </gbean> <gbean name="ClusterReceiverDisableMcastInterceptor" class="org.apache.geronimo.tomcat.cluster.ReceiverGBeanChannelInterceptorGBean"> <attribute name="className">org.apache.catalinageronimo.tribestomcat.transportinterceptor.nio.NioReceiver<DisableMcastInterceptor</attribute> <attribute name="initParams">address=IPAddress1/> port=10200 selectorTimeout=100 <reference maxThreads=6name="NextInterceptor"> </attribute> </gbean> <gbean name="ClusterSender" class="org.apache.geronimo.tomcat.cluster.SenderGBean"> <name>TcpPingInterceptor</name> <attribute name="className">org.apache.catalina.tribes.transport.ReplicationTransmitter</attribute> </reference> </gbean> <gbean name="DisableMcastInterceptorTcpPingInterceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.geronimocatalina.tribes.tomcatgroup.interceptorinterceptors.DisableMcastInterceptor<TcpPingInterceptor</attribute> <attribute name="initParams">Interval=240</>attribute> <reference name="NextInterceptor"> <name>TcpPingInterceptor< <name>TcpFailureDetector</name> </reference> </gbean> <gbean name="TcpPingInterceptorTcpFailureDetector" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor<TcpFailureDetector</attribute> <attribute name="initParams">Interval=240</attribute>> <reference name="NextInterceptor"> <name>TcpFailureDetector< <name>StaticMember1Interceptor</name> </reference> </gbean> <gbean name="TcpFailureDetectorStaticMember1Interceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.TcpFailureDetector</attribute>.group.interceptors.StaticMembershipInterceptor</attribute> <attribute name="initParams"/> <reference name="StaticMember"> <name>StaticMember2</name> <attribute name="initParams"/> </reference> <reference name="NextInterceptor"> <name>StaticMember1Interceptor< <name>MessageDispatch15Interceptor</name> </reference> </gbean> <gbean name="StaticMember1InterceptorMessageDispatch15Interceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor<MessageDispatch15Interceptor</attribute> <attribute name="initParams"/> <reference name="StaticMemberNextInterceptor"> <name>StaticMember2</name> </reference> <reference name="NextInterceptor"> <name>MessageDispatch15Interceptor<<name>ThroughputInterceptor</name> </reference> </gbean> <gbean name="MessageDispatch15InterceptorThroughputInterceptor" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor<ThroughputInterceptor</attribute> <attribute name="initParams"/> <reference name="NextInterceptor"> <name>ThroughputInterceptor</name> </reference><attribute name="initParams"/> </gbean> <gbean name="ThroughputInterceptorStaticMember2" class="org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBeanStaticMemberGBean"> <attribute name="className">org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor</attribute> <attribute name="initParams"/> </gbean> <gbean name="StaticMember2" class="org.apache.geronimo.tomcat.cluster.StaticMemberGBean"> <attribute name="className">org.apache.catalina.tribes.membership.StaticMember</attribute> <attribute name="initParams">port=TCP_port2 securePort=-1 host=IPAddress2 domain=test-domain membership.StaticMember</attribute> <attribute name="initParams">port=TCP_port2 securePort=-1 host=IPAddress2 domain=test-domain UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} </attribute> <reference name="NextStaticMember"> <name>StaticMember3</name> </reference> </gbean> <gbean name="StaticMember3" class="org.apache.geronimo.tomcat.cluster.StaticMemberGBean"> <attribute name="className">org.apache.catalina.tribes.membership.StaticMember</attribute> <attribute name="initParams">port=TCP_port3 securePort=-1 host=IPAddress3 domain=test-domain UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} </attribute> </gbean> ... |
Where
- IPAddress1 is the IP address or host name of current static member.
- TCP_port1 is the TCP port on the current node to listen for session replication data from other static members.
- IPAddress2 is the IP address or host name of the second static member.
- TCP_port2 is the TCP port on the second static member to listen for session replication data from other static members.
- IPAddress3 is the IP address or host name of the third static member.
- TCP_port3 is the TCP port on the third static member to listen for session replication data from other static members.