|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.curator.framework.recipes.locks.InterProcessMutex
public class InterProcessMutex
A re-entrant mutex that works across JVMs. Uses Zookeeper to hold the lock. All processes in all JVMs that use the same lock path will achieve an inter-process critical section. Further, this mutex is "fair" - each user will get the mutex in the order requested (from ZK's point of view)
| Constructor Summary | |
|---|---|
InterProcessMutex(org.apache.curator.framework.CuratorFramework client,
String path)
|
|
| Method Summary | |
|---|---|
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 |
isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVM |
void |
makeRevocable(RevocationListener<InterProcessMutex> listener)
Make the lock revocable. |
void |
makeRevocable(RevocationListener<InterProcessMutex> listener,
Executor executor)
Make the lock revocable. |
void |
release()
Perform one release of the mutex if the calling thread is the same thread that acquired it. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InterProcessMutex(org.apache.curator.framework.CuratorFramework client,
String path)
client - clientpath - the path to lock| Method Detail |
|---|
public void acquire()
throws Exception
release()
acquire in interface InterProcessLockException - ZK errors, connection interruptions
public boolean acquire(long time,
TimeUnit unit)
throws Exception
release()
acquire in interface InterProcessLocktime - time to waitunit - time unit
Exception - ZK errors, connection interruptionspublic boolean isAcquiredInThisProcess()
isAcquiredInThisProcess in interface InterProcessLock
public void release()
throws Exception
release in interface InterProcessLockException - ZK errors, interruptions, current thread does not own the lock
public Collection<String> getParticipantNodes()
throws Exception
Exception - ZK errors, interruptions, etc.public void makeRevocable(RevocationListener<InterProcessMutex> listener)
Revocable
makeRevocable in interface Revocable<InterProcessMutex>listener - the listener
public void makeRevocable(RevocationListener<InterProcessMutex> listener,
Executor executor)
Revocable
makeRevocable in interface Revocable<InterProcessMutex>listener - the listenerexecutor - executor for the listenerprotected byte[] getLockNodeBytes()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||