• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Where would you implement the crashed client code??

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I`m using RMI to handle the networking part, but where would i need to
implement the code for a crashed client.

I create a new Database object for each client. and then when they
change any data the record gets locked...

but now what is the client times out and the record does`nt get unlocked??
where can i implement this? i thought about adding a timeout, but is there a way to say if timeout then do this... or finally ???

is it even nessesary to handle this case??

Thanks
Derick
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Derick,

It is not necessary to handle this.

However it can be an interesting exercise to try and work out how to do it, and it is certainly something you would want to think about in real life.

Depending on your instructions, you may not be able to have a timeout value for how long a lock may be kept. You will have to check your instructions to see whether you can or not.

The other things you can think about are:

Since you have a Database object per client, I assume you are using the Database object as the key in your collection of owned locks. In which case you might want to use a WeakHashMap as the collection - if the remote client disconnects (or crashes) there will no longer be a remote reference to the Database object, so it will be automagically removed from the WeakHashMap (after RMI's lease value expires + garbage collector runs). Almost a no brainer solution. (You may want to create a separate daemon thread to monitor when locks disapear and notifyAll waiting threads that a lock has gone).

Alternatively you might want to have your per-client remote object implement the Unreferenced interface. If you do this then when the remote client disconnects (or crashes) then the unreferenced() method in that instance of the remote object will be run (after RMI's lease value expires + garbage collector runs) and you can manually clean up any locks.

Regards, Andrew
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Derick,

You could implement a �thin client� whereby the lock-update-unlock sequence is implemented by the server. See Stephen�s post in this thread.

Regards,
John

[ June 10, 2004: Message edited by: John Canavan ]
[ June 10, 2004: Message edited by: John Canavan ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic