Package org.infinispan.stats.wrappers
Class ExtendedStatisticLockManager
- java.lang.Object
-
- org.infinispan.stats.wrappers.ExtendedStatisticLockManager
-
- All Implemented Interfaces:
LockManager
public class ExtendedStatisticLockManager extends Object implements LockManager
Takes statistic about lock acquisition.- Since:
- 6.0
- Author:
- Roberto Palmieri, Sebastiano Peluso, Diego Didona, Pedro Ruivo
-
-
Constructor Summary
Constructors Constructor Description ExtendedStatisticLockManager(LockManager actual, CacheStatisticManager cacheStatisticManager, org.infinispan.commons.time.TimeService timeService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LockManager
getActual()
InfinispanLock
getLock(Object key)
int
getNumberOfLocksHeld()
Object
getOwner(Object key)
Retrieves the owner of the lock for thekey
.boolean
isLocked(Object key)
Tests if thekey
is locked.KeyAwareLockPromise
lock(Object key, Object lockOwner, long time, TimeUnit unit)
Attempts to lock thekey
if the lock isn't already held by thelockOwner
.KeyAwareLockPromise
lockAll(Collection<?> keys, Object lockOwner, long time, TimeUnit unit)
Same asLockManager.lock(Object, Object, long, TimeUnit)
but for multiple keys.boolean
ownsLock(Object key, Object owner)
Tests if thelockOwner
owns a lock on thekey
.String
printLockInfo()
Prints lock information for all locks.void
unlock(Object key, Object lockOwner)
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
unlockAll(InvocationContext ctx)
Same asunlockAll(context.getLockedKeys(), context.getKeyLockOwner();
.
-
-
-
Constructor Detail
-
ExtendedStatisticLockManager
public ExtendedStatisticLockManager(LockManager actual, CacheStatisticManager cacheStatisticManager, org.infinispan.commons.time.TimeService timeService)
-
-
Method Detail
-
getActual
public final LockManager getActual()
-
lock
public KeyAwareLockPromise lock(Object key, Object lockOwner, long time, TimeUnit unit)
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
public KeyAwareLockPromise lockAll(Collection<?> keys, Object lockOwner, long time, TimeUnit unit)
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
public void unlock(Object key, Object lockOwner)
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
public void unlockAll(Collection<?> keys, Object lockOwner)
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
public void unlockAll(InvocationContext ctx)
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
public boolean ownsLock(Object key, Object owner)
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
public boolean isLocked(Object key)
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
public Object getOwner(Object key)
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
public String 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
public InfinispanLock getLock(Object key)
- Specified by:
getLock
in interfaceLockManager
-
-