org.infinispan.util.concurrent.locks
Class DeadlockDetectingLockManager

java.lang.Object
  extended by org.infinispan.util.concurrent.locks.LockManagerImpl
      extended by 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

Field Summary
protected  boolean exposeJmxStats
           
protected  long spinDuration
           
 
Fields inherited from class org.infinispan.util.concurrent.locks.LockManagerImpl
configuration, lockContainer, trace
 
Constructor Summary
DeadlockDetectingLockManager()
           
 
Method Summary
 long getDetectedLocalDeadlocks()
           
 long getDetectedRemoteDeadlocks()
           
static long getLocallyInterruptedTransactions()
          Deprecated. 
 long getOverlapWithNotDeadlockAwareLockOwners()
           
 long getTotalNumberOfDetectedDeadlocks()
           
 void init()
           
 void injectTimeService(TimeService timeService)
           
 boolean lockAndRecord(Object key, InvocationContext ctx, long lockTimeout)
          Acquires a lock of type lockType, on a specific entry in the cache.
 void resetStatistics()
           
 void setExposeJmxStats(boolean exposeJmxStats)
           
 
Methods inherited from class org.infinispan.util.concurrent.locks.LockManagerImpl
acquireLock, acquireLockNoCheck, getConcurrencyLevel, 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
 

Field Detail

spinDuration

protected volatile long spinDuration

exposeJmxStats

protected volatile boolean exposeJmxStats
Constructor Detail

DeadlockDetectingLockManager

public DeadlockDetectingLockManager()
Method Detail

init

public void init()

injectTimeService

public void injectTimeService(TimeService timeService)

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 lock
ctx - 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 © 2013 JBoss, a division of Red Hat. All Rights Reserved.