arlut.csd.ganymede
Class DBSessionLockManager

java.lang.Object
  |
  +--arlut.csd.ganymede.DBSessionLockManager

public class DBSessionLockManager
extends java.lang.Object

This class coordinates lock activity for a server-side DBSession object. This class handles the logic to make sure that a session does not grant a new lock that would conflict with a lock already held by the same session.


Field Summary
private  java.util.Hashtable lockHash
           
private  arlut.csd.ganymede.DBSession session
           
 
Constructor Summary
DBSessionLockManager(arlut.csd.ganymede.DBSession session)
           
 
Method Summary
 boolean isLocked(arlut.csd.ganymede.DBLock lock)
          Returns true if the session's lock is currently locked, false otherwise.
 arlut.csd.ganymede.DBDumpLock openDumpLock()
          This method establishes a dump lock on all object bases in this Ganymede server.
 arlut.csd.ganymede.DBReadLock openReadLock()
          openReadLock establishes a read lock for the entire DBStore.
 arlut.csd.ganymede.DBReadLock openReadLock(java.util.Vector bases)
          Establishes a read lock for the DBObjectBases in bases.
 arlut.csd.ganymede.DBWriteLock openWriteLock(java.util.Vector bases)
          Establishes a write lock for the DBObjectBases in bases.
 void releaseAllLocks()
          releaseAllLocks() releases all locks held by this session.
 void releaseLock(arlut.csd.ganymede.DBLock lock)
          releaseLock releases a particular lock held by this session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockHash

private java.util.Hashtable lockHash

session

private arlut.csd.ganymede.DBSession session
Constructor Detail

DBSessionLockManager

public DBSessionLockManager(arlut.csd.ganymede.DBSession session)
Method Detail

isLocked

public boolean isLocked(arlut.csd.ganymede.DBLock lock)

Returns true if the session's lock is currently locked, false otherwise.


openReadLock

public arlut.csd.ganymede.DBReadLock openReadLock(java.util.Vector bases)
                                           throws java.lang.InterruptedException

Establishes a read lock for the DBObjectBases in bases.

The thread calling this method will block until the read lock can be established. If any of the DBObjectBases in the bases vector have transactions currently committing, the establishment of the read lock will be suspended until all such transactions are committed.

All viewDBObject calls done within the context of an open read lock will be transaction consistent. Other sessions may pull objects out for editing during the course of the session's read lock, but no visible changes will be made to those ObjectBases until the read lock is released.

java.lang.InterruptedException

openReadLock

public arlut.csd.ganymede.DBReadLock openReadLock()
                                           throws java.lang.InterruptedException

openReadLock establishes a read lock for the entire DBStore.

The thread calling this method will block until the read lock can be established. If transactions on the database are currently committing, the establishment of the read lock will be suspended until all such transactions are committed.

All viewDBObject calls done within the context of an open read lock will be transaction consistent. Other sessions may pull objects out for editing during the course of the session's read lock, but no visible changes will be made to those ObjectBases until the read lock is released.

java.lang.InterruptedException

openWriteLock

public arlut.csd.ganymede.DBWriteLock openWriteLock(java.util.Vector bases)
                                             throws java.lang.InterruptedException

Establishes a write lock for the DBObjectBases in bases.

The thread calling this method will block until the write lock can be established. If this DBSession already possesses a write lock, read lock, or dump lock, the openWriteLock() call will fail with an InterruptedException.

If one or more different DBSessions (besides this) have locks in place that would block acquisition of the write lock, this method will block until the lock can be acquired.

java.lang.InterruptedException

openDumpLock

public arlut.csd.ganymede.DBDumpLock openDumpLock()
                                           throws java.lang.InterruptedException

This method establishes a dump lock on all object bases in this Ganymede server.

java.lang.InterruptedException

releaseLock

public void releaseLock(arlut.csd.ganymede.DBLock lock)

releaseLock releases a particular lock held by this session. This method will not force a lock being held by another thread to drop out of its establish method.. it is intended to be called by the same thread that established the lock.


releaseAllLocks

public void releaseAllLocks()

releaseAllLocks() releases all locks held by this session.