use of com.vip.saturn.job.threads.SaturnThreadFactory in project Saturn by vipshop.
the class RestartAndDumpService method initRestart.
private void initRestart() throws Exception {
restartES = Executors.newSingleThreadExecutor(new SaturnThreadFactory(executorName + "-restart-watcher-thread", false));
// Remove the restart node, before add watcher that watches the create and update event
String nodePath = SaturnExecutorsNode.EXECUTORS_ROOT + "/" + executorName + "/restart";
coordinatorRegistryCenter.remove(nodePath);
restartNC = new NodeCache(curatorFramework, nodePath);
restartNC.getListenable().addListener(new NodeCacheListener() {
@Override
public void nodeChanged() throws Exception {
// Watch create, update event
if (restartNC.getCurrentData() != null) {
LogUtils.info(log, LogEvents.ExecutorEvent.RESTART, "The executor {} restart event is received", executorName);
restartES.execute(new Runnable() {
@Override
public void run() {
executeRestartOrDumpCmd("restart", LogEvents.ExecutorEvent.RESTART);
}
});
}
}
});
// Start, with not buildInitial.
// The initial data is null, so the create event will be triggered firstly.
restartNC.start(false);
}
use of com.vip.saturn.job.threads.SaturnThreadFactory in project Saturn by vipshop.
the class JobScheduler method initExecutorService.
private void initExecutorService() {
ThreadFactory factory = new SaturnThreadFactory(jobName);
executorService = new ExtendableThreadPoolExecutor(0, 100, 2, TimeUnit.MINUTES, new TaskQueue(), factory);
}
use of com.vip.saturn.job.threads.SaturnThreadFactory in project Saturn by vipshop.
the class TimeoutSchedulerExecutor method createScheduler.
public static synchronized ScheduledThreadPoolExecutor createScheduler(String executorName) {
if (!scheduledThreadPoolExecutorMap.containsKey(executorName)) {
ScheduledThreadPoolExecutor timeoutExecutor = new ScheduledThreadPoolExecutor(Math.max(2, Runtime.getRuntime().availableProcessors() / 2), new SaturnThreadFactory(executorName + "-timeout-watchdog", false));
timeoutExecutor.setRemoveOnCancelPolicy(true);
scheduledThreadPoolExecutorMap.put(executorName, timeoutExecutor);
return timeoutExecutor;
}
return scheduledThreadPoolExecutorMap.get(executorName);
}
Aggregations