throw new InterruptedException(); log.info(awaitingLogMessage(context)); if (workerShutdownWithRemaining(context.getShutdownCompleteLatch().getCount(), context)) { return false; + awaitingLogMessage(context)); return false; throw new InterruptedException(); log.info(awaitingFinalShutdownMessage(context)); if (workerShutdownWithRemaining(context.getShutdownCompleteLatch().getCount(), context)) { return false; + awaitingFinalShutdownMessage(context)); return false;
@Override public Boolean call() throws Exception { GracefulShutdownContext context; try { context = startWorkerShutdown.call(); } catch (Exception ex) { log.warn("Caught exception while requesting initial worker shutdown.", ex); throw ex; } return context.isShutdownAlreadyCompleted() || waitForRecordProcessors(context); } }
/** * This checks to see if the worker has already hit it's shutdown target, while there is outstanding record * processors. This maybe a little racy due to when the value of outstanding is retrieved. In general though the * latch should be decremented before the shutdown completion. * * @param outstanding * the number of record processor still awaiting shutdown. */ private boolean workerShutdownWithRemaining(long outstanding, GracefulShutdownContext context) { if (isWorkerShutdownComplete(context)) { if (outstanding != 0) { log.info("Shutdown completed, but shutdownCompleteLatch still had outstanding " + outstanding + " with a current value of " + context.getShutdownCompleteLatch().getCount() + ". shutdownComplete: " + context.getWorker().isShutdownComplete() + " -- Consumer Map: " + context.getWorker().getShardInfoShardConsumerMap().size()); return true; } } return false; }
Callable<Boolean> createGracefulShutdownCallable(Callable<GracefulShutdownContext> startWorkerShutdown) { return new GracefulShutdownCallable(startWorkerShutdown); }