This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unreferenced

 
Dayanand Kangala
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I have a doubt in the way unreferenced interface works. Can someone clear it?
I understood that the DGC maintains a reference count for each client invoking a method on the remote object. When the count becomes zero, then the unreferenced() method is invoked.
I wrote a remoteobject and implemented the unreferenced interface with a system.out.println() in the unreferenced() method - just to find out whether the method is getting called ! I accessed the remoteobject from a client application and then closed the application. But, even after 15 minutes the system.out.println() is not getting invoked! Is this because the DGC does not increment the reference counter if the remoteobject is accessed from the local machine?! (the above is not as per the requirement stated in the intructions.html).
Regards,
Dayanand
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unreferenced runs after 15 minutes. That is the default wait time. When you closed the app, instead of it dying, I think it closed cleanly and cleaned up the Remote Object for you.
Mark
 
Dayanand Kangala
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Spritzler:
Unreferenced runs after 15 minutes. That is the default wait time. When you closed the app, instead of it dying, I think it closed cleanly and cleaned up the Remote Object for you.
Mark

Hi,
I ran the client application (in win 2000) from command prompt and closed the command prompt instead of selecting the close icon from the application. But, this did not trigger the method after 15 mins (I went out and came back after 60 minutes, but no system.out.println).
Can you tell me a way to crash the client!! (or)trigger the unreferenced method.
Dayanand.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting.
I know this a stupid question, and I am sure it is, but the Server is still running in a seperate Command window, correct?
I think closing the command window is a "Crash" and should work.
What are you printing out?
Mark
 
harcharan kanwal
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i read in the rmi forum at java.sun.com that registry will be holding the reference to a client and acting as a client,eventhough the client is crashed.may be we have to run the registry in the separate console window and shut this console window running registry and the one running the client, to invoke the unreferenced method.need to do more research on it
http://forum.java.sun.com/thread.jsp?forum=58&thread=172926
 
Dayanand Kangala
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Spritzler:
Interesting.
...but the Server is still running in a seperate Command window, correct?

Yes. The server is running in another console.
I think closing the command window is a "Crash" and should work.
What are you printing out?

I have the following line:
system.out.println(" unreferenced method invoked");
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now the object you have that implements Unreferenced is the Remote Connection object, correct? Not the object that is in the registry?
Mark
 
Dayanand Kangala
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Spritzler:
Interesting.

Another interesting detail !!
I got really curious as to how the DGC works. So, started reading about how the DGC tracks the client and maintains the reference count for every remotedata that is accessed... I also tried to log using remoteserver.setLog() method... It was when doing this I noticed that the "System.out.println()" is getting called !!
the following is what is happening:
(a) I have a getconnection() method which returns the remotedata object to the client.
(b) the client uses this data object to perform all operations of searching
(c) As soon as this object is returned to the client, the unreferenced method is getting called!!
How could be happening?
Dayanand.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds more like the Connection Object is not correctly a Remote Object. It must extend Remote and UnicastRemoteObject. So to do this you have your DataAccess interface extend Remote, and the Remote implementation extend UnicastRemoteObject, and this Remote implementation is not registered in the RMI Registry.
Hope that helps
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic