public class InterProcessMultiLock extends Object implements InterProcessLock
Constructor and Description |
---|
InterProcessMultiLock(CuratorFramework client,
List<String> paths)
Creates a multi lock of
InterProcessMutex s |
InterProcessMultiLock(List<InterProcessLock> locks)
Creates a multi lock of any type of inter process lock
|
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.
|
boolean |
isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVM
|
void |
release()
Perform one release of the mutex.
|
public InterProcessMultiLock(CuratorFramework client, List<String> paths)
InterProcessMutex
sclient
- the clientpaths
- list of paths to manage in the order that they are to be lockedpublic InterProcessMultiLock(List<InterProcessLock> locks)
locks
- the lockspublic void acquire() throws Exception
InterProcessLock.release()
acquire
in interface InterProcessLock
Exception
- ZK errors, connection interruptionspublic boolean acquire(long time, TimeUnit unit) throws Exception
InterProcessLock.release()
acquire
in interface InterProcessLock
time
- time to waitunit
- time unitException
- ZK errors, connection interruptionspublic void release() throws Exception
NOTE: locks are released in the reverse order that they were acquired.
release
in interface InterProcessLock
Exception
- ZK errors, interruptions, current thread does not own the lockpublic boolean isAcquiredInThisProcess()
InterProcessLock
isAcquiredInThisProcess
in interface InterProcessLock
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.