Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Eric Huang:
In your opion, how should we handle InterruptedException inside catch block?
Why not throw the exception and handle it in your Connection object.
Also, I want to know whether there is a possibility that, in lock method, a client try to lock a record that has already been locked by himself. If so, how should we handle it?
How about "public boolean isLocked(Object clientId)" in the LockManager class? Call this method before actually calling the lock() method. Or you could do the same checking in the lock() method itself. ie.. if the client tries to lock the same record twice, do nothing.
Eugene, can you elaborate on this? As far as I can see, the interrupt will simply be ignored, a valid lock will be granted. Whether this breaks something or not really depends on what interrupts are used for in the server.Originally posted by Eugene Kononov:
Silently ignoring the exceptions [...] will cause some serious damage in your implementation: if the thread running the lock() method is interrupted, it will actually perform the record lock!
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan wrote:
Eugene, can you elaborate on this? As far as I can see, the interrupt will simply be ignored, a valid lock will be granted.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
I don't think RMI propagates a Thread.interrupt() over the wire, but I'm happy to be corrected on this. In other words, it wouldn't be the client interrupting the thread, but the server. I can imagine this could serve a useful purpose, e.g. in deadlock handling or server shutdown, although such pruposes are outside the scope of the FBN application.Originally posted by Eugene Kononov:
I still don't like ignoring the exceptions, though. If the caller interrupts a thread [...]
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Whoa! I hadn't picked up on the missing notifyAll(). Anyway, it looks great to me. With this implementation, you can at a hypothetical "later time" do things like breaking deadlocks by interrupting blocked lock() calls, etc. Eugene?
My pie came with a little toothpic holding up this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|