@Test public void shutdownWithoutStart() throws IOException { AsyncRequestResponseHandler handler = getAsyncRequestResponseHandler(1); handler.shutdown(); }
@Override public void shutdown() { long shutdownBeginTime = System.currentTimeMillis(); try { if (isRunning()) { isRunning = false; logger.info("Shutting down AsyncRequestResponseHandler"); for (AsyncRequestWorker asyncRequestWorker : asyncRequestWorkers) { try { long workerShutdownBeginTime = System.currentTimeMillis(); if (!asyncRequestWorker.shutdown(30, TimeUnit.SECONDS)) { logger.error("Shutdown of AsyncRequestWorker failed. This should not happen"); metrics.requestResponseHandlerShutdownError.inc(); } long workerShutdownTime = System.currentTimeMillis() - workerShutdownBeginTime; metrics.requestWorkerShutdownTimeInMs.update(workerShutdownTime); logger.info("AsyncRequestWorker shutdown took {} ms", workerShutdownTime); } catch (InterruptedException e) { logger.error("Await shutdown of AsyncRequestWorker was interrupted. It might not have shutdown", e); metrics.requestResponseHandlerShutdownError.inc(); } } asyncResponseHandler.close(); } } finally { long shutdownTime = System.currentTimeMillis() - shutdownBeginTime; logger.info("AsyncRequestResponseHandler shutdown took {} ms", shutdownTime); metrics.requestResponseHandlerShutdownTimeInMs.update(shutdownTime); } }
AsyncRequestResponseHandler implements RestRequestHandler, RestResponseHandler { @Override public void shutdown() { long shutdownBeginTime = System.currentTimeMillis(); try { if (isRunning()) { isRunning = false; logger.info("Shutting down AsyncRequestResponseHandler"); for (AsyncRequestWorker asyncRequestWorker : asyncRequestWorkers) { try { long workerShutdownBeginTime = System.currentTimeMillis(); if (!asyncRequestWorker.shutdown(30, TimeUnit.SECONDS)) { logger.error("Shutdown of AsyncRequestWorker failed. This should not happen"); metrics.requestResponseHandlerShutdownError.inc(); } long workerShutdownTime = System.currentTimeMillis() - workerShutdownBeginTime; metrics.requestWorkerShutdownTimeInMs.update(workerShutdownTime); logger.info("AsyncRequestWorker shutdown took {} ms", workerShutdownTime); } catch (InterruptedException e) { logger.error("Await shutdown of AsyncRequestWorker was interrupted. It might not have shutdown", e); metrics.requestResponseHandlerShutdownError.inc(); } } asyncResponseHandler.close(); } } finally { long shutdownTime = System.currentTimeMillis() - shutdownBeginTime; logger.info("AsyncRequestResponseHandler shutdown took {} ms", shutdownTime); metrics.requestResponseHandlerShutdownTimeInMs.update(shutdownTime); } } }
AsyncRequestResponseHandler implements RestRequestHandler, RestResponseHandler { @Override public void shutdown() { long shutdownBeginTime = System.currentTimeMillis(); try { if (isRunning()) { isRunning = false; logger.info("Shutting down AsyncRequestResponseHandler"); for (AsyncRequestWorker asyncRequestWorker : asyncRequestWorkers) { try { long workerShutdownBeginTime = System.currentTimeMillis(); if (!asyncRequestWorker.shutdown(30, TimeUnit.SECONDS)) { logger.error("Shutdown of AsyncRequestWorker failed. This should not happen"); metrics.requestResponseHandlerShutdownError.inc(); } long workerShutdownTime = System.currentTimeMillis() - workerShutdownBeginTime; metrics.requestWorkerShutdownTimeInMs.update(workerShutdownTime); logger.info("AsyncRequestWorker shutdown took {} ms", workerShutdownTime); } catch (InterruptedException e) { logger.error("Await shutdown of AsyncRequestWorker was interrupted. It might not have shutdown", e); metrics.requestResponseHandlerShutdownError.inc(); } } asyncResponseHandler.close(); } } finally { long shutdownTime = System.currentTimeMillis() - shutdownBeginTime; logger.info("AsyncRequestResponseHandler shutdown took {} ms", shutdownTime); metrics.requestResponseHandlerShutdownTimeInMs.update(shutdownTime); } } protected  AsyncRequestResponseHandler(RequestResponseHandlerMetrics metrics, int workerCount,
      RestRequestService restRequestService); }
