use of java.util.concurrent.ThreadFactory in project storm by apache.
the class Context method prepare.
/**
* initialization per Storm configuration
*/
@SuppressWarnings("rawtypes")
public void prepare(Map storm_conf) {
this.storm_conf = storm_conf;
connections = new HashMap<>();
//each context will have a single client channel factory
int maxWorkers = Utils.getInt(storm_conf.get(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS));
ThreadFactory bossFactory = new NettyRenameThreadFactory("client" + "-boss");
ThreadFactory workerFactory = new NettyRenameThreadFactory("client" + "-worker");
if (maxWorkers > 0) {
clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory), Executors.newCachedThreadPool(workerFactory), maxWorkers);
} else {
clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory), Executors.newCachedThreadPool(workerFactory));
}
clientScheduleService = new HashedWheelTimer(new NettyRenameThreadFactory("client-schedule-service"));
}
use of java.util.concurrent.ThreadFactory in project weave by continuuity.
the class SimpleKafkaClient method startUp.
@Override
protected void startUp() throws Exception {
brokerCache.startAndWait();
ThreadFactory threadFactory = Threads.createDaemonThreadFactory("kafka-client-netty-%d");
NioClientBossPool bossPool = new NioClientBossPool(Executors.newSingleThreadExecutor(threadFactory), 1, new HashedWheelTimer(threadFactory), null);
NioWorkerPool workerPool = new NioWorkerPool(Executors.newFixedThreadPool(4, threadFactory), 4);
bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(bossPool, workerPool));
bootstrap.setPipelineFactory(new KafkaChannelPipelineFactory());
connectionPool = new ConnectionPool(bootstrap);
}
use of java.util.concurrent.ThreadFactory in project dropwizard by dropwizard.
the class LifecycleEnvironmentTest method executorServiceThreadFactory.
@Test
public void executorServiceThreadFactory() throws ExecutionException, InterruptedException {
final String expectedName = "DropWizard ThreadFactory Test";
final String expectedNamePattern = expectedName + "-%d";
final ThreadFactory tfactory = (new ThreadFactoryBuilder()).setDaemon(false).setNameFormat(expectedNamePattern).build();
final ExecutorService executorService = environment.executorService("Dropwizard Service", tfactory).build();
final Future<Boolean> isFactoryInUse = executorService.submit(() -> Thread.currentThread().getName().startsWith(expectedName));
assertThat(isFactoryInUse.get()).isTrue();
}
use of java.util.concurrent.ThreadFactory in project jetty.project by eclipse.
the class ScheduledExecutorScheduler method doStart.
@Override
protected void doStart() throws Exception {
scheduler = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread thread = ScheduledExecutorScheduler.this.thread = new Thread(threadGroup, r, name);
thread.setDaemon(daemon);
thread.setContextClassLoader(classloader);
return thread;
}
});
scheduler.setRemoveOnCancelPolicy(true);
super.doStart();
}
use of java.util.concurrent.ThreadFactory in project elasticsearch by elastic.
the class FixedExecutorBuilder method build.
@Override
ThreadPool.ExecutorHolder build(final FixedExecutorSettings settings, final ThreadContext threadContext) {
int size = settings.size;
int queueSize = settings.queueSize;
final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(EsExecutors.threadName(settings.nodeName, name()));
final ExecutorService executor = EsExecutors.newFixed(name(), size, queueSize, threadFactory, threadContext);
final ThreadPool.Info info = new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.FIXED, size, size, null, queueSize < 0 ? null : new SizeValue(queueSize));
return new ThreadPool.ExecutorHolder(executor, info);
}
Aggregations