private void connectionEvent(WatchedEvent event) {
    switch (event.getState()) {
      case SyncConnected:
        this.identifier =
          this.prefix + "-0x" + Long.toHexString(this.recoverableZooKeeper.getSessionId());
        // Update our identifier. Otherwise ignore.
        LOG.debug("{} connected", this.identifier);
        break;

      // Abort the server if Disconnected or Expired
      case Disconnected:
        LOG.debug(prefix("Received Disconnected from ZooKeeper, ignoring"));
        break;

      case Closed:
        LOG.debug(prefix("ZooKeeper client closed, ignoring"));
        break;

      case Expired:
        String msg = prefix(this.identifier + " received expired from " + "ZooKeeper, aborting");
        // TODO: One thought is to add call to ZKListener so say,
        // ZKNodeTracker can zero out its data values.
        if (this.abortable != null) {
          this.abortable.abort(msg, new KeeperException.SessionExpiredException());
        }
        break;

      case ConnectedReadOnly:
      case SaslAuthenticated:
      case AuthFailed:
        break;

      default:
        throw new IllegalStateException("Received event is not valid: " + event.getState());
    }
  }
Called when there is a connection-related event via the Watcher callback.
<p>
If Disconnected or Expired, this should shutdown the cluster. But, since we send a
KeeperException.SessionExpiredException along with the abort call, it's possible for the
Abortable to catch it and try to create a new session with ZooKeeper. This is what the client
does in HCM.
<p>
@param event the connection-related event
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java