Class NonReentrantMutex
java.lang.Object
com.complexible.common.curator.framework.locks.NonReentrantMutex
- All Implemented Interfaces:
InterProcessTxLock
- Since:
- 4.3
- Author:
- Scott Fines
-
Constructor Summary
ConstructorsConstructorDescriptionNonReentrantMutex(org.apache.curator.framework.CuratorFramework client, String path) NonReentrantMutex(org.apache.curator.framework.CuratorFramework client, String path, org.apache.curator.framework.recipes.locks.LockInternalsDriver driver) -
Method Summary
Modifier and TypeMethodDescriptionvoidAcquire the mutex - blocking until it's available.booleanAcquire the mutex - blocks until it's available or the given time expires.protected byte[]Return a sorted list of all current nodes participating in the lockbooleanisAcquired(UUID theTxId) booleanvoidRelease a lock for a transaction.voidRelease all locks for all transactions that we've created.
-
Constructor Details
-
NonReentrantMutex
- Parameters:
client- clientpath- the path to lock
-
NonReentrantMutex
public NonReentrantMutex(org.apache.curator.framework.CuratorFramework client, String path, org.apache.curator.framework.recipes.locks.LockInternalsDriver driver) - Parameters:
client- clientpath- the path to lockdriver- lock driver
-
-
Method Details
-
acquire
Acquire the mutex - blocking until it's available. Each call to acquire must be balanced by a call torelease(UUID)- Specified by:
acquirein interfaceInterProcessTxLock- Parameters:
theTxId-- Throws:
Exception- ZK errors, connection interruptions
-
acquire
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 torelease(UUID)- Specified by:
acquirein interfaceInterProcessTxLock- Parameters:
theTxId-theTime- time to waittheTimeUnit- time unit- Returns:
- true if the mutex was acquired, false if not
- Throws:
Exception- ZK errors, connection interruptions
-
isAcquiredByAny
- Specified by:
isAcquiredByAnyin interfaceInterProcessTxLock- Returns:
- true if the mutex is acquired by any thread or process.
- Throws:
IOException
-
isAcquired
- Specified by:
isAcquiredin interfaceInterProcessTxLock- Parameters:
theTxId- the transaction id to check- Returns:
- true if there is a lock for the specified transaction id.
-
releaseAll
Release all locks for all transactions that we've created.- Specified by:
releaseAllin interfaceInterProcessTxLock- Throws:
Exception- IllegalMonitorStateException if one of the tx registered does not exist (concurrent release)
-
release
Description copied from interface:InterProcessTxLockRelease a lock for a transaction.- Specified by:
releasein interfaceInterProcessTxLock- Parameters:
theTxId-- Throws:
Exception
-
getParticipantNodes
Return a sorted list of all current nodes participating in the lock- Returns:
- list of nodes
- Throws:
IOException- ZK errors, interruptions, etc.
-
getLockNodeBytes
protected byte[] getLockNodeBytes()
-