• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disconnecting an RMI connection

 
David Sham
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have much experience with RMI, so I have a dumb question: In the Registry interface of RMI is the "unbind(String name)" method used to disconnect a client from a server without shutting the server down? Would this be the way to swap between remote servers for a client, or swap between standalone and remote modes? If I swap between modes, I don't want to shut the server down until the user shuts it down. I guess I would just do a rebind to get an RMI connection back to the desired server?

Any input is again appreciated. Thanks a lot!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

The unbind method is designed to be used on the server side - it removes the specified method from the registry of methods that can be called remotely. If the 'force' parameter is false, this will only remove the specified method from the registry - it will not disconnect any currently connected clients.

From the client side, if you wanted to change servers, all you need do is remove your current reference to the remote method (set it to null) and do a lookup for an alternate method and/or on an alternate server (or implicitly do both at once by just setting your reference to the new looked up value, which will automatically make your old value eligible for garbage collection).

I believe it is better to explicitly set the reference to the remote method to null, then call the garbage collector. This will result in the distributed garbage collector knowing that the client has disconnected earlier, which means that Unreferenced and/or WeakHashMap code can be called earlier. But this is all dependant on the operations of the garbage collector and the distributed garbage collector, which, as we know, is all a black box and cannot be relied on. So this is just a technicality.

Regards, Andrew
 
David Sham
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Thanks a bunch for your reply. Now I better understand how to swap servers and/or modes. Appreciate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic