@MBean(objectName="LockManager",
description="Manager that handles MVCC locks for entries")
public class DefaultLockManager
extends Object
implements LockManager
LockManager implementation for transactional and non-transactional caches.| Constructor and Description |
|---|
DefaultLockManager() |
| Modifier and Type | Method and Description |
|---|---|
int |
getConcurrencyLevel() |
InfinispanLock |
getLock(Object key) |
int |
getNumberOfLocksAvailable() |
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 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
LockManager.unlock(Object, Object) but for multiple keys. |
void |
unlockAll(InvocationContext context)
Same as
unlockAll(context.getLockedKeys(), context.getKeyLockOwner();. |
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.
Note this method will unlock a lock where the key is the lockOwner
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.
Note this method will not unlock a lock where the key is the lockOwner
unlockAll in interface LockManagerkeys - keys to unlock.lockOwner - the owner of the lock.public void unlockAll(InvocationContext context)
LockManagerunlockAll(context.getLockedKeys(), context.getKeyLockOwner();.
Note this method will not unlock a lock where the key is the lockOwner
unlockAll in interface LockManagercontext - the context with the locked keys and the lock owner.public boolean ownsLock(Object key, Object lockOwner)
LockManagerlockOwner owns a lock on the key.ownsLock in interface LockManagerkey - key to test.lockOwner - 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 LockManager@ManagedAttribute(description="The number of exclusive locks that are held.",
displayName="Number of locks held")
public int getNumberOfLocksHeld()
getNumberOfLocksHeld in interface LockManager@ManagedAttribute(description="The concurrency level that the MVCC Lock Manager has been configured with.",
displayName="Concurrency level",
dataType=TRAIT)
public int getConcurrencyLevel()
@ManagedAttribute(description="The number of exclusive locks that are available.",
displayName="Number of locks available")
public int getNumberOfLocksAvailable()
public InfinispanLock getLock(Object key)
getLock in interface LockManagerCopyright © 2022 JBoss by Red Hat. All rights reserved.