AsyncRequestResponseHandler implements RestRequestHandler, RestResponseHandler { @Override public void shutdown() { long shutdownBeginTime = System.currentTimeMillis(); try { if (isRunning()) { isRunning = false; logger.info("Shutting down AsyncRequestResponseHandler"); for (AsyncRequestWorker asyncRequestWorker : asyncRequestWorkers) { try { long workerShutdownBeginTime = System.currentTimeMillis(); if (!asyncRequestWorker.shutdown(30, TimeUnit.SECONDS)) { logger.error("Shutdown of AsyncRequestWorker failed. This should not happen"); metrics.requestResponseHandlerShutdownError.inc(); } long workerShutdownTime = System.currentTimeMillis() - workerShutdownBeginTime; metrics.requestWorkerShutdownTimeInMs.update(workerShutdownTime); logger.info("AsyncRequestWorker shutdown took {} ms", workerShutdownTime); } catch (InterruptedException e) { logger.error("Await shutdown of AsyncRequestWorker was interrupted. It might not have shutdown", e); metrics.requestResponseHandlerShutdownError.inc(); } } asyncResponseHandler.close(); } } finally { long shutdownTime = System.currentTimeMillis() - shutdownBeginTime; logger.info("AsyncRequestResponseHandler shutdown took {} ms", shutdownTime); metrics.requestResponseHandlerShutdownTimeInMs.update(shutdownTime); } } protected  AsyncRequestResponseHandler(RequestResponseHandlerMetrics metrics, int workerCount,
      RestRequestService restRequestService); @Override void start(); @Override void shutdown(); @Override void handleRequest(RestRequest restRequest, RestResponseChannel restResponseChannel); @Override void handleResponse(RestRequest restRequest, RestResponseChannel restResponseChannel,
      ReadableStreamChannel response, Exception exception); }
AsyncRequestResponseHandler implements RestRequestHandler, RestResponseHandler { @Override public void shutdown() { long shutdownBeginTime = System.currentTimeMillis(); try { if (isRunning()) { isRunning = false; logger.info("Shutting down AsyncRequestResponseHandler"); for (AsyncRequestWorker asyncRequestWorker : asyncRequestWorkers) { try { long workerShutdownBeginTime = System.currentTimeMillis(); if (!asyncRequestWorker.shutdown(30, TimeUnit.SECONDS)) { logger.error("Shutdown of AsyncRequestWorker failed. This should not happen"); metrics.requestResponseHandlerShutdownError.inc(); } long workerShutdownTime = System.currentTimeMillis() - workerShutdownBeginTime; metrics.requestWorkerShutdownTimeInMs.update(workerShutdownTime); logger.info("AsyncRequestWorker shutdown took {} ms", workerShutdownTime); } catch (InterruptedException e) { logger.error("Await shutdown of AsyncRequestWorker was interrupted. It might not have shutdown", e); metrics.requestResponseHandlerShutdownError.inc(); } } asyncResponseHandler.close(); } } finally { long shutdownTime = System.currentTimeMillis() - shutdownBeginTime; logger.info("AsyncRequestResponseHandler shutdown took {} ms", shutdownTime); metrics.requestResponseHandlerShutdownTimeInMs.update(shutdownTime); } } protected  AsyncRequestResponseHandler(RequestResponseHandlerMetrics metrics, int workerCount,
      RestRequestService restRequestService); @Override void start(); @Override void shutdown(); @Override void handleRequest(RestRequest restRequest, RestResponseChannel restResponseChannel); @Override void handleResponse(RestRequest restRequest, RestResponseChannel restResponseChannel,
      ReadableStreamChannel response, Exception exception);  }