tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r381388 - in /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes: ./ group/ group/interceptors/ tcp/
Date Mon, 27 Feb 2006 17:16:29 GMT
Author: fhanik
Date: Mon Feb 27 09:16:26 2006
New Revision: 381388

URL: http://svn.apache.org/viewcvs?rev=381388&view=rev
Log:
enhanced error handling throughout the stack

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelException.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelInterceptor.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelInterceptorBase.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/GzipInterceptor.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelException.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelException.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelException.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelException.java
Mon Feb 27 09:16:26 2006
@@ -15,6 +15,9 @@
  */
 package org.apache.catalina.tribes;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+
 /**
  * Channel Exception 
  * @author Filip Hanik
@@ -23,6 +26,7 @@
 
 public class ChannelException
     extends Exception {
+    private ArrayList faultyMembers=null;
     public ChannelException() {
         super();
     }
@@ -37,6 +41,25 @@
 
     public ChannelException(Throwable cause) {
         super(cause);
+    }
+    
+    public void addFaultyMember(Member mbr) {
+        if ( this.faultyMembers==null ) this.faultyMembers = new ArrayList();
+        faultyMembers.add(mbr);
+    }
+
+    public void setFaultyMembers(ArrayList faultyMembers) {
+        this.faultyMembers = faultyMembers;
+    }
+
+    public void setFaultyMembers(Member[] faultyMembers) {
+        if ( this.faultyMembers==null ) this.faultyMembers = new ArrayList();
+        this.faultyMembers.addAll(Arrays.asList(faultyMembers));
+    }
+
+    public Member[] getFaultyMembers() {
+        if ( this.faultyMembers==null ) return new Member[0];
+        return (Member[])faultyMembers.toArray(new Member[faultyMembers.size()]);
     }
 
 }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelInterceptor.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelInterceptor.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelInterceptor.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelInterceptor.java
Mon Feb 27 09:16:26 2006
@@ -38,7 +38,7 @@
 
     public ChannelInterceptor getPrevious();
 
-    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws IOException;
+    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException;
     
     public void messageReceived(ChannelMessage data);
     

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelSender.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelSender.java
Mon Feb 27 09:16:26 2006
@@ -38,8 +38,6 @@
 
     public void sendMessage(ChannelMessage message, Member member) throws java.io.IOException;
 
-    public void sendMessage(ChannelMessage message) throws java.io.IOException;
-    
     public boolean getWaitForAck();
     public void setWaitForAck(boolean isWaitForAck);
 }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
Mon Feb 27 09:16:26 2006
@@ -60,11 +60,18 @@
      * @param options int - sender options, see class documentation
      * @return ClusterMessage[] - the replies from the members, if any.
      */
