Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Clean unexport with RMI. Server side  RSS feed

 
Gilles Marceau
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Ranchers,

i am trying to design a clean remote object unexport with RMI, and
i am facing the following problem : how to be sure that no RMI
thread is still working inside the remote object ?
A clean solution would be to shut down the remote object (all
calls give a RemoteException) and wait for the completion of all other
threads that could be on going. Is there a way to count the number
of RMI thread running at a given time ? I didn't find how to do so,
so i made a kind of proxy on the remote object to count the
incoming/outcoming calls. When the count is zero, the remote object
can be unexported safely (this is the rough idea).

Does any of you think of a better solution ?

Thanks

Gilles
 
Gilles Marceau
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, maybe i should clarify my question to get more answers...

The issue is, in a RMI based server, how to handle waiting
thread inside the server (exposed remotly by the RMI framework)
at shutdown time.

Thanks in advance,

Gilles
 
Gilles Marceau
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, finally i found the answer, it was in the API.
All the process i explained is useless because UnicastRemoteObject.unexportObject has everything i need : by calling it with
the force parameter to false, the unexport process succeed only if there is no thread in process on the object to remove.
So I just need to call it until if complete successfully.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!