zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amirhossein Kiani <amirhki...@gmail.com>
Subject Re: Getting data after the watch
Date Fri, 02 Mar 2012 19:23:33 GMT
Many thanks Patrick for pointing me to the new documentation. I just found the other one from
Google somehow.

So what I think is happening is actually impossible: to do getData() on a node and see the
OLD data. in other words, I do not need to loop on a getData() to get the actual new data
after being notified about the data change.
The reason that I'm saying that is that's the behavior I'm seeing in my code, but it might
be just a bug on my side...

Cheers,
Amir

On Mar 2, 2012, at 9:54 AM, Patrick Hunt wrote:

> On Thu, Mar 1, 2012 at 4:11 PM, Amirhossein Kiani <amirhkiani@gmail.com> wrote:
>> Hi ZooKeepers,
> 
> Hi Amir.
> 
>> I just recently had an issue about getting the a node's updated data after the watch
was actually fired. Being pretty confused, I read the documentation page again and sure enough
this has been stated:
>> 
>> "A client will see a watch event for a znode it is watching before seeing the new
data that corresponds to that znode."
>> http://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html
>> 
> 
> Those docs are pretty old. Try using the current version:
> http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html
> 
>> Now, I'm confused about how a data watch could actually be useful... But aside from
that, is this statement also true about the node's list of Children? I.e. are a node's children
it's "data" too?
>> 
> 
> Watches let you know something changed. Then you can take actions.
> Typically this means that the data of a znode changed, or the znode
> itself changed (created/deleted, children added/removed). There are
> two separate calls related to your question - getData and getChildren,
> they set watches on the data an child list respectively.
> 
>> Because if this is the case, wouldn't the recipe for barriers hang if it gets the
watch for a new node addition goes off and in:
>> 
>>  if (list.size() < size) {
>>                        mutex.wait();
>> 
>>  list.size() is still smaller than size?
>> 
>> Or is this statement about watches only true for a data on the node?
> 
> No. It's true for both cases. If you set a data watch then it's
> guaranteed that if you getData after being notified you will see the
> updated data. Same for getChildren and it's child list.
> 
> Regards,
> 
> Patrick


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message