|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.storage.lock.DeadlockDetection
public class DeadlockDetection
Deadlock detection for resource and collection locks. The static methods in this class keep track of all waiting threads, which are currently waiting on a resource or collection lock. In some scenarios (e.g. a complex XQuery which modifies resources), a single thread may acquire different read/write locks on resources in a collection. The locks can be arbitrarily nested. For example, a thread may first acquire a read lock on a collection, then a read lock on a resource and later acquires a write lock on the collection to remove the resource. Since we have locks on both, collections and resources, deadlock situations are sometimes unavoidable. For example, imagine the following scenario:
Constructor Summary | |
---|---|
DeadlockDetection()
|
Method Summary | |
---|---|
static void |
addCollectionWaiter(Thread waiter,
Lock lock)
Register a thread as waiting for a resource lock. |
static void |
addResourceWaiter(Thread thread,
WaitingThread waiter)
Register a thread as waiting for a resource lock. |
static Lock |
clearCollectionWaiter(Thread waiter)
|
static Lock |
clearResourceWaiter(Thread thread)
Deregister a waiting thread. |
static WaitingThread |
deadlockCheckResource(Thread threadA,
Thread threadB)
Check if there's a risk for a circular wait between threadA and threadB. |
static void |
debug()
|
static void |
debug(PrintWriter writer,
String name,
LockInfo info)
|
static void |
debug(String name,
LockInfo info)
|
static WaitingThread |
getResourceWaiter(Thread thread)
|
static Map |
getWaitingThreads()
|
static boolean |
isBlockedBy(Thread threadA,
Thread threadB)
Check if the second thread is currently waiting for a resource lock and is blocked by the first thread. |
static Lock |
isWaitingFor(Thread waiter)
|
static boolean |
wouldDeadlock(Thread waiter,
Thread owner,
List waiters)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeadlockDetection()
Method Detail |
---|
public static void addResourceWaiter(Thread thread, WaitingThread waiter)
thread
- the threadwaiter
- the WaitingThread object which wraps around the threadpublic static Lock clearResourceWaiter(Thread thread)
thread
-
public static WaitingThread getResourceWaiter(Thread thread)
public static WaitingThread deadlockCheckResource(Thread threadA, Thread threadB)
WaitingThread
object for threadB is returned. This object can be used to suspend the waiting thread
in order to temporarily yield the lock to threadA.
threadA
- threadB
-
public static boolean isBlockedBy(Thread threadA, Thread threadB)
threadA
- the thread whose lock might be blocking threadBthreadB
- the thread to check
public static boolean wouldDeadlock(Thread waiter, Thread owner, List waiters)
public static void addCollectionWaiter(Thread waiter, Lock lock)
waiter
- the threadlock
- the lock objectpublic static Lock clearCollectionWaiter(Thread waiter)
public static Lock isWaitingFor(Thread waiter)
public static Map getWaitingThreads()
public static void debug(String name, LockInfo info)
public static void debug(PrintWriter writer, String name, LockInfo info)
public static void debug()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |