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

LockManager ... Timeout

 
Mario Zott
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all of you... from europe ;-)
How do you handle the timeout of lockedRecords?
I implemented a class LockManager that defines two methods lock(key=recordNr,owner=RemoteObj) ,unlock(key,owner), a HashMap lockedRecords and two static classes: one is called LockIdentifier which encapsulates owner and a timeStamp(long) - these objects are saved together with the key in the hashMap. the other static class is called CleanUpTask extends TimerTask and is used for cleanup by given timeOut... LockManager has 2 constructors one with 1. no param, 2. 1 param - the timeOut, if no param is used no Timer is used - means no cleanUp.
now i am wondering what the best timeOut time would be 30 secs?? in network mode its maybe too long but over http.. any suggestions?
greetz mario
 
Brian Blignaut
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using RMI or sockets? I did not have a timeout, instead I implemented the Unreferenced interface on my remote client connection (unique remote object returned to each client that connects to the server). This method will be called when RMI determines that there are no more remote clients referencing this object, in this method I simply call the lock manager and tell it to remove all locks for the current object.
I must mention though that this is not a requirement.
Hope this helps!
 
Mario Zott
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you think that 10 minutes is too long for having locks of dead clients - or did you change the
-Dsun.rmi.dgc.checkInterval ?? is it overkill to use both methods? i think everyone has his advantages/disadvantages.... but honestly i like the Unreferenced - Solution more.... i think i will use it and move on to the next problem... stay tuned and thanx for giving me your thought's....
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that 30 seconds is too short. It's fine for the Fly By Night project, but Data is a generic database class that will be reused in other projects, and so is hopefully the networked layer you built on top of it. So building in a 30 second timeout on the grounds that the FBN client doesn't need to hold locks for very long is a mistake. Other projects may have different requirements. I personally would be mighty p****d off if Oracle would junk my locks after a mere 30 seconds.
If you'd argue now that we're not trying to build Oracle here, you would have a point. So whether 30 seconds is right or not depends on how you view the Data class, really. Me, I'm an database person. I want it to behave as much like an RDBMS as it can.
As regards to a TimerTask, Unreferenced, or both, I think matters are more clear-cut. Cleanup is not a requirement. And preferring simplicity over performance is a requirement. As a consequence, I have the impression that you should implement cleanup only if it doesn't add to the complexity of the design. Unreferenced doesn't -- in my case, it was literally three extra lines of code in an existing class. TimerTask-based cleanup is probably considerably more heavyweight and therefore dubious. Doing both is completely over the top.
- Peter
[ February 06, 2003: Message edited by: Peter den Haan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic