code: static long writeSessionIdToZK(Configuration conf) throws IOException {
      AvatarZooKeeperClient zk = null;
      long ssid = -1;
      int maxTries = conf.getInt("dfs.avatarnode.zk.retries", 3);
      boolean mismatch = false;
      Long ssIdInZk = -1L;
  
      for (int i = 0; i < maxTries; i++) {
        try {
          zk = new AvatarZooKeeperClient(conf, null, false);
          ssid = writeSessionIdToZK(conf, zk);
          return ssid;
        } catch (Exception e) {
          LOG.error("Got Exception when writing session id to zk. Will retry...",
              e);
        } finally {
          shutdownZkClient(zk);
        }
      }
      if (mismatch)
        throw new IOException("Session Id in the NameNode : " + ssid
            + " does not match the session Id in Zookeeper : " + ssIdInZk);
      throw new IOException("Cannot connect to zk");
    }
docs: Generates a new session id for the cluster and writes it to zookeeper. Some
  other data in zookeeper (like the last transaction id) is written to
  zookeeper with the sessionId so that we can easily determine in which
  session was this data written. The sessionId is unique since it uses the
  current time.
  
  @return the session id that it wrote to ZooKeeper
  @throws IOException