final Ready initialMessage = new Ready(3, "Test");
final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
final RemoteNodeJobInvoker jobInvoker = new RemoteNodeJobInvoker(Executors.newCachedThreadPool(), initialMessage, conduit.getEnd1(), new InMemoryIdentifierMap(), new FunctionCosts(),
new DummyFunctionBlacklistQuery(), new DummyFunctionBlacklistMaintainer());
jobDispatcher.registerJobInvoker(jobInvoker);
final FudgeConnection remoteNode = conduit.getEnd2();
final Random rnd = new Random();
remoteNode.setFudgeMessageReceiver(new FudgeMessageReceiver() {
@Override
public void messageReceived(FudgeContext fudgeContext, FudgeMsgEnvelope msgEnvelope) {
final FudgeDeserializer dcontext = new FudgeDeserializer(fudgeContext);
final RemoteCalcNodeMessage message = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, msgEnvelope.getMessage());
assertNotNull(message);
assertTrue(message instanceof Execute);
final Execute job = (Execute) message;
try {
Thread.sleep(rnd.nextInt(30));
} catch (InterruptedException e) {
}
final Result result = new Result(JobDispatcherTest.createTestJobResult(job.getJob().getSpecification(), 0, "Test"));
final FudgeSerializer scontext = new FudgeSerializer(fudgeContext);
remoteNode.getFudgeMessageSender().send(FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg(result), result.getClass(), RemoteCalcNodeMessage.class));
}
});
final TestJobResultReceiver[] resultReceivers = new TestJobResultReceiver[100];
for (int i = 0; i < resultReceivers.length; i++) {
resultReceivers[i] = new TestJobResultReceiver();