Class TopKeyLockManager
java.lang.Object
org.infinispan.extendedstats.wrappers.TopKeyLockManager
- All Implemented Interfaces:
LockManager
Top-key stats about locks.
- Since:
- 6.0
- Author:
- Pedro Ruivo
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Retrieves the owner of the lock for thekey
.boolean
Tests if thekey
is locked.Attempts to lock thekey
if the lock isn't already held by thelockOwner
.lockAll
(Collection<?> keys, Object lockOwner, long time, TimeUnit unit) Same asLockManager.lock(Object, Object, long, TimeUnit)
but for multiple keys.boolean
Tests if thelockOwner
owns a lock on thekey
.Prints lock information for all locks.void
Releases the lock for thekey
if thelockOwner
is the lock owner.void
unlockAll
(Collection<?> keys, Object lockOwner) Same asLockManager.unlock(Object, Object)
but for multiple keys.void
Same asunlockAll(context.getLockedKeys(), context.getKeyLockOwner();
.
-
Constructor Details
-
TopKeyLockManager
-
-
Method Details
-
lock
Description copied from interface:LockManager
Attempts to lock thekey
if the lock isn't already held by thelockOwner
.This method is non-blocking and return immediately a
LockPromise
. TheLockPromise
can (and should) be used by the invoker to check when the lock is really acquired by invokingLockPromise.lock()
.- Specified by:
lock
in interfaceLockManager
- Parameters:
key
- key to lock.lockOwner
- the owner of the lock.time
- the maximum time to wait for the lockunit
- the time unit of thetime
argument- Returns:
- the
KeyAwareLockPromise
associated to this keys.
-
lockAll
Description copied from interface:LockManager
Same asLockManager.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.
- Specified by:
lockAll
in interfaceLockManager
- Parameters:
keys
- keys to lock.lockOwner
- the owner of the lock.time
- the maximum time to wait for the lockunit
- the time unit of thetime
argument- Returns:
- the
KeyAwareLockPromise
associated to this keys.
-
unlock
Description copied from interface:LockManager
Releases the lock for thekey
if thelockOwner
is the lock owner.Note this method will unlock a lock where the key is the lockOwner
- Specified by:
unlock
in interfaceLockManager
- Parameters:
key
- key to unlock.lockOwner
- the owner of the lock.
-
unlockAll
Description copied from interface:LockManager
Same asLockManager.unlock(Object, Object)
but for multiple keys.Note this method will not unlock a lock where the key is the lockOwner
- Specified by:
unlockAll
in interfaceLockManager
- Parameters:
keys
- keys to unlock.lockOwner
- the owner of the lock.
-
unlockAll
Description copied from interface:LockManager
Same asunlockAll(context.getLockedKeys(), context.getKeyLockOwner();
.Note this method will not unlock a lock where the key is the lockOwner
- Specified by:
unlockAll
in interfaceLockManager
- Parameters:
ctx
- the context with the locked keys and the lock owner.
-
ownsLock
Description copied from interface:LockManager
Tests if thelockOwner
owns a lock on thekey
.- Specified by:
ownsLock
in interfaceLockManager
- Parameters:
key
- key to test.owner
- the owner of the lock.- Returns:
true
if the owner does own the lock on the key,false
otherwise.
-
isLocked
Description copied from interface:LockManager
Tests if thekey
is locked.- Specified by:
isLocked
in interfaceLockManager
- Parameters:
key
- key to test.- Returns:
true
if the key is locked,false
otherwise.
-
getOwner
Description copied from interface:LockManager
Retrieves the owner of the lock for thekey
.- Specified by:
getOwner
in interfaceLockManager
- Returns:
- the owner of the lock, or
null
if not locked.
-
printLockInfo
Description copied from interface:LockManager
Prints lock information for all locks.- Specified by:
printLockInfo
in interfaceLockManager
- Returns:
- the lock information
-
getNumberOfLocksHeld
public int getNumberOfLocksHeld()- Specified by:
getNumberOfLocksHeld
in interfaceLockManager
- Returns:
- the number of locks held.
-
getLock
- Specified by:
getLock
in interfaceLockManager
-