private void recreateZKConnection() {
    try {
      zk.close();
    } catch (InterruptedException e) {
      LOG.error("Error closing ZK connection : ", e);
    } finally {
      try {
        createNewZKConnection();
      } catch (IOException e) {
        LOG.error("Error creating new ZK COnnection for agent: ", e);
      }
    }
  }
Watcher to get notification whenever status of task changes.
hbase-it/src/test/java/org/apache/hadoop/hbase/ChaosZKClient.java