use of com.datatorrent.common.util.NameableThreadFactory in project apex-core by apache.
the class DefaultApexPluginDispatcher method serviceInit.
@Override
protected void serviceInit(Configuration conf) throws Exception {
super.serviceInit(conf);
LOG.debug("Creating plugin dispatch queue with size {}", qsize);
blockingQueue = new ArrayBlockingQueue<>(qsize);
RejectedExecutionHandler rejectionHandler = new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
try {
blockingQueue.remove();
executor.submit(r);
} catch (NoSuchElementException ex) {
// Ignore no-such element as queue may finish, while this handler is called.
}
}
};
executorService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, blockingQueue, new NameableThreadFactory("PluginExecutorThread"), rejectionHandler);
}
Aggregations