RMI and CyclicBarrier and crashes
I have a program I've been developing and I've run into a small problem
I'm not sure how to resolve. The basic idea is that I have a server that
exports a single object using RMI. Clients make calls on this and cycle
through some work that needs to be done. On occasion a client program or
even a client machine may crash and I would like to be able to recover
from this. I've written the code to do so and now the clients can
restart where they left off with one exception.
There is a point where the server uses a CyclicBarrier to sync all the
clients and make sure that they are ready to start the next task in the
loop. If one of the clients crashes while in CyclicBarrier.await() and
then reconnects and hits the CyclicBarrier.await() again, it counts as
two threads towards the thread count in the CyclicBarrier.
Now this isn't what I want. When the client dies, I'd like all the
threads it has running to also go away, or at least not count toward the
total in the CyclicBarrier somehow.
This actually brings up another problem I have with my code now that may
need to be fixed in order to handle this problem. Right now the server
doesn't know anything about the client disconnecting. I'm not sure how
to make the Server aware of the disconnect. Is there a simple way to do
so? Is there something I can do when the client disconnects abruptly to
get rid of the thread in the CyclicBarrier?
Thanks. If you can help with this you are Java god.
Kenneth P. Turvey <email@example.com>