zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: Problem with WriteLock
Date Thu, 10 Mar 2011 01:19:57 GMT
That java api looks like it strongly encourages the caller to implement a
race condition.  If a call to lock fails
then the user must register a call-back or check if the lock has been
granted.  Unfortunately, the registration
of the call-back may happen after the lock has been granted in which case
the locker never knows.  If the locker
checks after registering the callback, they may wind up with double

Registering the callback before asking for the lock seems kind of scary as
well, though it might well work.

Why not do it like a real java lock and have a timeout?  If you don't get
the lock, you block until your timeout.
Then later you can call lock again and if you got it in the meantime it
should just succeed.

On Wed, Mar 9, 2011 at 4:54 PM, Erik Hetzner <erik.hetzner@ucop.edu> wrote:

> At Wed, 9 Mar 2011 18:48:11 -0600,
> Scott Fines wrote:
> >
> > Could you send on a link to your WriteLock implementation?
> This is the recipe distributed with ZK.
> http://svn.apache.org/repos/asf/zookeeper/tags/release-3.3.2/src/recipes/lock/
> > Also, have you considered using the locks provided in
> > menagerie<https://github.com/openUtility/menagerie>
> >  or KeptCollections <https://github.com/anthonyu/KeptCollections>? They
> may
> > or may not provide the features that you are interested in, but still
> worth
> > checking out.
> I hadn’t seen those. Thank you for the links!
> best, Erik
> Sent from my free software system <http://fsf.org/>.

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