Search in sources :

Example 1 with NioClientBossPool

use of org.jboss.netty.channel.socket.nio.NioClientBossPool 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);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer)

Example 2 with NioClientBossPool

use of org.jboss.netty.channel.socket.nio.NioClientBossPool in project cdap by caskdata.

the class NettyRouter method bootstrapClient.

private void bootstrapClient(final ChannelUpstreamHandler connectionTracker) {
    ExecutorService clientBossExecutor = createExecutorService(clientBossThreadPoolSize, "router-client-boss-thread-%d");
    ExecutorService clientWorkerExecutor = createExecutorService(clientWorkerThreadPoolSize, "router-client-worker-thread-%d");
    clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(new NioClientBossPool(clientBossExecutor, clientBossThreadPoolSize), new NioWorkerPool(clientWorkerExecutor, clientWorkerThreadPoolSize)));
    ChannelPipelineFactory pipelineFactory = new ClientChannelPipelineFactory(connectionTracker, connectionTimeout, timer);
    clientBootstrap.setPipelineFactory(pipelineFactory);
    clientBootstrap.setOption("bufferFactory", new DirectChannelBufferFactory());
}
Also used : NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) ExecutorService(java.util.concurrent.ExecutorService) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) DirectChannelBufferFactory(org.jboss.netty.buffer.DirectChannelBufferFactory)

Example 3 with NioClientBossPool

use of org.jboss.netty.channel.socket.nio.NioClientBossPool in project pinpoint by naver.

the class ClientChannelFactory method createChannelFactory.

public ChannelFactory createChannelFactory(int bossCount, int workerCount, Timer timer) {
    ExecutorService boss = newCachedThreadPool("Pinpoint-Client-Boss");
    BossPool bossPool = new NioClientBossPool(boss, bossCount, timer, ThreadNameDeterminer.CURRENT);
    ExecutorService worker = newCachedThreadPool("Pinpoint-Client-Worker");
    WorkerPool workerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
    return new NioClientSocketChannelFactory(bossPool, workerPool);
}
Also used : BossPool(org.jboss.netty.channel.socket.nio.BossPool) NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) WorkerPool(org.jboss.netty.channel.socket.nio.WorkerPool) NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ExecutorService(java.util.concurrent.ExecutorService)

Example 4 with NioClientBossPool

use of org.jboss.netty.channel.socket.nio.NioClientBossPool 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;
}
Also used : NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) Lifecycle(org.apache.druid.java.util.common.lifecycle.Lifecycle) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) HttpClientPipelineFactory(org.apache.druid.java.util.http.client.netty.HttpClientPipelineFactory) Slf4JLoggerFactory(org.jboss.netty.logging.Slf4JLoggerFactory)

Example 5 with NioClientBossPool

use of org.jboss.netty.channel.socket.nio.NioClientBossPool in project pinpoint by naver.

the class DefaultPinpointClientFactory method createChannelFactory.

private NioClientSocketChannelFactory createChannelFactory(int bossCount, int workerCount, Timer timer) {
    ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Client-Boss", true));
    NioClientBossPool bossPool = new NioClientBossPool(boss, bossCount, timer, ThreadNameDeterminer.CURRENT);
    ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Client-Worker", true));
    NioWorkerPool workerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
    return new NioClientSocketChannelFactory(bossPool, workerPool);
}
Also used : NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ExecutorService(java.util.concurrent.ExecutorService) PinpointThreadFactory(com.navercorp.pinpoint.common.util.PinpointThreadFactory)

Aggregations

NioClientBossPool (org.jboss.netty.channel.socket.nio.NioClientBossPool)5 NioClientSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory)5 NioWorkerPool (org.jboss.netty.channel.socket.nio.NioWorkerPool)5 ExecutorService (java.util.concurrent.ExecutorService)3 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 PinpointThreadFactory (com.navercorp.pinpoint.common.util.PinpointThreadFactory)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 Lifecycle (org.apache.druid.java.util.common.lifecycle.Lifecycle)1 HttpClientPipelineFactory (org.apache.druid.java.util.http.client.netty.HttpClientPipelineFactory)1 DirectChannelBufferFactory (org.jboss.netty.buffer.DirectChannelBufferFactory)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1 BossPool (org.jboss.netty.channel.socket.nio.BossPool)1 WorkerPool (org.jboss.netty.channel.socket.nio.WorkerPool)1 Slf4JLoggerFactory (org.jboss.netty.logging.Slf4JLoggerFactory)1 HashedWheelTimer (org.jboss.netty.util.HashedWheelTimer)1