tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r380264 - in /tomcat/container/tc5.5.x/modules: ./ groupcom/src/share/org/apache/catalina/cluster/ groupcom/src/share/org/apache/catalina/cluster/demos/ groupcom/src/share/org/apache/catalina/cluster/group/ groupcom/src/share/org/apache/cat...
Date Thu, 23 Feb 2006 23:05:51 GMT
Author: fhanik
Date: Thu Feb 23 15:05:48 2006
New Revision: 380264

URL: http://svn.apache.org/viewcvs?rev=380264&view=rev
Log:
Working out the quirks by first removing everything that doesn't belong

Added:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java
Removed:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSession.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/SendMessageData.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterReceiver.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterSender.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/Constants.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/Member.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/MembershipListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/MembershipService.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/MessageListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/Constants.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SocketReplicationListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SocketReplicationThread.java
Modified:
    tomcat/container/tc5.5.x/modules/build.xml
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
    tomcat/container/tc5.5.x/modules/ha/build.xml
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java

Modified: tomcat/container/tc5.5.x/modules/build.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/build.xml?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/build.xml (original)
+++ tomcat/container/tc5.5.x/modules/build.xml Thu Feb 23 15:05:48 2006
@@ -9,6 +9,8 @@
   <property file="../build.properties"/>
   <property file="${user.home}/build.properties"/-->
 
+  <property file="build.properties"/>
+
   <!-- =================== BUILD: Create Directories ====================== -->
   <target name="build-prepare">
     <available property="jdk1.4.present" classname="java.nio.Buffer" />
@@ -18,17 +20,30 @@
   <!-- =================== BUILD: Compile Subprojects ===================== -->
   <!-- Add a new target for each module subproject -->
 
-  <target name="cluster" if="jdk1.4.present">
+  <target name="cluster" if="jdk1.4.present" unless="cluster-ha">
     <ant dir="${basedir}/cluster" target="dist"/>
   </target>
 
+  <target name="groupcom" if="cluster-ha" >
+    <ant dir="${basedir}/groupcom" target="dist">
+        <property name="groupcom.dist" value="${cluster.dist}"/>
+    </ant>
+  </target>
+
+  <target name="ha" if="cluster-ha" >
+    <ant dir="${basedir}/ha" target="dist">
+        <property name="ha.dist" value="${cluster.dist}"/>
+    </ant>
+  </target>
+  
+  
   <target name="config" >
     <ant dir="${basedir}/storeconfig" target="dist"/>
   </target>
 
   <!-- ================= BUILD: Compile Server Components ================= -->
   <!-- Update the depends list for each subproject -->
