@Override public Task write(final HandlerContext ctx, final Object msg) throws Exception { if (msg instanceof Invocation) { // await checks isDone() await(hostingActive); final Invocation invocation = (Invocation) msg; if (invocation.getFromNode() == null) { // used by subsequent filters invocation.setFromNode(stage.getLocalAddress()); } if (invocation.getToNode() == null) { return writeInvocation(ctx, invocation); } } return ctx.write(msg); }
final NodeInfo info = activeNodes.get(invocation.getFromNode()); if (info != null && info.state == NodeState.RUNNING)
public Task<?> writeInvocation(final HandlerContext ctx, Invocation invocation) { final Addressable toReference = invocation.getToReference(); final RemoteReference<?> actorReference = (RemoteReference<?>) toReference; final NodeAddress toNode = invocation.getToNode(); Map<String, Object> actualHeaders = null; if (invocation.getHeaders() != null) { actualHeaders = new HashMap<>(); actualHeaders.putAll(invocation.getHeaders()); } final Message message = new Message() .withMessageType(invocation.isOneWay() ? MessageDefinitions.ONE_WAY_MESSAGE : MessageDefinitions.REQUEST_MESSAGE) .withToNode(toNode) .withFromNode(invocation.getFromNode()) .withHeaders(actualHeaders) .withInterfaceId(actorReference._interfaceId()) .withMessageId(invocation.getMessageId()) .withMethodId(invocation.getMethodId()) .withObjectId(RemoteReference.getId(actorReference)) .withPayload(invocation.getParams()) .withReferenceAddress(invocation.getToReference().address); if (logger.isTraceEnabled()) { logger.trace("sending message to " + toReference); } return writeMessage(ctx, message); }