Class LockManagerImpl
- java.lang.Object
-
- org.flowable.common.engine.impl.lock.LockManagerImpl
-
- All Implemented Interfaces:
LockManager
public class LockManagerImpl extends Object implements LockManager
- Author:
- Filip Hrisafov
-
-
Field Summary
Fields Modifier and Type Field Description protected CommandExecutorcommandExecutorprotected StringengineTypeprotected booleanhasAcquiredLockprotected static intLOCK_NAME_MAX_LENGTHprotected CommandConfiglockCommandConfigprotected DurationlockForceAcquireAfterprotected StringlockNameprotected DurationlockPollRateprotected static org.slf4j.LoggerLOGGER
-
Constructor Summary
Constructors Constructor Description LockManagerImpl(CommandExecutor commandExecutor, String lockName, Duration lockPollRate, String engineType)LockManagerImpl(CommandExecutor commandExecutor, String lockName, Duration lockPollRate, Duration forceAcquireAfter, String engineType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquireLock()Acquire the lock.booleanacquireLock(Duration lockForceAcquireAfter)Acquire the lock.protected <T> TexecuteCommand(Command<T> command)protected DurationgetLockPollRate()voidreleaseAndDeleteLock()Release the lock and delete the resources for the lock if needed.voidreleaseLock()Release the lock.voidwaitForLock(Duration waitTime)Wait for the givenwaitTimeto acquire the lock<T> TwaitForLockRunAndRelease(Duration waitTime, Supplier<T> supplier)Wait to acquire a lock, once a lock is acquired execute the supplier and release finally the lock.
-
-
-
Field Detail
-
LOGGER
protected static final org.slf4j.Logger LOGGER
-
LOCK_NAME_MAX_LENGTH
protected static final int LOCK_NAME_MAX_LENGTH
- See Also:
- Constant Field Values
-
commandExecutor
protected CommandExecutor commandExecutor
-
lockName
protected String lockName
-
lockPollRate
protected Duration lockPollRate
-
engineType
protected String engineType
-
lockCommandConfig
protected CommandConfig lockCommandConfig
-
hasAcquiredLock
protected boolean hasAcquiredLock
-
lockForceAcquireAfter
protected Duration lockForceAcquireAfter
-
-
Constructor Detail
-
LockManagerImpl
public LockManagerImpl(CommandExecutor commandExecutor, String lockName, Duration lockPollRate, String engineType)
-
LockManagerImpl
public LockManagerImpl(CommandExecutor commandExecutor, String lockName, Duration lockPollRate, Duration forceAcquireAfter, String engineType)
-
-
Method Detail
-
waitForLock
public void waitForLock(Duration waitTime)
Description copied from interface:LockManagerWait for the givenwaitTimeto acquire the lock- Specified by:
waitForLockin interfaceLockManager- Parameters:
waitTime- the duration to wait before throwing an exception
-
acquireLock
public boolean acquireLock()
Description copied from interface:LockManagerAcquire the lock.- Specified by:
acquireLockin interfaceLockManager- Returns:
trueif the lock was acquired,falseotherwise
-
acquireLock
public boolean acquireLock(Duration lockForceAcquireAfter)
Description copied from interface:LockManagerAcquire the lock. ThelockForceAcquireAfterwill be used to acquire an expired lock- Specified by:
acquireLockin interfaceLockManager- Parameters:
lockForceAcquireAfter- the amount of time after which the lock should be acquired- Returns:
trueif the lock was acquired,falseotherwise
-
releaseLock
public void releaseLock()
Description copied from interface:LockManagerRelease the lock.- Specified by:
releaseLockin interfaceLockManager
-
releaseAndDeleteLock
public void releaseAndDeleteLock()
Description copied from interface:LockManagerRelease the lock and delete the resources for the lock if needed.- Specified by:
releaseAndDeleteLockin interfaceLockManager
-
waitForLockRunAndRelease
public <T> T waitForLockRunAndRelease(Duration waitTime, Supplier<T> supplier)
Description copied from interface:LockManagerWait to acquire a lock, once a lock is acquired execute the supplier and release finally the lock.- Specified by:
waitForLockRunAndReleasein interfaceLockManager- Parameters:
waitTime- the duration to wait before throwing an exceptionsupplier- the supplier to be executed once the lock is acquired- Returns:
- the result from the
supplier
-
executeCommand
protected <T> T executeCommand(Command<T> command)
-
getLockPollRate
protected Duration getLockPollRate()
-
-