zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Carns <ca...@mcs.anl.gov>
Subject Re: question about lock recipe and watchers
Date Mon, 17 Sep 2012 18:15:06 GMT
On 09/17/2012 02:00 PM, Robin Bate Boerop wrote:
> I am about to implement a locking algorithm based on the below modification to the Zookeeper-website-recommended
one. Does anyone else have experience with this?
> Thank you, Michi, for the suggestion below.
> ________________________________________
> From: mutsuzaki@gmail.com [mutsuzaki@gmail.com] on behalf of Michi Mutsuzaki [michi@cs.stanford.edu]
> Sent: 15 September 2012 02:32
> To: user@zookeeper.apache.org
> Subject: Re: question about lock recipe and watchers
> You could set the watch using get() instead of exists(). These watches
> get set if and only if the znode exists, and they get triggered when
> the znode goes away.

I tried out Michi's suggestion over the weekend and it seems to be 
working great.  I just used a one-byte get() in place of the exists() 
call recommended in the recipe.  I'm actually using wget(), to be 
precise.  The wget() either returns an error immediately (because the 
node has already been deleted) or else returns successfully and queues a 
watcher that triggers when the node is deleted later.  There is no need 
to set a value in the node.


View raw message