public final class DBLockSync
extends java.lang.Object
This class acts to provide a singleton object for interlock coordination. All global data required for coordinating DBLock lock activity is stored in the singleton object.
Note that much code in the various DBLock subclasses, and in the rest of
the Ganymede server, establishes external synchronization on the
DBLockSync object referenced in DBStore.lockSync, so
certain methods in this class which do not appear synchronized may
in fact be dependent on external synchronization.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Hashtable |
lockHash
Identifier keys for current
DBLocks. |
private int |
locksHeld
A count of how many
DBLocks are established on DBObjectBases in this
DBStore. |
private int |
locksWaiting
A count of how many
DBLocks are waiting to be established on DBObjectBases in this
DBStore. |
| Constructor and Description |
|---|
DBLockSync() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
claimLockKey(java.lang.Object key,
DBLock lock)
This method associates a DBLock with the given key, making
sure that there is no conflicting lock request for the key
|
void |
decLockCount()
Decrements the count of held locks for the admin consoles.
|
void |
decLocksWaitingCount()
Decrements the count of locks waiting to be established.
|
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.
|
int |
getLocksWaitingCount()
Returns the number of locks currently waiting to be established.
|
java.util.Vector |
getReadLockVector(java.lang.Object key)
This method returns a Vector of DBReadLock objects associated
with key, if any.
|
void |
incLockCount()
Increments the count of held locks for the admin consoles.
|
void |
incLocksWaitingCount()
Increments the count of locks waiting to be established.
|
void |
resetLockHash(int count)
This method causes the DBLockSync object's lock owner hashtable
to be reset.
|
void |
unclaimLockKey(java.lang.Object key,
DBLock lock)
This method disassociates a DBLock from the given key
If the key was not previously claimed for the given lock, an
IllegalStateException will be thrown.
|
private 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.
private int locksHeld
A count of how many DBLocks are established on DBObjectBases in this
DBStore.
private int locksWaiting
A count of how many DBLocks are waiting to be established on DBObjectBases in this
DBStore.
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.
public boolean claimLockKey(java.lang.Object key,
DBLock lock)
This method associates a DBLock with the given key, making sure that there is no conflicting lock request for the key
public void unclaimLockKey(java.lang.Object key,
DBLock lock)
This method disassociates a DBLock from the given key
If the key was not previously claimed for the given lock, an IllegalStateException will be thrown.
public java.util.Vector getReadLockVector(java.lang.Object key)
This method returns a Vector of DBReadLock objects associated with key, if any. If there is no DBReadLock vector associated with the key, an IllegalStateException will be thrown.
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.
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.
public void incLocksWaitingCount()
Increments the count of locks waiting to be established.
public void decLocksWaitingCount()
Decrements the count of locks waiting to be established.
public void incLockCount()
Increments the count of held locks for the admin consoles.
public void decLockCount()
Decrements the count of held locks for the admin consoles.
public int getLocksWaitingCount()
Returns the number of locks currently waiting to be established.
public int getLockCount()
Returns the number of locks presently held in the database.