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

Put bookSeat at server side or client side???

 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I know there are totally different solutions on the positions of calling bookSeat() that lock() and unlock() are inside. Both of the solutions have their own advantages.
bookSeat(){
lock();
read();
modify();
unlock();
}
1. call it at client side follow sun's implication. and it will close to passing exam in theory. but some problem is really there. Record will be locked for ever when clients crashed after calling lock() without call unlock().
2. call it at server side against sun's implication.
but it's more reasonable. it's an atomic solution. avoid to deadlock a record.
Maybe Sun implies us to implement an generic DB server. but Sun is more explicitly tell us to implement an traditional client-server application. For such an application we are not supposed to put all business logic method at client side. We can certainly put some business logic method at server side. Let's say bookSeat() just like a stored procedure we put at server side.
Do you guys think Sun will penish this idea that is not stupid? I really take the second solution mentioned above.
My key question is will I be punished to fail the exam by taking the second solution.
Do you guys know if there are somebody to pass the exam by taking the second solution.
thanks for reply
Dasong :roll:
[ April 08, 2002: Message edited by: Dasong ]
[ April 10, 2002: Message edited by: Dasong ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused at what you are asking?
Mark
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark;
Thanks for reply.
I mean there two solution for calling lock/unlock.
in bookSeat() method
1. call them at client side. Sun implies this solution.
2.call them at server side. I feel this solution is more resonable. somebody say that is not generic DB Server's function. But I could say this function like a stored procedure in server side. It's real a traditional client-server architechure(Sun's instruction mentioned c/s).
Can both of the two solution pass the exam.
are there someone really to pass the exam by take the second solution.
Thanks
Dasong
[ April 08, 2002: Message edited by: Dasong ]
[ April 08, 2002: Message edited by: Dasong ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh, I think I got you. You are talking about where the bookSeats method should be. the second example is like a bookSeats stored procedure, where the client calls, but it runs on the server side.
I think the confusion lies in who calls it and where it actually runs.
Either side is fine for this assignment. However in the real world you would want it such that it reduces the amount of network traffic, or the main sources of bottlenecks.
I had a facade that was created on the client side, so in essence the booking method ran on the client side, but in it the calls to lock/read/modify/unlock where seperate network/RMI calls. I liked the simple elegance of the model, so that I could use it for both local and remote modes.
As far as the deadlock issue. I have the Remote object implement the Unreferenced interface, and that kills stale locks for me.
Mark
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark.
Now I know I won't be failed by puting the bookSeats() at server side. I'm still a little bit confused. I really want to reduce the network traffic so I gather 4 method call in one. Maybe my one method call's message package is bigger. could you give me more of your ideas about it
thanks in advance
Dasong
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the parameters you are sending to the book method?
Mark
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DataInfo Object
Dasong
 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Dasong:
Try the
try{...}
catch(){...}
finally{..}
and let the unlock in the finally{}, u can guarantee unlock is called when exeption occured.
Xiaoma Wang
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dasong:
Now I know I won't be failed by puting the bookSeats() at server side.
I think it is very difficult to put this method at the server side without violating one or more of the requirements to some extent. For example, the requirement that you should code the database for re-use, or the suggestion that you should have a class that implements the public Data methods (at least that's what my instructions said).
You will probably pass though.
- Peter
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Xiaoma and peter for your kind remind.
Xiaoma could you tell me where did you put the bookSeats() method. client side or server side. And did you pass the exam. thanks.
Dasong

[ April 09, 2002: Message edited by: Dasong ]
[ April 09, 2002: Message edited by: Dasong ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic