• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

culling dead locks

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy All,
I'm storing locks in a HashMap that contains recordNum and Connection instance pairs. RecordNum is the key in the map.
I want some opinions on whether or not I should be concerned with clients who have died an untimely death after locking a record and before unlocking it. (Pardon any puns.)
Is this important? What are some options for implementing?
2nd issue. If I have two clients up and 2nd client is waiting to obtain record lock, my client is unresponsive. I've thought about putting the client's booking logic into a separate thread, but my current logic can throw several exceptions and I couldn't see how to handle this in a separate thread, since I can't change the signature of run() by adding a "throws" clause. This is probably dumb and has an easy solution.
Any thoughts on either issue?
Thanks,
Debra
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Implement Unreferenced interface in your Connection object and let the 2nd client wait until the lock is released. This is an easy choice. In addition to it, you can spawn a thread to wake up every few seconds and cleanup those unused locks. That way the 2nd client waits only for few seconds of your choice.
[ May 27, 2002: Message edited by: Sai Prasad ]
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you depend on Unreferenced.unreferenced() alone, you will have to wait for java.smi.dgc.leaseValue to expire and for the sun.rmi.dgc.checkInterval time to pass. The defaults for these two are 600000ms and 300000ms, respectively. To set them low enough to be usefull for users of your application, they would need to be set so low (perhaps 10000 and 5000 ms) that you would have extra network traffic from your remote object leases being renewed, and some extra load on the server's JVM from checking for expired leases. I don't know how much though, but I would definitely look into it.
I like Sai's idea of a thread that checks every few seconds, but I am unsure how this would be viewed by the graders since crashed clients are not mentioned in the requirements. Maybe someone who got a high score and also did something like this will speak up.
-BJ
[ May 27, 2002: Message edited by: BJ Grau ]
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my submission, I did spawn a custom thread to clean up unreferenced locks and got 51/53. I also remember reading a post with high marks using custom thread. It is up to you.
 
Debra Bellmaine
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sai,
I like the idea of the separate thread, in addition to Unreferenced. Did you spawn the thread from your LockManager (if you used one)?
How did you check that the locks were unused?
Debra
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Debra:
Yes. I spawned the thread from the LockManager. In fact the Thread class is an inner class of LockManager. I record the time when the lock was made using another object called Lock which contains the Timestamp. I compare the current time and the locked time and if it is more than certain seconds (you need to pick this one), I remove the lock using the cleanup thread.
[ May 28, 2002: Message edited by: Sai Prasad ]
reply
    Bookmark Topic Watch Topic
  • New Topic