private static void checkIfParentQuota()

in kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/src/main/java/org/apache/zookeeper/ZooKeeperMain.java [446:474]


  private static void checkIfParentQuota(ZooKeeper zk, String path)
      throws InterruptedException, KeeperException {
    final String[] splits = path.split("/");
    String quotaPath = Quotas.quotaZookeeper;
    for (String str : splits) {
      if (str.length() == 0) {
        // this should only be for the beginning of the path
        // i.e. "/..." - split(path)[0] is empty string before first '/'
        continue;
      }
      quotaPath += "/" + str;
      List<String> children = null;
      try {
        children = zk.getChildren(quotaPath, false);
      } catch (KeeperException.NoNodeException ne) {
        LOG.debug("child removed during quota check", ne);
        return;
      }
      if (children.size() == 0) {
        return;
      }
      for (String child : children) {
        if (Quotas.limitNode.equals(child)) {
          throw new IllegalArgumentException(
              path + " has a parent " + quotaPath + " which has a quota");
        }
      }
    }
  }