public static void createPersistent(ZooKeeperWatcher zkw, String path, boolean createParents)
            throws KeeperException {
        try {
            ZKUtil.createAndWatch(zkw, path, null);
        } catch (NodeExistsException e) {
            if (!createParents) {
                throw e;
            }
        } catch (NoNodeException e) {
            if (!createParents) {
                throw e;
            }
            String parentDir = path.substring(0, path.lastIndexOf('/'));
            createPersistent(zkw, parentDir, createParents);
            createPersistent(zkw, path, createParents);
        }
    }
Create a persistent node.

@param createParents if true all parent dirs are created as well and no {@link
                     NodeExistsException} is thrown in case the path already exists
@throws InterruptedException     if operation was interrupted, or a required reconnection got
                                 interrupted
@throws IllegalArgumentException if called from anything except the ZooKeeper event thread
@throws KeeperException          if any ZooKeeper exception occurred
@throws RuntimeException         if any other exception occurs
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/common/zookeeper/ZKUtil.java