You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nk...@apache.org on 2013/04/19 19:06:42 UTC

svn commit: r1469952 - in /hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase: client/HConnectionManager.java ipc/HBaseClient.java

Author: nkeywal
Date: Fri Apr 19 17:06:42 2013
New Revision: 1469952

URL: http://svn.apache.org/r1469952
Log:
HBASE-8360  In HBaseClient#cancelConnections we should close fully the connection

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1469952&r1=1469951&r2=1469952&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Fri Apr 19 17:06:42 2013
@@ -26,6 +26,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.InetSocketAddress;
+import java.net.SocketException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -653,7 +654,8 @@ public class HConnectionManager {
               @Override
               public void newDead(ServerName sn) {
                 clearCaches(sn);
-                rpcEngine.getClient().cancelConnections(sn.getHostname(), sn.getPort(), null);
+                rpcEngine.getClient().cancelConnections(sn.getHostname(), sn.getPort(),
+                    new SocketException(sn.getServerName() + " is dead: closing its connection."));
               }
             }, conf, listenerClass);
       }

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java?rev=1469952&r1=1469951&r2=1469952&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java Fri Apr 19 17:06:42 2013
@@ -1370,11 +1370,14 @@ public class HBaseClient {
         if (connection.isAlive() &&
             connection.getRemoteAddress().getPort() == port &&
             connection.getRemoteAddress().getHostName().equals(hostname)) {
-          LOG.info("The server on " + hostname + ":" + port +
-              " is dead - stopping the connection " + connection.remoteId);
-          connection.closeConnection();
-          // We could do a connection.interrupt(), but it's safer not to do it, as the
-          //  interrupted exception behavior is not defined nor enforced enough.
+          if (connection.shouldCloseConnection.compareAndSet(false, true)) {
+            LOG.info("The server on " + hostname + ":" + port +
+                " is dead - closing the connection " + connection.remoteId);
+            connection.closeException = ioe;
+            connection.close();
+            // We could do a connection.interrupt(), but it's safer not to do it, as the
+            //  interrupted exception behavior is not defined nor enforced enough.
+          }
         }
       }
     }