Clients need to check if the record number is currently in the lockedRec, if not, can lock the record. If yes, use while loop to try certain amount of times ( i set it to be 100 sec), after this amount of time, there may be something wrong with the client who's currently locking this record, then, explicitly unlock the record by the server.
and then check for the locked record in the HashSet in the while statement
You can do it either way. There are two schools of thought on locking the whole database: loop through all the records and lock them (this was Mark's approach); set a "dblock" flag, that when set, will not allow any further records to be locked and wait for all pending locks to be unlocked at which time the dblock is established (this was my and I believe Nate's and Eugene's approach).
You should only have one instance of the DataLockManager, and it shouldn't be a Singleton though. Like you create one instance of the Data class, you will also have only one LockManager created, which every Client Remote Object should have a reference too, not a seperate instance created in each.
Could you hold this puppy for a sec? I need to adjust this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|