File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Unreferenced() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Unreferenced()" Watch "Unreferenced()" New topic
Author

Unreferenced()

Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
why we need non-duplication remote object to implement unreferenced? to do unlocking() has been locked??? what mechanism that is normally put in this method?
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
how is unreferenced() applicable over here?
my understanding is when one of the client performs
bookflight(){
lock()
read()
modify()
unlock()
}
while read() is being processed, the client crashes. And here unreferenced() comes in and do the unlocking that has been previously locked. Am i right?
- what do u mean client crashes ?
- In what scenario would a client crashes?
- how does a crashed client call up the unreferenced method ?
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
why unreferenced() is not called when there isn t any more dirty call?
do i need to implicitly NULL those objects that have references to remote object and then garbage collected them in order to call up the unreferenced() at the RemoteData.
pls do enlighten all the questions i have posted above and here.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Kruger,

- what do u mean client crashes ?

A network failure. It could be caused by a network server going down, a power outage at the client site, the client accidentally shutting down the application, etc.

- In what scenario would a client crashes?

See above.


- how does a crashed client call up the unreferenced method ?

How could the client call anything after a crash? The client doesn't call the unreferenced() method. The RMI runtime does on your server. When the DGC (distributed garbage collector) determines that there are no more reachable remote references to a Remote object, that object's unreferenced() method is called if it implements the Unreferenced interface and is marked for normal GC. So you don't have to worry about the unreferenced() method, RMI will take care of it for you.
Hope this explains it,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
so how does unreferenced() apply in our project here? what is its used? what logic to put inside the unreferenced() ?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Kruger,

so how does unreferenced() apply in our project here? what is its used? what logic to put inside the unreferenced() ?

It is used to unlock any locked records held by the dead client.
Michael Morris
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
my unreferenced() can't seem to be called up
when i terminate my client GUI.. what s the problem over here?
Pete Lyons
Ranch Hand

Joined: Aug 18, 2002
Posts: 109
In order to verify that your unreferenced is working properly, you will need to do 3 things:
1. Create some way to put a significant delay between when your client calls lock and when it calls unlock. You can use Thread.sleep, System.in.read, System.exit, or just comment out the call to unlock.
2. Put some System.out.println's in your unreferenced(), so you can see when it is being called on the server side object.
3. Run the server and client and start the booking process then quit the client without calling unlock. LEAVE the server running for about 15 minutes or so, and you should see your println's confirming that unreferenced was called.

Hope that clarifies it. You seem to be on the right track.
Pete
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
when the client crashes, it doesn't make sense for the server to wait for 10 minutes b4 all the remote object is garbage collected.
can we start up the server by passing this Djava.rmi.dgc.leaseValue=1000 to VM so that if no dirty call are made to the remote object within one minute, the remote object's unreferenced() will be called.
i came to know that we CANNOT/CAN customise this... so can we or can we not?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
when the client crashes, it doesn't make sense for the server to wait for 10 minutes b4 all the remote object is garbage collected.
can we start up the server by passing this Djava.rmi.dgc.leaseValue=1000 to VM so that if no dirty call are made to the remote object within one minute, the remote object's unreferenced() will be called.
i came to know that we CANNOT/CAN customise this... so can we or can we not?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unreferenced()