int zkMaxRetries = conf.getInt(BKJM_ZK_MAX_RETRIES,
BKJM_ZK_MAX_RETRIES_DEFAULT);
int zkRetryIntervalMs = conf.getInt(BKJM_ZK_RETRY_INTERVAL,
BKJM_ZK_RETRY_INTERVAL_DEFAULT);
CountDownLatch connectLatch = new CountDownLatch(1);
ConnectionWatcher connectionWatcher = new ConnectionWatcher(connectLatch);
ZooKeeper zooKeeper = new ZooKeeper(zkConnect, zkSessionTimeoutMs,
connectionWatcher);
// Use twice session timeout as the connection timeout
int zkConnectTimeoutMs = zkSessionTimeoutMs * 2;
if (!connectionWatcher.await(zkConnectTimeoutMs)) {
throw new IOException("Timed out waiting to connect to " + zkConnect
+ " after " + (zkSessionTimeoutMs * 2) + " ms.");
}
prepareBookKeeperEnv(ledgersAvailablePath, zooKeeper);