code: public String getLeaderHostName() throws KeeperException, InterruptedException {
  
          List<LeaderOffer> leaderOffers = toLeaderOffers(zooKeeper.getChildren(
                  rootNodeName, false));
  
          if (leaderOffers.size() > 0) {
              return leaderOffers.get(0).getHostName();
          }
  
          return null;
      }
docs: Fetch the (user supplied) hostname of the current leader. Note that by
  the time this method returns, state could have changed so do not depend
  on this to be strongly consistent. This method has to read all leader
  offers from ZooKeeper to determine who the leader is (i.e. there is no
  caching) so consider the performance implications of frequent invocation.
  If there are no leader offers this method returns null.
  
  @return hostname of the current leader
  @throws KeeperException
  @throws InterruptedException