org.infinispan.util.concurrent.locks
Class DeadlockDetectingLockManager
java.lang.Object
org.infinispan.util.concurrent.locks.LockManagerImpl
org.infinispan.util.concurrent.locks.DeadlockDetectingLockManager
- All Implemented Interfaces:
- LockManager
public class DeadlockDetectingLockManager
- extends LockManagerImpl
Lock manager in charge with processing deadlock detections.
Implementation notes: if a deadlock is detected, then one of the transactions has to rollback. The transaction that
rollbacks is determined by comparing the coin toss from DldGlobalTransaction
.
A thread calling LockManager.lockAndRecord(Object, org.infinispan.context.InvocationContext, long)
would run the deadlock detection algorithm only if all of the following take place:
- the call is made in the scope of a transaction (either locally originated or remotely originated)
- it cannot acquire lock on the given key and the lock owner is another transaction
- when comparing coin toss, this thread would loose against the other one - so it's always the potential loser that runs DLD.
If deadlock is detected then LockManager.lockAndRecord(Object, org.infinispan.context.InvocationContext, long)
would throw an
DeadlockDetectedException
. This is subsequently handled in
in the interceptor chain - locks owned by this tx are released.
- Author:
- Mircea.Markus@jboss.com
Methods inherited from class org.infinispan.util.concurrent.locks.LockManagerImpl |
acquireLock, acquireLock, acquireLockNoCheck, getConcurrencyLevel, getLockAcquisitionTimeout, getLockId, getNumberOfLocksAvailable, getNumberOfLocksHeld, getOwner, injectDependencies, isLocked, ownsLock, possiblyLocked, printLockInfo, unlock, unlockAll |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
spinDuration
protected volatile long spinDuration
exposeJmxStats
protected volatile boolean exposeJmxStats
DeadlockDetectingLockManager
public DeadlockDetectingLockManager()
init
public void init()
lockAndRecord
public boolean lockAndRecord(Object key,
InvocationContext ctx,
long lockTimeout)
throws InterruptedException
- Description copied from interface:
LockManager
- Acquires a lock of type lockType, on a specific entry in the cache. This method will try for a period of time and
give up if it is unable to acquire the required lock. The period of time is specified in
Configuration.getLockAcquisitionTimeout()
.
- Specified by:
lockAndRecord
in interface LockManager
- Overrides:
lockAndRecord
in class LockManagerImpl
- Parameters:
key
- key to lockctx
- invocation context associated with this invocation
- Returns:
- true if the lock was acquired, false otherwise.
- Throws:
InterruptedException
- if interrupted
setExposeJmxStats
public void setExposeJmxStats(boolean exposeJmxStats)
getTotalNumberOfDetectedDeadlocks
public long getTotalNumberOfDetectedDeadlocks()
resetStatistics
public void resetStatistics()
getDetectedRemoteDeadlocks
public long getDetectedRemoteDeadlocks()
getDetectedLocalDeadlocks
public long getDetectedLocalDeadlocks()
getOverlapWithNotDeadlockAwareLockOwners
public long getOverlapWithNotDeadlockAwareLockOwners()
getLocallyInterruptedTransactions
@Deprecated
public static long getLocallyInterruptedTransactions()
- Deprecated.
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.