@Override public void invoke(int statusCode, String reasonPhrase, String responseBody) { if (failed.compareAndSet(false, true)) { nextError.invoke(statusCode, reasonPhrase, responseBody); } } };
/** * Logs and gets error call back on the response with the provided error message. * * @param message The error message passed to the logger and the exception * @param query The query with the schema for processing this response */ private void logAndGetErrorCallback(String message, DruidAggregationQuery<?> query) { LOG.error(message); getErrorCallback(query).dispatch( Status.INTERNAL_SERVER_ERROR.getStatusCode(), "The server encountered an unexpected condition which prevented it from fulfilling the request.", message); }
/** * Stop the request timer, start the response timer, and then invoke the error callback code. * * @param statusCode Http status code of the error response * @param reasonPhrase The reason for the error. Often the status code description. * @param responseBody The body of the error response */ default void dispatch(int statusCode, String reasonPhrase, String responseBody) { RequestLog.stopTiming(REQUEST_WORKFLOW_TIMER); RequestLog.startTiming(RESPONSE_WORKFLOW_TIMER); invoke(statusCode, reasonPhrase, responseBody); } }
/** * Logs and gets error call back on the response with the provided error message. * * @param message The error message passed to the logger and the exception * @param query The query with the schema for processing this response */ private void logAndGetErrorCallback(String message, DruidAggregationQuery<?> query) { LOG.error(message); getErrorCallback(query).dispatch( INTERNAL_SERVER_ERROR.getStatusCode(), ErrorMessageFormat.INTERNAL_SERVER_ERROR_REASON_PHRASE.format(), message ); } }
@Override public void invoke(int statusCode, String reason, String responseBody) { if (RequestLog.isRunning(REQUEST_WORKFLOW_TIMER)) { RequestLog.stopTiming(REQUEST_WORKFLOW_TIMER); } next.getErrorCallback(druidQuery).invoke(statusCode, reason, responseBody); } };
response.getErrorCallback(druidQuery).dispatch( 507, // Insufficient Storage reason,
/** * Count and log error, then send error response. * * @param status The response status * @param response The druid response * @param druidQueryId The Druid query ID * @param error callback for handling http errors. */ private void markError(Status status, Response response, String druidQueryId, HttpErrorCallback error) { getHttpErrorMeter().mark(); LOG.debug( "druid {} error: {} {} {} and druid query id: {}", getServiceConfig().getNameAndUrl(), status.getStatusCode(), status.getReasonPhrase(), response.getResponseBody(), druidQueryId ); error.invoke( status.getStatusCode(), status.getReasonPhrase(), response.getResponseBody() ); } }
@Override public boolean handleRequest( final RequestContext context, final DataApiRequest request, final DruidAggregationQuery<?> druidQuery, final ResponseProcessor response ) { if (request.getFormat() != DefaultResponseFormatType.DEBUG) { return next.handleRequest(context, request, druidQuery, response); } response.getErrorCallback(druidQuery).dispatch(200, request.getFormat().toString(), "DEBUG"); return true; } }
success.invoke(mapper.readTree(jsonResponse.call())); } else { error.invoke(statusCode, reasonPhrase, jsonResponse.call());
String message = EMPTY_INTERVAL_FORMAT.format(request.getIntervals()); int badRequestCode = Response.Status.BAD_REQUEST.getStatusCode(); response.getErrorCallback(druidQuery).dispatch(badRequestCode, message, message); return true;
success.invoke(mapper.readTree(jsonResponse.call())); } else { error.invoke(statusCode, reasonPhrase, jsonResponse.call());
success.invoke(mapper.readTree(jsonResponse.call())); } else { error.invoke(statusCode, reasonPhrase, jsonResponse.call());
success.invoke(mapper.readTree(jsonResponse.call())); } else { error.invoke(statusCode, reasonPhrase, jsonResponse.call());