You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/05/14 00:14:09 UTC

[hbase] branch branch-2.1 updated: HBASE-21658 Addendum fix infinite wait when there are no meta locations yet

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new e0f8f9b  HBASE-21658 Addendum fix infinite wait when there are no meta locations yet
e0f8f9b is described below

commit e0f8f9b88678e6b1511a92ee96f5d68e6d2326d7
Author: zhangduo <zh...@apache.org>
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 00a92ab..2b40b3b 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;
@@ -114,4 +117,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));
+      }
+    }
+  }
 }