-    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws IOException {
+    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException {
         if ( destination == null ) destination = membershipService.getMembers();
+        ChannelException exception = null;
         for ( int i=0; i<destination.length; i++ ) {
-            clusterSender.sendMessage(msg,destination[i]);
+            try {
+                clusterSender.sendMessage(msg, destination[i]);
+            }catch ( Exception x ) {
+                if ( exception == null ) exception = new ChannelException(x);
+                exception.addFaultyMember(destination[i]);
+            }
         }
+        if ( exception != null ) throw exception;
     }
 
 

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelInterceptorBase.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelInterceptorBase.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelInterceptorBase.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelInterceptorBase.java
Mon Feb 27 09:16:26 2006
@@ -23,6 +23,7 @@
 import org.apache.catalina.tribes.ChannelInterceptor;
 import org.apache.catalina.tribes.InterceptorPayload;
 import org.apache.catalina.tribes.io.ClusterData;
+import org.apache.catalina.tribes.ChannelException;
 
 /**
  * Abstract class for the interceptor base class.
@@ -57,7 +58,7 @@
         return previous;
     }
 
-    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws IOException {
+    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException {
         if ( getNext() != null ) getNext().sendMessage(destination, msg, payload);
     }
     

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
Mon Feb 27 09:16:26 2006
@@ -109,6 +109,7 @@
             data.setMessage(b);
             getFirstInterceptor().sendMessage(destination, data, null);
         }catch ( Exception x ) {
+            if ( x instanceof ChannelException ) throw (ChannelException)x;
             throw new ChannelException(x);
         }
     }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/GzipInterceptor.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/GzipInterceptor.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/GzipInterceptor.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/GzipInterceptor.java
Mon Feb 27 09:16:26 2006
@@ -26,6 +26,7 @@
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
 import java.util.Arrays;
+import org.apache.catalina.tribes.ChannelException;
 
 
 
@@ -38,13 +39,13 @@
 public class GzipInterceptor extends ChannelInterceptorBase {
     public static final int DEFAULT_BUFFER_SIZE = 2048;
     
-    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws IOException {
+    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException {
         try {
             msg.setMessage(compress(msg.getMessage()));
             getNext().sendMessage(destination, msg, payload);
         } catch ( IOException x ) {
             log.error("Unable to compress byte contents");
-            throw x;
+            throw new ChannelException(x);
         }
     }
 

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java
Mon Feb 27 09:16:26 2006
@@ -810,6 +810,7 @@
              writeData(data);
              messageTransfered = true ;
         } catch (java.io.IOException x) {
+            exception = x;
             if( true ) { //allow resend
                 // second try with fresh connection
                 dataResendCounter++;
@@ -823,19 +824,16 @@
                 try {
                     writeData(data);
                     messageTransfered = true;
+                    exception = null;
                 } catch (IOException xx) {
                     xx.fillInStackTrace();
                     exception = xx;
-                    throw xx ;
                 }
             } else 
             {
-                
                 synchronized(this) {
                     closeSocket();
                 }
-                exception = x;
-                throw x ;
             }
         } finally {
             this.keepAliveCount++;

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java?rev=381388&r1=381387&r2=381388&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java
Mon Feb 27 09:16:26 2006
@@ -386,34 +386,30 @@
         }
     }
     
-    public void sendMessage(ChannelMessage message) throws IOException {
-        sendMessage(message,false);
-    }
-
     /**
      * send message to all senders (broadcast)
      * @see org.apache.catalina.tribes.ClusterSender#sendMessage(org.apache.catalina.tribes.ClusterMessage)
      */
-    public void sendMessage(ChannelMessage message, boolean domainOnly) throws IOException
{
-        long time = 0;
-        if (doTransmitterProcessingStats) {
-            time = System.currentTimeMillis();
-        }
-        try {
-            IDataSender[] senders = getSenders();
-            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(message, sender);
-            }
-        } finally {
-            if (doTransmitterProcessingStats) {
-                addProcessingStats(time);
-            }
-        }
-    }
+//    public void sendMessage(ChannelMessage message, boolean domainOnly) throws IOException
{
+//        long time = 0;
+//        if (doTransmitterProcessingStats) {
+//            time = System.currentTimeMillis();
+//        }
+//        try {
+//            IDataSender[] senders = getSenders();
+//            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(message, sender);
+//            }
+//        } finally {
+//            if (doTransmitterProcessingStats) {
+//                addProcessingStats(time);
+//            }
+//        }
+//    }
         
     
 
@@ -592,8 +588,8 @@
      * @return true if the message got sent, false otherwise
      * @throws java.io.IOException If an error occurs
      */
-    protected boolean sendMessageData(ChannelMessage data,
-                                      IDataSender sender) {
+    protected void sendMessageData(ChannelMessage data,
+                                   IDataSender sender) throws IOException {
         if (sender == null)
             throw new RuntimeException("Sender not available. Make sure sender information
is available to the ReplicationTransmitter.");
         try {
@@ -607,8 +603,7 @@
             sender.sendMessage(data);
             sender.setSuspect(false);
             addStats(data.getMessage().length);
-            return true;
-        } catch (Exception x) {
+        } catch (IOException x) {
             if (!sender.getSuspect()) {
                 if (log.isErrorEnabled() ) log.error("Unable to send replicated message,
is member ["+sender.toString()+"] down?",x);
             } else if (log.isDebugEnabled() ) {
@@ -616,7 +611,7 @@
             }
             sender.setSuspect(true);
             failureCounter++;
-            return false;
+            throw x;
         }
 
     }



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


Mime
View raw message