<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
+ <!--
+ <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
+ channelSendOptions="11">
+ <Manager className="org.apache.catalina.ha.session.DeltaManager"
+ expireSessionsOnShutdown="false"
+ notifyListenersOnReplication="true"/>
+
+ <Channel className="org.apache.catalina.tribes.group.GroupChannel">
+ <Membership className="org.apache.catalina.tribes.membership.McastService"
+ address="228.0.0.4"
+ port="45564"
+ frequency="500"
+ dropTime="3000"/>
+ <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
+ address="auto"
+ port="auto"
+ selectorTimeout="100"
+ maxThreads="6"/>
+ <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
+ <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
+ </Sender>
+ <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
+ <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
+ <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
+ </Channel>
+
+ <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
+ filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
+
+ <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
+ tempDir="/tmp/war-temp/"
+ deployDir="/tmp/war-deploy/"
+ watchDir="/tmp/war-listen/"
+ watchEnabled="false"/>
+ <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
+ </Cluster>
+ -->
+
+
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
<!-- Place holder for brief cluster documentation, the rest will be online
-->
- <!--
- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
- channelSendOptions="11">
- <Manager className="org.apache.catalina.ha.session.DeltaManager"
- expireSessionsOnShutdown="false"
- notifyListenersOnReplication="true"/>
-
- <Channel className="org.apache.catalina.tribes.group.GroupChannel">
- <Membership className="org.apache.catalina.tribes.membership.McastService"
- address="228.0.0.4"
- port="45564"
- frequency="500"
- dropTime="3000"/>
- <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
- address="auto"
- port="auto"
- selectorTimeout="100"
- maxThreads="6"/>
-
- <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
- <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
- </Sender>
- <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
- <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
- <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
- </Channel>
-
- <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
- filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
-
- <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
- tempDir="/tmp/war-temp/"
- deployDir="/tmp/war-deploy/"
- watchDir="/tmp/war-listen/"
- watchEnabled="false"/>
-
- <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
- </Cluster>
- -->
-
-
-
<!-- Normally, users must authenticate themselves to each web app
individually. Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
} else {
contextManager = new StandardManager();
}
- } else if ( (getCluster() != null) && distributable) {
+ }
+
+ // Configure default manager if none was specified
+ if (contextManager != null) {
+ setManager(contextManager);
+ }
+
+ if (manager!=null && (getCluster() != null) && distributable) {
//let the cluster know that there is a context that is distributable
//and that it has its own manager
getCluster().registerManager(manager);
}
- // Configure default manager if none was specified
- if (contextManager != null) {
- setManager(contextManager);
- }
// Start manager
if ((manager != null) && (manager instanceof Lifecycle)) {
long t1 = System.currentTimeMillis();
String jvmRoute = getLocalJvmRoute(request);
if (jvmRoute == null) {
- if (log.isWarnEnabled())
- log.warn(sm.getString("jvmRoute.missingJvmRouteAttribute"));
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("jvmRoute.missingJvmRouteAttribute"));
return;
}
handleJvmRoute( request, response,session.getIdInternal(), jvmRoute);
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.IntrospectionUtils;
+import org.apache.catalina.ha.session.ClusterSessionListener;
+import org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor;
+import org.apache.catalina.tribes.group.interceptors.TcpFailureDetector;
+import org.apache.catalina.ha.session.JvmRouteBinderValve;
+import org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener;
/**
* A <b>Cluster </b> implementation using simple multicast. Responsible for
*/
private Map properties = new HashMap();
- private int channelSendOptions =
- Channel.SEND_OPTIONS_ASYNCHRONOUS |
- Channel.SEND_OPTIONS_SYNCHRONIZED_ACK |
- Channel.SEND_OPTIONS_USE_ACK;
+ private int channelSendOptions = Channel.SEND_OPTIONS_ASYNCHRONOUS;
// ------------------------------------------------------------- Properties
* @param valve The new cluster Valve.
*/
public void addValve(Valve valve) {
- if (valve instanceof ClusterValve)
+ if (valve instanceof ClusterValve && (!valves.contains(valve)))
valves.add(valve);
}
log.error("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
manager = new org.apache.catalina.ha.session.DeltaManager();
} finally {
- if(manager != null) registerManager(manager);
+ if ( manager != null && (manager instanceof ClusterManager)) ((ClusterManager)manager).setCluster(this);
}
return manager;
}
Container context = manager.getContainer() ;
if(context != null && context instanceof Context) {
Container host = ((Context)context).getParent();
- if(host != null && host instanceof Host)
- clusterName = host.getName() +"#" + name ;
+ if(host != null && host instanceof Host && clusterName!=null && !(clusterName.indexOf("#")>=0))
+ clusterName = host.getName() +"#" + clusterName ;
}
}
return clusterName;
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, this);
try {
- if ( clusterDeployer != null ) clusterDeployer.setCluster(this);
- this.registerClusterValve();
- if ( channel == null ) channel = new GroupChannel();
+ checkDefaults();
+ registerClusterValve();
channel.addMembershipListener(this);
channel.addChannelListener(this);
channel.start(channel.DEFAULT);
}
}
+ protected void checkDefaults() {
+ if ( clusterListeners.size() == 0 ) {
+ addClusterListener(new JvmRouteSessionIDBinderListener());
+ addClusterListener(new ClusterSessionListener());
+ }
+ if ( valves.size() == 0 ) {
+ addValve(new JvmRouteBinderValve());
+ addValve(new ReplicationValve());
+ }
+ if ( clusterDeployer != null ) clusterDeployer.setCluster(this);
+ if ( channel == null ) channel = new GroupChannel();
+ if ( channel instanceof GroupChannel && !((GroupChannel)channel).getInterceptors().hasNext()) {
+ channel.addInterceptor(new MessageDispatch15Interceptor());
+ channel.addInterceptor(new TcpFailureDetector());
+ }
+ }
+
/**
* register all cluster valve to host or engine
* @throws Exception
</p>
</section>
-<section name="Quick Start">
+<section name="For the impatient">
+ <p>
+ Simply add <source><Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/></source>
+ to your <code><Engine></code> or your <code><Host></code> element to enable clustering.
+ </p>
+ <p>
+ Using the above configuration will enable all to all session replication
+ using the <code>DeltaManager</code> to replicate session deltas.<br/>
+ Here are some of the important default values:<br/>
+ 1. Multicast address is 228.0.0.4<br/>
+ 2. Multicast port is 45564<br/>
+ 3. The IP broadcasted is <code>java.net.InetAddress.getLocalHost().getHostAddress()</code><br/>
+ 4. The TCP port listening for replication messages is the first available server socket in range <code>4000-4100</code><br/>
+ </p>
+</section>
+
+<section name="Cluster Basics">
-<p>To run session replication in your Tomcat 5.5 container, the following steps
+<p>To run session replication in your Tomcat 6.0 container, the following steps
should be completed:</p>
<ul>
<li>All your session attributes must implement <code>java.io.Serializable</code></li>
<a href="balancer-howto.html">Load Balancing</a> chapter.</p>
<p>Note: Remember that your session state is tracked by a cookie, so your URL must look the same from the out
side otherwise, a new session will be created.</p>
-<p>Note: Clustering support currently requires the JDK version 1.4 or later.</p>
+<p>Note: Clustering support currently requires the JDK version 1.5 or later.</p>
</section>
To avoid port conflicts the receiver will automatically bind to a free port within the range of
<code> port <= bindPort <= port+autoBind</code>
So for example, if port is 4000, and autoBind is set to 10, then the receiver will open up
- a server socket on the first available port in the range 4000-4010.
+ a server socket on the first available port in the range 4000-4100.
</attribute>
<attribute name="autoBind" required="false">
Default value is <code>100</code>.