arlut.csd.ganymede
Class DBLockSync

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

public class DBLockSync
extends java.lang.Object

This class acts as a general synchronization object for interlock coordination. All global data required for coordinating lock activity is stored here.


Field Summary
(package private)  java.util.Hashtable lockHash
          Identifier keys for current DBLocks.
(package private)  int locksHeld
          A count of how many DBLocks are established on DBObjectBases in this DBStore.
 
Constructor Summary
DBLockSync()
           
 
Method Summary
 void addLock()
          Increments the count of held locks for the admin consoles.
 void addReadLock(java.lang.Object key, DBReadLock lock)
          This method associates a new DBReadLock with the given key, if possible.
 void clearLockHeld(java.lang.Object key)
          This method clears out a lock associated with the given key.
 void delReadLock(java.lang.Object key, DBReadLock lock)
          This method disassociates a DBReadLock from the given key, if possible.
 int getLockCount()
          Returns the number of locks presently held in the database.
 DBLock getLockHeld(java.lang.Object key)
          This method returns a DBLock associated with the given key, if any.
 java.util.Vector getReadLockVector(java.lang.Object key)
          This method returns a Vector of DBReadLock objects associated with key, if any.
 boolean isDumpLock(java.lang.Object key)
          This method returns true if the lock associated with key in the DBLockSync lockHash is a DBDumpLock.
 boolean isLockHeld(java.lang.Object key)
          This method returns true if there is a lock held in care of the given identifier in this DBLockSync object.
 boolean isReadLock(java.lang.Object key)
          This method returns true if the lock associated with key in the DBLockSync lockHash is a DBReadLock.
 boolean isWriteLock(java.lang.Object key)
          This method returns true if the lock associated with key in the DBLockSync lockHash is a DBWriteLock.
 void removeLock()
          Decrements the count of held locks for the admin consoles.
 void resetLockHash(int count)
          This method causes the DBLockSync object's lock owner hashtable to be reset.
 void setDumpLockHeld(java.lang.Object key, DBDumpLock lock)
          This method associates a dump lock with the given key.
 void setWriteLockHeld(java.lang.Object key, DBWriteLock lock)
          This method associates a write lock with the given key.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

lockHash

java.util.Hashtable lockHash

Identifier keys for current DBLocks.

This hash is used by the establish() method in various DBLock subclasses to guarantee that only one lock will established by a client at a time, to prevent any possibility of DBLock deadlock.

The values in this hash may either be scalar DBLock objects, or in the case of readers (where it is permissible for a single client to have several distinct reader locks), a Vector of DBLocks.


locksHeld

int locksHeld
A count of how many DBLocks are established on DBObjectBases in this DBStore.
Constructor Detail

DBLockSync

public DBLockSync()
Method Detail

resetLockHash

public void resetLockHash(int count)

This method causes the DBLockSync object's lock owner hashtable to be reset. If count is not zero, that value will be used to set the initial capacity for the hashtable.


isLockHeld

public boolean isLockHeld(java.lang.Object key)

This method returns true if there is a lock held in care of the given identifier in this DBLockSync object.


isReadLock

public boolean isReadLock(java.lang.Object key)

This method returns true if the lock associated with key in the DBLockSync lockHash is a DBReadLock.

If there is no lock associated with the key, or if the lock associated with the key is not a read lock, false will be returned.


isDumpLock

public boolean isDumpLock(java.lang.Object key)

This method returns true if the lock associated with key in the DBLockSync lockHash is a DBDumpLock.

If there is no lock associated with the key, or if the lock associated with the key is not a dump lock, false will be returned.


isWriteLock

public boolean isWriteLock(java.lang.Object key)

This method returns true if the lock associated with key in the DBLockSync lockHash is a DBWriteLock.

If there is no lock associated with the key, or if the lock associated with the key is not a write lock, false will be returned.


setWriteLockHeld

public void setWriteLockHeld(java.lang.Object key,
                             DBWriteLock lock)

This method associates a write lock with the given key.


setDumpLockHeld

public void setDumpLockHeld(java.lang.Object key,
                            DBDumpLock lock)

This method associates a dump lock with the given key.


addReadLock

public void addReadLock(java.lang.Object key,
                        DBReadLock lock)

This method associates a new DBReadLock with the given key, if possible. Multiple read locks may be associated with a single key in DBLockSync, but not if there is a write lock or dump lock associated with the key.

If there is already a dump or write lock associated with the key, an IllegalStateException will be thrown.


delReadLock

public void delReadLock(java.lang.Object key,
                        DBReadLock lock)

This method disassociates a DBReadLock from the given key, if possible.

If there are no read locks associated with the given key, an IllegalStateException will be thrown.


getReadLockVector

public java.util.Vector getReadLockVector(java.lang.Object key)

This method returns a Vector of DBReadLock objects associated with key, if any.

The Vector returned is part of DBLockSync's internal data structures, and should only be browsed in a block synchronized on this DBLockSync object.

The Vector returned should not be modified by external code.


getLockHeld

public DBLock getLockHeld(java.lang.Object key)

This method returns a DBLock associated with the given key, if any.

This method will only ever return a DBWriteLock or a DBDumpLock. If the key is associated with a Vector of DBReadLocks, null will be returned.


clearLockHeld

public void clearLockHeld(java.lang.Object key)

This method clears out a lock associated with the given key.


addLock

public void addLock()

Increments the count of held locks for the admin consoles.


removeLock

public void removeLock()

Decrements the count of held locks for the admin consoles.


getLockCount

public int getLockCount()

Returns the number of locks presently held in the database.