zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edward Capriolo <edlinuxg...@gmail.com>
Subject session establishment
Date Thu, 29 Jan 2015 01:27:31 GMT

Session establishment is asynchronous. This constructor will initiate
connection to the server and return immediately - potentially (usually)
before the session is fully established. The watcher argument specifies the
watcher that will be notified of any changes in state.

>>This notification can come at any point before or after the constructor
call has returned.

public class DummyWatcher implements Watcher {

  private CountDownLatch awaitConnection;

  public DummyWatcher(){
    awaitConnection = new CountDownLatch(1);

  public boolean connectOrThrow(long timeout, TimeUnit unit) throws
    return awaitConnection.await(timeout, unit);

  public void process(WatchedEvent event) {
    if (event.getState() == KeeperState.SyncConnected){


Does this mean that the following event might never fire or does it always

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message