Q1. Is the following statement true or not?
------------------------------------------------------------------
When the client creates a new RMI connection and gets the stub of the remote object, the RMI server will create a new remote implementation object for that stub; When the stub is dead an collected by GC at client side, the remote implementation object will be destroyed and collected by GC at server side too.
Q2. Does the lock associate session ID or customer ID?
------------------------------------------------------------------
A session ID stands for the period from the time a Customer Service Representative opens the application window and the time he closes the window.
A customer ID stands for the customer for whom the Customer Service Representative books the home services. Within a client session(namely session ID) a Customer Service Representative can book home services for more than 2 customers with different customer ID.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Hmmm, I haven't seen any assignments with a "session ID".
A CSR can start the application and book records for more than one customer. So in that context, if you have a session ID, then your last statement would be correct.
When the client creates a new RMI connection and gets the stub of the remote object, the RMI server will create a new remote implementation object for that stub; When the stub is dead an collected by GC at client side, the remote implementation object will be destroyed and collected by GC at server side too.
There is a possibility that a client can disappear without closing its DataProxy while a lock is active. This is very unlikely and will be dealt with by the RMI lease expiry, rather late, but sufficient for this project. My Data class has a finalize method that calls close, but I don't rely on GC or weak references.
My assignment is about the Bodgitt & Scarper. In the book Java 2 Developer Exam Cram, there is a LockManager in which record locks associate Client ID. Its method lock takes the form as public void lock(int rowNumber, Object client). Here the client is customer, isn't it?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Andrew Monkhouse:
Hi Hu Yong Jun,
No, in this case the client is supposed to be the instance of the client application - one per CSR. The CSR can still process more than one booking for different customers.
Note the "supposed to be" - there is a problem in this book in that the server does not generate a unique identifier for each client, so that lock method will not work as designed: all connecting CSRs will use the same "client" object.
I mention this problem (and some others) in my review of Alain Trottier's book here in the bunkhouse.
Regards, Andrew
Originally posted by peter wooster:
I've found in testing that the RMI lease is not a very reliable or easily tunable way to deal with orphan locks. I've just implemented a keepalive process that works quickly and reliably. It goes like this:
<cut>
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Andrew Monkhouse:
Hi Peter,
Can you elaborate on what your problems were with the RMI lease?
It is tunable - I used to set my lease to 10 seconds during testing (because I didn't want to wait for the normal lease expiration period), and I always found that my unreferenced() method was called for any orphaned connection.
So I will be interested to learn what problems you found.
Regards, Andrew
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Andrew Monkhouse:
Hi Peter,
Sorry, didn't realise that the problem was just in setting the lease value. You are correct in that you should not need to unexport the object.
Some things you should be aware of:it is possible for unreferenced() to be called while the server is still running methods called from the orphaned client. Logically, therefore, unreferenced() and finalize() will be called from different threads than the thread that your client's methods are running in.
Here's some sample code to show this:
...
Thanks Andrew,
Each business command gets a new DataProxy and therefore a new Data object, this object is closed at the end of the business command.
Originally posted by Marlene Miller:
Hi Peter, what does it mean to close an object? I am guessing, resources associated with the object (files, locks) are closed or removed. Thank you. Marlene
[ October 06, 2004: Message edited by: Marlene Miller ]
Each business command gets a new DataProxy and therefore a new Data object, this object is closed at the end of the business command.
DataProxy gets a DataAdapter from a DataAdapterFactory
This means that each client DataProxy has an associated Data instance on the server.
Originally posted by Marlene Miller:
Thank you very much Peter.
Peter, I don�t understand the role of a DataProxy on the client side. I would have guessed the stub (DataAdapterImpl_stub) was the proxy.
I have been assuming that (philosophically) RMI creates the illusion that a distributed program is running on one system. From the programmer�s perspective, remote objects and methods work like local objects and methods. But in reality, there is this stub on the client that stands-in for the remote object.
I am curious to know the purpose of this class, the DataProxy, between your business command and the DataAdapter object, and why it serves as a proxy.
Regards, Marlene
[ October 07, 2004: Message edited by: Marlene Miller ]
Lookout! Runaway whale! Hide behind this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|