@Test @Ignore public void ExecutorServiceの起動_終了テスト() { RepairServiceLauncher launcher = new RepairServiceLauncher(); assertThat(launcher.executor.getPoolSize(), is(1)); assertThat(launcher.executor.getTaskCount(), is(1L)); launcher.shutdown(); assertThat(launcher.executor.isTerminated(), is(true)); assertThat(launcher.executor.isShutdown(), is(true)); }
public void shutdown() { if (null != executor && !executor.isTerminated()) { logger.info("Shutting down RepairAds scheduler."); executor.shutdown(); try { long awaitShutdownInSec = DcCoreConfig.getAdsRepairAwaitShutdownInSec(); logger.info(String.format("Waiting RepairAds termination up to %d sec.", awaitShutdownInSec)); if (executor.awaitTermination(awaitShutdownInSec, TimeUnit.SECONDS)) { logger.info("Completed shutting down RepairAds scheduler."); } else { logger.warn("Shutting down timed out. RepairAds scheduler have not been terminated."); executor.shutdownNow(); } } catch (InterruptedException e) { executor.shutdownNow(); } } }
RepairServiceLauncher { public void shutdown() { if (null != executor && !executor.isTerminated()) { logger.info("Shutting down RepairAds scheduler."); executor.shutdown(); try { long awaitShutdownInSec = DcCoreConfig.getAdsRepairAwaitShutdownInSec(); logger.info(String.format("Waiting RepairAds termination up to %d sec.", awaitShutdownInSec)); if (executor.awaitTermination(awaitShutdownInSec, TimeUnit.SECONDS)) { logger.info("Completed shutting down RepairAds scheduler."); } else { logger.warn("Shutting down timed out. RepairAds scheduler have not been terminated."); executor.shutdownNow(); } } catch (InterruptedException e) { executor.shutdownNow(); } } } }
RepairServiceLauncher { public void shutdown() { if (null != executor && !executor.isTerminated()) { logger.info("Shutting down RepairAds scheduler."); executor.shutdown(); try { long awaitShutdownInSec = DcCoreConfig.getAdsRepairAwaitShutdownInSec(); logger.info(String.format("Waiting RepairAds termination up to %d sec.", awaitShutdownInSec)); if (executor.awaitTermination(awaitShutdownInSec, TimeUnit.SECONDS)) { logger.info("Completed shutting down RepairAds scheduler."); } else { logger.warn("Shutting down timed out. RepairAds scheduler have not been terminated."); executor.shutdownNow(); } } catch (InterruptedException e) { executor.shutdownNow(); } } } RepairServiceLauncher(); }
RepairServiceLauncher { public void shutdown() { if (null != executor && !executor.isTerminated()) { logger.info("Shutting down RepairAds scheduler."); executor.shutdown(); try { long awaitShutdownInSec = DcCoreConfig.getAdsRepairAwaitShutdownInSec(); logger.info(String.format("Waiting RepairAds termination up to %d sec.", awaitShutdownInSec)); if (executor.awaitTermination(awaitShutdownInSec, TimeUnit.SECONDS)) { logger.info("Completed shutting down RepairAds scheduler."); } else { logger.warn("Shutting down timed out. RepairAds scheduler have not been terminated."); executor.shutdownNow(); } } catch (InterruptedException e) { executor.shutdownNow(); } } } RepairServiceLauncher(); void shutdown(); }
RepairServiceLauncher { public void shutdown() { if (null != executor && !executor.isTerminated()) { logger.info("Shutting down RepairAds scheduler."); executor.shutdown(); try { long awaitShutdownInSec = DcCoreConfig.getAdsRepairAwaitShutdownInSec(); logger.info(String.format("Waiting RepairAds termination up to %d sec.", awaitShutdownInSec)); if (executor.awaitTermination(awaitShutdownInSec, TimeUnit.SECONDS)) { logger.info("Completed shutting down RepairAds scheduler."); } else { logger.warn("Shutting down timed out. RepairAds scheduler have not been terminated."); executor.shutdownNow(); } } catch (InterruptedException e) { executor.shutdownNow(); } } } RepairServiceLauncher(); void shutdown();  }