java/openmldb-taskmanager/src/main/java/com/_4paradigm/openmldb/taskmanager/zk/FailoverWatcher.java
protected void processConnection(WatchedEvent event) {
    switch (event.getState()) {
    case SyncConnected:
      LOG.info(hostPort.getHostPort() + " sync connect from ZooKeeper");
      try {
        waitToInitZooKeeper(2000); // init zookeeper in another thread, wait for a while
      } catch (Exception e) {
        LOG.fatal("Error to init ZooKeeper object after sleeping 2000 ms, exit immediately");
        System.exit(0);
      } 
      break;
    case Disconnected: // be triggered when kill the server or the leader of zk cluster 
      LOG.warn(hostPort.getHostPort() + " received disconnected from ZooKeeper");

      if (becomeActiveServer.get()) {
        // Exit if this is master and disconnect from ZK
        System.exit(0);
      }
      break;
    case AuthFailed:
      LOG.fatal(hostPort.getHostPort() + " auth fail, exit immediately");
      System.exit(0);
    case Expired:
      LOG.fatal(hostPort.getHostPort() + " received expired from ZooKeeper, exit immediately");
      System.exit(0);
      break;
    default:
      break;
    }
  }
/**
   * Deal with connection event, exit current process if auth fails or session expires.
   *
   * @param event the ZooKeeper event
   */
Deal with connection event, exit current process if auth fails or session expires.
@param event the ZooKeeper event
Deal with connection event exit current process if auth fails or session expires . @param event the ZooKeeper event
protected void processConnection(WatchedEvent event) {
    switch (event.getState()) {
    case SyncConnected:
      LOG.info(hostPort.getHostPort() + " sync connect from ZooKeeper");
      try {
        waitToInitZooKeeper(2000); 
      } catch (Exception e) {
        LOG.fatal("Error to init ZooKeeper object after sleeping 2000 ms, exit immediately");
        System.exit(0);
      } 
      break;
    case Disconnected: 
      LOG.warn(hostPort.getHostPort() + " received disconnected from ZooKeeper");
      if (becomeActiveServer.get()) {
        System.exit(0);
      }
      break;
    case AuthFailed:
      LOG.fatal(hostPort.getHostPort() + " auth fail, exit immediately");
      System.exit(0);
    case Expired:
      LOG.fatal(hostPort.getHostPort() + " received expired from ZooKeeper, exit immediately");
      System.exit(0);
      break;
    default:
      break;
    }
  }
protected void processConnection ( WatchedEvent event ) { switch ( event . getState ( ) ) { case SyncConnected : LOG . info ( hostPort . getHostPort ( ) + " sync connect from ZooKeeper" ) ; try { waitToInitZooKeeper ( 2000 ) ; } catch ( Exception e ) { LOG . fatal ( "Error to init ZooKeeper object after sleeping 2000 ms, exit immediately" ) ; System . exit ( 0 ) ; } break ; case Disconnected : LOG . warn ( hostPort . getHostPort ( ) + " received disconnected from ZooKeeper" ) ; if ( becomeActiveServer . get ( ) ) { System . exit ( 0 ) ; } break ; case AuthFailed : LOG . fatal ( hostPort . getHostPort ( ) + " auth fail, exit immediately" ) ; System . exit ( 0 ) ; case Expired : LOG . fatal ( hostPort . getHostPort ( ) + " received expired from ZooKeeper, exit immediately" ) ; System . exit ( 0 ) ; break ; default : break ; } }
Deal with connection event, exit current process if auth fails or session expires.
Deal with connection event exit current process if auth fails or session expires .
// init zookeeper in another thread, wait for a while // be triggered when kill the server or the leader of zk cluster  // Exit if this is master and disconnect from ZK