use of org.apache.druid.java.util.http.client.netty.HttpClientPipelineFactory in project druid by druid-io.
the class HttpClientInit method createBootstrap.
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) {
final NioClientBossPool bossPool = new NioClientBossPool(Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("HttpClient-Netty-Boss-%s").build()), bossPoolSize, timer, ThreadNameDeterminer.CURRENT);
final NioWorkerPool workerPool = new NioWorkerPool(Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("HttpClient-Netty-Worker-%s").build()), workerPoolSize, ThreadNameDeterminer.CURRENT);
final ClientBootstrap bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(bossPool, workerPool));
bootstrap.setOption("keepAlive", true);
bootstrap.setPipelineFactory(new HttpClientPipelineFactory());
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
try {
lifecycle.addMaybeStartHandler(new Lifecycle.Handler() {
@Override
public void start() {
}
@Override
public void stop() {
bootstrap.releaseExternalResources();
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
return bootstrap;
}
Aggregations