You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2016/11/19 16:18:03 UTC

hbase git commit: HBASE-17127 Locate region should fail fast if underlying Connection already closed

Repository: hbase
Updated Branches:
  refs/heads/master af4e4b645 -> ec9c9e201


HBASE-17127 Locate region should fail fast if underlying Connection already closed


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ec9c9e20
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ec9c9e20
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ec9c9e20

Branch: refs/heads/master
Commit: ec9c9e201a8fadcbdd08d67a20547f79bd105ac6
Parents: af4e4b6
Author: Yu Li <li...@apache.org>
Authored: Sat Nov 19 23:41:27 2016 +0800
Committer: Yu Li <li...@apache.org>
Committed: Sun Nov 20 00:00:14 2016 +0800

----------------------------------------------------------------------
 .../hbase/client/ConnectionImplementation.java  |  2 +-
 .../hbase/client/TestClientNoCluster.java       | 28 +++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ec9c9e20/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
index 53eb522..1134923 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
@@ -652,7 +652,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
     final byte [] row, boolean useCache, boolean retry, int replicaId)
   throws IOException {
     if (this.closed) {
-      throw new IOException(toString() + " closed");
+      throw new DoNotRetryIOException(toString() + " closed");
     }
     if (tableName== null || tableName.getName().length == 0) {
       throw new IllegalArgumentException(

http://git-wip-us.apache.org/repos/asf/hbase/blob/ec9c9e20/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
index 41c9a56..a4be9a2 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
@@ -33,7 +33,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.hadoop.hbase.CellComparator;
-
+import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -263,6 +263,32 @@ public class TestClientNoCluster extends Configured implements Tool {
     }
   }
 
+  @Test
+  public void testConnectionClosedOnRegionLocate() throws IOException {
+    Configuration testConf = new Configuration(this.conf);
+    testConf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
+    // Go against meta else we will try to find first region for the table on construction which
+    // means we'll have to do a bunch more mocking. Tests that go against meta only should be
+    // good for a bit of testing.
+    Connection connection = ConnectionFactory.createConnection(testConf);
+    Table table = connection.getTable(TableName.META_TABLE_NAME);
+    connection.close();
+    try {
+      Get get = new Get(Bytes.toBytes("dummyRow"));
+      table.get(get);
+      fail("Should have thrown DoNotRetryException but no exception thrown");
+    } catch (Exception e) {
+      if (!(e instanceof DoNotRetryIOException)) {
+        String errMsg =
+            "Should have thrown DoNotRetryException but actually " + e.getClass().getSimpleName();
+        LOG.error(errMsg, e);
+        fail(errMsg);
+      }
+    } finally {
+      table.close();
+    }
+  }
+
   /**
    * Override to shutdown going to zookeeper for cluster id and meta location.
    */