tp.impl
Class MyLM
java.lang.Object
tp.impl.MyLM
- All Implemented Interfaces:
- LM
public class MyLM
- extends Object
- implements LM
Your Lock Manager
By default, it supports timeout based deadlock detection.
Please refer comments (TODO) in the code when implementing lock conversion
and deadlock detection using wait-for graph.
Constructor Summary |
MyLM()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MyLM
public MyLM()
lockForRead
public void lockForRead(Transaction context,
Lockable resource)
throws LM.DeadLockException,
InterruptedException
- Description copied from interface:
LM
- obtain a read lock for given resource
- Specified by:
lockForRead
in interface LM
- Parameters:
context
- transaction identifierresource
- lockable resource identifier
- Throws:
LM.DeadLockException
- deadlock detected by either timeout or explicit deadlock detection algorithm
InterruptedException
- thread has been interrupted by coordination thread
lockForWrite
public void lockForWrite(Transaction context,
Lockable resource)
throws LM.DeadLockException,
InterruptedException
- Description copied from interface:
LM
- obtain a write lock for given resource
- Specified by:
lockForWrite
in interface LM
- Parameters:
context
- transaction identifierresource
- lockable resource identifier
- Throws:
LM.DeadLockException
- deadlock detected by either timeout or explicit deadlock detection algorithm
InterruptedException
- thread has been interrupted by coordination thread
unlockAll
public void unlockAll(Transaction context)
- Description copied from interface:
LM
- unlock all locks held by the transaction
- Specified by:
unlockAll
in interface LM
- Parameters:
context
- transaction identifier
setDeadlockTimeout
public void setDeadlockTimeout(long ms)
- Description copied from interface:
LM
- Set deadlock timeout in millisecond. The default value is 10 seconds.
Use this interface for testing concurrency control.
- Specified by:
setDeadlockTimeout
in interface LM
- Parameters:
ms
- timeout value in millisecond