code: public void waitToInitZooKeeper(long maxWaitMillis) throws Exception {
       long finished = System.currentTimeMillis() + maxWaitMillis;
       while (System.currentTimeMillis() < finished) {
         if (this.zooKeeper != null) {
           return;
         }
         
         try {
           Thread.sleep(1);
         } catch (InterruptedException e) {
           throw new Exception(e);
         }
       }
       throw new Exception();
     }
docs: Wait to init ZooKeeper object, only sleep when it's null.
  
  @param maxWaitMillis the max sleep time
  @throws Exception if ZooKeeper object is still null