This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.2 by this push:
new c41fe32 HBASE-21658 Addendum fix infinite wait when there are no meta
locations yet
c41fe32 is described below
commit c41fe3267a8f809867491fc9e935f7f0228cbde7
Author: zhangduo <[email protected]>
AuthorDate: Mon May 13 21:20:50 2019 +0800
HBASE-21658 Addendum fix infinite wait when there are no meta locations yet
---
.../org/apache/hadoop/hbase/client/ZKAsyncRegistry.java | 3 +++
.../apache/hadoop/hbase/client/TestZKAsyncRegistry.java | 17 +++++++++++++++++
2 files changed, 20 insertions(+)
diff --git
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java
index 34069d1..efeb887 100644
---
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java
+++
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java
@@ -138,6 +138,9 @@ class ZKAsyncRegistry implements AsyncRegistry {
private void getMetaRegionLocation(CompletableFuture<RegionLocations> future,
List<String> metaReplicaZNodes) {
+ if (metaReplicaZNodes.isEmpty()) {
+ future.completeExceptionally(new IOException("No meta znode available"));
+ }
HRegionLocation[] locs = new HRegionLocation[metaReplicaZNodes.size()];
MutableInt remaining = new MutableInt(locs.length);
for (String metaReplicaZNode : metaReplicaZNodes) {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java
index a4441b8..5a72dae 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java
@@ -18,10 +18,13 @@
package org.apache.hadoop.hbase.client;
import static org.apache.hadoop.hbase.HConstants.META_REPLICAS_NUM;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
@@ -115,4 +118,18 @@ public class TestZKAsyncRegistry {
LOG.info("DONE!");
}
}
+
+ @Test
+ public void testNoMetaAvailable() throws InterruptedException {
+ Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
+ conf.set("zookeeper.znode.metaserver", "whatever");
+ try (ZKAsyncRegistry registry = new ZKAsyncRegistry(conf)) {
+ try {
+ registry.getMetaRegionLocation().get();
+ fail("Should have failed since we set an incorrect meta znode prefix");
+ } catch (ExecutionException e) {
+ assertThat(e.getCause(), instanceOf(IOException.class));
+ }
+ }
+ }
}