Search in sources :

Example 1 with NioClientSocketChannelFactory

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

Example 2 with NioClientSocketChannelFactory

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

the class DefaultPinpointClientFactory method createBootStrap.

private ClientBootstrap createBootStrap(int bossCount, int workerCount, Timer timer) {
    // profiler, collector,
    logger.debug("createBootStrap boss:{}, worker:{}", bossCount, workerCount);
    NioClientSocketChannelFactory nioClientSocketChannelFactory = createChannelFactory(bossCount, workerCount, timer);
    return new ClientBootstrap(nioClientSocketChannelFactory);
}
Also used : NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap)

Example 3 with NioClientSocketChannelFactory

use of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory in project neo4j by neo4j.

the class NetworkSender method start.

@Override
public void start() throws Throwable {
    channels = new DefaultChannelGroup();
    // Start client bootstrap
    clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newSingleThreadExecutor(daemon("Cluster client boss", monitor)), Executors.newFixedThreadPool(2, daemon("Cluster client worker", monitor)), 2));
    clientBootstrap.setOption("tcpNoDelay", true);
    clientBootstrap.setPipelineFactory(new NetworkNodePipelineFactory());
    msgLog.debug("Started NetworkSender for " + toString(config));
}
Also used : DefaultChannelGroup(org.jboss.netty.channel.group.DefaultChannelGroup) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap)

Example 4 with NioClientSocketChannelFactory

use of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory 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 5 with NioClientSocketChannelFactory

use of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory in project camel by apache.

the class ClientModeTCPNettyServerBootstrapFactory method startServerBootstrap.

protected void startServerBootstrap() {
    // prefer using explicit configured thread pools
    BossPool bp = configuration.getBossPool();
    WorkerPool wp = configuration.getWorkerPool();
    if (bp == null) {
        // create new pool which we should shutdown when stopping as its not shared
        bossPool = new NettyClientBossPoolBuilder().withTimer(new HashedWheelTimer()).withBossCount(configuration.getBossCount()).withName("NettyClientTCPBoss").build();
        bp = bossPool;
    }
    if (wp == null) {
        // create new pool which we should shutdown when stopping as its not shared
        workerPool = new NettyWorkerPoolBuilder().withWorkerCount(configuration.getWorkerCount()).withName("NettyServerTCPWorker").build();
        wp = workerPool;
    }
    channelFactory = new NioClientSocketChannelFactory(bp, wp);
    serverBootstrap = new ClientBootstrap(channelFactory);
    serverBootstrap.setOption("keepAlive", configuration.isKeepAlive());
    serverBootstrap.setOption("tcpNoDelay", configuration.isTcpNoDelay());
    serverBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
    serverBootstrap.setOption("connectTimeoutMillis", configuration.getConnectTimeout());
    if (configuration.getBacklog() > 0) {
        serverBootstrap.setOption("backlog", configuration.getBacklog());
    }
    // set any additional netty options
    if (configuration.getOptions() != null) {
        for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
            serverBootstrap.setOption(entry.getKey(), entry.getValue());
        }
    }
    LOG.debug("Created ServerBootstrap {} with options: {}", serverBootstrap, serverBootstrap.getOptions());
    // set the pipeline factory, which creates the pipeline for each newly created channels
    serverBootstrap.setPipelineFactory(pipelineFactory);
    LOG.info("ServerBootstrap connecting to {}:{}", configuration.getHost(), configuration.getPort());
    ChannelFuture connectFuture = serverBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
    try {
        channel = openChannel(connectFuture);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) CamelException(org.apache.camel.CamelException) ConnectException(java.net.ConnectException) BossPool(org.jboss.netty.channel.socket.nio.BossPool) WorkerPool(org.jboss.netty.channel.socket.nio.WorkerPool) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) Map(java.util.Map)

Aggregations

NioClientSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory)25 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)19 InetSocketAddress (java.net.InetSocketAddress)11 ChannelFuture (org.jboss.netty.channel.ChannelFuture)9 NioClientBossPool (org.jboss.netty.channel.socket.nio.NioClientBossPool)5 NioWorkerPool (org.jboss.netty.channel.socket.nio.NioWorkerPool)5 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 ExecutorService (java.util.concurrent.ExecutorService)3 ThreadFactory (java.util.concurrent.ThreadFactory)3 Channel (org.jboss.netty.channel.Channel)3 ChannelFactory (org.jboss.netty.channel.ChannelFactory)3 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)3 BossPool (org.jboss.netty.channel.socket.nio.BossPool)3 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)3 WorkerPool (org.jboss.netty.channel.socket.nio.WorkerPool)3 HashedWheelTimer (org.jboss.netty.util.HashedWheelTimer)3 ClientPipelineFactory (org.mobicents.tools.heartbeat.client.ClientPipelineFactory)3 DefaultHttpRequest (org.jboss.netty.handler.codec.http.DefaultHttpRequest)2 HttpRequest (org.jboss.netty.handler.codec.http.HttpRequest)2 Slf4JLoggerFactory (org.jboss.netty.logging.Slf4JLoggerFactory)2