hadoop-zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neptune <opennept...@gmail.com>
Subject When session expired event fired?
Date Mon, 08 Feb 2010 22:37:16 GMT
Hi all.
I have a question. I started zookeeper(3.2.2) on three servers.
When session expired event fired in following code?
I expected that if client can't connect to server(disconnected) for session
timeout, zookeeper fires session expired event.
I killed three zookeeper server sequentially. Client retry to connect
zookeeper server. Never occured Expired event.

*class WatcherTest {
  public static void main(String[] args) {
    (new **WatcherTest*()).exec();
*  }

  private WatcherTest() throws Exception {
    zk = new ZooKeeper("server1:2181,server2:2181:server3:2181", 10 * 1000,
this);
  }
  private void exec() {
    while(ture) {
      //do something
    }
  }
  public void process(WatchedEvent event) {
    if (event.getType() == Event.EventType.None) {
      switch (event.getState()) {
      case SyncConnected:
        System.out.println("ZK SyncConnected");
        break;
      case Disconnected:
        System.out.println("ZK Disconnected");
        break;
      case Expired:
        System.out.println("ZK Session Expired");
        System.exit(0);
        break;
      }
    }
}
*

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