subprojects/parseq-zk-client/src/main/java/com/linkedin/parseq/zk/client/ZKClientImpl.java
public Task<Void> waitFor(KeeperState state) {
    return Task.async("waitFor " + state.toString(), () -> {
      SettablePromise<Void> promise = Promises.settable();
      synchronized (_mutex) {
        if (_currentState == state) {
          return Promises.VOID;
        } else {
          _listener.subscribe(state, (p) -> {
            if (p.isFailed()) {
              promise.fail(p.getError());
            } else {
              promise.done(null);
            }
          });
        }
      }
      return promise;
    });
  }
public Task<Void> waitFor(KeeperState state) {
    return Task.async("waitFor " + state.toString(), () -> {
      SettablePromise<Void> promise = Promises.settable();
      synchronized (_mutex) {
        if (_currentState == state) {
          return Promises.VOID;
        } else {
          _listener.subscribe(state, (p) -> {
            if (p.isFailed()) {
              promise.fail(p.getError());
            } else {
              promise.done(null);
            }
          });
        }
      }
      return promise;
    });
  }
public Task < Void > waitFor ( KeeperState state ) { return Task . async ( "waitFor " + state . toString ( ) , ( ) -> { SettablePromise < Void > promise = Promises . settable ( ) ; synchronized ( _mutex ) { if ( _currentState == state ) { return Promises . VOID ; } else { _listener . subscribe ( state , ( p ) - > { if ( p . isFailed ( ) ) { promise . fail ( p . getError ( ) ) ; } else { promise . done ( null ) ; } } ) ; } } return promise ; } ) ; }
Returns task that will wait for the given {@link KeeperState} to fulfill.
The task will be failed if the underlying zookeeper session expires.

@param state keeper state to wait for.
@return task that waits for a certain keeper state.
Returns task that will wait for the given { @link KeeperState } to fulfill . The task will be failed if the underlying zookeeper session expires .