ozone core API

org.ozoneDB.core
Interface Lock

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractLock

public interface Lock
extends java.io.Serializable

Locks are created by the TransactionManager and used by the core to manage concurrent access to the same containers/objects. There are several Lock implementations that provide different policies.

Version:
$Revision: 1.2 $Date: 2002/06/08 00:49:38 $
Author:
SMB

Field Summary
static int LEVEL_MAX
           
static int LEVEL_NONE
           
static int LEVEL_READ
           
static int LEVEL_UPGRADE
           
static int LEVEL_WRITE
           
static int NOT_ACQUIRED
           
 
Method Summary
 void checkDeadlock(Transaction ta)
          Check for deadlock and throw an exception if a deadlock is detected.
 boolean isAcquiredBy(Transaction ta)
           
 int level(Transaction ta)
          Returns the lock level for the specified transaction.
 DxCollection lockerIDs()
          Return all transactions that currently hold this lock.
 void release(Transaction ta)
          Release the previously aquired lock.
 void reset()
           
 int tryAcquire(Transaction ta, int level)
          Try to aquire this lock.
 

Field Detail

NOT_ACQUIRED

public static final int NOT_ACQUIRED
See Also:
Constant Field Values

LEVEL_NONE

public static final int LEVEL_NONE
See Also:
Constant Field Values

LEVEL_READ

public static final int LEVEL_READ
See Also:
Constant Field Values

LEVEL_UPGRADE

public static final int LEVEL_UPGRADE
See Also:
Constant Field Values

LEVEL_WRITE

public static final int LEVEL_WRITE
See Also:
Constant Field Values

LEVEL_MAX

public static final int LEVEL_MAX
See Also:
Constant Field Values
Method Detail

reset

public void reset()

checkDeadlock

public void checkDeadlock(Transaction ta)
                   throws TransactionError
Check for deadlock and throw an exception if a deadlock is detected. Although the transactions waits for locks and so seems also to be be a good place for deadlock detection, we do it here because each Lock implementations should hide the deadlock detection logic.

TransactionError

tryAcquire

public int tryAcquire(Transaction ta,
                      int level)
Try to aquire this lock. This method returns the previous level of the specified transaction, if the lock was sucessfully acquired. Otherwise it returns NOT_ACQUIRED.

Returns:
The previous level for the given transaction or NOT_ACQUIRED.

release

public void release(Transaction ta)
Release the previously aquired lock.


isAcquiredBy

public boolean isAcquiredBy(Transaction ta)

lockerIDs

public DxCollection lockerIDs()
Return all transactions that currently hold this lock.


level

public int level(Transaction ta)
Returns the lock level for the specified transaction. If ta is null, then we do not check ta against the transaction that has acquired this lock.

Parameters:
ta - The transaction that has acquired the lock or null.
Returns:
Lock level for ta if ta has aquired the lock or ta is null. LEVEL_NONE otherwise.

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.