You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@curator.apache.org by "kulkarni.swarnim@gmail.com" <ku...@gmail.com> on 2013/11/20 16:56:16 UTC

InterProcessMutex acquire

Hello,

So with the InterProcessMutex#acquire method[1], I was a little confused
with what the acquire method would actually do in case another thread
already owns the lock. The documentation seems a little conflicting. At one
place it says "Acquire the mutex - *blocks until it's available*" while at
another it says "java.lang.Exception - ZK errors, interruptions, *another
thread owns the lock*".

In my tests, I am seeing the blocking behavior but curious in what cases an
exception would get thrown?

If someone could clarify this for me, that will be awesome.

[1]
http://netflix.github.io/curator/doc/com/netflix/curator/framework/recipes/locks/InterProcessMutex.html#acquire(long,
java.util.concurrent.TimeUnit)

-- 
Swarnim

Re: InterProcessMutex acquire

Posted by "kulkarni.swarnim@gmail.com" <ku...@gmail.com>.
For the record, the JIRA is here[1]

[1] https://issues.apache.org/jira/browse/CURATOR-74


On Wed, Nov 20, 2013 at 1:24 PM, Jordan Zimmerman <
jordan@jordanzimmerman.com> wrote:

> I agree that's misleading. Please open a Jira to fix the doc.
>
> In any event, InterProcessMutex works just like a JVM lock except it spans
> JVMs. It's re-entrant for the thread that owns the lock. All other threads,
> JVMs, etc. will block until it's released.
>
> -JZ
>
> On Nov 20, 2013, at 7:56 AM, kulkarni.swarnim@gmail.com wrote:
>
> Hello,
>
> So with the InterProcessMutex#acquire method[1], I was a little confused
> with what the acquire method would actually do in case another thread
> already owns the lock. The documentation seems a little conflicting. At one
> place it says "Acquire the mutex - *blocks until it's available*" while
> at another it says "java.lang.Exception - ZK errors, interruptions, *another
> thread owns the lock*".
>
> In my tests, I am seeing the blocking behavior but curious in what cases
> an exception would get thrown?
>
> If someone could clarify this for me, that will be awesome.
>
> [1]
> http://netflix.github.io/curator/doc/com/netflix/curator/framework/recipes/locks/InterProcessMutex.html#acquire(long,
> java.util.concurrent.TimeUnit)
>
> --
> Swarnim
>
>
>


-- 
Swarnim

Re: InterProcessMutex acquire

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
I agree that's misleading. Please open a Jira to fix the doc.

In any event, InterProcessMutex works just like a JVM lock except it spans JVMs. It's re-entrant for the thread that owns the lock. All other threads, JVMs, etc. will block until it's released.

-JZ

On Nov 20, 2013, at 7:56 AM, kulkarni.swarnim@gmail.com wrote:

> Hello,
> 
> So with the InterProcessMutex#acquire method[1], I was a little confused with what the acquire method would actually do in case another thread already owns the lock. The documentation seems a little conflicting. At one place it says "Acquire the mutex - blocks until it's available" while at another it says "java.lang.Exception - ZK errors, interruptions, another thread owns the lock".
> 
> In my tests, I am seeing the blocking behavior but curious in what cases an exception would get thrown?
> 
> If someone could clarify this for me, that will be awesome.
> 
> [1] http://netflix.github.io/curator/doc/com/netflix/curator/framework/recipes/locks/InterProcessMutex.html#acquire(long, java.util.concurrent.TimeUnit)
> 
> -- 
> Swarnim