Exclusive use of a Jini server during long-running call
Posted
by
Matthew Flint
on Programmers
See other posts from Programmers
or by Matthew Flint
Published on 2012-05-02T21:05:17Z
Indexed on
2012/06/03
4:48 UTC
Read the original article
Hit count: 335
I'm trying to use Jini, in a "Masters/Workers" arrangement, but the Worker jobs may be long running. In addition, each worker needs to have exclusive access to a singleton resource on that machine.
As it stands, if a Worker receives another request while a previous request is running, then the new request is accepted and executed in a second thread.
Are there any best-practices to ensure that a Worker accepts no further jobs until the current job is complete?
Things I've considered:
- synchronize the job on the server, with a lock on the singleton resource. This would work, but is far from ideal. A call from a Master would block until the current Worker thread completes, even if other Workers become free in the meantime
- unregister the Worker from the registry while the job is running, then re-register when it completes. Might work OK, but something doesn't smell right with this idea...
Of course, I'm quite happy to be told that there are more appropriate technologies than Jini... but I wouldn't want anything too heavyweight, like rolling out EJB containers all over the place.
© Programmers or respective owner