/** * Check if a stopwatch is currently running. * * @param caller the caller to name this stopwatch with its class's simple name * * @return whether this stopwatch is currently running */ public static boolean isRunning(Object caller) { return isRunning(caller.getClass().getSimpleName()); }
/** * Sends the response back to the user. * * @param response The response to send to the user * @param asyncResponse The channel over which to send the response */ private void send(Response response, AsyncResponse asyncResponse) { if (RequestLog.isRunning(RESPONSE_WORKFLOW_TIMER)) { RequestLog.stopTiming(RESPONSE_WORKFLOW_TIMER); } asyncResponse.resume(response); }
/** * Publish final response to user. * * @param response The Response to send back to the user */ private void publishResponse(Response response) { if (RequestLog.isRunning(RESPONSE_WORKFLOW_TIMER)) { RequestLog.stopTiming(RESPONSE_WORKFLOW_TIMER); } asyncResponse.resume(response); } }
@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); } };
@Override public void invoke(Throwable error) { if (RequestLog.isRunning(REQUEST_WORKFLOW_TIMER)) { RequestLog.stopTiming(REQUEST_WORKFLOW_TIMER); } next.getFailureCallback(druidQuery).invoke(error); } };