/** * This method may only be invoked on a root node, as it passes the current reply to the member {@link * ReplyHandler}. */ private void notifySender() { reply.getTrace().swap(trace); handler.handleReply(reply); reply = null; }
/** * This is a convenience method to add an error to this. If a reply has already been set, this method will add the * error to it. If no reply is set, this method calls {@link #setError(Error)}. This method also fiddles with the * trace object so that the error gets written to it. * * @param err The error to add. */ public void addError(Error err) { if (reply != null) { reply.getTrace().swap(trace); reply.addError(err); reply.getTrace().swap(trace); } else { setError(err); } }
/** * Swaps the state that makes this routable unique to another routable. The state is what identifies a routable for * message bus, so only one message can ever have the same state. This function must be called explicitly when * cloning and copying messages. * * @param rhs The routable to swap state with. */ public void swapState(Routable rhs) { Object context = this.context; this.context = rhs.context; rhs.context = context; callStack.swap(rhs.getCallStack()); trace.swap(rhs.getTrace()); }
/** * Removes and returns the reply of the current child. This is the correct way of reusing a reply of a child node, * the {@link #getReplyRef()} should be used when just inspecting a child reply. * * @return The reply. */ public Reply removeReply() { Reply ret = entry.getReply(); ret.getTrace().setLevel(entry.getTrace().getLevel()); ret.getTrace().swap(entry.getTrace()); entry.setReply(null); return ret; }
trace.swap(empty); } else if (trace.getLevel() > 0) { trace.getRoot().addChild(reply.getTrace().getRoot());
"Reply (type " + reply.getType() + ") received at " + clientIdent + "."); reply.getTrace().swap(ctx.trace); if (error != null) { reply.addError(error);
@Override public final void send(RoutingNode recipient, Version version, byte[] payload, long timeRemaining) { SendContext ctx = new SendContext(recipient, timeRemaining); RPCServiceAddress address = (RPCServiceAddress)recipient.getServiceAddress(); Message msg = recipient.getMessage(); Route route = new Route(recipient.getRoute()); Hop hop = route.removeHop(0); Request req = encodeRequest(version, route, address,msg, timeRemaining, payload, ctx.trace.getLevel()); if (ctx.trace.shouldTrace(TraceLevel.SEND_RECEIVE)) { ctx.trace.trace(TraceLevel.SEND_RECEIVE, "Sending message (version " + version + ") from " + clientIdent + " to '" + address.getServiceName() + "' with " + ctx.timeout + " seconds timeout."); } if (hop.getIgnoreResult()) { address.getTarget().getJRTTarget().invokeVoid(req); if (ctx.trace.shouldTrace(TraceLevel.SEND_RECEIVE)) { ctx.trace.trace(TraceLevel.SEND_RECEIVE, "Not waiting for a reply from '" + address.getServiceName() + "'."); } Reply reply = new EmptyReply(); reply.getTrace().swap(ctx.trace); net.getOwner().deliverReply(reply, recipient); } else { req.setContext(ctx); address.getTarget().getJRTTarget().invokeAsync(req, ctx.timeout, this); } req.discardParameters(); // allow garbage collection of request parameters }