public class ExtendedStatisticLockManager extends Object implements LockManager
Constructor and Description |
---|
ExtendedStatisticLockManager(LockManager actual,
CacheStatisticManager cacheStatisticManager,
TimeService timeService) |
Modifier and Type | Method and Description |
---|---|
LockManager |
getActual() |
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 ExtendedStatisticLockManager(LockManager actual, CacheStatisticManager cacheStatisticManager, TimeService timeService)
public final LockManager getActual()
public KeyAwareLockPromise lock(Object key, Object lockOwner, long time, TimeUnit unit)
LockManager
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()
.
lock
in interface LockManager
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.public KeyAwareLockPromise lockAll(Collection<?> keys, Object lockOwner, long time, TimeUnit unit)
LockManager
LockManager.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 LockManager
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.public void unlock(Object key, Object lockOwner)
LockManager
key
if the lockOwner
is the lock owner.unlock
in interface LockManager
key
- key to unlock.lockOwner
- the owner of the lock.public void unlockAll(Collection<?> keys, Object lockOwner)
LockManager
LockManager.unlock(Object, Object)
but for multiple keys.unlockAll
in interface LockManager
keys
- keys to unlock.lockOwner
- the owner of the lock.public void unlockAll(InvocationContext ctx)
LockManager
unlockAll(context.getLockedKeys(), context.getKeyLockOwner();
.unlockAll
in interface LockManager
ctx
- the context with the locked keys and the lock owner.public boolean ownsLock(Object key, Object owner)
LockManager
lockOwner
owns a lock on the key
.ownsLock
in interface LockManager
key
- 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)
LockManager
key
is locked.isLocked
in interface LockManager
key
- key to test.true
if the key is locked, false
otherwise.public Object getOwner(Object key)
LockManager
key
.getOwner
in interface LockManager
null
if not locked.public String printLockInfo()
LockManager
printLockInfo
in interface LockManager
public int getNumberOfLocksHeld()
getNumberOfLocksHeld
in interface LockManager
public InfinispanLock getLock(Object key)
getLock
in interface LockManager
Copyright © 2023 JBoss, a division of Red Hat. All rights reserved.