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 2017/03/20 22:08:19 UTC

hbase git commit: HBASE-17175 backport HBASE-17127 (Locate region should fail fast if underlying Connection already closed) to 1.3.1

Repository: hbase
Updated Branches:
  refs/heads/branch-1.3 226b6fa44 -> 98b5d2cd4


HBASE-17175 backport HBASE-17127 (Locate region should fail fast if underlying Connection already closed) to 1.3.1


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

Branch: refs/heads/branch-1.3
Commit: 98b5d2cd4b0badef5f576cb35c8c8f1df1c88899
Parents: 226b6fa
Author: Yu Li <li...@apache.org>
Authored: Tue Mar 21 06:05:29 2017 +0800
Committer: Yu Li <li...@apache.org>
Committed: Tue Mar 21 06:05:29 2017 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/ConnectionManager.java  |  2 +-
 .../hbase/client/TestClientNoCluster.java       | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/98b5d2cd/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
index 4e9d208..cba441e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
@@ -1171,7 +1171,7 @@ class ConnectionManager {
     public RegionLocations locateRegion(final TableName tableName,
       final byte [] row, boolean useCache, boolean retry, int replicaId)
     throws IOException {
-      if (this.closed) throw new IOException(toString() + " closed");
+      if (this.closed) throw new DoNotRetryIOException(toString() + " closed");
       if (tableName== null || tableName.getName().length == 0) {
         throw new IllegalArgumentException(
             "table name cannot be null or zero length");

http://git-wip-us.apache.org/repos/asf/hbase/blob/98b5d2cd/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 2d50c1b..f6968bc 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
@@ -39,6 +39,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -286,6 +287,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.
    */