HBASE-21658 Addendum fix infinite wait when there are no meta locations yet
This commit is contained in:
parent
0797243365
commit
0b8493f886
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue