@Override public void invoke(Throwable error) { if (failed.compareAndSet(false, true)) { nextFail.invoke(error); } } };
/** * Fail the request. * * @param format Format string for the failure message. Expects to take an interval * @param druidQuery Druid query that failed * @param interval Interval of the failing druid query */ private void fail(String format, DruidAggregationQuery<?> druidQuery, Interval interval) { String message = String.format(format, interval); Exception e = new IllegalStateException(message); LOG.error(message, e); getFailureCallback(druidQuery).invoke(e); }
/** * Stop the request timer, start the response timer, and then invoke the failure callback code. * * @param error The error that caused the failure */ default void dispatch(Throwable error) { RequestLog.stopTiming(REQUEST_WORKFLOW_TIMER); RequestLog.startTiming(RESPONSE_WORKFLOW_TIMER); invoke(error); } }
@Override public void onThrowable(Throwable t) { RequestLog.restore(logCtx); RequestLog.stopTiming(timerName); if (outstanding.decrementAndGet() == 0) { RequestLog.startTiming(RESPONSE_WORKFLOW_TIMER); } exceptionMeter.mark(); LOG.error("druid {} request failed:", serviceConfig.getNameAndUrl(), t); failure.invoke(t); } });
@Override public void invoke(Throwable error) { if (RequestLog.isRunning(REQUEST_WORKFLOW_TIMER)) { RequestLog.stopTiming(REQUEST_WORKFLOW_TIMER); } next.getFailureCallback(druidQuery).invoke(error); } };
@Override public Response onCompleted(Response response) { String druidQueryId = response.getHeader("X-Druid-Query-Id"); Status status = Status.fromStatusCode(response.getStatusCode()); logRequest(logCtx, timerName, outstanding, druidQueryId, status); if (hasError(status)) { markError(status, response, druidQueryId, error); } else { try { success.invoke(jsonNodeBuilderStrategy.apply(response)); } catch (RuntimeException e) { failure.invoke(e); } } // we consumed this response, so pass null to any chains return null; }
failure.invoke(t); return CompletedFuture.throwing(t);