Reply createSendTimedoutReply(Message msg, Error error) { Reply reply = new EmptyReply(); reply.setMessage(msg); reply.addError(error); msg.swapState(reply); return reply; }
private boolean handleReplyWithOnlyIgnoredErrors(Reply r) { if (DocumentProtocol.hasOnlyErrorsOfType(r, DocumentProtocol.ERROR_MESSAGE_IGNORED)) { if (ignore == null) { ignore = new EmptyReply(); } ignore.addError(r.getError(0)); return true; } return false; }
@Override public void handleMessage(Message msg) { MessageHandler msgHandler = this.msgHandler.get(); if (msgHandler == null) { Reply reply = new EmptyReply(); reply.swapState(msg); reply.addError(new Error(ErrorCode.SESSION_BUSY, "Session not fully configured yet.")); sendReply(reply); return; } msgHandler.handleMessage(msg); }
@Override public void handleMessage(Message msg) { MessageHandler msgHandler = this.msgHandler.get(); if (msgHandler == null) { Reply reply = new EmptyReply(); reply.swapState(msg); reply.addError(new Error(ErrorCode.SESSION_BUSY, "Session not fully configured yet.")); sendReply(reply); return; } msgHandler.handleMessage(msg); }
private void dispatchErrorReply(Message msg, int errCode, String errMsg) { Reply reply = new EmptyReply(); reply.swapState(msg); reply.addError(new Error(errCode, errMsg)); session.sendReply(reply); }
/** * This is a convenience method to assign an {@link EmptyReply} containing a single error to this. This also fiddles * with the trace object so that the error gets written to it. * * @param err The error to set. * @see #setReply(Reply) */ public void setError(Error err) { Reply reply = new EmptyReply(); reply.getTrace().setLevel(trace.getLevel()); reply.addError(err); setReply(reply); }
/** * <p>Constructs and schedules a Reply containing an error to the handler of the given Message.</p> * * @param msg The message to reply to. * @param errCode The code of the error to set. * @param errMsg The message of the error to set. */ private void deliverError(Message msg, int errCode, String errMsg) { Reply reply = new EmptyReply(); reply.swapState(msg); reply.addError(new Error(errCode, errMsg)); deliverReply(reply, reply.popHandler()); }
private void mergeAllReplyErrors(Reply r) { if (handleReplyWithOnlyIgnoredErrors(r)) { return; } if (error == null) { error = new EmptyReply(); r.swapState(error); return; } for (int j = 0; j < r.getNumErrors(); ++j) { error.addError(r.getError(j)); } }
@Override public void select(RoutingContext routingContext) { synchronized (this) { if (initException != null) { Reply reply = new EmptyReply(); reply.addError(new com.yahoo.messagebus.Error(ErrorCode.POLICY_ERROR, "Policy threw exception during init:" + exceptionMessageWithTrace(initException))); routingContext.setReply(reply); return; } checkStartInit(); if (initState == InitState.RUNNING) { Reply reply = new EmptyReply(); reply.addError(new com.yahoo.messagebus.Error(ErrorCode.SESSION_BUSY, "Policy is waiting to be initialized.")); routingContext.setReply(reply); return; } } doSelect(routingContext); }
private void handleMessageProcessingException(Reply reply, Exception e, String what) { final String errorDesc = formatProcessingException(e, what); final String fullMsg = formatIdentifyingVisitorErrorString(errorDesc); log.log(LogLevel.ERROR, fullMsg, e); int errorCode; synchronized (progress.getToken()) { if (!params.skipBucketsOnFatalErrors()) { errorCode = ErrorCode.APP_FATAL_ERROR; transitionTo(new StateDescription(State.FAILED, errorDesc)); } else { errorCode = DocumentProtocol.ERROR_UNPARSEABLE; } } reply.addError(new Error(errorCode, errorDesc)); }
public BucketId handleBucketIdCalculation(RoutingContext context) { BucketId id = getBucketId(context.getMessage()); if (id == null || id.getRawId() == 0) { Reply reply = new EmptyReply(); reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "No bucket id available in message.")); context.setReply(reply); } return id; } }
/** * Deliver an error reply to the recipients of a {@link SendContext} in a way that avoids entanglement. * * @param ctx The send context that contains the recipient data. * @param errCode The error code to return. * @param errMsg The error string to return. */ private void replyError(SendContext ctx, int errCode, String errMsg) { for (RoutingNode recipient : ctx.recipients) { Reply reply = new EmptyReply(); reply.getTrace().setLevel(ctx.traceLevel); reply.addError(new Error(errCode, errMsg)); owner.deliverReply(reply, recipient); } }
/** * 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); } }
private MessageHandler createMessageHandler() { return (message) -> { try { taskExecutor.submitTask(new HandleMessageTask(message)); } catch (RejectedExecutionException e) { Reply reply = ((DocumentMessage)message).createReply(); message.swapState(reply); reply.addError(new Error( DocumentProtocol.ERROR_ABORTED, "Visitor session has been aborted")); receiver.reply(reply); } }; }
public void merge(RoutingContext context) { List<String> lst = new ArrayList<String>(); Reply ret = new EmptyReply(); for (RoutingNodeIterator it = context.getChildIterator(); it.isValid(); it.next()) { lst.add(it.getRoute().toString()); Reply reply = it.getReplyRef(); for (int i = 0; i < reply.getNumErrors(); ++i) { ret.addError(reply.getError(i)); } } context.setReply(ret); context.trace(1, "Merged " + lst + "."); }
/** * Send an error reply for a given request. * * @param request The JRT request to reply to. * @param version The version to serialize for. * @param traceLevel The trace level to set in the reply. * @param err The error to reply with. */ private void replyError(Request request, Version version, int traceLevel, Error err) { Reply reply = new EmptyReply(); reply.setContext(new ReplyContext(request, version)); reply.getTrace().setLevel(traceLevel); reply.addError(err); handleReply(reply); }
@Override public void processingFailed(ErrorCode errorCode, String errorMsg) { MbusResponse response = new MbusResponse(errorCode.getDiscStatus(), requestMsg.createReply()); response.getReply().addError(new com.yahoo.messagebus.Error(errorCode.getDocumentProtocolStatus(), errorMsg)); ResponseDispatch.newInstance(response).dispatch(this); }
public void select(RoutingContext ctx) { Hop hop = getRecipient(ctx); if (hop != null) { Route route = new Route(ctx.getRoute()); route.setHop(0, hop); ctx.addChild(route); } else { Reply reply = new EmptyReply(); reply.addError(new Error(ErrorCode.NO_ADDRESS_FOR_SERVICE, "None of the configured recipients are currently available.")); ctx.setReply(reply); } }
private void handleDocumentMessage(DocumentMessage msg) { Reply reply = msg.createReply(); msg.swapState(reply); if (params.getLocalDataHandler() == null) { log.log(LogLevel.ERROR, sessionName + ": Got visitor data back to client with no local data destination."); reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "Visitor data with no local data destination")); receiver.reply(reply); return; } try { params.getLocalDataHandler().onMessage(msg, new AckToken(reply)); } catch (Exception e) { handleMessageProcessingException(reply, e, "DocumentMessage"); // Immediately reply since we cannot count on AckToken being registered receiver.reply(reply); } }
@Override public void run() { Reply reply = decode(envelope.reply.getProtocol(), payload, Reply.class); reply.setRetryDelay(envelope.reply.getRetryDelay()); reply.getTrace().getRoot().addChild(TraceNode.decode(envelope.reply.getTrace().getRoot().encode())); for (int i = 0, len = envelope.reply.getNumErrors(); i < len; ++i) { Error error = envelope.reply.getError(i); reply.addError(new Error(error.getCode(), error.getMessage(), error.getService() != null ? error.getService() : envelope.sender.hostId)); } owner.deliverReply(reply, envelope.parent.recipient); } });