You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2012/05/03 18:42:51 UTC

svn commit: r1333537 - in /hbase/branches/0.92: CHANGES.txt src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java

Author: tedyu
Date: Thu May  3 16:42:50 2012
New Revision: 1333537

URL: http://svn.apache.org/viewvc?rev=1333537&view=rev
Log:
HBASE-5883  Backup master is going down due to connection refused exception (Jieshan)

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1333537&r1=1333536&r2=1333537&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Thu May  3 16:42:50 2012
@@ -57,6 +57,7 @@ Release 0.92.2 - Unreleased
    HBASE-5611  Replayed edits from regions that failed to open during recovery aren't removed from
                the global MemStore size (Jieshan)
    HBASE-5897  prePut coprocessor hook causing substantial CPU usage (Todd)
+   HBASE-5883  Backup master is going down due to connection refused exception (Jieshan)
 
   IMPROVEMENTS
    HBASE-5592  Make it easier to get a table from shell (Ben West)

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java?rev=1333537&r1=1333536&r2=1333537&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java Thu May  3 16:42:50 2012
@@ -577,7 +577,9 @@ public class CatalogTracker {
       LOG.debug("Exception connecting to " + sn);
     } catch (IOException ioe) {
       Throwable cause = ioe.getCause();
-      if (cause != null && cause instanceof EOFException) {
+      if (ioe instanceof ConnectException) {
+        // Catch. Connect refused.
+      } else if (cause != null && cause instanceof EOFException) {
         // Catch. Other end disconnected us.
       } else if (cause != null && cause.getMessage() != null &&
         cause.getMessage().toLowerCase().contains("connection reset")) {

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java?rev=1333537&r1=1333536&r2=1333537&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java Thu May  3 16:42:50 2012
@@ -234,18 +234,31 @@ public class HBaseRPC {
     while (true) {
       try {
         return getProxy(protocol, clientVersion, addr, conf, rpcTimeout);
-      } catch(ConnectException se) {  // namenode has not been started
-        ioe = se;
-        if (maxAttempts >= 0 && ++reconnectAttempts >= maxAttempts) {
-          LOG.info("Server at " + addr + " could not be reached after " +
-            reconnectAttempts + " tries, giving up.");
-          throw new RetriesExhaustedException("Failed setting up proxy " +
-            protocol + " to " + addr.toString() + " after attempts=" +
-            reconnectAttempts, se);
-      }
       } catch(SocketTimeoutException te) {  // namenode is busy
         LOG.info("Problem connecting to server: " + addr);
         ioe = te;
+      } catch (IOException ioex) {
+        // We only handle the ConnectException.
+        ConnectException ce = null;
+        if (ioex instanceof ConnectException) {
+          ce = (ConnectException) ioex;
+          ioe = ce;
+        } else if (ioex.getCause() != null
+            && ioex.getCause() instanceof ConnectException) {
+          ce = (ConnectException) ioex.getCause();
+          ioe = ce;
+        } else if (ioex.getMessage().toLowerCase()
+            .contains("connection refused")) {
+          ce = new ConnectException(ioex.getMessage());
+          ioe = ce;
+        } else {
+          // This is the exception we can't handle.
+          ioe = ioex;
+        }
+        if (ce != null) {
+          handleConnectionException(++reconnectAttempts, maxAttempts, protocol,
+              addr, ce);
+        }
       }
       // check if timed out
       if (System.currentTimeMillis()-timeout >= startTime) {
@@ -262,6 +275,25 @@ public class HBaseRPC {
   }
 
   /**
+   * @param retries current retried times.
+   * @param maxAttmpts max attempts
+   * @param protocol protocol interface
+   * @param addr address of remote service
+   * @param ce ConnectException
+   * @throws RetriesExhaustedException
+   */
+  private static void handleConnectionException(int retries, int maxAttmpts,
+      Class<?> protocol, InetSocketAddress addr, ConnectException ce)
+      throws RetriesExhaustedException {
+    if (maxAttmpts >= 0 && retries >= maxAttmpts) {
+      LOG.info("Server at " + addr + " could not be reached after "
+          + maxAttmpts + " tries, giving up.");
+      throw new RetriesExhaustedException("Failed setting up proxy " + protocol
+          + " to " + addr.toString() + " after attempts=" + maxAttmpts, ce);
+    }
+  }
+
+  /**
    * Construct a client-side proxy object that implements the named protocol,
    * talking to a server at the named address.
    *