From 3d94fc19193e5bbd29504daba075e52e198bf95d Mon Sep 17 00:00:00 2001 From: fhanik Date: Fri, 13 Oct 2006 18:21:47 +0000 Subject: [PATCH] slow progress, but moving forward with documentation git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@463768 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/ha/ClusterValve.java | 9 ++- .../apache/catalina/ha/tcp/ReplicationValve.java | 16 ++--- webapps/docs/config/cluster-valve.xml | 68 +++++++++++++++------- webapps/docs/config/cluster.xml | 10 ++++ 4 files changed, 72 insertions(+), 31 deletions(-) diff --git a/java/org/apache/catalina/ha/ClusterValve.java b/java/org/apache/catalina/ha/ClusterValve.java index d82f6df89..42c93b7ca 100644 --- a/java/org/apache/catalina/ha/ClusterValve.java +++ b/java/org/apache/catalina/ha/ClusterValve.java @@ -15,13 +15,16 @@ */ 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 diff --git a/java/org/apache/catalina/ha/tcp/ReplicationValve.java b/java/org/apache/catalina/ha/tcp/ReplicationValve.java index 5f5f9ba50..b1acbc964 100644 --- a/java/org/apache/catalina/ha/tcp/ReplicationValve.java +++ b/java/org/apache/catalina/ha/tcp/ReplicationValve.java @@ -212,7 +212,7 @@ public class ReplicationValve /** * Calc processing stats */ - public boolean isDoProcessingStats() { + public boolean doStatistics() { return doProcessingStats; } @@ -220,7 +220,7 @@ public class ReplicationValve * Set Calc processing stats * @see #resetStatistics() */ - public void setDoProcessingStats(boolean doProcessingStats) { + public void setStatistics(boolean doProcessingStats) { this.doProcessingStats = doProcessingStats; } @@ -326,7 +326,7 @@ public class ReplicationValve long totalstart = 0; //this happens before the request - if(isDoProcessingStats()) { + if(doStatistics()) { totalstart = System.currentTimeMillis(); } if (primaryIndicator) { @@ -415,7 +415,7 @@ public class ReplicationValve 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 { @@ -432,7 +432,7 @@ public class ReplicationValve log.error(sm.getString("ReplicationValve.send.failure"), x); } finally { // FIXME this stats update are not cheap!! - if(isDoProcessingStats()) { + if(doStatistics()) { updateStats(totalstart,start); } } @@ -452,7 +452,7 @@ public class ReplicationValve log.debug(sm.getString("ReplicationValve.crossContext.sendDelta", session.getManager().getContainer().getName() )); sendMessage(session,(ClusterManager)session.getManager(),containerCluster); - if(isDoProcessingStats()) { + if(doStatistics()) { nrOfCrossContextSendRequests++; } } @@ -515,7 +515,7 @@ public class ReplicationValve log.debug(sm.getString("ReplicationValve.invoke.uri", uri)); sendMessage(session,manager,cluster); } else - if(isDoProcessingStats()) + if(doStatistics()) nrOfFilterRequests++; } @@ -551,7 +551,7 @@ public class ReplicationValve } else { cluster.send(msg); } - if(isDoProcessingStats()) + if(doStatistics()) nrOfSendRequests++; } } diff --git a/webapps/docs/config/cluster-valve.xml b/webapps/docs/config/cluster-valve.xml index 86e58dd65..76750b696 100644 --- a/webapps/docs/config/cluster-valve.xml +++ b/webapps/docs/config/cluster-valve.xml @@ -8,36 +8,64 @@ Filip Hanik - The Channel object + The Cluster Valve object
- - - +

+ A cluster valve is no different from any other Tomcat Valve. + 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. +

+

+ A cluster valve must implement the org.apache.catalina.ha.ClusterValve interface. + This is a simple interface that extends the org.apache.catalina.Valve interface. +

- -
- - - - - - - - - - - - - +
+ The ReplicationValve 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. + + + + Set value to org.apache.catalina.ha.tcp.ReplicationValve + + + 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 filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;" + The filter uses regular expressions and each filter is delimited by a semi colon. + Pattern#compile(java.lang.String) + + + + + + + Boolean value. Set to true if you want the valve to collect request statistics. + Default value is false + + +
- +
+ In case of a mod_jk failover, the JvmRouteBinderValve will replace the + jvmWorker 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. + + + + + +
diff --git a/webapps/docs/config/cluster.xml b/webapps/docs/config/cluster.xml index 9673fa7f9..5a1622022 100644 --- a/webapps/docs/config/cluster.xml +++ b/webapps/docs/config/cluster.xml @@ -24,6 +24,16 @@ making the configuration seem like a lot, but don't lose faith, instead you have a tremendous control over what is going on.

+
+

+ You can place the <Cluster> element inside either the <Engine> + container or the <Host> container.
+ 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 <Cluster> inside the <Engine> + 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. +

+

To configure context attribute replication, simply do this by swapping out the context implementation used for your application context. -- 2.11.0