public class SmartLockManager extends Object implements LockManager
Uses RedisLockManager is Redis is configured or otherwise JavaLockManager
| Constructor and Description |
|---|
SmartLockManager() |
| Modifier and Type | Method and Description |
|---|---|
List<LockInfo> |
getLocks()
Returns the list of known locks.
|
String |
getName() |
boolean |
isLocked(String lock)
Determines if the lock is currently being locked.
|
boolean |
tryLock(String lockName,
Duration acquireTimeout)
Tries to acquire the lock with the given name within the given interval.
|
void |
unlock(String lock,
boolean force)
Unlocks the given lock.
|
@Nonnull public String getName()
getName in interface sirius.kernel.di.std.Namedpublic boolean tryLock(@Nonnull String lockName, @Nullable Duration acquireTimeout)
LockManagertryLock in interface LockManagerlockName - the name of the lock to acquire.acquireTimeout - the max time to wait for a lock. Used null to immediatelly return if a lock
cannot
be obtained.public boolean isLocked(@Nonnull String lock)
LockManagerisLocked in interface LockManagerlock - the name of the lock to checkpublic void unlock(String lock, boolean force)
LockManagerunlock in interface LockManagerlock - the name of the lockforce - true if the lock should be removed, even if it is acquired by another nodepublic List<LockInfo> getLocks()
LockManagergetLocks in interface LockManagerCopyright © 2018. All rights reserved.