42
SCJP, OCMJD, OCMJEA
I believe it would be a mistake to do this if that was your only reason for having timeouts. There are plenty of other ways to handle clients disconnecting while owning a lock. While there is nothing explicitly forbidding a timeout on owning a lock, there is nothing (in my opinion) that indicates that this would be desirable either.Originally posted by Jeroen T Wenting:
I chose to implement a Timer based timeout mechanism. Mainly I did this to prevent locks being retained in case of clients that disconnect and terminate in the middle of a transaction leaving stale locks in place (and potential programming errors by 3rd party clients that fail to properly unlock records).
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
42
SCJP, OCMJD, OCMJEA
Originally posted by Eva Van Shtock:
Hello,
Thank you guys for helpening me out in other threads.
I have a doubt about one method from the DB interface:
// Locks a record so that it can only be updated or deleted by this client.
// Returned value is a cookie that must be used when the record is unlocked,
// updated, or deleted. If the specified record is already locked by a //different
// client, the current thread gives up the CPU and consumes no CPU cycles
// until the record is unlocked.
public long lock(int recNo) throws RecordNotFoundException;
The question is: Is it a design issue whether to time out OR should I block the client until he can access the record?
Sun says I must implement the DB as described. That means I cannot just time out, does it?
Regards,
Eva
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
42
SCJP, OCMJD, OCMJEA
Originally posted by Eva Van Shtock:
and how can you queue requests Anton?
there is nothing in RMI which allows you to do so.
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Oricio mentioned the two common ways: Unreferenced (the easier way) and WeakHashMaps.Originally posted by Jeroen T Wenting:
How would the server detect whether a client has disconnected?
RMI doesn't AFAIK have a system to silently track existing connections...
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
42
42
Poop goes in a willow feeder. Wipe with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|