/** * <p>Returns whether or not this reply contains any fatal errors.</p> * * @return True if it contains fatal errors. */ public boolean hasFatalErrors() { for (Error error : errors) { if (error.getCode() >= ErrorCode.FATAL_ERROR) { return true; } } return false; }
/** * Retrieves a set of integer error codes */ public Set<Integer> getErrorCodes() { Set<Integer> errorCodes = new HashSet<>(); for (Error error : errors) { errorCodes.add(error.getCode()); } return errorCodes; }
/** * Return whether a (transient) error shall be exempt from visitor * error reporting. This to prevent spamming handlers and output with * errors for things that are happening naturally in the system. * @return true if the error should be reported */ private boolean shouldReportError(Reply reply) { Error error = reply.getError(0); switch (error.getCode()) { case DocumentProtocol.ERROR_BUCKET_NOT_FOUND: case DocumentProtocol.ERROR_BUCKET_DELETED: return false; } return true; }
private static boolean isErrorOfType(Reply reply, int errorCode) { return reply.getError(0).getCode() == errorCode; }
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; }
private boolean isFatalError(Reply reply) { Error error = reply.getError(0); switch (error.getCode()) { case ErrorCode.TIMEOUT: case DocumentProtocol.ERROR_BUCKET_NOT_FOUND: case DocumentProtocol.ERROR_WRONG_DISTRIBUTION: return false; } return error.isFatal(); }
static private boolean isSendQFull(Result res) { return !res.isAccepted() && (res.getError().getCode() == ErrorCode.SEND_QUEUE_FULL); }
private static String getErrorMessage(Error r) { return DocumentProtocol.getErrorName(r.getCode()) + ": " + r.getMessage(); }
private static Result toResult(long reqId, com.yahoo.messagebus.Result mbusResult) { if (mbusResult.isAccepted()) { return new Result(reqId); } return new Result( messageBusErrorToResultType(mbusResult.getError().getCode()), new Error(mbusResult.getError().getMessage() + " (" + mbusResult.getError().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; }
boolean isConditionNotMet = result.getError().getCode() == DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED; repliesFromOldMessages.add(createOperationStatus(msg.get().getOperationId(), result.getError().getMessage(), ErrorCode.ERROR, isConditionNotMet, msg.get().getMessage()));
private Result sendMessage( FeederSettings settings, DocumentOperationMessageV3 msg, AtomicInteger threadsAvailableForFeeding) throws InterruptedException { Result result = null; while (result == null || result.getError().getCode() == SEND_QUEUE_FULL) { msg.getMessage().pushHandler(feedReplyHandler); if (settings.denyIfBusy && threadsAvailableForFeeding.get() < 1) { return sourceSession.getResource().sendMessage(msg.getMessage()); } else { result = sourceSession.getResource().sendMessageBlocking(msg.getMessage()); } if (result.isAccepted()) { return result; } Thread.sleep(100); } return result; }
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 public void handleReply(Reply reply) { Object o = reply.getContext(); if (!(o instanceof ReplyContext)) { return; } ReplyContext context = (ReplyContext) o; final double latencyInSeconds = (System.currentTimeMillis() - context.creationTime) / 1000.0d; metric.set(MetricNames.LATENCY, latencyInSeconds, null); if (reply.hasErrors()) { Set<Integer> errorCodes = reply.getErrorCodes(); metricsHelper.reportFailure(DocumentOperationType.fromMessage(reply.getMessage()), DocumentOperationStatus.fromMessageBusErrorCodes(errorCodes)); metric.add(MetricNames.FAILED, 1, null); enqueue(context, reply.getError(0).getMessage(), ErrorCode.ERROR, reply.getError(0).getCode() == DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED, reply.getTrace()); } else { metricsHelper.reportSuccessful(DocumentOperationType.fromMessage(reply.getMessage()), latencyInSeconds); metric.add(MetricNames.SUCCEEDED, 1, null); enqueue(context, "Document processed.", ErrorCode.OK, false, reply.getTrace()); } }
@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); } });
@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() : "")); }
Cursor e = array.addObject(); Error mbusE = reply.getError(i); e.setLong(CODE_F, mbusE.getCode()); e.setString(MSG_F, mbusE.getMessage()); if (mbusE.getService() != null) {