@Override
  public void process(WatchedEvent event) {
    if (EventType.None == event.getType()) {
      switch (event.getState()) {
        case Disconnected: // Intentional fall through of case
        case Expired: // ZooReader is handling the Expiration of the original ZooKeeper object for
                      // us
          log.debug("ZooKeeper connection disconnected, clearing secret manager");
          secretManager.removeAllKeys();
          break;
        case SyncConnected:
          log.debug("ZooKeeper reconnected, updating secret manager");
          try {
            updateAuthKeys();
          } catch (KeeperException | InterruptedException e) {
            log.error("Failed to update secret manager after ZooKeeper reconnect");
          }
          break;
        default:
          log.warn("Unhandled: " + event);
      }

      // Nothing more to do for EventType.None
      return;
    }

    String path = event.getPath();
    if (null == path) {
      return;
    }

    if (!path.startsWith(baseNode)) {
      log.info("Ignoring event for path: {}", path);
      return;
    }

    try {
      if (path.equals(baseNode)) {
        processBaseNode(event);
      } else {
        processChildNode(event);
      }
    } catch (KeeperException | InterruptedException e) {
      log.error("Failed to communicate with ZooKeeper", e);
    }
  }
 /**
  * Process the {@link WatchedEvent} for the base znode that the {@link AuthenticationKey}s are
  * stored in.
  */
 void processBaseNode(WatchedEvent event) throws KeeperException, InterruptedException {
   switch (event.getType()) {
     case NodeDeleted:
       // The parent node was deleted, no children are possible, remove all keys
       log.debug("Parent ZNode was deleted, removing all AuthenticationKeys");
       secretManager.removeAllKeys();
       break;
     case None:
       // Not connected, don't care
       break;
     case NodeCreated: // intentional fall-through to NodeChildrenChanged
     case NodeChildrenChanged:
       // Process each child, and reset the watcher on the parent node. We know that the node
       // exists
       updateAuthKeys(event.getPath());
       break;
     case NodeDataChanged:
       // The data on the parent changed. We aren't storing anything there so it's a noop
       break;
     default:
       log.warn("Unsupported event type: {}", event.getType());
       break;
   }
 }