Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unreferenced Interface,

 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
Do we need to implemet Unreferenced interface for our remote object? and why?
Thanks in advance
Sam
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
Well it depends on whether or not and how you plan to deal with stale clients. Read through (you can actually skip most of it and do a search from your browser for unreferenced) this post and you decide if you need to implement it:
Long Thread on Locking
Hope this helps,
Michael Morris
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
The way I did clean the dead client is different.

I create a nested class inside of LockManager to hold objectID, recordNum and the time it received the lock and I have Vector to store or remove that kind of object during lock and unlock, I also create a daemon thread running every 2 second and check if there is any expired object is in Vector then it will clean the dead client and unlock that record too.
how do you feel about it ? is that the right design
Regards
Sam
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
It's OK to do it that way, I know that many have taken a similar approach. A couple of points though:
  • Implementing Unreferenced is a no-brainer
  • Using a roll-your-own timeout assumes something that may not be true, ie the client may just be taking its own sweet time


  • But I don't think you'll lose any points for dealing with stale clients in this manner.
    Hope this helps,
    Michael Morris
     
    Mark Spritzler
    ranger
    Sheriff
    Posts: 17278
    6
    IntelliJ IDE Mac Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sam, I'd suggest you use ArrayList instead of Vector.
    Vector and HashTable is considered the old collections, whereas ArrayList and HashSet are par tof the newer collections objects, the are more light-weight than the older versions.
    Mark
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic