In the set data iterator, there is a with version method you can use to set to guarantee the read-modify-write is uninterrupted.
Sent from my phone, please pardon the typos and brevity. On Oct 2, 2014 1:39 PM, "Benjamin Jaton" <[email protected]> wrote: > Hi Vines, I'm not sure I understand what you mean: > The only methods that will give you a stat object are getData() , exists() > and getChildren(), how can I know the node hasn't been updated when I do a > setData()? > > > On Thu, Sep 25, 2014 at 6:08 AM, John Vines <[email protected]> wrote: > >> Another option is to use the Stat object so you can do a >> read-modify-write to guarantee that you're writing over the value you read. >> >> On Wed, Sep 24, 2014 at 5:28 PM, Benjamin Jaton <[email protected]> >> wrote: >> >>> It's more a "compare-and-set type operation" but on the same node. >>> I think I have to do a lock indeed. >>> >>> Thanks! >>> >>> On Wed, Sep 24, 2014 at 8:35 AM, Jordan Zimmerman < >>> [email protected]> wrote: >>> >>>> There are no ZooKeeper APIs that will allow you to atomically check the >>>> value of a node and change another node based on that value. You’d need to >>>> write a recipe for that. i.e. get a lock (InterProcessMutex), get the >>>> value, change another value, release the lock. >>>> >>>> -JZ >>>> >>>> >>>> On September 23, 2014 at 6:48:19 PM, Benjamin Jaton ( >>>> [email protected]) wrote: >>>> >>>> Hello, >>>> >>>> I would like to know if there is a way to get the value of a node, >>>> update it and save it, all in the same transaction. I have been looking for >>>> a way to do that but no luck. >>>> Any idea? >>>> >>>> Thanks >>>> Ben >>>> >>>> >>> >> >
