In ZooKeeper, is there a way to write a hierarchy atomically without implementing distributed locks yourself?

StackOverflow https://stackoverflow.com//questions/9628545

Question

let's say I want to write out this tree to zookeeper

.            a
.           / \
.          b   c
.         / \
.        d   e

some other client could come along and delete node b right after I create it but before I'm able to write node 'd' or 'e'.

Is there a way I can write this hierarchy atomically, or possibly lock a certain path?

Was it helpful?

Solution

You can use the new multi() API

It completes all the operations or aborts them all.

OTHER TIPS

You can coordinate different clients by either electing a leader or maintaining locks You can read a nice description on Zookeeper's recipes on the Netflix curator docs (which is also a nice library to use if you want to do anything with zookeeper)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top