-  <target name="build" depends="build-prepare,cluster,config"/>
+  <target name="build" depends="build-prepare,cluster,groupcom,ha,config"/>
 
 
   <!-- ======================= BUILD: Clean Directory ===================== -->

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java?rev=380264&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java
(added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java
Thu Feb 23 15:05:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1999,2004-2006 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.cluster;
+
+import org.apache.catalina.cluster.ClusterMessage;
+import org.apache.catalina.cluster.Member;
+import org.apache.catalina.cluster.MembershipListener;
+import org.apache.catalina.cluster.MessageListener;
+import java.io.IOException;
+
+/**
+ * Abstract class for the interceptor base class.
+ * @author Filip Hanik
+ * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $
+ */
+
+public interface ChannelInterceptor extends MembershipListener, MessageListener {
+
+    public void setNext(ChannelInterceptor next) ;
+
+    public ChannelInterceptor getNext();
+
+    public void setPrevious(ChannelInterceptor previous);
+
+    public ChannelInterceptor getPrevious();
+
+    public ClusterMessage[] sendMessage(Member[] destination, ClusterMessage msg, int options)
throws IOException;
+
+}

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java
Thu Feb 23 15:05:48 2006
@@ -34,6 +34,12 @@
     public static final int MBR_TX_SEQ = 8;
     
     /**
+     * Adds an interceptor to the channel message chain.
+     * @param interceptor ChannelInterceptor
+     */
+    public void addInterceptor(ChannelInterceptor interceptor);
+    
+    /**
      * Starts up the channel. This can be called multiple times for individual services to
start
      * The svc parameter can be the logical or value of any constants
      * @param svc int value of <BR>

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java
Thu Feb 23 15:05:48 2006
@@ -79,8 +79,7 @@
         service.setMcastFrequency(500);
         service.setMcastDropTime(5000);
         service.setMcastPort(45565);
-        service.setLocalMemberProperties(rl.getHost(),port);
-        
+
         channel = new GroupChannel();
         channel.setClusterReceiver(rl);
         channel.setClusterSender(ps);

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
Thu Feb 23 15:05:48 2006
@@ -79,6 +79,7 @@
      */
     public void start(int svc) throws ChannelException {
         try {
+            membershipService.setLocalMemberProperties(getClusterReceiver().getHost(), getClusterReceiver().getPort());
             if ( (svc & ClusterChannel.MBR_RX_SEQ) == ClusterChannel.MBR_RX_SEQ) membershipService.start(MembershipService.MBR_RX);
             if ( (svc & ClusterChannel.SND_RX_SEQ) == ClusterChannel.SND_RX_SEQ) clusterReceiver.start();
             if ( (svc & ClusterChannel.SND_TX_SEQ) == ClusterChannel.SND_TX_SEQ) clusterSender.start();

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
Thu Feb 23 15:05:48 2006
@@ -20,6 +20,7 @@
 import org.apache.catalina.cluster.MembershipListener;
 import org.apache.catalina.cluster.MessageListener;
 import java.io.IOException;
+import org.apache.catalina.cluster.ChannelInterceptor;
 
 /**
  * Abstract class for the interceptor base class.
@@ -27,28 +28,28 @@
  * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $
  */
 
-public abstract class ChannelInterceptorBase implements MembershipListener, MessageListener
{
+public abstract class ChannelInterceptorBase implements ChannelInterceptor{
     
-    private ChannelInterceptorBase next;
-    private ChannelInterceptorBase previous;
+    private ChannelInterceptor next;
+    private ChannelInterceptor previous;
     
     public ChannelInterceptorBase() {
         
     }
     
-    protected final void setNext(ChannelInterceptorBase next) {
+    public final void setNext(ChannelInterceptor next) {
         this.next = next;
     }
     
-    public final ChannelInterceptorBase getNext() {
+    public final ChannelInterceptor getNext() {
         return next;
     }
     
-    protected final void setPrevious(ChannelInterceptorBase previous) {
+    public final void setPrevious(ChannelInterceptor previous) {
         this.previous = previous;
     }
 
-    public final ChannelInterceptorBase getPrevious() {
+    public final ChannelInterceptor getPrevious() {
         return previous;
     }
 

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
Thu Feb 23 15:05:48 2006
@@ -23,6 +23,7 @@
 import org.apache.catalina.cluster.MembershipService;
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.cluster.Member;
+import org.apache.catalina.cluster.ChannelInterceptor;
 
 
 /**
@@ -35,7 +36,7 @@
  */
 public class GroupChannel implements ClusterChannel {
     private ChannelCoordinator coordinator = new ChannelCoordinator();
-    private ChannelInterceptorBase interceptors = null;
+    private ChannelInterceptor interceptors = null;
 
     public GroupChannel() {
     }
@@ -45,13 +46,13 @@
      * Adds an interceptor to the stack for message processing
      * @param interceptor ChannelInterceptorBase
      */
-    public void addInterceptor(ChannelInterceptorBase interceptor) { 
+    public void addInterceptor(ChannelInterceptor interceptor) { 
         if ( interceptors == null ) {
             this.interceptors = interceptor;
             this.interceptors.setNext(coordinator);
             coordinator.setPrevious(this.interceptors);
         } else {
-            ChannelInterceptorBase last = interceptors;
+            ChannelInterceptor last = interceptors;
             while ( last.getNext() != coordinator ) {
                 last = last.getNext();
             }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
Thu Feb 23 15:05:48 2006
@@ -413,6 +413,7 @@
     }
 
     public String getHost() {
+        getBind();
         return getTcpListenAddress();
     }
 

Modified: tomcat/container/tc5.5.x/modules/ha/build.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/build.xml?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/build.xml (original)
+++ tomcat/container/tc5.5.x/modules/ha/build.xml Thu Feb 23 15:05:48 2006
@@ -19,6 +19,7 @@
   <path id="ha.classpath">
     <pathelement location="${catalina.build}/server/lib/catalina.jar"/>
     <pathelement location="${catalina.build}/server/lib/tomcat-util.jar"/>
+    <pathelement location="${catalina.build}/server/lib/catalina-groups.jar"/>
     <pathelement location="${commons-modeler.jar}"/>
     <pathelement location="${commons-logging.jar}"/>
     <pathelement location="${jmx.jar}"/>

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
Thu Feb 23 15:05:48 2006
@@ -23,7 +23,7 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.commons.logging.Log;
-import org.apache.catalina.cluster.tcp.ClusterReceiverBase;
+
 
 
 /**
@@ -62,13 +62,6 @@
     public Log getLogger();
     
     /**
-     * receive a message to all the members in the cluster.
-     *
-     * @param msg ClusterMessage
-     */
-    public void receive(ClusterMessage msg);
- 
-    /**
      * Sends a message to all the members in the cluster
      * @param msg ClusterMessage
      */
@@ -110,15 +103,11 @@
     
     public void setClusterSender(ClusterSender sender);
     
-    public ClusterSender getClusterSender();
-    
-    public void setClusterReceiver(ClusterReceiverBase receiver);
-    
-    public ClusterReceiverBase getClusterReceiver();
-    
-    public void setMembershipService(MembershipService service);
+    public void setClusterReceiver(ClusterReceiver receiver);
     
     public MembershipService getMembershipService();
+
+    public void setMembershipService(MembershipService service);
     
     public void addValve(Valve valve);
     

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java?rev=380264&r1=380263&r2=380264&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
Thu Feb 23 15:05:48 2006
@@ -20,17 +20,11 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.modelmbean.ModelMBean;
-
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
@@ -42,27 +36,23 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.catalina.cluster.CatalinaCluster;
+import org.apache.catalina.cluster.ClusterChannel;
+import org.apache.catalina.cluster.ClusterListener;
 import org.apache.catalina.cluster.ClusterManager;
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.cluster.ClusterReceiver;
 import org.apache.catalina.cluster.ClusterSender;
 import org.apache.catalina.cluster.ClusterValve;
 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.mcast.McastService;
-import org.apache.catalina.cluster.session.ClusterSessionListener;
+import org.apache.catalina.cluster.group.ChannelInterceptorBase;
+import org.apache.catalina.cluster.group.GroupChannel;
 import org.apache.catalina.cluster.session.DeltaManager;
 import org.apache.catalina.cluster.util.IDynamicProperty;
-import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.util.LifecycleSupport;
 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.tomcat.util.IntrospectionUtils;
 
 /**
@@ -78,8 +68,8 @@
  * @author Peter Rossbach
  * @version $Revision: 379550 $, $Date: 2006-02-21 12:06:35 -0600 (Tue, 21 Feb 2006) $
  */
-public class SimpleTcpCluster implements CatalinaCluster, Lifecycle,
-        MembershipListener, LifecycleListener, IDynamicProperty {
+public class SimpleTcpCluster extends ChannelInterceptorBase 
+    implements CatalinaCluster, Lifecycle, LifecycleListener, IDynamicProperty {
 
     public static Log log = LogFactory.getLog(SimpleTcpCluster.class);
 
@@ -109,11 +99,12 @@
     public static final String SEND_MESSAGE_FAILURE_EVENT = "send_message_failure";
 
     public static final String RECEIVE_MESSAGE_FAILURE_EVENT = "receive_message_failure";
-
+    
     /**
-     * the service that provides the membership
+     * Group channel.
      */
-    protected MembershipService membershipService = null;
+    protected ClusterChannel channel = new GroupChannel();
+
 
     /**
      * Name for logging purpose
@@ -141,16 +132,6 @@
     protected LifecycleSupport lifecycle = new LifecycleSupport(this);
 
     /**
-     * Globale MBean Server
-     */
-    private MBeanServer mserver = null;
-
-    /**
-     * Current Catalina Registry
-     */
-    private Registry registry = null;
-
-    /**
      * Has this component been started?
      */
     protected boolean started = false;
@@ -167,22 +148,11 @@
 
     private String managerClassName = "org.apache.catalina.cluster.session.DeltaManager";
 
-    /**
-     * Sender to send data with
-     */
-    private org.apache.catalina.cluster.ClusterSender clusterSender;
-
-    /**
-     * Receiver to register call back with
-     */
-    private ClusterReceiverBase clusterReceiver;
 
     private List valves = new ArrayList();
 
     private org.apache.catalina.cluster.ClusterDeployer clusterDeployer;
 
-    private boolean defaultMode = true ;
-    
     /**
      * Listeners of messages
      */
@@ -193,8 +163,6 @@
      */
     private boolean notifyLifecycleListenerOnFailure = false;
 
-    private ObjectName objectName = null;
-
     /**
      * dynamic sender <code>properties</code>
      */
@@ -205,10 +173,6 @@
      */
     private String clusterLogName = "org.apache.catalina.cluster.tcp.SimpleTcpCluster";
 
-    private boolean doClusterLog = false;
-
-    private Log clusterLog = null;
-
     // ------------------------------------------------------------- Properties
 
     public SimpleTcpCluster() {
@@ -287,20 +251,6 @@
                 this.notifyLifecycleListenerOnFailure);
     }
 
-    /**
-     * @return Returns the defaultMode.
-     */
-    public boolean isDefaultMode() {
-        return defaultMode;
-    }
-    
-    /**
-     * @param defaultMode The defaultMode to set.
-     */
-    public void setDefaultMode(boolean defaultMode) {
-        this.defaultMode = defaultMode;
-    }
-    
     public String getManagerClassName() {
         if(managerClassName != null)
             return managerClassName;
@@ -311,28 +261,20 @@
         this.managerClassName = managerClassName;
     }
 
-    public ClusterSender getClusterSender() {
-        return clusterSender;
-    }
-
     public void setClusterSender(ClusterSender clusterSender) {
-        this.clusterSender = clusterSender;
+        this.channel.setClusterSender(clusterSender);
     }
 
-    public ClusterReceiverBase getClusterReceiver() {
-        return clusterReceiver;
+    public void setClusterReceiver(ClusterReceiver clusterReceiver) {
+        this.channel.setClusterReceiver(clusterReceiver);
     }
 
-    public void setClusterReceiver(ClusterReceiverBase clusterReceiver) {
-        this.clusterReceiver = clusterReceiver;
+    public void setMembershipService(MembershipService membershipService) {
+        this.channel.setMembershipService(membershipService);
     }
-
+    
     public MembershipService getMembershipService() {
-        return membershipService;
-    }
-
-    public void setMembershipService(MembershipService membershipService) {
-        this.membershipService = membershipService;
+        return ((GroupChannel)channel).getMembershipService();
     }
 
     /**
@@ -410,7 +352,7 @@
      * has members
      */
     public boolean hasMembers() {
-        return membershipService.hasMembers();
+        return getMembershipService().hasMembers();
     }
     
     /**
@@ -418,7 +360,7 @@
      * @return all members or empty array 
      */
     public Member[] getMembers() {
-        return membershipService.getMembers();
+        return getMembershipService().getMembers();
     }
 
     /**
@@ -427,7 +369,7 @@
      * @return Member
      */
     public Member getLocalMember() {
-        return membershipService.getLocalMember();
+        return getMembershipService().getLocalMember();
     }
 
     // ------------------------------------------------------------- dynamic
@@ -653,8 +595,8 @@
     public void backgroundProcess() {
         if (clusterDeployer != null)
             clusterDeployer.backgroundProcess();
-        if (clusterSender != null)
-            clusterSender.backgroundProcess();
+//        if (this.channel.getClusterSender() != null)
+//            this.channel.getClusterSender().backgroundProcess();
     }
 
     /**
@@ -718,63 +660,14 @@
     public void start() throws LifecycleException {
         if (started)
             throw new LifecycleException(sm.getString("cluster.alreadyStarted"));
-        if (log.isInfoEnabled())
-            log.info("Cluster is about to start");
-        getClusterLog();
+        if (log.isInfoEnabled()) log.info("Cluster is about to start");
+
         // Notify our interested LifecycleListeners
         lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, this);
         try {
-            if(isDefaultMode() && valves.size() == 0) {
-                createDefaultClusterValves() ;
-            }
-            registerClusterValve();
-            registerMBeans();
-            // setup the default cluster session listener (DeltaManager support)
-            if(isDefaultMode() && clusterListeners.size() == 0) {
-                createDefaultClusterListener();
-            }
-            // setup the default cluster Receiver
-            if(isDefaultMode() && clusterReceiver == null) {
-                createDefaultClusterReceiver();
-            }
-            // setup the default cluster sender
-            if(isDefaultMode() && clusterSender == null) {
-                createDefaultClusterSender();
-            }
-            // start the receiver.
-            if(clusterReceiver != null) {
-                clusterReceiver.setSendAck(clusterSender.isWaitForAck());
-                clusterReceiver.setCompress(clusterSender.isCompress());
-                clusterReceiver.setCatalinaCluster(this);
-                clusterReceiver.start();
-            }
-     
-            // start the sender.
-            if(clusterSender != null && clusterReceiver != null) {
-                clusterSender.setCatalinaCluster(this);
-                clusterSender.start();
-            }
-            
-            // start the membership service.
-            if(isDefaultMode() && membershipService == null) {
-                createDefaultMembershipService();
-            }
-            
-            if(membershipService != null && clusterReceiver != null) {
-                membershipService.setLocalMemberProperties(clusterReceiver.getHost(), clusterReceiver.getPort());
-                membershipService.setMembershipListener(this);
-                membershipService.setCatalinaCluster(this);
-                membershipService.start();
-                // start the deployer.
-                try {
-                    if (clusterDeployer != null) {
-                        clusterDeployer.setCluster(this);
-                        clusterDeployer.start();
-                    }
-                } catch (Throwable x) {
-                    log.fatal("Unable to retrieve the container deployer. Cluster deployment
disabled.",x);
-                }
-            }
+            this.registerClusterValve();
+            channel.addInterceptor(this);
+            channel.start(channel.DEFAULT);
             this.started = true;
             // Notify our interested LifecycleListeners
             lifecycle.fireLifecycleEvent(AFTER_START_EVENT, this);
@@ -785,128 +678,6 @@
     }
 
     /**
-     * Create default membership service:
-     * <pre>
-     * &lt;Membership 
-     *             className="org.apache.catalina.cluster.mcast.McastService"
-     *             mcastAddr="228.0.0.4"
-     *             mcastPort="8012"
-     *             mcastFrequency="1000"
-     *             mcastDropTime="30000"/&gt;
-     * </pre>
-     */
-    protected void createDefaultMembershipService() {
-        if (log.isInfoEnabled()) {
-            log.info(sm.getString(
-                    "SimpleTcpCluster.default.addMembershipService",
-                    getClusterName()));
-        }
-        
-        McastService mService= new McastService();
-        mService.setMcastAddr("228.0.0.4");
-        mService.setMcastPort(8012);
-        mService.setMcastFrequency(1000);
-        mService.setMcastDropTime(30000);
-        transferProperty("service",mService);        
-        setMembershipService(mService);          
-    }
-
-    
-    /**
-     * Create default cluster sender
-     * <pre>
-     *  &lt;Sender
-     *     className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
-     *     replicationMode="fastasyncqueue"
-     *     doTransmitterProcessingStats="true"
-     *     doProcessingStats="true"/&gt;
-     *  </pre>
-     */
-    protected void createDefaultClusterSender() {
-        if (log.isInfoEnabled()) {
-            log.info(sm.getString(
-                    "SimpleTcpCluster.default.addClusterSender",
-                    getClusterName()));
-        }        
-        ReplicationTransmitter sender= new ReplicationTransmitter();
-        sender.setReplicationMode("fastasyncqueue");
-        sender.setDoTransmitterProcessingStats(true);
-        sender.setProperty("doProcessingStats", "true");
-        transferProperty("sender",sender);
-        setClusterSender(sender);          
-    }
-
-    /**
-     * Create default receiver:
-     * <pre>
-     *   &lt;Receiver 
-     *     className="org.apache.catalina.cluster.tcp.SocketReplicationListener"
-     *     tcpListenAddress="auto"
-     *     tcpListenPort="8015"
-     *     tcpListenMaxPort="8019"
-     *     doReceivedProcessingStats="true"
-     *   /&gt;
-     * </pre>
-     */
-    protected void createDefaultClusterReceiver() {
-        if (log.isInfoEnabled()) {
-            log.info(sm.getString(
-                    "SimpleTcpCluster.default.addClusterReceiver",
-                    getClusterName()));
-        }
-        SocketReplicationListener receiver= new SocketReplicationListener();
-        receiver.setTcpListenAddress("auto");
-        receiver.setDoReceivedProcessingStats(true);
-        receiver.setTcpListenPort(8015);
-        receiver.setTcpListenMaxPort(8019);
-        transferProperty("receiver",receiver);
-        setClusterReceiver(receiver);          
-        
-    }
-
-    /**
-     * Create default session cluster listener:
-     *  <pre>
-     * &lt;ClusterListener 
-     *   className="org.apache.catalina.cluster.session.ClusterSessionListener" /&gt;
-     * </pre>
-     */
-    protected void createDefaultClusterListener() {
-        if (log.isInfoEnabled()) {
-            log.info(sm.getString(
-                    "SimpleTcpCluster.default.addClusterListener",
-                    getClusterName()));
-        }
-        ClusterSessionListener listener = new ClusterSessionListener();
-        transferProperty("listener",listener);
-        addClusterListener(listener);
-        
-    }
-
-    /**
-     * Create default ReplicationValve
-     * <pre>
-     * &lt;Valve 
-     *    className="org.apache.catalina.cluster.tcp.ReplicationValve"
-     *    filter=".*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"
-     *    primaryIndicator="true" /&gt;
-     * </pre>
-     */
-    protected void createDefaultClusterValves() {
-        if (log.isInfoEnabled()) {
-            log.info(sm.getString(
-                    "SimpleTcpCluster.default.addClusterValves",
-                    getClusterName()));
-        }
-        ReplicationValve valve= new ReplicationValve() ;
-        valve.setFilter(".*\\.gif;.*\\.js;.*\\.css;.*\\.png;.*\\.jpeg;.*\\.jpg;.*\\.htm;.*\\.html;.*\\.txt;");
-        valve.setPrimaryIndicator(true);
-        transferProperty("valve",valve);
-        addValve(valve);
-        
-    }
-
-    /**
      * register all cluster valve to host or engine
      * @throws Exception
      * @throws ClassNotFoundException
@@ -971,36 +742,16 @@
         if (clusterDeployer != null) {
             clusterDeployer.stop();
         }
-        // FIXME remove registered managers!!
-        if(membershipService != null) {
-            membershipService.stop();
-            membershipService.removeMembershipListener();
-        }
-        if(clusterSender != null) {
-            try {
-                clusterSender.stop();
-            } catch (Exception x) {
-                log.error("Unable to stop cluster sender.", x);
-            }
-        }
-        if(clusterReceiver != null ){
-            try {
-                clusterReceiver.stop();
-                clusterReceiver.setCatalinaCluster(null);
-            } catch (Exception x) {
-                log.error("Unable to stop cluster receiver.", x);
-            }
-        }
-        unregisterMBeans();
+        this.managers.clear();
         try {
-            unregisterClusterValve();
+            channel.stop(ClusterChannel.DEFAULT);
+            this.unregisterClusterValve();
         } catch (Exception x) {
             log.error("Unable to stop cluster valve.", x);
         }
         started = false;
         // Notify our interested LifecycleListeners
         lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, this);
-        clusterLog = null ;
    }
 
     
@@ -1040,22 +791,7 @@
      * @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);
+        throw new UnsupportedOperationException();
     } 
 
     
@@ -1068,29 +804,19 @@
      *      org.apache.catalina.cluster.Member)
      */
     public void send(ClusterMessage msg, Member dest) {
-        long start = 0;
-        if (doClusterLog)
-            start = System.currentTimeMillis();
         try {
-            msg.setAddress(membershipService.getLocalMember());
+            msg.setAddress(getMembershipService().getLocalMember());
             if (dest != null) {
-                if (!membershipService.getLocalMember().equals(dest)) {
-                    clusterSender.sendMessage(msg, dest);
+                if (!getMembershipService().getLocalMember().equals(dest)) {
+                    channel.send(new Member[] {dest}, msg, 0);
                 } else
                     log.error("Unable to send message to local member " + msg);
             } else {
-                clusterSender.sendMessage(msg);
+                channel.send(null,msg,0);
             }
         } catch (Exception x) {
-            if (notifyLifecycleListenerOnFailure) {
-                // Notify our interested LifecycleListeners
-                lifecycle.fireLifecycleEvent(SEND_MESSAGE_FAILURE_EVENT,
-                        new SendMessageData(msg, dest, x));
-            }
             log.error("Unable to send message through cluster sender.", x);
         }
-        if (doClusterLog)
-            logSendMessage(msg, start, dest);
     }
 
     /**
@@ -1100,11 +826,9 @@
      */
     public void memberAdded(Member member) {
         try {
-            if (log.isInfoEnabled())
-                log.info("Replication member added:" + member);
+            if (log.isInfoEnabled()) log.info("Replication member added:" + member);
             // Notify our interested LifecycleListeners
             lifecycle.fireLifecycleEvent(BEFORE_MEMBERREGISTER_EVENT, member);
-            clusterSender.add(member);
             // Notify our interested LifecycleListeners
             lifecycle.fireLifecycleEvent(AFTER_MEMBERREGISTER_EVENT, member);
         } catch (Exception x) {
@@ -1119,12 +843,10 @@
      * @see org.apache.catalina.cluster.MembershipListener#memberDisappeared(org.apache.catalina.cluster.Member)
      */
     public void memberDisappeared(Member member) {
-        if (log.isInfoEnabled())
-            log.info("Received member disappeared:" + member);
+        if (log.isInfoEnabled()) log.info("Received member disappeared:" + member);
         try {
             // Notify our interested LifecycleListeners
             lifecycle.fireLifecycleEvent(BEFORE_MEMBERUNREGISTER_EVENT, member);
-            clusterSender.remove(member);
             // Notify our interested LifecycleListeners
             lifecycle.fireLifecycleEvent(AFTER_MEMBERUNREGISTER_EVENT, member);
         } catch (Exception x) {
@@ -1143,11 +865,9 @@
      * @param message
      *            receveived Message
      */
-    public void receive(ClusterMessage message) {
+    public void messageReceived(ClusterMessage message) {
 
         long start = 0;
-        if (doClusterLog)
-            start = System.currentTimeMillis();
         if (log.isDebugEnabled() && message != null)
             log.debug("Assuming clocks are synched: Replication for "
                     + message.getUniqueId() + " took="
@@ -1176,183 +896,17 @@
                     + message.getClass().getName()
                     + " transfered but no listener registered");
         }
-        if (doClusterLog)
-            logReceiveMessage(message, start, accepted);
     }
 
     // --------------------------------------------------------- Logger
 
-    /**
-     * @return Returns the clusterLogName.
-     */
-    public String getClusterLogName() {
-        return clusterLogName;
-    }
-    
-    /**
-     * @param clusterLogName The clusterLogName to set.
-     */
-    public void setClusterLogName(String clusterLogName) {
-        this.clusterLogName = clusterLogName;
-    }
-    
-    /**
-     * @return Returns the doClusterLog.
-     */
-    public boolean isDoClusterLog() {
-        return doClusterLog;
-    }
-    
-    /**
-     * @param doClusterLog The doClusterLog to set.
-     */
-    public void setDoClusterLog(boolean doClusterLog) {
-        this.doClusterLog = doClusterLog;
-    }    
     public Log getLogger() {
         return log;
     }
 
-    public Log getClusterLog() {
-        if (clusterLog == null && clusterLogName != null
-                && !"".equals(clusterLogName))
-            clusterLog = LogFactory.getLog(clusterLogName);
-
-        return clusterLog;
-    }
-
-    /**
-     * log received message to cluster transfer log
-     * @param message
-     * @param start
-     * @param accepted
-     */
-    protected void logReceiveMessage(ClusterMessage message, long start,
-            boolean accepted) {
-        if (clusterLog != null && clusterLog.isInfoEnabled()) {
-            clusterLog.info(sm.getString("SimpleTcpCluster.log.receive", new Object[] {
-                    new Date(start),
-                    new Long(System.currentTimeMillis() - start),
-                    message.getAddress().getHost(),
-                    new Integer(message.getAddress().getPort()),
-                    message.getUniqueId(), new Boolean(accepted) }));
-        }
-    }
-
-    /**
-     * log sended message to cluster transfer log
-     * @param message
-     * @param start
-     * @param dest
-     */
-    protected void logSendMessage(ClusterMessage message, long start,
-            Member dest) {
-        if (clusterLog != null && clusterLog.isInfoEnabled()) {
-            if (dest != null) {
-                clusterLog.info(sm.getString("SimpleTcpCluster.log.send",
-                        new Object[] { new Date(start),
-                                new Long(System.currentTimeMillis() - start),
-                                dest.getHost(), new Integer(dest.getPort()),
-                                message.getUniqueId() }));
-            } else {
-                clusterLog.info(sm.getString("SimpleTcpCluster.log.send.all",
-                        new Object[] { new Date(start),
-                                new Long(System.currentTimeMillis() - start),
-                                message.getUniqueId() }));
-            }
-        }
-    }
-
-    // --------------------------------------------- JMX MBeans
-
-    /**
-     * register Means at cluster.
-     */
-    protected void registerMBeans() {
-        try {
-            getMBeanServer();
-            String domain = mserver.getDefaultDomain();
-            String name = ":type=Cluster";
-            if (container instanceof StandardHost) {
-                domain = ((StandardHost) container).getDomain();
-                name += ",host=" + container.getName();
-            } else {
-                if (container instanceof StandardEngine) {
-                    domain = ((StandardEngine) container).getDomain();
-                }
-            }
-            ObjectName clusterName = new ObjectName(domain + name);
-
-            if (mserver.isRegistered(clusterName)) {
-                if (log.isWarnEnabled())
-                    log.warn(sm.getString("cluster.mbean.register.already",
-                            clusterName));
-                return;
-            }
-            setObjectName(clusterName);
-            mserver.registerMBean(getManagedBean(this), getObjectName());
-        } catch (Exception ex) {
-            log.error(ex.getMessage(), ex);
-        }
-    }
-
-    protected void unregisterMBeans() {
-        if (mserver != null) {
-            try {
-                mserver.unregisterMBean(getObjectName());
-            } catch (Exception e) {
-                log.error(e);
-            }
-        }
-    }
-
-    /**
-     * Get current Catalina MBean Server and load mbean registry
-     * 
-     * @return The server
-     * @throws Exception
-     */
-    public MBeanServer getMBeanServer() throws Exception {
-        if (mserver == null) {
-            if (MBeanServerFactory.findMBeanServer(null).size() > 0) {
-                mserver = (MBeanServer) MBeanServerFactory
-                        .findMBeanServer(null).get(0);
-            } else {
-                mserver = MBeanServerFactory.createMBeanServer();
-            }
-            registry = Registry.getRegistry(null, null);
-            registry.loadMetadata(this.getClass().getResourceAsStream(
-                    "mbeans-descriptors.xml"));
-        }
-        return (mserver);
-    }
 
-    /**
-     * Returns the ModelMBean
-     * 
-     * @param object
-     *            The Object to get the ModelMBean for
-     * @return The ModelMBean
-     * @throws Exception
-     *             If an error occurs this constructors throws this exception
-     */
-    public ModelMBean getManagedBean(Object object) throws Exception {
-        ModelMBean mbean = null;
-        if (registry != null) {
-            ManagedBean managedBean = registry.findManagedBean(object.getClass().getName());
-            mbean = managedBean.createMBean(object);
-        }
-        return mbean;
-    }
-
-    public void setObjectName(ObjectName name) {
-        objectName = name;
-    }
-
-    public ObjectName getObjectName() {
-        return objectName;
-    }
 
+    
     // ------------------------------------------------------------- deprecated
 
     /**



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


Mime
View raw message