HBASE-21658 Addendum fix infinite wait when there are no meta locations yet
This commit is contained in:
parent
00efac9361
commit
e0f8f9b886
|
@ -138,6 +138,9 @@ class ZKAsyncRegistry implements AsyncRegistry {
|
||||||
|
|
||||||
private void getMetaRegionLocation(CompletableFuture<RegionLocations> future,
|
private void getMetaRegionLocation(CompletableFuture<RegionLocations> future,
|
||||||
List<String> metaReplicaZNodes) {
|
List<String> metaReplicaZNodes) {
|
||||||
|
if (metaReplicaZNodes.isEmpty()) {
|
||||||
|
future.completeExceptionally(new IOException("No meta znode available"));
|
||||||
|
}
|
||||||
HRegionLocation[] locs = new HRegionLocation[metaReplicaZNodes.size()];
|
HRegionLocation[] locs = new HRegionLocation[metaReplicaZNodes.size()];
|
||||||
MutableInt remaining = new MutableInt(locs.length);
|
MutableInt remaining = new MutableInt(locs.length);
|
||||||
for (String metaReplicaZNode : metaReplicaZNodes) {
|
for (String metaReplicaZNode : metaReplicaZNodes) {
|
||||||
|
|
|
@ -18,10 +18,13 @@
|
||||||
package org.apache.hadoop.hbase.client;
|
package org.apache.hadoop.hbase.client;
|
||||||
|
|
||||||
import static org.apache.hadoop.hbase.HConstants.META_REPLICAS_NUM;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -114,4 +117,18 @@ public class TestZKAsyncRegistry {
|
||||||
LOG.info("DONE!");
|
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