public interface LockManager
| Modifier and Type | Method and Description |
|---|---|
InfinispanLock |
getLock(Object key) |
int |
getNumberOfLocksHeld() |
Object |
getOwner(Object key)
Retrieves the owner of the lock for the
key. |
boolean |
isLocked(Object key)
Tests if the
key is locked. |
KeyAwareLockPromise |
lock(Object key,
Object lockOwner,
long time,
TimeUnit unit)
Attempts to lock the
key if the lock isn't already held by the lockOwner. |
KeyAwareLockPromise |
lockAll(Collection<?> keys,
Object lockOwner,
long time,
TimeUnit unit)
Same as
lock(Object, Object, long, TimeUnit) but for multiple keys. |
boolean |
ownsLock(Object key,
Object lockOwner)
Tests if the
lockOwner owns a lock on the key. |
String |
printLockInfo()
Prints lock information for all locks.
|
void |
unlock(Object key,
Object lockOwner)
Releases the lock for the
key if the lockOwner is the lock owner. |
void |
unlockAll(Collection<?> keys,
Object lockOwner)
Same as
unlock(Object, Object) but for multiple keys. |
void |
unlockAll(InvocationContext context)
Same as
unlockAll(context.getLockedKeys(), context.getKeyLockOwner();. |
KeyAwareLockPromise lock(Object key, Object lockOwner, long time, TimeUnit unit)
key if the lock isn't already held by the lockOwner.
This method is non-blocking and return immediately a LockPromise. The LockPromise can (and should)
be used by the invoker to check when the lock is really acquired by invoking LockPromise.lock().
key - key to lock.lockOwner - the owner of the lock.time - the maximum time to wait for the lockunit - the time unit of the time argumentKeyAwareLockPromise associated to this keys.KeyAwareLockPromise lockAll(Collection<?> keys, Object lockOwner, long time, TimeUnit unit)
lock(Object, Object, long, TimeUnit) but for multiple keys.
It ensures no deadlocks if the method is invoked by different lock owners for the same set (or subset) of keys.
keys - keys to lock.lockOwner - the owner of the lock.time - the maximum time to wait for the lockunit - the time unit of the time argumentKeyAwareLockPromise associated to this keys.void unlock(Object key, Object lockOwner)
key if the lockOwner is the lock owner.key - key to unlock.lockOwner - the owner of the lock.void unlockAll(Collection<?> keys, Object lockOwner)
unlock(Object, Object) but for multiple keys.keys - keys to unlock.lockOwner - the owner of the lock.void unlockAll(InvocationContext context)
unlockAll(context.getLockedKeys(), context.getKeyLockOwner();.context - the context with the locked keys and the lock owner.boolean ownsLock(Object key, Object lockOwner)
lockOwner owns a lock on the key.key - key to test.lockOwner - the owner of the lock.true if the owner does own the lock on the key, false otherwise.boolean isLocked(Object key)
key is locked.key - key to test.true if the key is locked, false otherwise.Object getOwner(Object key)
key.null if not locked.String printLockInfo()
int getNumberOfLocksHeld()
InfinispanLock getLock(Object key)
Copyright © 2025 JBoss, a division of Red Hat. All rights reserved.