slow progress, but moving forward with documentation
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 13 Oct 2006 18:21:47 +0000 (18:21 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 13 Oct 2006 18:21:47 +0000 (18:21 +0000)
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
java/org/apache/catalina/ha/tcp/ReplicationValve.java
webapps/docs/config/cluster-valve.xml
webapps/docs/config/cluster.xml

index d82f6df..42c93b7 100644 (file)
  */
 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
index 5f5f9ba..b1acbc9 100644 (file)
@@ -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++;
         }
     }
index 86e58dd..76750b6 100644 (file)
@@ -8,36 +8,64 @@
 
   <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=&quot;.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;&quot;</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>
 
 
index 9673fa7..5a16220 100644 (file)
   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>&lt;Cluster&gt;</code> element inside either the <code>&lt;Engine&gt;</code>
+   container or the <code>&lt;Host&gt;</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>&lt;Cluster&gt;</code> inside the <code>&lt;Engine&gt;</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.