use of org.apache.zookeeper.KeeperException.OperationTimeoutException in project SilverKing by Morgan-Stanley.
the class MetaClientCore method getZooKeeper.
public ZooKeeperExtended getZooKeeper(int getZKMaxAttempts, int getZKSleepUnit) throws KeeperException {
ZooKeeperExtended _zk;
int attemptIndex;
assert getZKMaxAttempts > 0;
assert getZKSleepUnit > 0;
_zk = null;
attemptIndex = 0;
while (_zk == null) {
_zk = _getZooKeeper();
if (_zk == null) {
if (attemptIndex < getZKMaxAttempts - 1) {
ThreadUtil.randomSleep(getZKSleepUnit << attemptIndex);
++attemptIndex;
} else {
Log.warning("getZooKeeper() failed after " + (attemptIndex + 1) + " attempts");
throw new OperationTimeoutException();
}
}
}
return _zk;
}
Aggregations