This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Random IDGenerator RMIServer

 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys
It this a right choice to create a server which gives each client a unique ID for identification as soon as he connects to
a RMIServer, When he call lock method on the server he is identified
with his ID that has been stored in a form of Key/Value(rec/ID) in
a HashMap, through that HashMap the locking and unlocking can be
performed.
Like This:
On Server:
public double getRandom() throws RemoteException{
return Math.random();
}
On Client:
double ID=server.getRandom();
Then call seatBooking Method On Server like This:
ticketBooking(int rec, ID, int tickets){}
On Server:
public String ticketBooking(int rec, int ID, int tickets)throws Ex..{
lock(rec, ID); //I had Modified Lock arguments Is it right
//or points will be deducted
readRecord(rec);
Modification
unlock(rec, ID);
Is My design is right or some better Idea
Anurag Mishra
 
Gregory Garrison
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't use any id. In fact, I implemented all locking within the Data class. This technique prevent's you from having to implement a client ID. Though it seems as if the specs hint at using the client data conversion class to implement all the locking I don't think it is appropriate and feel that I can justify this under the rules of encapsilation. It additionally provides simplicity which the specs stress.
 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Gregory,
Can You briefly explain me what mechanism you have used in your locking and unlocking methods, You have created your locking on server side or client side.
Anurag Mishra
 
HenkGijsbert
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anurag,
I believe all your questions are answered in the mailthread 'lock\unlock the correct question.
Some remarks on your solution: yes, you will loose points if you change the signature of the 'lock' method.
Wy have a server method do the complete record updating INCLUDED the locking and unlocking? The virtue of locking is that it can be used by a client, that can 'fool around' with some record for some time. Using it from the server misses the need. In that case you would not need the lock and unlock method, but you could just syncronize the entire 'ticketBooking' method. I would advice you to remove this method from your server, since the examiner might substract points from it.
Hope this helps you,
Regards,
Henk van Jaarsveld (The Netherlands)
 
HenkGijsbert
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and besides, getRandom() could generate identical ID's...
 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
I am not using Client ID Mechanism.

Anurag Mishra
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic