Package org.infinispan.stats.wrappers
Class TopKeyLockManager
- java.lang.Object
-
- org.infinispan.stats.wrappers.TopKeyLockManager
-
- All Implemented Interfaces:
LockManager
public class TopKeyLockManager extends java.lang.Object implements LockManager
Top-key stats about locks.- Since:
- 6.0
- Author:
- Pedro Ruivo
-
-
Constructor Summary
Constructors Constructor Description TopKeyLockManager(LockManager current, StreamSummaryContainer container)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.infinispan.util.concurrent.locks.impl.InfinispanLockgetLock(java.lang.Object key)intgetNumberOfLocksHeld()java.lang.ObjectgetOwner(java.lang.Object key)Retrieves the owner of the lock for thekey.booleanisLocked(java.lang.Object key)Tests if thekeyis locked.KeyAwareLockPromiselock(java.lang.Object key, java.lang.Object lockOwner, long time, java.util.concurrent.TimeUnit unit)Attempts to lock thekeyif the lock isn't already held by thelockOwner.KeyAwareLockPromiselockAll(java.util.Collection<?> keys, java.lang.Object lockOwner, long time, java.util.concurrent.TimeUnit unit)Same asLockManager.lock(Object, Object, long, TimeUnit)but for multiple keys.booleanownsLock(java.lang.Object key, java.lang.Object owner)Tests if thelockOwnerowns a lock on thekey.java.lang.StringprintLockInfo()Prints lock information for all locks.voidunlock(java.lang.Object key, java.lang.Object lockOwner)Releases the lock for thekeyif thelockOwneris the lock owner.voidunlockAll(java.util.Collection<?> keys, java.lang.Object lockOwner)Same asLockManager.unlock(Object, Object)but for multiple keys.voidunlockAll(InvocationContext ctx)Same asunlockAll(context.getLockedKeys(), context.getKeyLockOwner();.
-
-
-
Constructor Detail
-
TopKeyLockManager
public TopKeyLockManager(LockManager current, StreamSummaryContainer container)
-
-
Method Detail
-
lock
public KeyAwareLockPromise lock(java.lang.Object key, java.lang.Object lockOwner, long time, java.util.concurrent.TimeUnit unit)
Description copied from interface:LockManagerAttempts to lock thekeyif the lock isn't already held by thelockOwner.This method is non-blocking and return immediately a
LockPromise. TheLockPromisecan (and should) be used by the invoker to check when the lock is really acquired by invokingLockPromise.lock().- Specified by:
lockin 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 thetimeargument- Returns:
- the
KeyAwareLockPromiseassociated to this keys.
-
lockAll
public KeyAwareLockPromise lockAll(java.util.Collection<?> keys, java.lang.Object lockOwner, long time, java.util.concurrent.TimeUnit unit)
Description copied from interface:LockManagerSame 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:
lockAllin 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 thetimeargument- Returns:
- the
KeyAwareLockPromiseassociated to this keys.
-
unlock
public void unlock(java.lang.Object key, java.lang.Object lockOwner)Description copied from interface:LockManagerReleases the lock for thekeyif thelockOwneris the lock owner.Note this method will unlock a lock where the key is the lockOwner
- Specified by:
unlockin interfaceLockManager- Parameters:
key- key to unlock.lockOwner- the owner of the lock.
-
unlockAll
public void unlockAll(java.util.Collection<?> keys, java.lang.Object lockOwner)Description copied from interface:LockManagerSame asLockManager.unlock(Object, Object)but for multiple keys.Note this method will not unlock a lock where the key is the lockOwner
- Specified by:
unlockAllin interfaceLockManager- Parameters:
keys- keys to unlock.lockOwner- the owner of the lock.
-
unlockAll
public void unlockAll(InvocationContext ctx)
Description copied from interface:LockManagerSame asunlockAll(context.getLockedKeys(), context.getKeyLockOwner();.Note this method will not unlock a lock where the key is the lockOwner
- Specified by:
unlockAllin interfaceLockManager- Parameters:
ctx- the context with the locked keys and the lock owner.
-
ownsLock
public boolean ownsLock(java.lang.Object key, java.lang.Object owner)Description copied from interface:LockManagerTests if thelockOwnerowns a lock on thekey.- Specified by:
ownsLockin interfaceLockManager- Parameters:
key- key to test.owner- the owner of the lock.- Returns:
trueif the owner does own the lock on the key,falseotherwise.
-
isLocked
public boolean isLocked(java.lang.Object key)
Description copied from interface:LockManagerTests if thekeyis locked.- Specified by:
isLockedin interfaceLockManager- Parameters:
key- key to test.- Returns:
trueif the key is locked,falseotherwise.
-
getOwner
public java.lang.Object getOwner(java.lang.Object key)
Description copied from interface:LockManagerRetrieves the owner of the lock for thekey.- Specified by:
getOwnerin interfaceLockManager- Returns:
- the owner of the lock, or
nullif not locked.
-
printLockInfo
public java.lang.String printLockInfo()
Description copied from interface:LockManagerPrints lock information for all locks.- Specified by:
printLockInfoin interfaceLockManager- Returns:
- the lock information
-
getNumberOfLocksHeld
public int getNumberOfLocksHeld()
- Specified by:
getNumberOfLocksHeldin interfaceLockManager- Returns:
- the number of locks held.
-
getLock
public org.infinispan.util.concurrent.locks.impl.InfinispanLock getLock(java.lang.Object key)
- Specified by:
getLockin interfaceLockManager
-
-