code: @Override
    protected void processConnection(WatchedEvent event) {
      super.processConnection(event);
      switch (event.getState()) {
      case Disconnected:
        if (beenActiveMaster) {
          LOG.fatal(hostPort.getHostPort()
              + " disconnected from ZooKeeper, stop serving and exit immediately");
          System.exit(0);
        } else {
          LOG.warn(hostPort.getHostPort()
              + " disconnected from ZooKeeper, wait to sync and try to become active master");
        }
        break;
      default:
        break;
      }
    }
docs: Deal with the connection event.
  
  @param event the ZooKeeper event.