public class LockManagerImpl extends Object implements LockManager
| Modifier and Type | Field and Description |
|---|---|
protected CommandExecutor |
commandExecutor |
protected String |
engineType |
protected boolean |
hasAcquiredLock |
protected static int |
LOCK_NAME_MAX_LENGTH |
protected CommandConfig |
lockCommandConfig |
protected Duration |
lockForceAcquireAfter |
protected String |
lockName |
protected Duration |
lockPollRate |
protected static org.slf4j.Logger |
LOGGER |
| Constructor and Description |
|---|
LockManagerImpl(CommandExecutor commandExecutor,
String lockName,
Duration lockPollRate,
Duration forceAcquireAfter,
String engineType) |
LockManagerImpl(CommandExecutor commandExecutor,
String lockName,
Duration lockPollRate,
String engineType) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireLock()
Acquire the lock.
|
boolean |
acquireLock(Duration lockForceAcquireAfter)
Acquire the lock.
|
protected <T> T |
executeCommand(Command<T> command) |
protected Duration |
getLockPollRate() |
void |
releaseAndDeleteLock()
Release the lock and delete the resources for the lock if needed.
|
void |
releaseLock()
Release the lock.
|
void |
waitForLock(Duration waitTime)
Wait for the given
waitTime to acquire the lock |
<T> T |
waitForLockRunAndRelease(Duration waitTime,
Supplier<T> supplier)
Wait to acquire a lock, once a lock is acquired execute the supplier and release finally the lock.
|
protected static final org.slf4j.Logger LOGGER
protected static final int LOCK_NAME_MAX_LENGTH
protected CommandExecutor commandExecutor
protected String lockName
protected Duration lockPollRate
protected String engineType
protected CommandConfig lockCommandConfig
protected boolean hasAcquiredLock
protected Duration lockForceAcquireAfter
public LockManagerImpl(CommandExecutor commandExecutor, String lockName, Duration lockPollRate, String engineType)
public LockManagerImpl(CommandExecutor commandExecutor, String lockName, Duration lockPollRate, Duration forceAcquireAfter, String engineType)
public void waitForLock(Duration waitTime)
LockManagerwaitTime to acquire the lockwaitForLock in interface LockManagerwaitTime - the duration to wait before throwing an exceptionpublic boolean acquireLock()
LockManageracquireLock in interface LockManagertrue if the lock was acquired, false otherwisepublic boolean acquireLock(Duration lockForceAcquireAfter)
LockManagerlockForceAcquireAfter will be used to acquire an expired lockacquireLock in interface LockManagerlockForceAcquireAfter - the amount of time after which the lock should be acquiredtrue if the lock was acquired, false otherwisepublic void releaseLock()
LockManagerreleaseLock in interface LockManagerpublic void releaseAndDeleteLock()
LockManagerreleaseAndDeleteLock in interface LockManagerpublic <T> T waitForLockRunAndRelease(Duration waitTime, Supplier<T> supplier)
LockManagerwaitForLockRunAndRelease in interface LockManagerwaitTime - the duration to wait before throwing an exceptionsupplier - the supplier to be executed once the lock is acquiredsupplierprotected <T> T executeCommand(Command<T> command)
protected Duration getLockPollRate()
Copyright © 2022 Flowable. All rights reserved.