tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r380923 - in /tomcat/container/tc5.5.x/modules: groupcom/src/share/org/apache/catalina/cluster/ groupcom/src/share/org/apache/catalina/cluster/group/ groupcom/src/share/org/apache/catalina/cluster/io/ groupcom/src/share/org/apache/catalina/...
Date Sat, 25 Feb 2006 11:58:44 GMT
Author: fhanik
Date: Sat Feb 25 03:58:40 2006
New Revision: 380923

URL: http://svn.apache.org/viewcvs?rev=380923&view=rev
Log:
Completed server.xml refactoring and separated out cluster communication, referred to as channel
from session replication

Added:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelListener.java
Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Channel.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelMessage.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.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/io/XByteBuffer.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
    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/ClusterRuleSet.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Channel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Channel.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Channel.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Channel.java
Sat Feb 25 03:58:40 2006
@@ -15,6 +15,8 @@
  */
 package org.apache.catalina.cluster;
 
+import java.io.Serializable;
+
 /**
  * Channel interface
  * A channel is an object that manages a group of members.
@@ -72,7 +74,7 @@
      * @param options int - sender options, see class documentation
      * @return ClusterMessage[] - the replies from the members, if any. 
      */
-    public ChannelMessage[] send(Member[] destination, ChannelMessage msg, int options) throws
ChannelException;
+    public ChannelMessage[] send(Member[] destination, Serializable msg, int options) throws
ChannelException;
 
     
     public void setClusterSender(ChannelSender sender);
@@ -85,7 +87,7 @@
     public void heartbeat();
     
     public void setMembershipListener(MembershipListener listener);
