private boolean _busy;
private JobInvokerRegister _callback;
@Override
public boolean invoke(final CalculationJob job, final JobInvocationReceiver receiver) {
final JobInvoker instance = this;
synchronized (instance) {
if (_busy) {
return false;
}
_executorService.execute(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(rnd.nextInt(50));
} catch (InterruptedException e) {
s_logger.warn("invoker {} interrupted", getInvokerId ());
}
s_logger.debug("invoker {} completed job {}", getInvokerId (), job.getSpecification());
receiver.jobCompleted(createTestJobResult(job.getSpecification(), 0L, instance.toString()));
synchronized (instance) {
_busy = false;
if (_callback != null) {
s_logger.debug("re-registering invoker {} with dispatcher", getInvokerId ());
final JobInvokerRegister callback = _callback;