public static boolean createEphemeralNodeAndWatch(ZooKeeperWatcher zkw, String zNode,
            byte[] data, CreateMode mode) throws KeeperException {
        try {
            waitForZKConnectionIfAuthenticating(zkw);
            zkw.getRecoverableZooKeeper().create(zNode, data, createACL(zkw, zNode),
                    mode);
        } catch (KeeperException.NodeExistsException nee) {
            if (!watchAndCheckExists(zkw, zNode)) {
                // It did exist but now it doesn't, try again
                return createEphemeralNodeAndWatch(zkw, zNode, data, mode);
            }
            return false;
        } catch (InterruptedException e) {
            logger.info("Interrupted", e);
            Thread.currentThread().interrupt();
        }
        return true;
    }
Set the specified zNode to be an ephemeral node carrying the specified
data.

If the node is created successfully, a watcher is also set on the node.

If the node is not created successfully because it already exists, this
method will also set a watcher on the node.

If there is another problem, a KeeperException will be thrown.

@param zkw     zk reference
@param zNode   path of node to watch
@param data    write data
@param mode    create mode
@return  whether success
@throws KeeperException process exception
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/common/zookeeper/ZKUtil.java