• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

terminate of programs

 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember seeing some posts regarding "dangling" connections for either client (server down) or server (client down) side, but can not find them now. Do we really need to handle this? Do we have to terminate the program decently? Any suggestions or links?
Thanks a lot!
Cathy
 
Jim Bedenbaugh
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cathy Young:
I remember seeing some posts regarding "dangling" connections for either client (server down) or server (client down) side, but can not find them now. Do we really need to handle this? Do we have to terminate the program decently? Any suggestions or links?

You need to implement the Unreferenced method. . .
 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Bedenbaugh:

You need to implement the Unreferenced method. . .


How should I implement unreferenced ()? How can I tell if it is still referenced and notify the server?
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cathy,
You just have to make your remote object class (RemoteData, probably) implement the Unreferenced interface :

Then, inside your class, you can override the unreferenced method. This method is called when the remote object instance is no longer referenced. So, this happens at server side. You don't have to notify your server, it is done by the RMI itself (beautiful isn't it ? )
Here is the code of my unreferenced method :

Hope this helps ...
Stephane
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
i think you mis understood the concept of unrefrenced in rmi
please refer to this thread for more info
http://www.coderanch.com/t/182024/java-developer-SCJD/certification/small-unreferenced

hope this helps,
cheers,
parthi.
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Parthiban,
If each client receives its own RemoteData object (as in my case), then an instance of RemoteData becoming Unreferenced automatically tells me which client doesn't exist anymore. So, when that happens, my unreferenced method takes care of releasing the locks formerly owned by this client.
And the client didn't have to include any notification code (which would of course be unwise, as the client doesn't exist anymore ...).
Could you please precise what is wrong in my understanding, so that I correct whatever would be wrong ?
Thanks,
Stephane
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Beta Testers,
I think we are not told to manage distributed garbase collection system. So if I can manage tracking active client count through datastructure and event binding, we don't need to implement Unreferenced in our class.
Is it?
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
lets assume the remote object is FBN
you have created a Registry and have registered this object FBN to serve its clients
you are not registering multiple objects of fbn but only one ...
the rmi pools this object and serves its request as it needs to .. it does not guarantee that the same thread will be given to the client each time when it receives a request .. it might be the same or the other thread from the thread pool ... it does not call the unrefrenced method when ever a particular thread gets destroyed.. its called by the rmi when it determines that no single client has a reference to this object and not when each and every single client stops accessing this remote object .. that too this does not get called immediately but on the will or the rmi server it wil take time to happen.
i would suggest if you want to release the locks which are there for too long to have a maintenance class inside the lockmanager and have a lease period for each lock and when the lease period expires unlock it does not matter which client locked it .. the lease period has expired ... right now my lease period is 1 min
hey big guys what do you think ??
cheers,
parthi.
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ashik uzzaman:
Dear Beta Testers,
I think we are not told to manage distributed garbase collection system. So if I can manage tracking active client count through datastructure and event binding, we don't need to implement Unreferenced in our class.
Is it?

Hi Ashik we are not talking about beta version of scjd
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic