tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r380229 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/startup/ modules/cluster/src/share/org/apache/catalina/cluster/ modules/cluster/src/share/org/apache/catalina/cluster/deploy/ modules/cluster/src/share/org/apach...
Date Thu, 23 Feb 2006 21:28:33 GMT
Author: fhanik
Date: Thu Feb 23 13:28:29 2006
New Revision: 380229

URL: http://svn.apache.org/viewcvs?rev=380229&view=rev
Log:
Rollback to before the 5.5.x refactoring began. Changes prior to revision 377402 (the one I rolled back to) contains useful bug fixes for 5.5.16


Added:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSetFactory.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterRuleSet.java
      - copied, changed from r379923, tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java
      - copied unchanged from r377407, tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java
      - copied, changed from r379923, tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java
Removed:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ChannelException.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterChannel.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterListener.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/
Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/Catalina.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterMessage.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterReceiver.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MembershipService.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/ObjectReader.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterSessionListener.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicationStream.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterData.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/Catalina.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/Catalina.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/Catalina.java (original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/Catalina.java Thu Feb 23 13:28:29 2006
@@ -322,13 +322,13 @@
         digester.addRuleSet(new EngineRuleSet("Server/Service/"));
         digester.addRuleSet(new HostRuleSet("Server/Service/Engine/"));
         digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/"));
-        digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Host/Cluster/"));
+        digester.addRuleSet(ClusterRuleSetFactory.getClusterRuleSet("Server/Service/Engine/Host/Cluster/"));
         digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/"));
 
         // When the 'engine' is found, set the parentClassLoader.
         digester.addRule("Server/Service/Engine",
                          new SetParentClassLoaderRule(parentClassLoader));
-        digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Cluster/"));
+        digester.addRuleSet(ClusterRuleSetFactory.getClusterRuleSet("Server/Service/Engine/Cluster/"));
 
         long t2=System.currentTimeMillis();
         if (log.isDebugEnabled())

Added: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSetFactory.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSetFactory.java?rev=380229&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSetFactory.java (added)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSetFactory.java Thu Feb 23 13:28:29 2006
@@ -0,0 +1,182 @@
+/*
+ * Copyright 1999-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.catalina.startup;
+
+
+import org.apache.tomcat.util.digester.Digester;
+import org.apache.tomcat.util.digester.RuleSetBase;
+import java.lang.reflect.Constructor;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import java.lang.reflect.InvocationTargetException;
+public class ClusterRuleSetFactory {
+    
+    public static Log log = LogFactory.getLog(ClusterRuleSetFactory.class);
+    
+    public static RuleSetBase getClusterRuleSet(String prefix) {
+        //first try the same classloader as this class server/lib
+        try {
+            return loadRuleSet(prefix,ClusterRuleSetFactory.class.getClassLoader());
+        } catch ( Exception x ) {
+            //display warning
+            if ( log.isWarnEnabled() ) log.warn("Unable to load ClusterRuleSet, falling back on context classloader",x);
+        }
+        //try to load it from the context class loader
+        try {
+            return loadRuleSet(prefix,Thread.currentThread().getContextClassLoader());
+        } catch ( Exception x ) {
+            //display warning
+            if ( log.isWarnEnabled() ) log.warn("Unable to load ClusterRuleSet, falling back on DefaultClusterRuleSet",x);
+        }
+        return new DefaultClusterRuleSet(prefix);
+    }
+    
+    
+    protected static RuleSetBase loadRuleSet(String prefix, ClassLoader cl) 
+        throws ClassNotFoundException, InstantiationException, 
+               NoSuchMethodException,IllegalAccessException,
+               InvocationTargetException {
+        Class clazz = Class.forName("org.apache.catalina.cluster.ClusterRuleSet",true,cl);
+        Constructor cons = clazz.getConstructor(new Class[] {String.class});
+        return (RuleSetBase)cons.newInstance(new String[] {prefix});
+    }
+    
+    /**
+     * <p><strong>RuleSet</strong> for processing the contents of a
+     * Cluster definition element.  </p>
+     *
+     * @author Filip Hanik
+     * @author Peter Rossbach
+     * @version $Revision: 379550 $ $Date: 2006-02-21 12:06:35 -0600 (Tue, 21 Feb 2006) $
+     */
+
+    public static class DefaultClusterRuleSet extends RuleSetBase {
+
+
+        // ----------------------------------------------------- Instance Variables
+
+
+        /**
+         * The matching pattern prefix to use for recognizing our elements.
+         */
+        protected String prefix = null;
+
+
+        // ------------------------------------------------------------ Constructor
+
+
+        /**
+         * Construct an instance of this <code>RuleSet</code> with the default
+         * matching pattern prefix.
+         */
+        public DefaultClusterRuleSet() {
+
+            this("");
+
+        }
+
+
+        /**
+         * Construct an instance of this <code>RuleSet</code> with the specified
+         * matching pattern prefix.
+         *
+         * @param prefix Prefix for matching pattern rules (including the
+         *  trailing slash character)
+         */
+        public DefaultClusterRuleSet(String prefix) {
+            super();
+            this.namespaceURI = null;
+            this.prefix = prefix;
+        }
+
+
+        // --------------------------------------------------------- Public Methods
+
+
+        /**
+         * <p>Add the set of Rule instances defined in this RuleSet to the
+         * specified <code>Digester</code> instance, associating them with
+         * our namespace URI (if any).  This method should only be called
+         * by a Digester instance.</p>
+         *
+         * @param digester Digester instance to which the new Rule instances
+         *  should be added.
+         */
+        public void addRuleInstances(Digester digester) {
+            //Cluster configuration start
+            digester.addObjectCreate(prefix + "Membership",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Membership");
+            digester.addSetNext(prefix + "Membership",
+                                "setMembershipService",
+                                "org.apache.catalina.cluster.MembershipService");
+
+            digester.addObjectCreate(prefix + "Sender",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Sender");
+            digester.addSetNext(prefix + "Sender",
+                                "setClusterSender",
+                                "org.apache.catalina.cluster.ClusterSender");
+
+            digester.addObjectCreate(prefix + "Receiver",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Receiver");
+            digester.addSetNext(prefix + "Receiver",
+                                "setClusterReceiver",
+                                "org.apache.catalina.cluster.ClusterReceiver");
+
+            digester.addObjectCreate(prefix + "Valve",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Valve");
+            digester.addSetNext(prefix + "Valve",
+                                "addValve",
+                                "org.apache.catalina.Valve");
+
+            digester.addObjectCreate(prefix + "Deployer",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Deployer");
+            digester.addSetNext(prefix + "Deployer",
+                                "setClusterDeployer",
+                                "org.apache.catalina.cluster.ClusterDeployer");
+
+            digester.addObjectCreate(prefix + "Listener",
+                    null, // MUST be specified in the element
+                    "className");
+            digester.addSetProperties(prefix + "Listener");
+            digester.addSetNext(prefix + "Listener",
+                                "addLifecycleListener",
+                                "org.apache.catalina.LifecycleListener");
+
+            digester.addObjectCreate(prefix + "ClusterListener",
+                    null, // MUST be specified in the element
+                    "className");
+            digester.addSetProperties(prefix + "ClusterListener");
+            digester.addSetNext(prefix + "ClusterListener",
+                                "addClusterListener",
+                                "org.apache.catalina.cluster.MessageListener");
+            //Cluster configuration end
+        }
+
+
+    }
+}

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java Thu Feb 23 13:28:29 2006
@@ -23,8 +23,6 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.commons.logging.Log;
-import org.apache.catalina.cluster.tcp.ClusterReceiverBase;
-
 
 /**
  * A <b>CatalinaCluster</b> interface allows to plug in and out the 
@@ -112,9 +110,9 @@
     
     public ClusterSender getClusterSender();
     
-    public void setClusterReceiver(ClusterReceiverBase receiver);
+    public void setClusterReceiver(ClusterReceiver receiver);
     
-    public ClusterReceiverBase getClusterReceiver();
+    public ClusterReceiver getClusterReceiver();
     
     public void setMembershipService(MembershipService service);
     
@@ -122,9 +120,9 @@
     
     public void addValve(Valve valve);
     
-    public void addClusterListener(ClusterListener listener);
+    public void addClusterListener(MessageListener listener);
     
-    public void removeClusterListener(ClusterListener listener);
+    public void removeClusterListener(MessageListener listener);
     
     public void setClusterDeployer(ClusterDeployer deployer);
     

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java Thu Feb 23 13:28:29 2006
@@ -103,17 +103,4 @@
      * call from container Background Process
      */
     public void backgroundProcess();
-    
-    /**
-     * Returns the cluster the cluster deployer is associated with
-     * @return CatalinaCluster
-     */
-    public CatalinaCluster getCluster();
-
-    /**
-     * Associates the cluster deployer with a cluster
-     * @param cluster CatalinaCluster
-     */
-    public void setCluster(CatalinaCluster cluster);
-
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterMessage.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterMessage.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterMessage.java Thu Feb 23 13:28:29 2006
@@ -18,9 +18,7 @@
 import java.io.Serializable;
 
 /**
- * @author Filip Hanik
  * @author Peter Rossbach
- * 
  */
 public interface ClusterMessage extends Serializable {
     

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterReceiver.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterReceiver.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterReceiver.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterReceiver.java Thu Feb 23 13:28:29 2006
@@ -35,7 +35,25 @@
      */
     public void stop();
 
+    /**
+     * set callback.
+     *
+     * @param cluster The cluster
+     */
+    public void setCatalinaCluster(CatalinaCluster cluster);
+    
+    /**
+     * get Callback.
+     *
+     * @return The cluster
+     */
+    public CatalinaCluster getCatalinaCluster();
     
+    /**
+     * Send Ack to sender or not.
+     *
+     * @return The flag value
+     */
     public boolean isSendAck();
     
     /**
@@ -59,8 +77,5 @@
      * @return The port
      */
     public int getPort();
-    
-    public void setMessageListener(MessageListener listener);
-    public MessageListener getMessageListener();
 
 }

Copied: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterRuleSet.java (from r379923, tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java)
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterRuleSet.java?p2=tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterRuleSet.java&p1=tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java&r1=379923&r2=380229&rev=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterRuleSet.java Thu Feb 23 13:28:29 2006
@@ -15,7 +15,7 @@
  */
 
 
-package org.apache.catalina.startup;
+package org.apache.catalina.cluster;
 
 
 import org.apache.tomcat.util.digester.Digester;
@@ -92,7 +92,7 @@
         digester.addSetNext(prefix + "Membership",
                             "setMembershipService",
                             "org.apache.catalina.cluster.MembershipService");
-        
+
         digester.addObjectCreate(prefix + "Sender",
                                  null, // MUST be specified in the element
                                  "className");
@@ -107,7 +107,7 @@
         digester.addSetProperties(prefix + "Receiver");
         digester.addSetNext(prefix + "Receiver",
                             "setClusterReceiver",
-                            "org.apache.catalina.cluster.tcp.ClusterReceiverBase");
+                            "org.apache.catalina.cluster.ClusterReceiver");
 
         digester.addObjectCreate(prefix + "Valve",
                                  null, // MUST be specified in the element
@@ -116,7 +116,7 @@
         digester.addSetNext(prefix + "Valve",
                             "addValve",
                             "org.apache.catalina.Valve");
-        
+
         digester.addObjectCreate(prefix + "Deployer",
                                  null, // MUST be specified in the element
                                  "className");
@@ -124,7 +124,7 @@
         digester.addSetNext(prefix + "Deployer",
                             "setClusterDeployer",
                             "org.apache.catalina.cluster.ClusterDeployer");
-        
+
         digester.addObjectCreate(prefix + "Listener",
                 null, // MUST be specified in the element
                 "className");
@@ -132,15 +132,24 @@
         digester.addSetNext(prefix + "Listener",
                             "addLifecycleListener",
                             "org.apache.catalina.LifecycleListener");
-        
+
         digester.addObjectCreate(prefix + "ClusterListener",
                 null, // MUST be specified in the element
                 "className");
         digester.addSetProperties(prefix + "ClusterListener");
         digester.addSetNext(prefix + "ClusterListener",
                             "addClusterListener",
-                            "org.apache.catalina.cluster.ClusterListener");
+                            "org.apache.catalina.cluster.MessageListener");
         //Cluster configuration end
+    }
+
+
+    public void setPrefix(String prefix) {
+        this.prefix = prefix;
+    }
+
+    public String getPrefix() {
+        return prefix;
     }
 
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MembershipService.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MembershipService.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MembershipService.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MembershipService.java Thu Feb 23 13:28:29 2006
@@ -28,10 +28,7 @@
 
 
 public interface MembershipService {
-    
-    public static final int MBR_RX = 1;
-    public static final int MBR_TX = 2;
-    
+
     /**
      * Sets the properties for the membership service. This must be called before
      * the <code>start()</code> method is called.
@@ -102,7 +99,7 @@
      * If you call this method twice, the last listener will be used.
      * @param listener The listener
      */
-    public void setMembershipListener(MembershipListener listener);
+    public void addMembershipListener(MembershipListener listener);
     
     /**
      * removes the membership listener.

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java Thu Feb 23 13:28:29 2006
@@ -24,5 +24,18 @@
     public boolean equals(Object listener);
     
     public int hashCode();
+    
+    /**
+     * Returns the cluster the cluster deployer is associated with
+     * @return CatalinaCluster
+     */
+    public CatalinaCluster getCluster();
+
+    /**
+     * Associates the cluster deployer with a cluster
+     * @param cluster CatalinaCluster
+     */
+    public void setCluster(CatalinaCluster cluster);
+
 
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java Thu Feb 23 13:28:29 2006
@@ -34,7 +34,6 @@
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.cluster.Member;
 import org.apache.commons.modeler.Registry;
-import org.apache.catalina.cluster.ClusterListener;
 
 /**
  * <p>
@@ -55,7 +54,7 @@
  * @author Peter Rossbach
  * @version 1.1
  */
-public class FarmWarDeployer extends ClusterListener implements ClusterDeployer, FileChangeListener {
+public class FarmWarDeployer implements ClusterDeployer, FileChangeListener {
     /*--Static Variables----------------------------------------*/
     public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
             .getLog(FarmWarDeployer.class);

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/ObjectReader.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/ObjectReader.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/ObjectReader.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/ObjectReader.java Thu Feb 23 13:28:29 2006
@@ -38,6 +38,8 @@
 
     private SocketChannel channel;
 
+    private Selector selector;
+
     private ListenCallback callback;
 
     private XByteBuffer buffer;
@@ -50,6 +52,7 @@
      */
     public ObjectReader(SocketChannel channel, Selector selector, ListenCallback callback) {
         this.channel = channel;
+        this.selector = selector;
         this.callback = callback;
         this.buffer = new XByteBuffer();
     }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java Thu Feb 23 13:28:29 2006
@@ -18,14 +18,6 @@
 
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.cluster.tcp.ClusterData;
-import java.io.ObjectOutputStream;
-import java.util.zip.GZIPOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
-import org.apache.catalina.cluster.session.ReplicationStream;
 
 /**
  * The XByteBuffer provides a dual functionality.
@@ -345,10 +337,10 @@
      * @return - a full package (header,compress,size,data,footer)
      * 
      */
-    public static byte[] createDataPackage(ClusterData cdata)
+    public static byte[] createDataPackage(byte[] indata, int compressed)
             throws java.io.IOException {
-        byte[] data = cdata.getMessage();
-        byte[] comprdata = XByteBuffer.toBytes(cdata.getCompress());
+        byte[] data = indata;
+        byte[] comprdata = XByteBuffer.toBytes(compressed);
         int length = 
             START_DATA.length + //header length
             4 + //compression flag
@@ -363,63 +355,4 @@
         System.arraycopy(END_DATA, 0, result, START_DATA.length + 8 + data.length, END_DATA.length);
         return result;
     }
-    
-    public static ClusterMessage deserialize(ClusterData data, boolean compress) 
-        throws IOException, ClassNotFoundException, ClassCastException {
-        Object message = null;
-        if (data != null) {
-            InputStream instream;
-            if (compress ) {
-                instream = new GZIPInputStream(new ByteArrayInputStream(data.getMessage()));
-            } else {
-                instream = new ByteArrayInputStream(data.getMessage());
-            }
-            ReplicationStream stream = new ReplicationStream(instream,XByteBuffer.class.getClassLoader());
-            message = stream.readObject();
-            instream.close();
-        }
-        if ( message == null ) {
-            return null;
-        } else if (message instanceof ClusterMessage)
-            return (ClusterMessage) message;
-        else {
-            throw new ClassCastException("Message has the wrong class. It should implement ClusterMessage, instead it is:"+message.getClass().getName());
-        }
-    }
-
-    /**
-     * Serializes a message into cluster data
-     * @param msg ClusterMessage
-     * @param compress boolean
-     * @return ClusterData
-     * @throws IOException
-     */
-    public static ClusterData serialize(ClusterMessage msg, boolean compress) throws IOException {
-        msg.setTimestamp(System.currentTimeMillis());
-        ByteArrayOutputStream outs = new ByteArrayOutputStream();
-        ObjectOutputStream out;
-        GZIPOutputStream gout = null;
-        ClusterData data = new ClusterData();
-        data.setType(msg.getClass().getName());
-        data.setUniqueId(msg.getUniqueId());
-        data.setTimestamp(msg.getTimestamp());
-        data.setCompress(msg.getCompress());
-        data.setResend(msg.getResend());
-        if (compress) {
-            gout = new GZIPOutputStream(outs);
-            out = new ObjectOutputStream(gout);
-        } else {
-            out = new ObjectOutputStream(outs);
-        }
-        out.writeObject(msg);
-        // flush out the gzip stream to byte buffer
-        if(gout != null) {
-            gout.flush();
-            gout.close();
-        }
-        data.setMessage(outs.toByteArray());
-        return data;
-    }
-
-    
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java Thu Feb 23 13:28:29 2006
@@ -257,8 +257,8 @@
      * @throws java.lang.Exception if a IO error occurs
      */
     public void start() throws java.lang.Exception {
-        start(MembershipService.MBR_RX);
-        start(MembershipService.MBR_TX);
+        start(1);
+        start(2);
         registerMBean();
     }
     
@@ -440,7 +440,7 @@
      * so calling this method twice will result in only the second listener being active.
      * @param listener The listener
      */
-    public void setMembershipListener(MembershipListener listener) {
+    public void addMembershipListener(MembershipListener listener) {
         this.listener = listener;
     }
     /**

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterSessionListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterSessionListener.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterSessionListener.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterSessionListener.java Thu Feb 23 13:28:29 2006
@@ -20,11 +20,10 @@
 
 import org.apache.catalina.cluster.ClusterManager;
 import org.apache.catalina.cluster.ClusterMessage;
-import org.apache.catalina.cluster.*;
 
 /**
  * Receive replicated SessionMessage form other cluster node.
- * @author Filip Hanik
+ * 
  * @author Peter Rossbach
  * @version $Revision$ $Date$
  */

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java Thu Feb 23 13:28:29 2006
@@ -1069,29 +1069,29 @@
      * @param session cross context session
      */
     protected void registerSessionAtReplicationValve(DeltaSession session) {
-        if(replicationValve == null) {
-            if(container instanceof StandardContext
-                    && ((StandardContext)container).getCrossContext()) {
-                Cluster cluster = getCluster() ;
-                if(cluster != null && cluster instanceof CatalinaCluster) {
-                    Valve[] valves = ((CatalinaCluster)cluster).getValves();
-                    if(valves != null && valves.length > 0) {
-                        for(int i=0; replicationValve == null && i < valves.length ; i++ ){
-                            if(valves[i] instanceof ReplicationValve)
-                                replicationValve = (ReplicationValve)valves[i] ;
-                        }
-
-                        if(replicationValve == null && log.isDebugEnabled()) {
-                            log.debug("no ReplicationValve found for CrossContext Support");
-                        }
-                    }
-                }
-            }
-        }
-        if(replicationValve != null) {
-            replicationValve.registerReplicationSession(session);
-        }
-    }
+	    	if(replicationValve == null) {
+	    		if(container instanceof StandardContext
+	    				&& ((StandardContext)container).getCrossContext()) {
+	    			Cluster cluster = getCluster() ;
+	    			if(cluster != null && cluster instanceof CatalinaCluster) {
+	    				Valve[] valves = ((CatalinaCluster)cluster).getValves();
+	    				if(valves != null && valves.length > 0) {
+	    					for(int i=0; replicationValve == null && i < valves.length ; i++ ){
+	    						if(valves[i] instanceof ReplicationValve)
+	    							replicationValve = (ReplicationValve)valves[i] ;
+	    					}
+	    					
+	    					if(replicationValve == null && log.isDebugEnabled()) {
+	    						log.debug("no ReplicationValve found for CrossContext Support");
+	    					}
+	    				}
+	    			}
+	    		}
+	    	}
+	    	if(replicationValve != null) {
+	    		replicationValve.registerReplicationSession(session);
+	    	}
+    	}
     
     /**
      * Find the master of the session state

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java Thu Feb 23 13:28:29 2006
@@ -25,14 +25,13 @@
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.cluster.CatalinaCluster;
-
+import org.apache.catalina.cluster.MessageListener;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.util.StringManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.modeler.ManagedBean;
 import org.apache.commons.modeler.Registry;
-import org.apache.catalina.cluster.*;
 
 /**
  * Register new JvmRouteSessionIDBinderListener to receive Session ID changes.
@@ -71,7 +70,7 @@
 
     private Registry registry = null;
 
-    private ClusterListener sessionMoverListener;
+    private MessageListener sessionMoverListener;
 
     /*
      * start and stop cluster

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java Thu Feb 23 13:28:29 2006
@@ -25,7 +25,6 @@
 import org.apache.catalina.Session;
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.cluster.*;
 
 /**
  * Receive SessionID cluster change from other backup node after primary session

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicationStream.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicationStream.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicationStream.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicationStream.java Thu Feb 23 13:28:29 2006
@@ -73,11 +73,11 @@
             try
             {
                 if ( tryRepFirst ) return findReplicationClass(name);
-                else return findExternalClass(name);
+                else return findWebappClass(name);
             }
             catch ( Exception x )
             {
-                if ( tryRepFirst ) return findExternalClass(name);
+                if ( tryRepFirst ) return findWebappClass(name);
                 else return findReplicationClass(name);
             }
         } catch (ClassNotFoundException e) {
@@ -90,7 +90,7 @@
         return Class.forName(name, false, getClass().getClassLoader());
     }
 
-    public Class findExternalClass(String name)
+    public Class findWebappClass(String name)
         throws ClassNotFoundException, IOException {
         return Class.forName(name, false, classLoader);
     }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterData.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterData.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterData.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterData.java Thu Feb 23 13:28:29 2006
@@ -19,15 +19,11 @@
 
 
 /**
- * The cluster data class is used to transport around the byte array from
- * a ClusterMessage object. This is just a utility class to avoid having to 
- * serialize and deserialize the ClusterMessage more than once. 
  * @author Peter Rossbach
- * @author Filip Hanik
  * @version $Revision$ $Date$
  * @since 5.5.10
  */
-public class ClusterData  {
+public class ClusterData {
 
     private int resend = ClusterMessage.FLAG_DEFAULT ;
     private int compress = ClusterMessage.FLAG_DEFAULT ;

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java Thu Feb 23 13:28:29 2006
@@ -16,22 +16,32 @@
 
 package org.apache.catalina.cluster.tcp;
 
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.cluster.CatalinaCluster;
 import org.apache.catalina.cluster.ClusterMessage;
+import org.apache.catalina.cluster.ClusterReceiver;
+import org.apache.catalina.cluster.io.ListenCallback;
+import org.apache.catalina.cluster.session.ClusterSessionListener;
+import org.apache.catalina.cluster.session.ReplicationStream;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.util.StringManager;
 
 /**
-* @author Filip Hanik
+* FIXME i18n log messages
 * @author Peter Rossbach
 * @version $Revision$ $Date$
 */
 
-public class ClusterReceiverBase extends ReplicationListener {
+public abstract class ClusterReceiverBase implements Runnable, ClusterReceiver,ListenCallback {
     
     protected static org.apache.commons.logging.Log log =
         org.apache.commons.logging.LogFactory.getLog( ClusterReceiverBase.class );
@@ -42,7 +52,11 @@
     protected StringManager sm = StringManager.getManager(Constants.Package);
 
     private CatalinaCluster cluster;
-    
+    private java.net.InetAddress bind;
+    private String tcpListenAddress;
+    private int tcpListenPort;
+    private boolean sendAck;
+    protected boolean doListen = false;
 
     /**
      * total bytes to recevied
@@ -79,6 +93,10 @@
     private long lastChecked = System.currentTimeMillis();
 
 
+    /**
+     * Compress message data bytes
+     */
+    private boolean compress = true ;
 
     /**
      * Transmitter Mbean name
@@ -92,7 +110,34 @@
         return doListen;
     }
 
+    /**
+     * @return Returns the bind.
+     */
+    public java.net.InetAddress getBind() {
+        if (bind == null) {
+            try {
+                if ("auto".equals(tcpListenAddress)) {
+                    tcpListenAddress = java.net.InetAddress.getLocalHost()
+                            .getHostAddress();
+                }
+                if (log.isDebugEnabled())
+                    log.debug("Starting replication listener on address:"
+                            + tcpListenAddress);
+                bind = java.net.InetAddress.getByName(tcpListenAddress);
+            } catch (IOException ioe) {
+                log.error("Failed bind replication listener on address:"
+                        + tcpListenAddress, ioe);
+            }
+        }
+      return bind;
+    }
     
+    /**
+     * @param bind The bind to set.
+     */
+    public void setBind(java.net.InetAddress bind) {
+        this.bind = bind;
+    }
     public void setCatalinaCluster(CatalinaCluster cluster) {
         this.cluster = cluster;
     }
@@ -118,7 +163,61 @@
         return objectName;
     }
     
+    /**
+     * @return Returns the compress.
+     */
+    public boolean isCompress() {
+        return compress;
+    }
+    
+    /**
+     * @param compressMessageData The compress to set.
+     */
+    public void setCompress(boolean compressMessageData) {
+        this.compress = compressMessageData;
+    }
+    
+    /**
+     * Send ACK to sender
+     * 
+     * @return True if sending ACK
+     */
+    public boolean isSendAck() {
+        return sendAck;
+    }
+
+    /**
+     * set ack mode or not!
+     * 
+     * @param sendAck
+     */
+    public void setSendAck(boolean sendAck) {
+        this.sendAck = sendAck;
+    }
+ 
+    public String getTcpListenAddress() {
+        return tcpListenAddress;
+    }
+    
+    public void setTcpListenAddress(String tcpListenAddress) {
+        this.tcpListenAddress = tcpListenAddress;
+    }
+    
+    public int getTcpListenPort() {
+        return tcpListenPort;
+    }
     
+    public void setTcpListenPort(int tcpListenPort) {
+        this.tcpListenPort = tcpListenPort;
+    }
+  
+    public String getHost() {
+        return getTcpListenAddress();
+    }
+
+    public int getPort() {
+        return getTcpListenPort();
+    }
     // ------------------------------------------------------------- stats
 
     /**
@@ -199,7 +298,14 @@
      * @see org.apache.catalina.cluster.ClusterReceiver#start()
      */
     public void start() {
-        super.start();
+        try {
+            getBind();
+            Thread t = new Thread(this, "ClusterReceiver");
+            t.setDaemon(true);
+            t.start();
+        } catch (Exception x) {
+            log.fatal("Unable to start cluster receiver", x);
+        }
         registerReceiverMBean();
     }
 
@@ -211,7 +317,7 @@
      * @see #stopListening()
      */
     public void stop() {
-        super.stop();
+        stopListening();
         unregisterRecevierMBean();
      
     }
@@ -240,9 +346,10 @@
                     return;
                 }
                 setObjectName(receiverName);
-                mserver.registerMBean(scluster.getManagedBean(this),getObjectName());
+                mserver.registerMBean(scluster.getManagedBean(this),
+                        getObjectName());
             } catch (Exception e) {
-                log.warn("Unable to register JMX bean ClusterReceiverBase",e);
+                log.warn(e);
             }
         }
     }
@@ -264,8 +371,33 @@
         }
     }
 
+    /**
+     * stop Listener sockets
+     */
+    protected abstract void stopListening() ;
+
+    /**
+     * Start Listener
+     * @throws Exception
+     */
+    protected abstract void listen ()
+       throws Exception ;
+
     
-    
+    /**
+     * Start thread and listen
+     */
+    public void run()
+    {
+        try
+        {
+            listen();
+        }
+        catch ( Exception x )
+        {
+            log.error("Unable to start cluster listener.",x);
+        }
+    }
 
     // --------------------------------------------------------- receiver messages
 
@@ -283,10 +415,6 @@
         }
         try {
             ClusterMessage message = deserialize(data);
-            // calc stats really received bytes
-            totalReceivedBytes += data.getMessage().length;
-            //totalReceivedBytes += data.length;
-            nrOfMsgsReceived++;
             cluster.receive(message);
         } catch (Exception x) {
             log
@@ -300,7 +428,43 @@
         }
     }
 
-    
+    /**
+     * deserialize the receieve cluster message
+     * @param data uncompress data
+     * @return The message
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    //protected ClusterMessage deserialize(byte[] data)
+    protected ClusterMessage deserialize(ClusterData data)
+            throws IOException, ClassNotFoundException {
+        Object message = null;
+        if (data != null) {
+            InputStream instream;
+            if (isCompress() || data.getCompress() == ClusterMessage.FLAG_ALLOWED ) {
+                instream = new GZIPInputStream(new ByteArrayInputStream(data.getMessage()));
+            } else {
+                instream = new ByteArrayInputStream(data.getMessage());
+            }
+            ReplicationStream stream = new ReplicationStream(instream,
+                    getClass().getClassLoader());
+            message = stream.readObject();
+            // calc stats really received bytes
+            totalReceivedBytes += data.getMessage().length;
+            //totalReceivedBytes += data.length;
+            nrOfMsgsReceived++;
+            instream.close();
+        }
+        if (message instanceof ClusterMessage)
+            return (ClusterMessage) message;
+        else {
+            if (log.isDebugEnabled())
+                log.debug("Message " + message.toString() + " from type "
+                        + message.getClass().getName()
+                        + " transfered but is not a cluster message");
+            return null;
+        }
+    }
     
     // --------------------------------------------- Performance Stats
 
@@ -341,6 +505,11 @@
         }
     }
     
-    
+    /* (non-Javadoc)
+     * @see org.apache.catalina.cluster.io.ListenCallback#sendAck()
+     */
+    public void sendAck() throws IOException {
+        // do nothing
+    }
 
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java Thu Feb 23 13:28:29 2006
@@ -865,8 +865,9 @@
             isMessageTransferStarted = true ;
         }
         try {
+            byte[] message = data.getMessage();
             OutputStream out = socket.getOutputStream();
-            out.write(XByteBuffer.createDataPackage(data));
+            out.write(XByteBuffer.createDataPackage(message,data.getCompress()));
             out.flush();
             if (isWaitForAck())
                 waitForAck(ackTimeout);

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java Thu Feb 23 13:28:29 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999,2004-2005 The Apache Software Foundation.
- *
+ * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
 
 package org.apache.catalina.cluster.tcp;
 
-import java.io.IOException;
+
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.nio.channels.SelectableChannel;
@@ -26,56 +26,33 @@
 import java.nio.channels.SocketChannel;
 import java.util.Iterator;
 
-import org.apache.catalina.cluster.ClusterMessage;
-import org.apache.catalina.cluster.ClusterReceiver;
-import org.apache.catalina.cluster.group.ChannelInterceptorBase;
-import org.apache.catalina.cluster.io.ListenCallback;
 import org.apache.catalina.cluster.io.ObjectReader;
-import org.apache.catalina.cluster.io.XByteBuffer;
-import org.apache.catalina.util.StringManager;
-import org.apache.catalina.cluster.MessageListener;
 
 /**
- * @author Filip Hanik
- * @author Peter Rossbach
- * @version $Revision$ $Date$
- */
-public class ReplicationListener
-    implements Runnable, ClusterReceiver, ListenCallback {
-    protected static org.apache.commons.logging.Log log =
-        org.apache.commons.logging.LogFactory.getLog(ReplicationListener.class);
-
-    /**
-     * The string manager for this package.
-     */
-    protected StringManager sm = StringManager.getManager(Constants.Package);
+* FIXME i18n log messages
+* FIXME jmx support
+* @author Peter Rossbach
+* @author Filip Hanik
+* @version $Revision$ $Date$
+*/
+public class ReplicationListener extends ClusterReceiverBase
+{
 
     /**
      * The descriptive information about this implementation.
      */
-    private static final String info = "ReplicationListener/1.3";
-
+    private static final String info = "ReplicationListener/1.2";
+    
     private ThreadPool pool = null;
     private int tcpThreadCount;
-    private long tcpSelectorTimeout;
+    private long tcpSelectorTimeout;    
     private Selector selector = null;
-
-    private java.net.InetAddress bind;
-    private String tcpListenAddress;
-    private int tcpListenPort;
-    private boolean sendAck;
-    protected boolean doListen = false;
-    /**
-     * Compress message data bytes
-     */
-    private boolean compress = true;
-
-
+    
     private Object interestOpsMutex = new Object();
-    private MessageListener listener = null;
+    
     public ReplicationListener() {
     }
-
+    
     /**
      * Return descriptive information about this implementation and the
      * corresponding version number, in the format
@@ -86,52 +63,38 @@
         return (info);
 
     }
-
+ 
     public long getTcpSelectorTimeout() {
         return tcpSelectorTimeout;
     }
-
     public void setTcpSelectorTimeout(long tcpSelectorTimeout) {
         this.tcpSelectorTimeout = tcpSelectorTimeout;
     }
-
     public int getTcpThreadCount() {
         return tcpThreadCount;
     }
-
     public void setTcpThreadCount(int tcpThreadCount) {
         this.tcpThreadCount = tcpThreadCount;
     }
-
     public Object getInterestOpsMutex() {
         return interestOpsMutex;
     }
 
-    public void stop() {
-        this.stopListening();
-    }
-
     /**
      * start cluster receiver
      * @throws Exception
      * @see org.apache.catalina.cluster.ClusterReceiver#start()
      */
     public void start() {
-        try {
-            pool = new ThreadPool(tcpThreadCount, TcpReplicationThread.class, interestOpsMutex);
-        } catch (Exception e) {
-            log.error("ThreadPool can initilzed. Listener not started", e);
-            return;
-        }
-        try {
-            getBind();
-            Thread t = new Thread(this, "ReplicationListener");
-            t.setDaemon(true);
-            t.start();
-        } catch (Exception x) {
-            log.fatal("Unable to start cluster receiver", x);
-        }
-    }
+            try {
+                pool = new ThreadPool(tcpThreadCount, TcpReplicationThread.class, interestOpsMutex);
+            } catch (Exception e) {
+                log.error("ThreadPool can initilzed. Listener not started",e);
+                return ;
+            }
+            super.start() ;
+     }
+    
 
     /**
      * get data from channel and store in byte array
@@ -139,12 +102,14 @@
      * @throws IOException
      * @throws java.nio.channels.ClosedChannelException
      */
-    protected void listen() throws Exception {
+    protected void listen ()
+        throws Exception
+    {
         if (doListen) {
             log.warn("ServerSocketChannel allready started");
             return;
         }
-        doListen = true;
+        doListen=true;
         // allocate an unbound server socket channel
         ServerSocketChannel serverChannel = ServerSocketChannel.open();
         // Get the associated ServerSocket to bind it with
@@ -152,11 +117,11 @@
         // create a new Selector for use below
         selector = Selector.open();
         // set the port the server channel will listen to
-        serverSocket.bind(new InetSocketAddress(getBind(), getTcpListenPort()));
+        serverSocket.bind (new InetSocketAddress (getBind(),getTcpListenPort()));
         // set non-blocking mode for the listening socket
-        serverChannel.configureBlocking(false);
+        serverChannel.configureBlocking (false);
         // register the ServerSocketChannel with the Selector
-        serverChannel.register(selector, SelectionKey.OP_ACCEPT);
+        serverChannel.register (selector, SelectionKey.OP_ACCEPT);
         while (doListen && selector != null) {
             // this may block for a long time, upon return the
             // selected set contains keys of the ready channels
@@ -164,14 +129,14 @@
 
                 int n = selector.select(tcpSelectorTimeout);
                 if (n == 0) {
-                    //there is a good chance that we got here
+                    //there is a good chance that we got here 
                     //because the TcpReplicationThread called
                     //selector wakeup().
                     //if that happens, we must ensure that that
                     //thread has enough time to call interestOps
                     synchronized (interestOpsMutex) {
                         //if we got the lock, means there are no
-                        //keys trying to register for the
+                        //keys trying to register for the 
                         //interestOps method
                     }
                     continue; // nothing to do
@@ -187,7 +152,7 @@
                             (ServerSocketChannel) key.channel();
                         SocketChannel channel = server.accept();
                         Object attach = new ObjectReader(channel, selector,
-                            this);
+                                    this) ;
                         registerChannel(selector,
                                         channel,
                                         SelectionKey.OP_READ,
@@ -214,7 +179,7 @@
 
         }
         serverChannel.close();
-        if (selector != null)
+        if(selector != null)
             selector.close();
     }
 
@@ -226,63 +191,36 @@
     protected void stopListening() {
         // Bugzilla 37529: http://issues.apache.org/bugzilla/show_bug.cgi?id=37529
         doListen = false;
-        if (selector != null) {
+        if ( selector != null ) {
             try {
-                for (int i = 0; i < getTcpThreadCount(); i++) {
+                for(int i = 0; i < getTcpThreadCount(); i++) {
                     selector.wakeup();
                 }
                 selector.close();
-            } catch (Exception x) {
-                log.error("Unable to close cluster receiver selector.", x);
+            } catch ( Exception x ) {
+                log.error("Unable to close cluster receiver selector.",x);
             } finally {
-                selector = null;
+                selector = null;                
             }
         }
-    }
-
-    /**
-     * deserialize the receieve cluster message
-     * @param data uncompress data
-     * @return The message
-     * @throws IOException
-     * @throws ClassNotFoundException
-     */
-    //protected ClusterMessage deserialize(byte[] data)
-    protected ClusterMessage deserialize(ClusterData data) throws IOException, ClassNotFoundException {
-        boolean compress = isCompress() || data.getCompress() == ClusterMessage.FLAG_ALLOWED;
-        ClusterMessage message = null;
-        if (data != null) {
-            message = XByteBuffer.deserialize(data, compress);
-        }
-        return message;
-    }
-
+   }
+        
     // ----------------------------------------------------------
 
     /**
      * Register the given channel with the given selector for
      * the given operations of interest
      */
-    protected void registerChannel(Selector selector,
-                                   SelectableChannel channel,
-                                   int ops,
-                                   Object attach) throws Exception {
-        if (channel == null)return; // could happen
+    protected void registerChannel (Selector selector,
+                                    SelectableChannel channel,
+                                    int ops,
+                                    Object attach)
+    throws Exception {
+        if (channel == null) return; // could happen
         // set the new channel non-blocking
-        channel.configureBlocking(false);
+        channel.configureBlocking (false);
         // register it with the selector
-        channel.register(selector, ops, attach);
-    }
-
-    /**
-     * Start thread and listen
-     */
-    public void run() {
-        try {
-            listen();
-        } catch (Exception x) {
-            log.error("Unable to start replication listener.", x);
-        }
+        channel.register (selector, ops, attach);
     }
 
     // ----------------------------------------------------------
@@ -295,14 +233,16 @@
      *  automatically invalidates the associated key.  The selector
      *  will then de-register the channel on the next select call.
      */
-    protected void readDataFromSocket(SelectionKey key) throws Exception {
-        TcpReplicationThread worker = (TcpReplicationThread) pool.getWorker();
+    protected void readDataFromSocket (SelectionKey key)
+        throws Exception
+    {
+        TcpReplicationThread worker = (TcpReplicationThread)pool.getWorker();
         if (worker == null) {
             // No threads available, do nothing, the selection
             // loop will keep calling this method until a
             // thread becomes available.
             // FIXME: This design could be improved.
-            if (log.isDebugEnabled())
+            if(log.isDebugEnabled())
                 log.debug("No TcpReplicationThread available");
         } else {
             // invoking this wakes up the worker thread then returns
@@ -310,121 +250,5 @@
         }
     }
 
-    public void messageDataReceived(ClusterData data) {
-        if ( this.listener != null ) {
-            try {
-                ClusterMessage msg = deserialize(data);
-                listener.messageReceived(msg);
-            }catch ( java.io.IOException x ) {
-                if ( log.isErrorEnabled() ) {
-                    log.error("Unable to receive and deserialize cluster data. IOException.",x);
-                }
-            }catch ( java.lang.ClassNotFoundException cx ) {
-                if ( log.isErrorEnabled() ) {
-                    log.error("Unable to receive and deserialize cluster data. ClassNotFoundException.",cx);
-                }
-            }
-        }
-    }
-
-    /**
-     * @return Returns the bind.
-     */
-    public java.net.InetAddress getBind() {
-        if (bind == null) {
-            try {
-                if ("auto".equals(tcpListenAddress)) {
-                    tcpListenAddress = java.net.InetAddress.getLocalHost()
-                                       .getHostAddress();
-                }
-                if (log.isDebugEnabled())
-                    log.debug("Starting replication listener on address:"
-                              + tcpListenAddress);
-                bind = java.net.InetAddress.getByName(tcpListenAddress);
-            } catch (IOException ioe) {
-                log.error("Failed bind replication listener on address:"
-                          + tcpListenAddress, ioe);
-            }
-        }
-        return bind;
-    }
-
-    /**
-     * @param bind The bind to set.
-     */
-    public void setBind(java.net.InetAddress bind) {
-        this.bind = bind;
-    }
-
-    /**
-     * @return Returns the compress.
-     */
-    public boolean isCompress() {
-        return compress;
-    }
-
-    /**
-     * @param compressMessageData The compress to set.
-     */
-    public void setCompress(boolean compressMessageData) {
-        this.compress = compressMessageData;
-    }
-
-    /**
-     * Send ACK to sender
-     *
-     * @return True if sending ACK
-     */
-    public boolean isSendAck() {
-        return sendAck;
-    }
-
-    /**
-     * set ack mode or not!
-     *
-     * @param sendAck
-     */
-    public void setSendAck(boolean sendAck) {
-        this.sendAck = sendAck;
-    }
-
-    public String getTcpListenAddress() {
-        return tcpListenAddress;
-    }
-
-    public void setTcpListenAddress(String tcpListenAddress) {
-        this.tcpListenAddress = tcpListenAddress;
-    }
-
-    public int getTcpListenPort() {
-        return tcpListenPort;
-    }
-
-    public MessageListener getMessageListener() {
-        return listener;
-    }
-
-    public void setTcpListenPort(int tcpListenPort) {
-        this.tcpListenPort = tcpListenPort;
-    }
-
-    public void setMessageListener(MessageListener listener) {
-        this.listener = listener;
-    }
-
-    public String getHost() {
-        return getTcpListenAddress();
-    }
-
-    public int getPort() {
-        return getTcpListenPort();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.catalina.cluster.io.ListenCallback#sendAck()
-     */
-    public void sendAck() throws IOException {
-        // do nothing
-    }
-
+    
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java Thu Feb 23 13:28:29 2006
@@ -35,14 +35,13 @@
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.util.StringManager;
 import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.catalina.cluster.io.XByteBuffer;
 
 /**
- * Transmit message to other cluster members
- * Actual senders are created based on the replicationMode
+ * Transmit message to ohter cluster members create sender from replicationMode
  * type 
  * FIXME i18n log messages
  * FIXME compress data depends on message type and size 
+ * FIXME send very big messages at some block see FarmWarDeployer!
  * TODO pause and resume senders
  * 
  * @author Peter Rossbach
@@ -415,9 +414,11 @@
     
     /**
      * Send data to one member
+     * FIXME set filtering messages
      * @see org.apache.catalina.cluster.ClusterSender#sendMessage(org.apache.catalina.cluster.ClusterMessage, org.apache.catalina.cluster.Member)
      */
-    public void sendMessage(ClusterMessage message, Member member) throws IOException {       
+    public void sendMessage(ClusterMessage message, Member member)
+            throws java.io.IOException {       
         long time = 0 ;
         if(doTransmitterProcessingStats) {
             time = System.currentTimeMillis();
@@ -438,21 +439,47 @@
      * Send to all senders at same cluster domain as message from address
      * @param message Cluster message to send
      * @since 5.5.10
+     * FIXME Refactor with sendMessage get a sender list from
      */
-    public void sendMessageClusterDomain(ClusterMessage message) throws IOException {
-        sendMessage(message,true);
-    
-    }
+    public void sendMessageClusterDomain(ClusterMessage message) 
+         throws java.io.IOException {
+        long time = 0;
+        if (doTransmitterProcessingStats) {
+            time = System.currentTimeMillis();
+        }
+        try {
+            String domain = message.getAddress().getDomain();
+            if(domain == null)
+                throw new RuntimeException("Domain at member not set");
+            ClusterData data = serialize(message);
+            IDataSender[] senders = getSenders();
+            for (int i = 0; i < senders.length; i++) {
 
-    public void sendMessage(ClusterMessage message) throws IOException {
-        sendMessage(message,false);
+                IDataSender sender = senders[i];
+                if(domain.equals(sender.getDomain())) {
+                    try {
+                        boolean success = sendMessageData(data, sender);
+                    } catch (Exception x) {
+                        //THIS WILL NEVER HAPPEN, as sendMessageData swallows the error
+                    }
+                }
+            }
+        } finally {
+            // FIXME better exception handling
+            if (doTransmitterProcessingStats) {
+                addProcessingStats(time);
+            }
+        }
+    
     }
 
     /**
      * send message to all senders (broadcast)
      * @see org.apache.catalina.cluster.ClusterSender#sendMessage(org.apache.catalina.cluster.ClusterMessage)
+     * FIXME Refactor with sendMessageClusterDomain!
      */
-    public void sendMessage(ClusterMessage message, boolean domainOnly) throws IOException {
+    public void sendMessage(ClusterMessage message)
+            throws java.io.IOException {
         long time = 0;
         if (doTransmitterProcessingStats) {
             time = System.currentTimeMillis();
@@ -463,19 +490,19 @@
             for (int i = 0; i < senders.length; i++) {
 
                 IDataSender sender = senders[i];
-                //domain filter
-                String domain = message.getAddress().getDomain();
-                if ( domainOnly && !(domain.equals(sender.getDomain())) ) continue;
-                sendMessageData(data, sender);
+                try {
+                    sendMessageData(data, sender);
+                } catch (Exception x) {
+                    // FIXME remember exception and send it at finally
+                }
             }
         } finally {
+            // FIXME better exception handling
             if (doTransmitterProcessingStats) {
                 addProcessingStats(time);
             }
         }
     }
-        
-    
 
     /**
      * start the sender and register transmitter mbean
@@ -714,7 +741,7 @@
                 mserver.unregisterMBean(getSenderObjectName(sender));
             }
         } catch (Exception e) {
-            if ( log.isDebugEnabled() ) log.debug("'ReplicationTransmitter' Unable to to deregister IDataSender",e);
+            log.warn(e);
         }
     }
 
@@ -738,7 +765,7 @@
                 mserver.registerMBean(cluster.getManagedBean(sender),
                         senderName);
             } catch (Exception e) {
-                if ( log.isDebugEnabled() ) log.debug("'ReplicationTransmitter' Unable to register sender bean",e);
+                log.warn(e);
             }
         }
     }
@@ -764,7 +791,7 @@
                     + sender.getAddress().getHostAddress() + ",senderPort="
                     + sender.getPort());
         } catch (Exception e) {
-            if ( log.isDebugEnabled() ) log.debug("'ReplicationTransmitter' Unable to retrieve sender name",e);
+            log.warn(e);
         }
         return senderName;
     }
@@ -779,9 +806,32 @@
      * @since 5.5.10
      */
     protected ClusterData serialize(ClusterMessage msg) throws IOException {
-        boolean compress = ((isCompress() && msg.getCompress() != ClusterMessage.FLAG_FORBIDDEN)
-                             || msg.getCompress() == ClusterMessage.FLAG_ALLOWED);
-        return XByteBuffer.serialize(msg,compress);
+        msg.setTimestamp(System.currentTimeMillis());
+        ByteArrayOutputStream outs = new ByteArrayOutputStream();
+        ObjectOutputStream out;
+        GZIPOutputStream gout = null;
+        ClusterData data = new ClusterData();
+        data.setType(msg.getClass().getName());
+        data.setUniqueId(msg.getUniqueId());
+        data.setTimestamp(msg.getTimestamp());
+        data.setCompress(msg.getCompress());
+        data.setResend(msg.getResend());
+        // FIXME add stats: How much comress and uncompress messages and bytes are transfered
+        if ((isCompress() && msg.getCompress() != ClusterMessage.FLAG_FORBIDDEN)
+                || msg.getCompress() == ClusterMessage.FLAG_ALLOWED) {
+            gout = new GZIPOutputStream(outs);
+            out = new ObjectOutputStream(gout);
+        } else {
+            out = new ObjectOutputStream(outs);
+        }
+        out.writeObject(msg);
+        // flush out the gzip stream to byte buffer
+        if(gout != null) {
+            gout.flush();
+            gout.close();
+        }
+        data.setMessage(outs.toByteArray());
+        return data;
     }
  
 
@@ -800,9 +850,9 @@
      * @throws java.io.IOException If an error occurs
      */
     protected boolean sendMessageData(ClusterData data,
-                                      IDataSender sender) {
+                                   IDataSender sender) throws java.io.IOException {
         if (sender == null)
-            throw new RuntimeException("Sender not available. Make sure sender information is available to the ReplicationTransmitter.");
+            throw new java.io.IOException("Sender not available. Make sure sender information is available to the ReplicationTransmitter.");
         try {
             // deprecated not needed DataSender#pushMessage can handle connection
             if (autoConnect) {

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java Thu Feb 23 13:28:29 2006
@@ -50,7 +50,7 @@
 import org.apache.catalina.cluster.Member;
 import org.apache.catalina.cluster.MembershipListener;
 import org.apache.catalina.cluster.MembershipService;
-import org.apache.catalina.cluster.ClusterListener;
+import org.apache.catalina.cluster.MessageListener;
 import org.apache.catalina.cluster.mcast.McastService;
 import org.apache.catalina.cluster.session.ClusterSessionListener;
 import org.apache.catalina.cluster.session.DeltaManager;
@@ -175,7 +175,7 @@
     /**
      * Receiver to register call back with
      */
-    private ClusterReceiverBase clusterReceiver;
+    private org.apache.catalina.cluster.ClusterReceiver clusterReceiver;
 
     private List valves = new ArrayList();
 
@@ -319,11 +319,11 @@
         this.clusterSender = clusterSender;
     }
 
-    public ClusterReceiverBase getClusterReceiver() {
+    public ClusterReceiver getClusterReceiver() {
         return clusterReceiver;
     }
 
-    public void setClusterReceiver(ClusterReceiverBase clusterReceiver) {
+    public void setClusterReceiver(ClusterReceiver clusterReceiver) {
         this.clusterReceiver = clusterReceiver;
     }
 
@@ -357,13 +357,14 @@
      * Get the cluster listeners associated with this cluster. If this Array has
      * no listeners registered, a zero-length array is returned.
      */
-    public ClusterListener[] findClusterListeners() {
+    public MessageListener[] findClusterListeners() {
         if (clusterListeners.size() > 0) {
-            ClusterListener[] listener = new ClusterListener[clusterListeners.size()];
+            MessageListener[] listener = new MessageListener[clusterListeners
+                    .size()];
             clusterListeners.toArray(listener);
             return listener;
         } else
-            return new ClusterListener[0];
+            return new MessageListener[0];
 
     }
 
@@ -372,7 +373,7 @@
      * 
      * @see org.apache.catalina.cluster.CatalinaCluster#addClusterListener(org.apache.catalina.cluster.MessageListener)
      */
-    public void addClusterListener(ClusterListener listener) {
+    public void addClusterListener(MessageListener listener) {
         if (listener != null && !clusterListeners.contains(listener)) {
             clusterListeners.add(listener);
             listener.setCluster(this);
@@ -384,7 +385,7 @@
      * 
      * @see org.apache.catalina.cluster.CatalinaCluster#removeClusterListener(org.apache.catalina.cluster.MessageListener)
      */
-    public void removeClusterListener(ClusterListener listener) {
+    public void removeClusterListener(MessageListener listener) {
         if (listener != null) {
             clusterListeners.remove(listener);
             listener.setCluster(null);
@@ -761,8 +762,9 @@
             }
             
             if(membershipService != null && clusterReceiver != null) {
-                membershipService.setLocalMemberProperties(clusterReceiver.getHost(), clusterReceiver.getPort());
-                membershipService.setMembershipListener(this);
+                membershipService.setLocalMemberProperties(clusterReceiver
+                    .getHost(), clusterReceiver.getPort());
+                membershipService.addMembershipListener(this);
                 membershipService.setCatalinaCluster(this);
                 membershipService.start();
                 // start the deployer.
@@ -1003,7 +1005,29 @@
         clusterLog = null ;
    }
 
-    
+    /**
+     * send message to all cluster members same cluster domain
+     * 
+     * @see org.apache.catalina.cluster.CatalinaCluster#send(org.apache.catalina.cluster.ClusterMessage)
+     */
+    public void sendClusterDomain(ClusterMessage msg) {
+        long start = 0;
+        if (doClusterLog)
+            start = System.currentTimeMillis();
+        try {
+            msg.setAddress(membershipService.getLocalMember());
+            clusterSender.sendMessageClusterDomain(msg);
+        } catch (Exception x) {
+            if (notifyLifecycleListenerOnFailure) {
+                // Notify our interested LifecycleListeners
+                lifecycle.fireLifecycleEvent(SEND_MESSAGE_FAILURE_EVENT,
+                        new SendMessageData(msg, null, x));
+            }
+            log.error("Unable to send message through cluster sender.", x);
+        }
+        if (doClusterLog)
+            logSendMessage(msg, start, null);
+    } 
 
 
     /**
@@ -1035,31 +1059,6 @@
     }
     
     /**
-     * send message to all cluster members same cluster domain
-     * 
-     * @see org.apache.catalina.cluster.CatalinaCluster#send(org.apache.catalina.cluster.ClusterMessage)
-     */
-    public void sendClusterDomain(ClusterMessage msg) {
-        long start = 0;
-        if (doClusterLog)
-            start = System.currentTimeMillis();
-        try {
-            msg.setAddress(membershipService.getLocalMember());
-            clusterSender.sendMessageClusterDomain(msg);
-        } catch (Exception x) {
-            if (notifyLifecycleListenerOnFailure) {
-                // Notify our interested LifecycleListeners
-                lifecycle.fireLifecycleEvent(SEND_MESSAGE_FAILURE_EVENT,
-                        new SendMessageData(msg, null, x));
-            }
-            log.error("Unable to send message through cluster sender.", x);
-        }
-        if (doClusterLog)
-            logSendMessage(msg, start, null);
-    } 
-
-    
-    /**
      * send a cluster message to one member
      * 
      * @param msg message to transfer
@@ -1158,7 +1157,7 @@
         boolean accepted = false;
         if (message != null) {
             for (Iterator iter = clusterListeners.iterator(); iter.hasNext();) {
-                ClusterListener listener = (ClusterListener) iter.next();
+                MessageListener listener = (MessageListener) iter.next();
                 if (listener.accept(message)) {
                     accepted = true;
                     listener.messageReceived(message);
@@ -1339,7 +1338,8 @@
     public ModelMBean getManagedBean(Object object) throws Exception {
         ModelMBean mbean = null;
         if (registry != null) {
-            ManagedBean managedBean = registry.findManagedBean(object.getClass().getName());
+            ManagedBean managedBean = registry.findManagedBean(object
+                    .getClass().getName());
             mbean = managedBean.createMBean(object);
         }
         return mbean;

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java Thu Feb 23 13:28:29 2006
@@ -140,7 +140,6 @@
         if (log.isTraceEnabled()) {
             log.trace("sending " + pkgcnt + " ack packages to " + channel.socket().getLocalPort() );
         }
-
         
         if (sendAck) {
             while ( pkgcnt > 0 ) {

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml (original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml Thu Feb 23 13:28:29 2006
@@ -86,11 +86,11 @@
                  
   </mbean>
 
-  <mbean         name="ClusterReceiverBase"
+  <mbean         name="ReplicationListener"
            description="Tcp Cluster ReplicationListener implementation"
                domain="Catalina"
                 group="Cluster"
-                 type="org.apache.catalina.cluster.tcp.ClusterReceiverBase">
+                 type="org.apache.catalina.cluster.tcp.ReplicationListener">
     <attribute   name="info"
           description="Class version info"
                  type="java.lang.String"

Copied: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java (from r379923, tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java)
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java?p2=tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java&p1=tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java&r1=379923&r2=380229&rev=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ClusterRuleSet.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java Thu Feb 23 13:28:29 2006
@@ -15,7 +15,7 @@
  */
 
 
-package org.apache.catalina.startup;
+package org.apache.catalina.cluster;
 
 
 import org.apache.tomcat.util.digester.Digester;

Modified: tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml?rev=380229&r1=380228&r2=380229&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml Thu Feb 23 13:28:29 2006
@@ -237,7 +237,7 @@
    Receiver    Sender   Membership  \
      \                               -- Valve
      -- SocketReplicationListener    |      \
-     -- ClusterReceiverBase          |       -- ReplicationValve
+     -- ReplicationListener          |       -- ReplicationValve
                                      |       -- JvmRouteBinderValve 
                                      |
                                      -- LifecycleListener 
@@ -436,7 +436,7 @@
 <section name="Complex Cluster Configuration">
 <p>
 <br/><b>Example</b> Configure cluster with complete sub elements. Activate this node
-as master farm delopyer. Message receiver is NIO based <em>ClusterReceiverBase</em> with six parallel
+as master farm delopyer. Message receiver is NIO based <em>ReplicationListener</em> with six parallel
 worker threads.
 <br/>
 <source>
@@ -483,7 +483,7 @@
                                      mcastFrequency="1000"
                                       mcastDropTime="30000"/&gt;
                   &lt;Receiver 
-                                           className="org.apache.catalina.cluster.tcp.ClusterReceiverBase"
+                                           className="org.apache.catalina.cluster.tcp.ReplicationListener"
                                     tcpListenAddress="auto"
                                        tcpListenPort="9015"
                                   tcpSelectorTimeout="100"



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message