private final ConcurrentMap<String, ManagedExecutorService> executors
= new ConcurrentHashMap<String, ManagedExecutorService>();
public ExecutionServiceImpl(NodeEngineImpl nodeEngine) {
this.nodeEngine = nodeEngine;
final Node node = nodeEngine.getNode();
logger = node.getLogger(ExecutionService.class.getName());
final ClassLoader classLoader = node.getConfigClassLoader();
final ThreadFactory threadFactory = new PoolExecutorThreadFactory(node.threadGroup,
node.getThreadPoolNamePrefix("cached"), classLoader);
cachedExecutorService = new ThreadPoolExecutor(
3, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(), threadFactory, new RejectedExecutionHandler() {
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (logger.isFinestEnabled()) {
logger.finest( "Node is shutting down; discarding the task: " + r);
}
}
});
final String scheduledThreadName = node.getThreadNamePrefix("scheduled");
scheduledExecutorService = new ScheduledThreadPoolExecutor(1, new SingleExecutorThreadFactory(node.threadGroup, classLoader, scheduledThreadName));
enableRemoveOnCancelIfAvailable();
final int coreSize = Runtime.getRuntime().availableProcessors();
// default executors