*/
package org.apache.catalina.ha;
+import org.apache.catalina.Valve;
+
/**
- * Cluster Valve Interface to mark all Cluster Valves
- * Only those Valve can'be configured as Cluster Valves
+ * Cluster valves are a simple extension to the Tomcat valve architecture
+ * with a small addition of being able to reference the cluster component in the container it sits in.
+ * @author Filip Hanik
* @author Peter Rossbach
* @version $Revision: 303842 $, $Date: 2005-04-10 11:20:46 -0500 (Sun, 10 Apr 2005) $
*/
-public interface ClusterValve {
+public interface ClusterValve extends Valve{
/**
* Returns the cluster the cluster deployer is associated with
* @return CatalinaCluster
/**
* Calc processing stats
*/
- public boolean isDoProcessingStats() {
+ public boolean doStatistics() {
return doProcessingStats;
}
* Set Calc processing stats
* @see #resetStatistics()
*/
- public void setDoProcessingStats(boolean doProcessingStats) {
+ public void setStatistics(boolean doProcessingStats) {
this.doProcessingStats = doProcessingStats;
}
long totalstart = 0;
//this happens before the request
- if(isDoProcessingStats()) {
+ if(doStatistics()) {
totalstart = System.currentTimeMillis();
}
if (primaryIndicator) {
protected void sendReplicationMessage(Request request, long totalstart, boolean isCrossContext, ClusterManager clusterManager, CatalinaCluster containerCluster) {
//this happens after the request
long start = 0;
- if(isDoProcessingStats()) {
+ if(doStatistics()) {
start = System.currentTimeMillis();
}
try {
log.error(sm.getString("ReplicationValve.send.failure"), x);
} finally {
// FIXME this stats update are not cheap!!
- if(isDoProcessingStats()) {
+ if(doStatistics()) {
updateStats(totalstart,start);
}
}
log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",
session.getManager().getContainer().getName() ));
sendMessage(session,(ClusterManager)session.getManager(),containerCluster);
- if(isDoProcessingStats()) {
+ if(doStatistics()) {
nrOfCrossContextSendRequests++;
}
}
log.debug(sm.getString("ReplicationValve.invoke.uri", uri));
sendMessage(session,manager,cluster);
} else
- if(isDoProcessingStats())
+ if(doStatistics())
nrOfFilterRequests++;
}
} else {
cluster.send(msg);
}
- if(isDoProcessingStats())
+ if(doStatistics())
nrOfSendRequests++;
}
}
<properties>
<author email="fhanik@apache.org">Filip Hanik</author>
- <title>The Channel object</title>
+ <title>The Cluster Valve object</title>
</properties>
<body>
<section name="Introduction">
-
-
-
+ <p>
+ A cluster valve is no different from any other <a href="valve.html">Tomcat <code>Valve</code></a>.
+ The cluster valves are interceptors in the invokation chain for HTTP requests, and the clustering implementation
+ uses these valves to make intelligent decision around data and when data should be replicated.
+ </p>
+ <p>
+ A cluster valve must implement the <code>org.apache.catalina.ha.ClusterValve</code> interface.
+ This is a simple interface that extends the <code>org.apache.catalina.Valve</code> interface.
+ </p>
</section>
-
-<section name="Attributes">
-
- <subsection name="Common Attributes">
-
- <attributes>
-
- <attribute name="className" required="true">
-
- </attribute>
-
-
- </attributes>
-
-
+<section name="org.apache.catalina.ha.tcp.ReplicationValve">
+ The <code>ReplicationValve</code> will notify the cluster at the end of a HTTP request
+ so that the cluster can make a decision whether there is data to be replicated or not.
+ <subsection name="Attributes">
+ <attributes>
+ <attribute name="className" required="true">
+ Set value to <code>org.apache.catalina.ha.tcp.ReplicationValve</code>
+ </attribute>
+ <attribute name="filter" required="false">
+ For known file extensions or urls, you can use a filter to
+ notify the cluster that the session has not been modified during this
+ request and the cluster doesn't have to probe the session managers for changes.
+ If there is a filter match, the cluster assumes there has been no session change.
+ An example filter would look like <code>filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"</code>
+ The filter uses regular expressions and each filter is delimited by a semi colon.
+ <code>Pattern#compile(java.lang.String)</code>
+ </attribute>
+ <attribute name="className" required="false">
+ </attribute>
+ <attribute name="className" required="false">
+ </attribute>
+ <attribute name="statistics" required="false">
+ Boolean value. Set to <code>true</code> if you want the valve to collect request statistics.
+ Default value is <code>false</code>
+ </attribute>
+ </attributes>
</subsection>
+</section>
-
+<section name="org.apache.catalina.ha.session.JvmRouteBinderValve">
+ In case of a mod_jk failover, the <code>JvmRouteBinderValve</code> will replace the
+ <code>jvmWorker</code> attribute in the session Id, to make future requests stick to this
+ node. If you want failback capability, don't enable this valve, but if you want your failover to stick,
+ and for mod_jk not to have to keep probing the node that went down, you use this valve.
+ <subsection name="Attributes">
+ <attributes>
+ <attribute name="className" required="true">
+ </attribute>
+ </attributes>
+ </subsection>
</section>
making the configuration seem like a lot, but don't lose faith, instead you have a tremendous control
over what is going on.</p>
</section>
+<section name="Engine vs Host placement">
+ <p>
+ You can place the <code><Cluster></code> element inside either the <code><Engine></code>
+ container or the <code><Host></code> container.<br/>
+ Placing it in the engine, means that you will support clustering in all virtual hosts of Tomcat,
+ and share the messaging component. When you place the <code><Cluster></code> inside the <code><Engine></code>
+ element, the cluster will append the host name of each session manager to the managers name so that two contexts with
+ the same name but sitting inside two different hosts will be distinguishable.
+ </p>
+</section>
<section name="Context Attribute Replication">
<p>To configure context attribute replication, simply do this by swapping out the context implementation
used for your application context.