code: protected void connectZooKeeper() throws IOException {
      LOG.info("Connecting ZooKeeper " + zkQuorum);
  
      for (int i = 0; i <= connectRetryTimes; i++) {
        try {
          zooKeeper = new ZooKeeper(zkQuorum, sessionTimeout, this);
          break;
        } catch (IOException e) {
          if (i == connectRetryTimes) {
            throw new IOException("Can't connect ZooKeeper after retrying", e);
          }
          LOG.error("Exception to connect ZooKeeper, retry " + (i + 1) + " times");
        }
      }
    }
docs: Connect with ZooKeeper with retries.
  
  @throws IOException when error to construct ZooKeeper object after retrying