Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Blocking

 
Nagu Rathina
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ref : "The lock method should block until the requested lock can be applied"
what does it mean by block? should the client wait indefinitely till the other releases the lock? or can I just give message to client that "cannot lock record. try later." & let it proceed furthur...
Pl clarify me.
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client should wait until the other client releases the lock.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the client should wait indefinitely.
pseudocode:

[ July 30, 2002: Message edited by: Erick Reid ]
 
Nagu Rathina
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u all.
 
Nagu Rathina
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if a client blocks, when it requests for lock, what should I show in the client GUI? Now, it is just hanging....becoz I call wait()...
Lock DB:
In server GUI, I have a button for locking DB. if it is clicked, all clients requesting lock will hang....
Should I remove this button?
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My client application just waited with a busy cursor. It would have been better to display a "please wait" message and prevent further screen entries.
 
Nagu Rathina
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should I call Lock(-1) before server is shut down? is it better to do it instead of providing a button for it?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should absolutely lock the database before shutting down the server. If you don't you could leave a client hanging forever waiting to lock a record or possibly even corrupt the database or allow the client to believe that a flight was booked that really wasn't (that one's a long-shot). So have your server call lock(-1) before shutting down.
Michael Morris
 
Nagu Rathina
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My client application just waited with a busy cursor...........
Do u call lock() using a seperate thread?
I use LockManager for implementing lock()& unlock. when my GuiController calls lock(recnum), it goes to LockMgr thru RemoteDataAccess. when other client has locked, I call wait(). The thread takes control of everything and my Gui becomes fully white. when lock is released and it comes out of wait(), gui shows everything properly. what should I do to avoid this prob?
Thanks Michael for lock(-1).
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, locking should occur on a thread other than the swing event thread for exactly the reason you state. I'm not real clear on your design, but you probably need to utilize a Facade pattern to separate the GUI from the database. In other words, you really shouldn't make calls to the RemoteDataAccess implementation from a GUI (swing) object.
Hope this is helpful,
Michael Morris
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You should absolutely lock the database before shutting down the server.

I didn't have server GUI, didn't have graceful shutdown (it was just Ctrl-C), and didn't lock the database before shutdown. And I still got full score for the server. I would say all these features are the extras that do not add anything to your design extendibility.
Eugene.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So Eugene,
What happens when twenty clients are waiting for the same lock and the server ungracefully dies, leaving them hanging? I've been programming for thirty years and you don't know the hate mail I would get if I released a client-server app that at a minimum at least prevented further locks to occur and waited for all pending locks to be relinquished before closing the server.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic