tp
Interface LM

All Known Implementing Classes:
MyLM

public interface LM

Lock Manager interface


Nested Class Summary
static class LM.DeadLockException
           
static class LM.LockType
           
 
Field Summary
static long DEFAULT_DEADLOCK_TIMEOUT
          A transaction is considered in deadlock if it waits for lock more than 10 seconds.
 
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
 

Field Detail

DEFAULT_DEADLOCK_TIMEOUT

static final long DEFAULT_DEADLOCK_TIMEOUT
A transaction is considered in deadlock if it waits for lock more than 10 seconds.

See Also:
setDeadlockTimeout(long), Constant Field Values
Method Detail

lockForRead

void lockForRead(Transaction context,
                 Lockable resource)
                 throws LM.DeadLockException,
                        InterruptedException
obtain a read lock for given resource

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

void lockForWrite(Transaction context,
                  Lockable resource)
                  throws LM.DeadLockException,
                         InterruptedException
obtain a write lock for given resource

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

void unlockAll(Transaction context)
unlock all locks held by the transaction

Parameters:
context - transaction identifier

setDeadlockTimeout

void setDeadlockTimeout(long ms)
Set deadlock timeout in millisecond. The default value is 10 seconds. Use this interface for testing concurrency control.

Parameters:
ms - timeout value in millisecond