/** * Returns a concatenated error string from the errors contained in a reply. * * @param reply The reply whose errors to concatenate. * @return The error string. */ static String getErrorMessage(Reply reply) { if (!reply.hasErrors()) { return null; } StringBuilder errors = new StringBuilder(); for (int i = 0; i < reply.getNumErrors(); ++i) { errors.append(reply.getError(i)).append(" "); } return errors.toString(); }
public static int fromMbusReply(final Reply reply) { int statusCode = Response.Status.OK; for (int i = 0, len = reply.getNumErrors(); i < len; ++i) { statusCode = Math.max(statusCode, fromMbusError(reply.getError(i))); } return statusCode; }
public Reply awaitErrors(Integer... errCodes) { Reply reply = awaitReply(); if (reply == null) { return null; } List<Integer> lst = new LinkedList<>(Arrays.asList(errCodes)); for (int i = 0, len = reply.getNumErrors(); i < len; ++i) { Error err = reply.getError(i); System.out.println(err); int idx = lst.indexOf(err.getCode()); if (idx < 0) { return null; } lst.remove(idx); } if (!lst.isEmpty()) { return null; } return reply; }
RoutingNode node = stack.pop(); if (node.reply != null) { for (int i = 0; i < node.reply.getNumErrors(); ++i) { Error error = node.reply.getError(i); int errorCode = error.getCode();
/** * Returns true if the given reply has at least one error, and all errors are of the given type. * * @param reply The reply to check for error. * @param errCode The error code to check for. * @return Whether or not the reply has only the given error code. */ public static boolean hasOnlyErrorsOfType(Reply reply, int errCode) { if (!reply.hasErrors()) { return false; } for (int i = 0; i < reply.getNumErrors(); ++i) { if (reply.getError(i).getCode() != errCode) { return false; } } return true; }
/** * Returns whether or not the given reply should be retried. * * @param reply The reply to check. * @return True if retry is required. */ public boolean shouldRetry(Reply reply) { int numErrors = reply.getNumErrors(); if (numErrors == 0) { return false; } for (int i = 0; i < numErrors; ++i) { if (!retryPolicy.canRetry(reply.getError(i).getCode())) { return false; } } return true; }
@Override public void handleReply(Reply reply) { setReply(reply); if (routeMetrics != null) { for (int i = 0; i < reply.getNumErrors(); i++) { routeMetrics.addError(reply.getError(i)); } } notifyParent(); } }
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)); } }
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 + "."); }
public void merge(RoutingContext context) { RoutingNodeIterator it = context.getChildIterator(); Reply reply = it.removeReply(); LoadBalancer.Node target = (LoadBalancer.Node)context.getContext(); boolean busy = false; for (int i = 0; i < reply.getNumErrors(); i++) { if (reply.getError(i).getCode() == ErrorCode.SESSION_BUSY) { busy = true; } } loadBalancer.received(target, busy); context.setReply(reply); }
@Override protected void createResponse(Values ret, Reply reply, Version version, byte [] payload) { int[] eCodes = new int[reply.getNumErrors()]; String[] eMessages = new String[reply.getNumErrors()]; String[] eServices = new String[reply.getNumErrors()]; for (int i = 0; i < reply.getNumErrors(); ++i) { Error error = reply.getError(i); eCodes[i] = error.getCode(); eMessages[i] = error.getMessage(); eServices[i] = error.getService() != null ? error.getService() : ""; } ret.add(new StringValue(version.toString())); ret.add(new DoubleValue(reply.getRetryDelay())); ret.add(new Int32Array(eCodes)); ret.add(new StringArray(eMessages)); ret.add(new StringArray(eServices)); ret.add(new StringValue(reply.getProtocol())); ret.add(new DataValue(payload)); ret.add(new StringValue(reply.getTrace().getRoot() != null ? reply.getTrace().getRoot().encode() : "")); }
for (int i = 0; i < reply.getNumErrors(); i++) { metrics.addFailure(reply.getError(i)); if (reply.getNumErrors() == 0) { metrics.latency.addValue(msg.getTimeReceived() - sendTime);
@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); } });
if (reply.getNumErrors() > 0) { Cursor array = root.setArray(ERRORS_F); for (int i = 0; i < reply.getNumErrors(); i++) { Cursor e = array.addObject(); Error mbusE = reply.getError(i);