HBASE-19102 TestZooKeeperMainServer fails with KeeperException

Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
Michael Stack 2017-10-26 21:05:04 -07:00
parent 27d8a6d126
commit 6547128789
No known key found for this signature in database
GPG Key ID: 9816C7FC8ACC93D2
1 changed files with 13 additions and 0 deletions

View File

@ -20,7 +20,9 @@
package org.apache.hadoop.hbase.zookeeper;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.curator.shaded.com.google.common.base.Stopwatch;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
@ -48,6 +50,15 @@ public class ZooKeeperMainServer {
public HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(String[] args)
throws IOException, InterruptedException {
super(args);
// Make sure we are connected before we proceed. Can take a while on some systems. If we
// run the command without being connected, we get ConnectionLoss KeeperErrorConnection...
Stopwatch stopWatch = Stopwatch.createStarted();
while (!this.zk.getState().isConnected()) {
Thread.sleep(1);
if (stopWatch.elapsed(TimeUnit.SECONDS) > 10) {
throw new InterruptedException("Failed connect " + this.zk);
}
}
}
/**
@ -100,6 +111,8 @@ public class ZooKeeperMainServer {
}
}
// If command-line arguments, run our hack so they are executed.
// ZOOKEEPER-1897 was committed to zookeeper-3.4.6 but elsewhere in this class we say
// 3.4.6 breaks command-processing; TODO.
if (hasCommandLineArguments(args)) {
HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain zkm =
new HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(newArgs);