Most efficient way to create a path in zookeeper where root elements of the path may or may not exist?

前端 未结 2 1114
迷失自我
迷失自我 2021-02-08 11:02

Imagine a path \"/root/child1/child2/child3\"

Imagine in zookeeper that maybe a part of this exists, say \"/root/child1\"

There is no equivalent of \"mkdir -p\"

2条回答
  •  清歌不尽
    2021-02-08 11:16

    You can use Netflix's curator library which makes using zookeeper much simpler

    client.create().withMode(CreateMode.PERSISTENT).forPath("/root/child1/child2/child3", new byte[0]).withACL(ZooDefs.Ids.OPEN_ACL_UNSAFE).creatingParentsIfNeeded();
    

提交回复
热议问题