@Override public void waitForConnection() throws InterruptedException { if (isCurrentThreadEventThread()) { throw new RuntimeException("waitForConnection should not be called from within the ZooKeeper event thread."); } synchronized (connectedMonitor) { while (!connected && !stop) { connectedMonitor.wait(); } } if (stop) { throw new InterruptedException("This ZooKeeper handle is shutting down."); } }
@Override public void waitForConnection() throws InterruptedException { if (isCurrentThreadEventThread()) { throw new RuntimeException("waitForConnection should not be called from within the ZooKeeper event thread."); } synchronized (connectedMonitor) { while (!connected && !stop) { connectedMonitor.wait(); } } if (stop) { throw new InterruptedException("This ZooKeeper handle is shutting down."); } }
@Override public <T> T retryOperation(ZooKeeperOperation<T> operation) throws InterruptedException, KeeperException { if (isCurrentThreadEventThread()) { throw new RuntimeException("retryOperation should not be called from within the ZooKeeper event thread."); } int tryCount = 0; while (true) { tryCount++; try { return operation.execute(); } catch (KeeperException.ConnectionLossException e) { // ok } if (tryCount > 3) { log.warn("ZooKeeper operation attempt " + tryCount + " failed due to connection loss."); } waitForConnection(); } }
@Override public <T> T retryOperation(ZooKeeperOperation<T> operation) throws InterruptedException, KeeperException { if (isCurrentThreadEventThread()) { throw new RuntimeException("retryOperation should not be called from within the ZooKeeper event thread."); } int tryCount = 0; while (true) { tryCount++; try { return operation.execute(); } catch (KeeperException.ConnectionLossException e) { // ok } if (tryCount > 3) { log.warn("ZooKeeper operation attempt " + tryCount + " failed due to connection loss."); } waitForConnection(); } }