public class NonReentrantMutex extends Object implements org.apache.curator.framework.recipes.locks.InterProcessLock
| Constructor and Description |
|---|
NonReentrantMutex(org.apache.curator.framework.CuratorFramework client,
String path,
boolean theAllowsReentrancy) |
NonReentrantMutex(org.apache.curator.framework.CuratorFramework client,
String path,
org.apache.curator.framework.recipes.locks.LockInternalsDriver driver,
boolean theAllowsReentrancy) |
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Acquire the mutex - blocking until it's available.
|
boolean |
acquire(long time,
TimeUnit unit)
Acquire the mutex - blocks until it's available or the given time expires.
|
protected byte[] |
getLockNodeBytes() |
Collection<String> |
getParticipantNodes()
Return a sorted list of all current nodes participating in the lock
|
boolean |
isAcquired() |
boolean |
isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVM
|
void |
release()
Perform one release of the mutex if the calling thread is the same thread that acquired it.
|
public NonReentrantMutex(org.apache.curator.framework.CuratorFramework client,
String path,
boolean theAllowsReentrancy)
client - clientpath - the path to locktheAllowsReentrancy - public NonReentrantMutex(org.apache.curator.framework.CuratorFramework client,
String path,
org.apache.curator.framework.recipes.locks.LockInternalsDriver driver,
boolean theAllowsReentrancy)
client - clientpath - the path to lockdriver - lock drivertheAllowsReentrancy - public void acquire()
throws Exception
release()acquire in interface org.apache.curator.framework.recipes.locks.InterProcessLockException - ZK errors, connection interruptionspublic boolean acquire(long time,
TimeUnit unit)
throws Exception
release()acquire in interface org.apache.curator.framework.recipes.locks.InterProcessLocktime - time to waitunit - time unitException - ZK errors, connection interruptionspublic boolean isAcquiredInThisProcess()
isAcquiredInThisProcess in interface org.apache.curator.framework.recipes.locks.InterProcessLockpublic boolean isAcquired()
throws IOException
IOExceptionpublic void release()
throws Exception
release in interface org.apache.curator.framework.recipes.locks.InterProcessLockException - ZK errors, interruptions, current thread does not own the lockpublic Collection<String> getParticipantNodes() throws IOException
IOException - ZK errors, interruptions, etc.protected byte[] getLockNodeBytes()
Copyright © 2010-2016 Stardog Union. All Rights Reserved.