-    public void setMessageListener(MessageListener listener);
+    public void setChannelListener(ChannelListener listener);
     
     /**
      * has members

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelListener.java?rev=380923&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelListener.java
(added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelListener.java
Sat Feb 25 03:58:40 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 1999,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.cluster;
+
+import java.io.Serializable;
+
+public interface ChannelListener {
+
+    /**
+     * Receive a message from the cluster.
+     * @param msg ClusterMessage
+     * @return ClusterMessage - response to the message sent. <br>
+     * The response object may be ignored and is not required for the 
+     * implementation to send back to the sender.
+     */
+    public void messageReceived(Serializable msg, Member sender);
+
+    public boolean accept(Serializable msg, Member sender);
+
+    public boolean equals(Object listener);
+
+    public int hashCode();
+
+}

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelMessage.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelMessage.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelMessage.java
Sat Feb 25 03:58:40 2006
@@ -23,10 +23,6 @@
  */
 public interface ChannelMessage extends Serializable {
     
-    public final static int RESEND_FORBIDDEN = 0 ;
-    public final static int RESEND_ALLOWED = 1 ;
-    public final static int RESEND_DEFAULT = 2 ;
-    
     /**
      * Get the address that this message originated from.  This would be set
      * if the message was being relayed from a host other than the one

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java
Sat Feb 25 03:58:40 2006
@@ -15,7 +15,7 @@
  */
 package org.apache.catalina.cluster;
 
-import org.apache.catalina.cluster.io.ClusterData;
+import java.io.Serializable;
 
 public interface MessageListener {
     

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=380923&r1=380922&r2=380923&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
Sat Feb 25 03:58:40 2006
@@ -28,6 +28,8 @@
 import org.apache.catalina.cluster.MessageListener;
 import org.apache.catalina.cluster.io.ClusterData;
 import org.apache.catalina.cluster.io.XByteBuffer;
+import java.io.Serializable;
+import org.apache.catalina.cluster.ChannelListener;
 
 /**
  * The GroupChannel manages the replication channel. It coordinates
@@ -41,7 +43,7 @@
     private ChannelCoordinator coordinator = new ChannelCoordinator();
     private ChannelInterceptor interceptors = null;
     private MembershipListener membershipListener;
-    private MessageListener messageListener;
+    private ChannelListener channelListener;
 
     public GroupChannel() {
         addInterceptor(this);
@@ -80,12 +82,10 @@
      * @param options int - sender options, see class documentation
      * @return ClusterMessage[] - the replies from the members, if any.
      */
-    public ChannelMessage[] send(Member[] destination, ChannelMessage msg, int options) throws
ChannelException {
+    public ChannelMessage[] send(Member[] destination, Serializable msg, int options) throws
ChannelException {
         if ( msg == null ) return null;
-        msg.setAddress(getMembershipService().getLocalMember());
-        msg.setTimestamp(System.currentTimeMillis());
         try {
-            ClusterData data = XByteBuffer.serialize(msg, options,false);
+            ClusterData data = XByteBuffer.serialize(msg, options,getMembershipService().getLocalMember());
             return getFirstInterceptor().sendMessage(destination, data, null);
         }catch ( Exception x ) {
             throw new ChannelException(x);
@@ -96,8 +96,8 @@
         if ( msg == null ) return;
         else if ( msg instanceof ClusterData ) {
             try {
-                ChannelMessage fwd = XByteBuffer.deserialize( (ClusterData) msg, false);
-                if ( messageListener != null ) messageListener.messageReceived(fwd);
+                Serializable fwd = XByteBuffer.deserialize( (ClusterData) msg);
+                if ( channelListener != null ) channelListener.messageReceived(fwd,msg.getAddress());
             }catch ( Exception x ) {
                 log.error("Unable to deserialize channel message.",x);
             }
@@ -179,16 +179,18 @@
         this.membershipListener = membershipListener;
     }
 
-    public void setMessageListener(MessageListener messageListener) {
-        this.messageListener = messageListener;
+    public void setChannelListener(ChannelListener channelListener) {
+
+        this.channelListener = channelListener;
     }
 
     public MembershipListener getMembershipListener() {
         return membershipListener;
     }
 
-    public MessageListener getMessageListener() {
-        return messageListener;
+    public ChannelListener getChannelListener() {
+
+        return channelListener;
     }
 
     /**

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
Sat Feb 25 03:58:40 2006
@@ -26,6 +26,9 @@
 import java.io.InputStream;
 import java.util.zip.GZIPInputStream;
 import org.apache.catalina.cluster.io.ReplicationStream;
+import java.io.Serializable;
+import org.apache.catalina.cluster.Member;
+import java.util.UUID;
 
 /**
  * The XByteBuffer provides a dual functionality.
@@ -364,26 +367,21 @@
         return result;
     }
     
-    public static ChannelMessage deserialize(ClusterData data, boolean compress) 
+    public static Serializable deserialize(ClusterData data) 
         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());
-            }
+            InputStream  instream = new ByteArrayInputStream(data.getMessage());
             ReplicationStream stream = new ReplicationStream(instream,new ClassLoader[] {XByteBuffer.class.getClassLoader()});
             message = stream.readObject();
             instream.close();
         }
         if ( message == null ) {
             return null;
-        } else if (message instanceof ChannelMessage)
-            return (ChannelMessage) message;
+        } else if (message instanceof Serializable)
+            return (Serializable) message;
         else {
-            throw new ClassCastException("Message has the wrong class. It should implement
ClusterMessage, instead it is:"+message.getClass().getName());
+            throw new ClassCastException("Message has the wrong class. It should implement
Serializable, instead it is:"+message.getClass().getName());
         }
     }
 
@@ -394,29 +392,20 @@
      * @return ClusterData
      * @throws IOException
      */
-    public static ClusterData serialize(ChannelMessage msg, int options, boolean compress)
throws IOException {
-        msg.setTimestamp(System.currentTimeMillis());
-        ByteArrayOutputStream outs = new ByteArrayOutputStream();
-        ObjectOutputStream out;
-        GZIPOutputStream gout = null;
+    public static ClusterData serialize(Serializable msg, int options, Member local) throws
IOException {
         ClusterData data = new ClusterData();
+        data.setAddress(local);
         data.setType(msg.getClass().getName());
-        data.setUniqueId(msg.getUniqueId());
-        data.setTimestamp(msg.getTimestamp());
+        data.setUniqueId(UUID.randomUUID().toString());
+        data.setTimestamp(System.currentTimeMillis());
         data.setOptions(options);
-        data.setResend(data.RESEND_DEFAULT);
-        data.setAddress(msg.getAddress());
-        if (compress) {
-            gout = new GZIPOutputStream(outs);
-            out = new ObjectOutputStream(gout);
-        } else {
-            out = new ObjectOutputStream(outs);
-        }
+        ByteArrayOutputStream outs = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream(outs);
         out.writeObject(msg);
         // flush out the gzip stream to byte buffer
-        if(gout != null) {
-            gout.flush();
-            gout.close();
+        if(out != null) {
+            out.flush();
+            out.close();
         }
         data.setMessage(outs.toByteArray());
         return data;

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSender.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSender.java
Sat Feb 25 03:58:40 2006
@@ -810,25 +810,26 @@
              writeData(data);
              messageTransfered = true ;
         } catch (java.io.IOException x) {
-            if(data.getResend() == ChannelMessage.RESEND_ALLOWED || 
-                    (data.getResend() == ChannelMessage.RESEND_DEFAULT && isResend()
)) {
-                // second try with fresh connection
-                dataResendCounter++;
-                if (log.isTraceEnabled())
-                    log.trace(sm.getString("IDataSender.send.again", address.getHostAddress(),
-                            new Integer(port)),x);
-                synchronized(this) {
-                    closeSocket();
-                    openSocket();
-                }
-                try {
-                    writeData(data);
-                    messageTransfered = true;
-                } catch (IOException xx) {
-                    exception = xx;
-                    throw xx ;
-                }
-            } else {
+//            if(data.getResend() == ChannelMessage.RESEND_ALLOWED || 
+//                    (data.getResend() == ChannelMessage.RESEND_DEFAULT && isResend()
)) {
+//                // second try with fresh connection
+//                dataResendCounter++;
+//                if (log.isTraceEnabled())
+//                    log.trace(sm.getString("IDataSender.send.again", address.getHostAddress(),
+//                            new Integer(port)),x);
+//                synchronized(this) {
+//                    closeSocket();
+//                    openSocket();
+//                }
+//                try {
+//                    writeData(data);
+//                    messageTransfered = true;
+//                } catch (IOException xx) {
+//                    exception = xx;
+//                    throw xx ;
+//                }
+//            } else 
+            {
                 synchronized(this) {
                     closeSocket();
                 }

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=380923&r1=380922&r2=380923&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
Sat Feb 25 03:58:40 2006
@@ -34,6 +34,7 @@
 import org.apache.catalina.cluster.io.ObjectReader;
 import org.apache.catalina.cluster.io.XByteBuffer;
 import org.apache.catalina.util.StringManager;
+import java.io.Serializable;
 
 /**
  * @author Filip Hanik
@@ -248,11 +249,11 @@
      * @throws ClassNotFoundException
      */
     //protected ClusterMessage deserialize(byte[] data)
-    protected ChannelMessage deserialize(ClusterData data) throws IOException, ClassNotFoundException
{
+    protected Serializable deserialize(ClusterData data) throws IOException, ClassNotFoundException
{
         boolean compress = false;
-        ChannelMessage message = null;
+        Serializable message = null;
         if (data != null) {
-            message = XByteBuffer.deserialize(data, compress);
+            message = XByteBuffer.deserialize(data);
         }
         return message;
     }
@@ -313,8 +314,8 @@
     public void messageDataReceived(ClusterData data) {
         if ( this.listener != null ) {
             try {
-                ChannelMessage msg = deserialize(data);
-                listener.messageReceived(msg);
+                Serializable msg = deserialize(data);
+                listener.messageReceived((ChannelMessage)msg);
             }catch ( java.io.IOException x ) {
                 if ( log.isErrorEnabled() ) {
                     log.error("Unable to receive and deserialize cluster data. IOException.",x);

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
Sat Feb 25 03:58:40 2006
@@ -641,7 +641,7 @@
      * @since 5.5.10
      */
     protected ClusterData serialize(ChannelMessage msg) throws IOException {
-        return XByteBuffer.serialize(msg, 0, false);
+        return XByteBuffer.serialize(msg, 0, msg.getAddress());
     }
  
 

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=380923&r1=380922&r2=380923&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
Sat Feb 25 03:58:40 2006
@@ -122,5 +122,7 @@
     public void removeManager(String name,Manager manager);
     public void addManager(String name,Manager manager);
     public Valve[] getValves();
+    
+    public void setChannel(Channel channel);
 
 }

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterRuleSet.java
Sat Feb 25 03:58:40 2006
@@ -85,29 +85,50 @@
      */
     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",
+        digester.addObjectCreate(prefix + "Channel",
                                  null, // MUST be specified in the element
                                  "className");
-        digester.addSetProperties(prefix + "Sender");
-        digester.addSetNext(prefix + "Sender",
-                            "setClusterSender",
-                            "org.apache.catalina.cluster.ChannelSender");
+        digester.addSetProperties(prefix + "Channel");
+        digester.addSetNext(prefix + "Channel",
+                            "setChannel",
+                            "org.apache.catalina.cluster.Channel");
 
-        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");
+
+        String channelPrefix = prefix + "Channel/";
+        { //channel properties
+            digester.addObjectCreate(channelPrefix + "Membership",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(channelPrefix + "Membership");
+            digester.addSetNext(channelPrefix + "Membership",
+                                "setMembershipService",
+                                "org.apache.catalina.cluster.MembershipService");
+
+            digester.addObjectCreate(channelPrefix + "Sender",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(channelPrefix + "Sender");
+            digester.addSetNext(channelPrefix + "Sender",
+                                "setClusterSender",
+                                "org.apache.catalina.cluster.ChannelSender");
+
+            digester.addObjectCreate(channelPrefix + "Receiver",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(channelPrefix + "Receiver");
+            digester.addSetNext(channelPrefix + "Receiver",
+                                "setClusterReceiver",
+                                "org.apache.catalina.cluster.ChannelReceiver");
+
+            digester.addObjectCreate(channelPrefix + "Interceptor",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(channelPrefix + "Interceptor");
+            digester.addSetNext(channelPrefix + "Interceptor",
+                                "addInterceptor",
+                                "org.apache.catalina.cluster.ChannelInterceptor");
+        }
 
         digester.addObjectCreate(prefix + "Valve",
                                  null, // MUST be specified in the element

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessage.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessage.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessage.java
Sat Feb 25 03:58:40 2006
@@ -20,6 +20,7 @@
 
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.cluster.Member;
+import org.apache.catalina.cluster.ClusterMessageBase;
 
 /**
  * Contains the data for a file being transferred over TCP, this is 
@@ -28,19 +29,16 @@
  * @version 1.0
  */
 
-public class FileMessage implements ClusterMessage, Serializable {
+public class FileMessage extends ClusterMessageBase implements ClusterMessage, Serializable
{
     private int messageNumber;
     private byte[] data;
     private int dataLength;
     private org.apache.catalina.cluster.Member address;
     
-    private long timestamp;
     private long totalLength;
     private long totalNrOfMsgs;
     private String fileName;
     private String contextPath;
-    private int resend = ClusterMessage.RESEND_FORBIDDEN;
-    private int options = ClusterMessage.RESEND_DEFAULT ;
     
     public FileMessage(Member source,
                        String fileName,
@@ -106,12 +104,7 @@
         return result.toString();
     }
 
-    public long getTimestamp() {
-        return timestamp;
-    }
-    public void setTimestamp(long timestamp) {
-        this.timestamp = timestamp;
-    }
+    
     public String getFileName() {
         return fileName;
     }
@@ -121,35 +114,5 @@
     public String getContextPath() {
         return contextPath;
     }
-
-    /**
-     * @return Returns the compress.
-     * @since 5.5.10 
-     */
-    public int getOptions() {
-
-        return options;
-    }
-    /**
-     * @param compress The compress to set.
-     * @since 5.5.10
-     */
-    public void setOptions(int options) {
-
-        this.options = options;
-    }
-    /**
-     * @return Returns the resend.
-     * @since 5.5.10
-     */
-    public int getResend() {
-        return resend;
-    }
-    /**
-     * @param resend The resend to set.
-     * @since 5.5.10
-     */
-    public void setResend(int resend) {
-        this.resend = resend;
-    }
+    
 }

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java
Sat Feb 25 03:58:40 2006
@@ -26,8 +26,6 @@
     private String uniqueId;
     private String contextPath;
     private boolean undeploy;
-    private int resend = ClusterMessage.RESEND_DEFAULT ;
-    private int options = ClusterMessage.RESEND_DEFAULT ;
 
     public UndeployMessage() {} //for serialization
     public UndeployMessage(Member address,
@@ -82,35 +80,4 @@
     public void setUndeploy(boolean undeploy) {
         this.undeploy = undeploy;
     }
-    /**
-     * @return Returns the compress.
-     * @since 5.5.10 
-     */
-    public int getOptions() {
-
-        return options;
-    }
-    /**
-     * @param compress The compress to set.
-     * @since 5.5.10
-     */
-    public void setOptions(int options) {
-
-        this.options = options;
-    }
-    /**
-     * @return Returns the resend.
-     * @since 5.5.10
-     */
-    public int getResend() {
-        return resend;
-    }
-    /**
-     * @param resend The resend to set.
-     * @since 5.5.10
-     */
-    public void setResend(int resend) {
-        this.resend = resend;
-    }
-
 }

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
Sat Feb 25 03:58:40 2006
@@ -942,7 +942,6 @@
                     SessionMessage.EVT_GET_ALL_SESSIONS, null, "GET-ALL",
                     "GET-ALL-" + getName());
             // set reference time
-            msg.setTimestamp(beforeSendTime);
             stateTransferCreateSendTime = beforeSendTime ;
             // request session state
             counterSend_EVT_GET_ALL_SESSIONS++;

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java
Sat Feb 25 03:58:40 2006
@@ -16,6 +16,7 @@
 package org.apache.catalina.cluster.session;
 
 import org.apache.catalina.cluster.ClusterMessage;
+import org.apache.catalina.cluster.ClusterMessageBase;
 
 /**
  * Session id change cluster message
@@ -24,22 +25,16 @@
  * 
  * @version $Revision: 326110 $ $Date: 2005-10-18 09:08:36 -0500 (Tue, 18 Oct 2005) $
  */
-public class SessionIDMessage implements ClusterMessage {
-
-	private org.apache.catalina.cluster.Member address;
+public class SessionIDMessage extends ClusterMessageBase implements ClusterMessage {
 
 	private int messageNumber;
 
-	private long timestamp;
-
 	private String orignalSessionID;
 
 	private String backupSessionID;
 
 	private String host ;
 	private String contextPath;
-    private int resend = ClusterMessage.RESEND_DEFAULT ;
-    private int options = ClusterMessage.RESEND_DEFAULT ;
 
 	public org.apache.catalina.cluster.Member getAddress() {
 		return address;
@@ -103,21 +98,7 @@
 		this.messageNumber = messageNumber;
 	}
 
-	/**
-	 * @return Returns the timestamp.
-	 */
-	public long getTimestamp() {
-		return timestamp;
-	}
-
-	/**
-	 * @param timestamp
-	 *            The timestamp to set.
-	 */
-	public void setTimestamp(long timestamp) {
-		this.timestamp = timestamp;
-	}
-
+	
 	/**
 	 * @return Returns the backupSessionID.
 	 */
@@ -148,36 +129,7 @@
 		this.orignalSessionID = orignalSessionID;
 	}
 
-    /**
-     * @return Returns the compress.
-     * @since 5.5.10 
-     */
-    public int getOptions() {
-
-        return options;
-    }
-    /**
-     * @param compress The compress to set.
-     * @since 5.5.10
-     */
-    public void setOptions(int options) {
-
-        this.options = options;
-    }
-    /**
-     * @return Returns the resend.
-     * @since 5.5.10
-     */
-    public int getResend() {
-        return resend;
-    }
-    /**
-     * @param resend The resend to set.
-     * @since 5.5.10
-     */
-    public void setResend(int resend) {
-        this.resend = resend;
-    }
+    
 
 
 }

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java?rev=380923&r1=380922&r2=380923&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
(original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
Sat Feb 25 03:58:40 2006
@@ -18,6 +18,7 @@
 
 import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.cluster.Member;
+import org.apache.catalina.cluster.ClusterMessageBase;
 
 /**
  * Session cluster message
@@ -27,7 +28,7 @@
  * 
  * @version $Revision: 326110 $ $Date: 2005-10-18 09:08:36 -0500 (Tue, 18 Oct 2005) $
  */
-public class SessionMessageImpl implements SessionMessage, java.io.Serializable {
+public class SessionMessageImpl extends ClusterMessageBase implements SessionMessage, java.io.Serializable
{
     
     public SessionMessageImpl() {
     }
@@ -40,13 +41,11 @@
     private int mEvtType = -1;
     private byte[] mSession;
     private String mSessionID;
-    private Member mSrc;
+
     private String mContextName;
     private long serializationTimestamp;
     private boolean timestampSet = false ;
     private String uniqueId;
-    private int resend = ClusterMessage.RESEND_DEFAULT ;
-    private int options = 0;
 
 
     private SessionMessageImpl( String contextName,
@@ -145,26 +144,6 @@
         }
     }
 
-    /**
-     * Get the address that this message originated from.  This would be set
-     * if the message was being relayed from a host other than the one
-     * that originally sent it.
-     */
-    public Member getAddress()
-    {
-        return this.mSrc;
-    }
-
-    /**
-     * Use this method to set the address that this message originated from.
-     * This can be used when re-sending the EVT_GET_ALL_SESSIONS message to
-     * another machine in the group.
-     */
-    public void setAddress(Member src)
-    {
-        this.mSrc = src;
-    }
-
     public String getContextName() {
        return mContextName;
     }
@@ -173,37 +152,6 @@
     }
     public void setUniqueId(String uniqueId) {
         this.uniqueId = uniqueId;
-    }
-
-    /**
-     * @return Returns the compress.
-     * @since 5.5.10 
-     */
-    public int getOptions() {
-
-        return options;
-    }
-    /**
-     * @param compress The compress to set.
-     * @since 5.5.10
-     */
-    public void setOptions(int options) {
-
-        this.options = options;
-    }
-    /**
-     * @return Returns the resend.
-     * @since 5.5.10
-     */
-    public int getResend() {
-        return resend;
-    }
-    /**
-     * @param resend The resend to set.
-     * @since 5.5.10
-     */
-    public void setResend(int resend) {
-        this.resend = resend;
     }
 
 }

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=380923&r1=380922&r2=380923&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
Sat Feb 25 03:58:40 2006
@@ -18,6 +18,7 @@
 
 import java.beans.PropertyChangeSupport;
 import java.io.IOException;
+import java.io.Serializable;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -36,14 +37,16 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.catalina.cluster.CatalinaCluster;
+import org.apache.catalina.cluster.Channel;
+import org.apache.catalina.cluster.ChannelListener;
 import org.apache.catalina.cluster.ClusterListener;
 import org.apache.catalina.cluster.ClusterManager;
 import org.apache.catalina.cluster.ClusterMessage;
-import org.apache.catalina.cluster.ChannelSender;
 import org.apache.catalina.cluster.ClusterValve;
 import org.apache.catalina.cluster.Member;
-import org.apache.catalina.cluster.MembershipService;
+import org.apache.catalina.cluster.MembershipListener;
 import org.apache.catalina.cluster.group.GroupChannel;
+import org.apache.catalina.cluster.group.interceptors.GzipInterceptor;
 import org.apache.catalina.cluster.session.DeltaManager;
 import org.apache.catalina.cluster.util.IDynamicProperty;
 import org.apache.catalina.util.LifecycleSupport;
@@ -51,11 +54,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.catalina.cluster.group.interceptors.GzipInterceptor;
-import org.apache.catalina.cluster.MembershipListener;
-import org.apache.catalina.cluster.MessageListener;
-import org.apache.catalina.cluster.Channel;
-import org.apache.catalina.cluster.ChannelMessage;
 
 /**
  * A <b>Cluster </b> implementation using simple multicast. Responsible for
@@ -72,7 +70,7 @@
  */
 public class SimpleTcpCluster 
     implements CatalinaCluster, Lifecycle, LifecycleListener, IDynamicProperty,
-               MembershipListener, MessageListener{
+               MembershipListener, ChannelListener{
 
     public static Log log = LogFactory.getLog(SimpleTcpCluster.class);
 
@@ -330,6 +328,10 @@
         this.clusterDeployer = clusterDeployer;
     }
 
+    public void setChannel(Channel channel) {
+        this.channel = channel;
+    }
+
     /**
      * has members
      */
@@ -453,6 +455,10 @@
         return managers;
     }
 
+    public Channel getChannel() {
+        return channel;
+    }
+
     /**
      * Create new Manager without add to cluster (comes with start the manager)
      * 
@@ -647,11 +653,9 @@
             if ( clusterDeployer != null ) clusterDeployer.setCluster(this);
             this.registerClusterValve();
             channel.setMembershipListener(this);
-            channel.setMessageListener(this);
-            channel.addInterceptor(new GzipInterceptor());
+            channel.setChannelListener(this);
             channel.start(channel.DEFAULT);
             if (clusterDeployer != null) clusterDeployer.start();
-
             this.started = true;
             // Notify our interested LifecycleListeners
             lifecycle.fireLifecycleEvent(AFTER_START_EVENT, this);
@@ -830,13 +834,15 @@
      * @param message
      *            receveived Message
      */
-    public boolean accept(ChannelMessage msg) {
+    public boolean accept(Serializable msg, Member sender) {
         return (msg instanceof ClusterMessage);
     }
     
     
-    public void messageReceived(ChannelMessage message) {
-        messageReceived((ClusterMessage)message);
+    public void messageReceived(Serializable message, Member sender) {
+        ClusterMessage fwd = (ClusterMessage)message;
+        fwd.setAddress(sender);
+        messageReceived(fwd);
     }
 
     public void messageReceived(ClusterMessage message) {



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


Mime
View raw message