public class TopKeyLockManager extends Object implements LockManager
| Constructor and Description |
|---|
TopKeyLockManager(LockManager current,
StreamSummaryContainer container) |
| 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
LockManager.lock(Object, Object, long, TimeUnit) but for multiple keys. |
boolean |
ownsLock(Object key,
Object owner)
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
LockManager.unlock(Object, Object) but for multiple keys. |
void |
unlockAll(InvocationContext ctx)
Same as
unlockAll(context.getLockedKeys(), context.getKeyLockOwner();. |
public TopKeyLockManager(LockManager current, StreamSummaryContainer container)
public KeyAwareLockPromise lock(Object key, Object lockOwner, long time, TimeUnit unit)
LockManagerkey 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().
lock in interface LockManagerkey - 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.public KeyAwareLockPromise lockAll(Collection<?> keys, Object lockOwner, long time, TimeUnit unit)
LockManagerLockManager.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.
lockAll in interface LockManagerkeys - 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.public void unlock(Object key, Object lockOwner)
LockManagerkey if the lockOwner is the lock owner.unlock in interface LockManagerkey - key to unlock.lockOwner - the owner of the lock.public void unlockAll(Collection<?> keys, Object lockOwner)
LockManagerLockManager.unlock(Object, Object) but for multiple keys.unlockAll in interface LockManagerkeys - keys to unlock.lockOwner - the owner of the lock.public void unlockAll(InvocationContext ctx)
LockManagerunlockAll(context.getLockedKeys(), context.getKeyLockOwner();.unlockAll in interface LockManagerctx - the context with the locked keys and the lock owner.public boolean ownsLock(Object key, Object owner)
LockManagerlockOwner owns a lock on the key.ownsLock in interface LockManagerkey - key to test.owner - the owner of the lock.true if the owner does own the lock on the key, false otherwise.public boolean isLocked(Object key)
LockManagerkey is locked.isLocked in interface LockManagerkey - key to test.true if the key is locked, false otherwise.public Object getOwner(Object key)
LockManagerkey.getOwner in interface LockManagernull if not locked.public String printLockInfo()
LockManagerprintLockInfo in interface LockManagerpublic int getNumberOfLocksHeld()
getNumberOfLocksHeld in interface LockManagerpublic InfinispanLock getLock(Object key)
getLock in interface LockManagerCopyright © 2024 JBoss, a division of Red Hat. All rights reserved.