You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2016/12/04 22:33:23 UTC
hbase git commit: HBASE-17127 Locate region should fail fast if
underlying Connection already closed
Repository: hbase
Updated Branches:
refs/heads/0.98 691af41d1 -> 6ea27ebed
HBASE-17127 Locate region should fail fast if underlying Connection already closed
Conflicts:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
Amending-Author: Andrew Purtell <ap...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6ea27ebe
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6ea27ebe
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6ea27ebe
Branch: refs/heads/0.98
Commit: 6ea27ebed59c7ded4135330114c35469a3bab99a
Parents: 691af41
Author: Yu Li <li...@apache.org>
Authored: Sat Nov 19 23:41:27 2016 +0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Sun Dec 4 14:32:26 2016 -0800
----------------------------------------------------------------------
.../hadoop/hbase/client/HConnectionManager.java | 3 ++-
.../hbase/client/TestClientNoCluster.java | 27 ++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/6ea27ebe/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
index bc83dad..7e723eb 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -1166,7 +1167,7 @@ public class HConnectionManager {
private HRegionLocation locateRegion(final TableName tableName,
final byte [] row, boolean useCache, boolean retry)
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/6ea27ebe/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 a0e51ea..7dcdf83 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;
@@ -282,6 +283,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.
+ HConnection connection = HConnectionManager.createConnection(testConf);
+ HTableInterface 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.
*/