Thanks Max, Ken and Philippe
Am very happy with the score
After the long wait for results! I submitted my assignment and took the exam in the first week of December!
Have a question: What all comes under general consideration? I am simply curious as to what I left out that they took off 10 points for general consideration...
Raj, here is my lock-unlock design:
For performance issues across a network, I decided to have a dedicated Data object per connection rather than using a singleton Data object to handle all requests to the database.
I implemented the lock and unlock methods in RemoteData class. For clarity and simplicity it made sense to implement these methods where they are actually used and RemoteData takes care of all database related remote calls. After all we need locking only when there are multiple remote clients trying to modify DB. In a local connection every connection has a devoted database of its own and there is no need to lock-unlock the DB.
My lock method first checks that database shouldn't be locked, if it is not locked then lock method calls lockRecord method for locking individual records. lockRecord method checks whether the specified record is already locked. If the specified lock is already locked then this thread waits until its unlocked. When the thread finds the record unlocked, it locks the record.
The unlock method, in a synchronized block, checks first whether this record is already locked. If it finds the record locked, the method checks if this thread is the owner of the lock. If yes then it unlocks the record otherwise it simply returns without unlocking the record.
When the lock method is called with -1 as the record number, the method checks first whether the database is already locked. If the database is already locked then a RemoteException is thrown telling the client that DB is already locked. If DB is not already locked then it is locked and no more client requests are accepted for booking, though the existing locked records are allowed to complete their booking.
Unlocking Entire Database: I did not provide this functionality.