You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Vinayak Borkar <vb...@yahoo.com> on 2013/03/13 17:44:07 UTC

Op.Check in ZooKeeper.multi and cversion

Hi,


I have a case where I need to create a new node (N) as a child of a node 
(P) only if the existing set of children satisfies a certain condition. 
In my code I was planning to fetch the list of children (along with the 
parent's cversion), verify if the condition on the existing set of 
children allows me to add a new node, and then in a multi() invocation 
create a child only if the cversion of the parent is the same as what I 
had witnessed before.

However, I see that the Op.Check operation only allows me to check the 
data version of a node and not the cversion.

I see that a slightly more expensive work-around would be to make sure 
that every mutation that adds or removes children to/from P also makes a 
data change to P so that I maintain the invariant that cversion == 
version for P and then just use Op.Check.

Is there a better way to solve my problem?

Thanks,
Vinayak