tp.impl
Class MyLM

java.lang.Object
  extended by 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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface tp.LM
LM.DeadLockException, LM.LockType
 
Field Summary
 
Fields inherited from interface tp.LM
DEFAULT_DEADLOCK_TIMEOUT
 
Constructor Summary
MyLM()
           
 
Method Summary
 void lockForRead(Transaction context, Lockable resource)
          obtain a read lock for given resource
 void lockForWrite(Transaction context, Lockable resource)
          obtain a write lock for given resource
 void setDeadlockTimeout(long ms)
          Set deadlock timeout in millisecond.
 void unlockAll(Transaction context)
          unlock all locks held by the transaction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyLM

public MyLM()
Method Detail

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 identifier
resource - 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 identifier
resource - 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