Class InterProcessMultiLock
- java.lang.Object
-
- org.apache.curator.framework.recipes.locks.InterProcessMultiLock
-
- All Implemented Interfaces:
InterProcessLock
public class InterProcessMultiLock extends Object implements InterProcessLock
-
-
Constructor Summary
Constructors Constructor Description InterProcessMultiLock(List<InterProcessLock> locks)
Creates a multi lock of any type of inter process lockInterProcessMultiLock(CuratorFramework client, List<String> paths)
Creates a multi lock ofInterProcessMutex
s
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.boolean
isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVMvoid
release()
Perform one release of the mutex.
-
-
-
Constructor Detail
-
InterProcessMultiLock
public InterProcessMultiLock(CuratorFramework client, List<String> paths)
Creates a multi lock ofInterProcessMutex
s- Parameters:
client
- the clientpaths
- list of paths to manage in the order that they are to be locked
-
InterProcessMultiLock
public InterProcessMultiLock(List<InterProcessLock> locks)
Creates a multi lock of any type of inter process lock- Parameters:
locks
- the locks
-
-
Method Detail
-
acquire
public void acquire() throws Exception
Acquire the mutex - blocking until it's available. Each call to acquire must be balanced by a call toInterProcessLock.release()
- Specified by:
acquire
in interfaceInterProcessLock
- Throws:
Exception
- ZK errors, connection interruptions
-
acquire
public boolean acquire(long time, TimeUnit unit) throws Exception
Acquire the mutex - blocks until it's available or the given time expires. Each call to acquire that returns true must be balanced by a call toInterProcessLock.release()
- Specified by:
acquire
in interfaceInterProcessLock
- Parameters:
time
- time to waitunit
- time unit- Returns:
- true if the mutex was acquired, false if not
- Throws:
Exception
- ZK errors, connection interruptions
-
release
public void release() throws Exception
Perform one release of the mutex.NOTE: locks are released in the reverse order that they were acquired.
- Specified by:
release
in interfaceInterProcessLock
- Throws:
Exception
- ZK errors, interruptions, current thread does not own the lock
-
isAcquiredInThisProcess
public boolean isAcquiredInThisProcess()
Description copied from interface:InterProcessLock
Returns true if the mutex is acquired by a thread in this JVM- Specified by:
isAcquiredInThisProcess
in interfaceInterProcessLock
- Returns:
- true/false
-
-