public class LockManagerImpl extends Object implements LockManager
| Modifier and Type | Field and Description |
|---|---|
protected CommandExecutor |
commandExecutor |
protected String |
engineType |
protected boolean |
hasAcquiredLock |
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.
|
protected <T> T |
executeCommand(Command<T> command) |
protected Duration |
getLockPollRate() |
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 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 void releaseLock()
LockManagerreleaseLock 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 © 2021 Flowable. All rights reserved.