Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to produce the clientID?

 
Zhou Can
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the clientId in my design , But to my muddle is how to produce an unique clientID for every client.
Could u help me ?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Zhoucan"-
This is your third notice.
Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
[ December 04, 2002: Message edited by: Mark Spritzler ]
 
Charles Dupin
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used new UID() on the server and return it to the client as confirmation id.
I hope it is good enough for the assignement.
Any other idea?
 
jay denzel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think the most widely used approach is to use the connection object itself as the client ID. This is the way I did it and I guess many others also. The idea is to issue a unique client connection object in remote mode using a RMI connection factory. This object reference is handed over until you access the database using the LockManager, the LockManager puts the object reference along with the record number in a Map.
Hope this helps.
jay
-----
SCJP
SCJD
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I worked quite a lot on this clientID work but I submitted my assignment with different design. And I was satisfied with my work when I got 51 out off 53 in server design. My approach was based on Spooler like tech. Apart from record no. being locked it also get spooled with the RecordSpooler class which implemented Spooler interface. This technique was helpfull in the case only that client was able to unlock the record who had actually acquired that lock. And if attempt was made by an connection who has not acquired a lock then that record will never be unlocked.
thank's
gurpreet
 
Charles Dupin
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay,
I think the most widely used approach is to use the connection object itself as the client ID.

How do you get the connection object reference?
The return values of 'lookup' for two clients in my implementaion are equals. Please tell me how you force the server to return different objects for each client.
Thanks
Charles.
[ December 08, 2002: Message edited by: Charles Dupin ]
[ December 08, 2002: Message edited by: Charles Dupin ]
 
jay denzel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Returning a new client connection object which can also be used as the client ID can be achieved by using a factory pattern.
This is the way I did it.
I had a RMI Connection factory object which is registered as a service. Each client trying to access the database uses a local connection factory which contacts the RMI connection factory to return a remote connection object. Every connection object (local or remote) implements a DataClient interface which holds all public methods of Data.
The returned object is the client ID, because each object is unique. The LockManager can use it for locking/unlocking. I used the client ID as the key in the LockManagers HashMap.
Hope this helps.
jay
------
SCJP
SCJD
 
Charles Dupin
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great
Thanks
Charles
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use the java.rmi.server.UID.
Hope it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic