• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to produce the clientID?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great
Thanks
Charles
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use the java.rmi.server.UID.
Hope it helps.
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic