public interface LockManager extends Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
acquireLockDefault()
Tries to acquire the default lock regardless who is the current owner.
|
void |
clean()
force to delete all the locks in the database.
|
void |
close() |
void |
ensureLockDefault()
Tries to refresh the default lock when the current LockChecker has the lock or , when the lock
is expired, is the last owner
|
default String |
getDefaultKey() |
int |
getLockMaxTries() |
String |
getOwner() |
boolean |
isLockHeld() |
void |
releaseLockDefault()
Release the default lock when is acquired by the current LockChecker.
|
LockManager |
setLockAcquiredForMillis(long lockAcquiredForMillis)
Indicates the number of milliseconds the lock will be acquired for
|
LockManager |
setLockMaxTries(int lockMaxTries)
Updates the maximum number of tries to acquire the lock, if the flag 'waitForLog' is set
|
LockManager |
setLockMaxWaitMillis(long lockMaxWaitMillis)
If the flag 'waitForLog' is set, indicates the maximum time it will wait for the lock in each try.
|
default String getDefaultKey()
void acquireLockDefault()
throws LockCheckException
Tries to acquire the default lock regardless who is the current owner.
If the lock is already acquired by the current LockChecker or is expired, will be updated
In case the lock is acquired by another LockChecker, it will wait until the current lock is expired and will try to acquire it again. This will be repeated as many times as (maxTries - 1)
LockCheckException - if the lock cannot be acquiredvoid ensureLockDefault()
throws LockCheckException
Tries to refresh the default lock when the current LockChecker has the lock or , when the lock is expired, is the last owner
Notice that it does not try to acquire when is acquired by another LockChecker
LockCheckException - if, in case of needed, the lock cannot be refreshedvoid releaseLockDefault()
Release the default lock when is acquired by the current LockChecker.
When the lock is not acquired by the current LockChecker, it won't make any change. Does not throw any exception neither.
Idempotent operation.
LockManager setLockMaxWaitMillis(long lockMaxWaitMillis)
If the flag 'waitForLog' is set, indicates the maximum time it will wait for the lock in each try.
Default 3 minutes
lockMaxWaitMillis - max waiting time for lock. Must be greater than 0int getLockMaxTries()
LockManager setLockMaxTries(int lockMaxTries)
Updates the maximum number of tries to acquire the lock, if the flag 'waitForLog' is set
Default 1
lockMaxTries - number of triesLockManager setLockAcquiredForMillis(long lockAcquiredForMillis)
Indicates the number of milliseconds the lock will be acquired for
Default 3 minutes
lockAcquiredForMillis - milliseconds the lock will be acquired forString getOwner()
boolean isLockHeld()
void clean()
void close()
close in interface AutoCloseableclose in interface CloseableCopyright © 2021. All rights reserved.