tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r376115 - in /tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp: DataSender.java PooledSocketSender.java ReplicationTransmitter.java SenderState.java SocketSender.java
Date Wed, 08 Feb 2006 23:28:05 GMT
Author: fhanik
Date: Wed Feb  8 15:27:58 2006
New Revision: 376115

URL: http://svn.apache.org/viewcvs?rev=376115&view=rev
Log:
Fixed error reporting. When a node crashes, instead of filling up the logs with oodles and
oodles of errors message the system will now print the error once if there is one and then
mark the member as a suspect.
To view all error message, you can still enable debug logging and it will show up in the logs,
so they don't get swallowed.


Added:
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SenderState.java
Modified:
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/PooledSocketSender.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SocketSender.java

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java?rev=376115&r1=376114&r2=376115&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/DataSender.java
Wed Feb  8 15:27:58 2006
@@ -16,15 +16,12 @@
 
 package org.apache.catalina.cluster.tcp;
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-
-import org.apache.catalina.cluster.ClusterMessage;
-import org.apache.catalina.cluster.io.XByteBuffer;
-import org.apache.catalina.util.StringManager;
+import java.io.*;
+import java.net.*;
+
+import org.apache.catalina.cluster.*;
+import org.apache.catalina.cluster.io.*;
+import org.apache.catalina.util.*;
 
 /**
  * Send cluster messages with only one socket. Ack and keep Alive Handling is
@@ -87,7 +84,7 @@
     /**
      * sender is in suspect state (last transfer failed)
      */
-    private boolean suspect = false;
+    private SenderState senderState = new SenderState();
 
     /**
      * wait time for ack
@@ -221,10 +218,13 @@
         this.port = port;
         this.domain = domain;
         if (log.isDebugEnabled())
-            log.debug(sm.getString("IDataSender.create",address, new Integer(
-                    port)));
+            log.debug(sm.getString("IDataSender.create",address, new Integer(port)));
     }
 
+    public DataSender(String domain,InetAddress host, int port, SenderState state) {
+        this(domain,host,port);
+        if ( state != null ) this.senderState = state;
+    }
     // ------------------------------------------------------------- Properties
 
     /**
@@ -457,15 +457,18 @@
     }
 
     public boolean isSuspect() {
-        return suspect;
+        return senderState.isSuspect() || senderState.isFailing();
     }
 
     public boolean getSuspect() {
-        return suspect;
+        return isSuspect();
     }
 
     public void setSuspect(boolean suspect) {
-        this.suspect = suspect;
+        if ( suspect ) 
+            this.senderState.setSuspect();
+        else
+            this.senderState.setReady();
     }
 
     public long getAckTimeout() {
@@ -539,6 +542,11 @@
     public Socket getSocket() {
         return socket;
     }
+
+    public SenderState getSenderState() {
+        return senderState;
+    }
+
     /**
      * @param socket The socket to set.
      */
@@ -903,11 +911,14 @@
             }
         } catch (IOException x) {
             missingAckCounter++;
+            String errmsg = sm.getString("IDataSender.ack.missing", getAddress(),
+                                         new Integer(socket.getLocalPort()), 
+                                         new Long(this.ackTimeout));
             if ( !this.isSuspect() ) {
-                log.warn(sm.getString("IDataSender.ack.missing", getAddress(),
-                                      new Integer(socket.getLocalPort()), 
-                                      new Long(this.ackTimeout)), x);
                 this.setSuspect(true);
+                if ( log.isWarnEnabled() ) log.warn(errmsg, x);
+            } else {
+                if ( log.isDebugEnabled() )log.debug(errmsg, x);
             }
             throw x;
         } finally {

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/PooledSocketSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/PooledSocketSender.java?rev=376115&r1=376114&r2=376115&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/PooledSocketSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/PooledSocketSender.java
Wed Feb  8 15:27:58 2006
@@ -16,9 +16,9 @@
 
 package org.apache.catalina.cluster.tcp;
 
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.LinkedList;
+import java.io.*;
+import java.net.*;
+import java.util.*;
 
 /**
  * Send cluster messages with a pool of sockets (25).
@@ -227,8 +227,10 @@
 
         private SocketSender getNewSocketSender() {
             //new SocketSender(
-            SocketSender sender = new SocketSender(getDomain(),parent.getAddress(), parent
-                    .getPort());
+            SocketSender sender = new SocketSender(getDomain(),
+                                                   parent.getAddress(), 
+                                                   parent.getPort(),
+                                                   parent.getSenderState() );
             sender.setKeepAliveMaxRequestCount(parent
                     .getKeepAliveMaxRequestCount());
             sender.setKeepAliveTimeout(parent.getKeepAliveTimeout());

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java?rev=376115&r1=376114&r2=376115&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
Wed Feb  8 15:27:58 2006
@@ -866,10 +866,10 @@
             addStats(data.getMessage().length);
             return true;
         } catch (Exception x) {
-            if (log.isErrorEnabled()) {
-                if (!sender.getSuspect()) {
-                    log.error("Unable to send replicated message, is member ["+sender.toString()+"]
down?",x);
-                }
+            if (!sender.getSuspect()) {
+                if (log.isErrorEnabled() ) log.error("Unable to send replicated message,
is member ["+sender.toString()+"] down?",x);
+            } else if (log.isDebugEnabled() ) {
+                log.debug("Unable to send replicated message, is member ["+sender.toString()+"]
down?",x);
             }
             sender.setSuspect(true);
             failureCounter++;

Added: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SenderState.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SenderState.java?rev=376115&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SenderState.java
(added)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SenderState.java
Wed Feb  8 15:27:58 2006
@@ -0,0 +1,82 @@
+/*
+ * 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.tcp;
+
+
+/**
+ * Send cluster messages with a pool of sockets (25).
+ * 
+ * FIXME support processing stats
+ * 
+ * @author Filip Hanik
+ * @version 1.0
+ * @since 5.5.16
+ */
+
+public class SenderState {
+    
+    public static final int READY = 0;
+    public static final int SUSPECT = 1;
+    public static final int FAILING = 2;
+    /**
+     * The descriptive information about this implementation.
+     */
+    private static final String info = "SenderState/1.0";
+
+    // ----------------------------------------------------- Instance Variables
+
+    private int state = READY;
+
+    //  ----------------------------------------------------- Constructor
+
+    
+    public SenderState() {
+        this(READY);
+    }
+
+    public SenderState(int state) {
+        this.state = state;
+    }
+    
+    public boolean isSuspect() {
+        return state == SUSPECT;
+    }
+
+    public void setSuspect() {
+        state = SUSPECT;
+    }
+    
+    public boolean isReady() {
+        return state == READY;
+    }
+    
+    public void setReady() {
+        state = READY;
+    }
+    
+    public boolean isFailing() {
+        return state == FAILING;
+    }
+    
+    public void setFailing() {
+        state = FAILING;
+    }
+    
+
+    //  ----------------------------------------------------- Public Properties
+
+}

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SocketSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SocketSender.java?rev=376115&r1=376114&r2=376115&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SocketSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SocketSender.java
Wed Feb  8 15:27:58 2006
@@ -45,6 +45,10 @@
         super(domain,host, port);
     }
 
+    public SocketSender(String domain,InetAddress host, int port, SenderState state) {
+        super(domain,host, port, state);
+    }
+
     // ------------------------------------------------------------- Properties
 
     /**
@@ -64,4 +68,4 @@
         return buf.toString();
     }
 
-}
\ No newline at end of file
+}



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


Mime
View raw message