zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: WriteLock does not work.
Date Sun, 15 Dec 2013 14:08:35 GMT
Are you using a JVM language? Curator already has a revocable lock recipe.



On Dec 15, 2013, at 8:28 AM, mdzfirst mdzfirst <mdzfirst@gmail.com> wrote:

> Hi everyone,
> I would like to implement a 'preemptible' mutex with the WriteLock example
> in the recipe. My method is like this.
> 1. Acquire the WriteLock and get the resources
> 2. Set a watch on the lock's root node with getChildren() repeatedly, using
> a separate ZooKeeper client
> 3. If only one child (self) is found, sleep
> 4. The callback function only wakes up the main thread
> 5. If the watch is triggered and > 1 children are found, release the
> resources and unlock the WriteLock
> In my design, I will execute the jar multiple times. Each time a new one is
> started, the old one should be forced to release the mutex. It works. The
> first execution does stop. However, the second process seems to lose its
> watch on the first one, because the callback function I passed to the
> WriteLock object is never evoked. The callback function is used to
> synchronize the locking request and is thus very important.
> Can anyone see any flaws in my design, or provide a different way that
> works? Thanks~
> Best regards,
> mdzfirst

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