aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Locks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Locks" Watch "Locks" New topic
Author

Locks

Farouk Mohamed1
Ranch Hand

Joined: Jul 26, 2001
Posts: 113
Hi
Please can you comment on my locking schema:
1. RemoteDataInterface extends DataInterface
2. RemoteData class implements RemoteDataInterface extends UnicastRemoteObject
3. RemoteData class has a reference to Data class.
4. Added in RemoteData a method called connect() added in DataInterface,RemoteDataInterface, the method is used to
connect to either local or remote database by a client ConnectionFactory. This method creates an entry on the server singletion ConnectionManager which has hashmap in which association between
client thread and remoteData class is made.
5. The RemoteData class also has reference to singleton Lock Manager and locks and unlocks where implemented without signature change. And has another HashMap to (RecordNo,getConnection()).The getConnection returns the association between current thread and RemoteDataInstance.
Please is this design correct and agreeable please please comment on this i have to decide this before i proceed
Regards
Farouk
Farouk Mohamed1
Ranch Hand

Joined: Jul 26, 2001
Posts: 113
Hi
Just to clarify things better
LockManager getConnection gets the association between currentthread and RemoteData Instance returned by the ConnectionManager which creates this method using the connect message sent from the client
Please reply if you have any queries regarding my doubt inthe previous message
Farouk
Farouk Mohamed1
Ranch Hand

Joined: Jul 26, 2001
Posts: 113
Gurus please help
Farouk
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Farouk, remember that forums are not real time - it may take a while for answers to arrive. Patience is a virtue
In any case, the weakness in your proposal is the association between clients and threads. On the server, there any client request may be serviced by any thread. There are a number of ways I have seen the client identification issue addressed: in no particular order, by simply ignoring it, by modifying the lock() and unlock() signatures, by creating a client-side adapter object that has unmodified Data signatures but delegates to a server-side object that does take client ID arguments, or by giving each clients its own unique connection object. If you search through the forum you will no doubt find even more approaches...
- Peter
Farouk Mohamed1
Ranch Hand

Joined: Jul 26, 2001
Posts: 113
Hi Peter
I really appreciate your reply and i apologize for the rush.
Why do you say it is a weekness of associating a thread and a remotedata object for client identification. As i understand RMI serves multiple request in multiple threads for the same client.
Can you please tell me in what way it is a weakness
I think my approach is the same as giving each client its own copy of connection object(in my case RemoteData object)
Please reply
Farouk
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Locks