use of com.vip.saturn.job.basic.JobScheduler in project Saturn by vipshop.
the class SaturnExecutor method shutdownJobSchedulers.
private void shutdownJobSchedulers() {
Map<String, JobScheduler> schdMap = JobRegistry.getSchedulerMap().get(executorName);
if (MapUtils.isEmpty(schdMap)) {
return;
}
long startTime = System.currentTimeMillis();
List<Future<?>> futures = new ArrayList<>();
Iterator<String> it = schdMap.keySet().iterator();
while (it.hasNext()) {
final String jobName = it.next();
final JobScheduler jobScheduler = schdMap.get(jobName);
if (jobScheduler != null) {
futures.add(shutdownJobsExecutorService.submit(new Runnable() {
@Override
public void run() {
try {
jobScheduler.shutdown(false);
} catch (Throwable t) {
LogUtils.error(log, jobName, "shutdown JobScheduler error", t);
}
}
}));
}
}
for (Future<?> future : futures) {
try {
future.get();
} catch (Exception e) {
LogUtils.error(log, LogEvents.ExecutorEvent.SHUTDOWN, "wait shutdown job error", e);
}
}
LogUtils.info(log, LogEvents.ExecutorEvent.SHUTDOWN, "Shutdown phase [shutdownJobSchedulers] took {}ms", System.currentTimeMillis() - startTime);
}
Aggregations