• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

here I am again - one more time with unreferenced problems

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the last time I will post about this issue. But I have new information to report, and yet still I am unable to get unreferenced called.
If any of you guys can help, if you've got unreferenced called ok, please response and I will send you choclate.
Anyone who had been able to get unreferenced called, please advise. I've battled with this problem for a long time, and even bought an RMI book, but have not found any answers. Many people have had this problem, and I have used all suggestions I've found on the various BBs.
Problem: I want each client to be cleaned up when its remote reference is set to null. I tweaked the server side lease time and checkInterval to 20 seconds each to speed up the DGC.
The object I bind to the registry is a ConnectionFactory that creates another remote object - one for each client called RemoteDataAccess.
The problem: the client sets the reference to the remote object (RemoteDataAccess) to null, but the RemoteDataAccess' unreferenced method is never called. The RemoteDataAccessis NOT bound to the registry (that was one mistake I previously made), so the registry is not keeping the reference count at one. Unreferenced is never called, either when exiting gracefully (setting the remote reference to null), or crashing.
Both the ConnectionFactory and the RemoteDataAccess object extends RemoteUnicastObject. The Factory is bound to the registry, the RemoteDataAccess object implements the Unreferenced interface.
Good heavens, what am I missing here???
Is it required that I use codebase for non-activitable objects? I thought I might use the java.rmi.server.logCalls to debug this issue, but the API says it's deprecated.
If anyone can help I would really really appreciate it. I've beat this one 'til it's almost dead!!! It's driving me crazy but I don't like to give up.
Thanks - and I'm serious about the choclate!
Melinda
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post your ConnectionFactory.getConnection method?
Just shooting in the dark here, but I am wondering if you might be handing out references to the same instance of RemoteDataAccess from your ConnectionFactory. Does getConnection do something like;

or does it do something like this:

[ February 21, 2003: Message edited by: BJ Grau ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this. Not sure if it will work, but it is an idea.
Don't set the remote object to null, and close the client, so that there is still an object on the server side.
I am not sure, but I thought that unreferenced gets called when the client crashes. I am not sure if it is supposed to get called if the client sets the reference to null
Mark
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Unreferenced should (eventually) be called when no more remote references to the object for whatever reason -- setting the reference to null, or crashing clients, whatever. Of course, this depends on the action of the client-side garbage collector and the RMI leasing mechanism respectively.
The only answer I have at this point is really inane: "it worked for me". Are you sure, as in 100%, that you have really released all non-local references?
- Peter
 
Melinda White
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all. Here is my code. Hope it's formated ok.I am not supporting the port parmater.
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So is there an instance variable in your ConnectionFactory for remoteDataAccess?
like this:

if so, then your ConnectionFactory still has a reference to it. Try making it local to getConnection:

[ February 22, 2003: Message edited by: BJ Grau ]
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with BJ, the member variable ConnectionFactory.dataAccessRemote will continue to have an active reference to the last DataAccessRemote object created, until the ConnectionFactory object goes out of scope: his advice is, IMO, the way to go, if you're using unreferenced. As a side note, why not just make ConnectionFacto ry.getConnection() a static method? Or are you reusing the connection factory instance down the line somewhere?

Also, please be aware that there are perfectly good alternatives to using unreferenced, as explained here. I have had students get perfect scores by using that approach.
One final note: Don't stop posting on our account. We're all hoping for that chocolate. Can I suggest these?
All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
[ February 22, 2003: Message edited by: Max Habibi ]
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I originally handled crashed clients leaving a lock behind with Unreferenced but later switched to using WeakHashMap in my lock implementation. WeakHashMap works like a champ, even better than Unreferenced in my opinion because you get a much quicker resolution to a crashed client leaving a lock behind. To get as quick of a resolution with Unreferenced you have to monkey with the lease time and check interval settings which can affect overall rmi performance.
I am leaving Unreferenced in my application to be used for anything else that may need to be done in the future when a client exits or crashes such as logging etc but will rely on WeakHashMap for the issue of locks.
Also, I'm OK with those Richart chocolates that Max pointed out. Just send me a private email when you are ready and I'll give you my work address.
-BJ
 
Max Habibi
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey hey hey, I expect you to share those chocolates
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Melinda White
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
Progress continues. First, I think I found a really stupid mistake that is the source of my problem.
I recently refactored my code so that the remote object that's bound to the registry is not the same object that the client holds uniquely - since the registry keeps the reference count at one and Unreferenced will never get called. In this refactor I lost the code that did the registry lookup - thus my client doesn't have a remote object at all. Yikes!
Second, I will follow up with results and the choclate results as well. My, I've never seen choclates from Paris before. I thought Godiva was IT.
Thank you ALL for being such a great resource.
Melinda
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by BJ Grau:
[...] WeakHashMap works like a champ, even better than Unreferenced in my opinion because you get a much quicker resolution to a crashed client leaving a lock behind.

Please elaborate. As I read it, this boils down to a remote object being garbage collected before the RMI server releases its reference to it, which is obvious nonsense. So I'm probably not reading this statement the way you intended it.
- Peter
[ February 24, 2003: Message edited by: Peter den Haan ]
 
Melinda White
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IT WORKED like a champ!

Now I will try to email you about that choclate.
MANY THANKS, Melinda
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you are right Peter. I think I mixed up my test results (too many test classes) and didn't think about what I was seeing. Thanks for pointing that out - better to insert my foot in my mouth here and have someone notice than to submit the same information to Sun and have them point it out for me in the form of a lower score.
Thanks,
BJ
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic