suncertify.db
Class DbLockTable

java.lang.Object
  |
  +--suncertify.db.DbLockTable

public class DbLockTable
extends java.lang.Object

The "DbLockTable" class represents a table of locks with the following features:A

Version:
1.0 07/31/99

Method Summary
 void releaseLocks()
          The method to release all locks from the DataBase.
 void releaseLocks(java.lang.String clientID)
          The method releases all the locks currently held by the "clientID".
 void removeLock(int recNum, java.lang.String clientID)
          The method to remove a lock set by the clientID before.
 void setLock(int recNum, java.lang.String clientID)
          The method to set a lock on a record/DataBase by a clientID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLock

public void setLock(int recNum,
                    java.lang.String clientID)
The method to set a lock on a record/DataBase by a clientID. It places the lock based on the following conditions: If the same client who has placed the lock before,request again to lock the same record or DataBase, no new lock is added into the lockTable.This is achieved by the default behaviour of Hashtable.put() method, which returns "false" if the (key) already exist. If the locking cannot be achieved, the thread/cllient blocks itself by calling "wait()".With this call, it releases the lock on the "DbLockTable" instance and hence allows any other client who holds the lock, to come in and remove the lock. Once the blocking Client is notified by another Client who has released a lock, it tries to place a lock again. It returns after it has obtained the desired lock.
Parameters:
recNum - : The record number of the record requested to be locked If it is "-1" the request is to lock the DataBase.
clientID - : The Id of the Client requesting the Lock. This is a Globally unique ID obtained as the concatenation of "hostname of client" and the unique id returned by "java.rmi.UID" at client side.

removeLock

public void removeLock(int recNum,
                       java.lang.String clientID)
The method to remove a lock set by the clientID before. If the lock does not exist, it does nothing and return. If the setter of the lock is not the clientID specified, then do nothing. If the clientID is the setter of the lock and the lock already exist from before,then remove the lock from the lockTable and calls "notifyAll()" to inform clients waiting on to place a lock to try again.
Parameters:
recNum: - The record number from which lock is to be released.
clientID: - The clientID who wants to release the lock from recNum.

releaseLocks

public void releaseLocks(java.lang.String clientID)
The method releases all the locks currently held by the "clientID". This method must be called whenever a connection is severed with the client having the id "clientId".
Parameters:
clientId - : The clientID whose connection has been just severed.

releaseLocks

public void releaseLocks()
The method to release all locks from the DataBase. This routine is called from: