@Override
  public void process(WatchedEvent event) {
    if (event.getType().equals(Watcher.Event.EventType.NodeDeleted)) {
      zooKeeperHiveHelper.deregisterZnode();
    }
  }
The watcher class which sets the de-register flag when the given znode is deleted.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/ZKDeRegisterWatcher.java