/** * Creates a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss thread * @param bossCount * the maximum number of boss threads * @param workerPool * the {@link WorkerPool} to use to do the IO */ public NioClientSocketChannelFactory( Executor bossExecutor, int bossCount, WorkerPool<NioWorker> workerPool) { this(new NioClientBossPool(bossExecutor, bossCount), workerPool); }
/** * Create a new instance * * @param bossExecutor the Executor to use for server the {@link NioClientBoss} * @param bossCount the number of {@link NioClientBoss} instances this {@link NioClientBossPool} will hold * @param timer the Timer to use for handle connect timeouts * @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null} * if you not want to set one explicit. */ public NioClientBossPool(Executor bossExecutor, int bossCount, Timer timer, ThreadNameDeterminer determiner) { super(bossExecutor, bossCount, false); this.determiner = determiner; this.timer = timer; init(); }
clientBossPool.shutdown(); workerPool.shutdown(); sharedWorkerPool.shutdown();
/** * Creates a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss thread * @param bossCount * the maximum number of boss threads * @param workerPool * the {@link WorkerPool} to use to do the IO * @param timer * the {@link Timer} to use to handle the connection timeouts */ public NioClientSocketChannelFactory( Executor bossExecutor, int bossCount, WorkerPool<NioWorker> workerPool, Timer timer) { this(new NioClientBossPool(bossExecutor, bossCount, timer, null), workerPool); }
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) final NioClientBossPool bossPool = new NioClientBossPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
public NettyIoPool(String name, NettyIoPoolConfig config) { this.name = checkNotNull(name, "name is null"); checkNotNull(config, "config is null"); String prefix = "netty-client-" + name + "-io-"; this.hashedWheelTimer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat(prefix + "timer-%s").setDaemon(true).build()); // Give netty infinite thread "sources" for worker and boss. // Netty will name the threads and will size the pool appropriately this.bossExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat(prefix + "boss-%s").setDaemon(true).build()); this.workerExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat(prefix + "worker-%s").setDaemon(true).build()); this.bossPool = new NioClientBossPool(bossExecutor, config.getIoBossThreads(), hashedWheelTimer, ThreadNameDeterminer.CURRENT); this.workerPool = new NioWorkerPool(workerExecutor, config.getIoWorkerThreads(), ThreadNameDeterminer.CURRENT); }
/** * Creates a new boss pool. */ public BossPool build() { Timer internalTimer = timer; if (!stopTimer) { internalTimer = new UnstoppableTimer(timer); } return new NioClientBossPool(Executors.newCachedThreadPool(), bossCount, internalTimer, new CamelNettyThreadNameDeterminer(pattern, name)); }
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) final NioClientBossPool bossPool = new NioClientBossPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) final NioClientBossPool bossPool = new NioClientBossPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
new NioClientBossPool(executor, 1, newTimer(config, "Boss Pool"), new BossThreadNamer()); final int num_workers = config.hasProperty("hbase.workers.size") ?
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) final NioClientBossPool bossPool = new NioClientBossPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) final NioClientBossPool bossPool = new NioClientBossPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
private static ClientBootstrap createBootstrap(Lifecycle lifecycle, Timer timer, int bossPoolSize, int workerPoolSize) final NioClientBossPool bossPool = new NioClientBossPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
/** * Returns a {@link ClientBootstrap} instance for the named transport. */ @Override public synchronized ClientBootstrap newClientBootstrap() throws Exception { ClientSocketChannelFactory clientChannelFactory = this.clientChannelFactory; if (clientChannelFactory == null) { Executor bossExecutor = executorServiceFactory.newExecutorService("boss.client"); NioClientBossPool bossPool = new NioClientBossPool(bossExecutor, 1); Executor workerExecutor = executorServiceFactory.newExecutorService("worker.client"); NioWorkerPool workerPool = new NioWorkerPool(workerExecutor, 1); clientChannelFactory = new NioClientSocketChannelFactory(bossPool, workerPool); // unshared channelFactories.add(clientChannelFactory); } return new ClientBootstrap(clientChannelFactory) { @Override public ChannelFuture connect(final SocketAddress localAddress, final SocketAddress remoteAddress) { final InetSocketAddress localChannelAddress = toInetSocketAddress((ChannelAddress) localAddress); final InetSocketAddress remoteChannelAddress = toInetSocketAddress((ChannelAddress) remoteAddress); return super.connect(localChannelAddress, remoteChannelAddress); } }; }
ioExecutorService = Executors.newCachedThreadPool(); serverBossPool = new NioServerBossPool(ioExecutorService, 1); clientBossPool = new NioClientBossPool(ioExecutorService, 1); workerPool = new NioWorkerPool(ioExecutorService, 3);
ChannelAddress localAddress = addressFactory.newChannelAddress(controlURI, options); NioClientBossPool clientBossPool = new NioClientBossPool(newCachedThreadPool(), 1); NioServerBossPool serverBossPool = new NioServerBossPool(newCachedThreadPool(), 1); NioWorkerPool workerPool = new NioWorkerPool(newCachedThreadPool(), 1);
public NiftyClient(NettyClientConfig nettyClientConfig) { this.nettyClientConfig = nettyClientConfig; this.timer = nettyClientConfig.getTimer(); this.bossExecutor = nettyClientConfig.getBossExecutor(); this.workerExecutor = nettyClientConfig.getWorkerExecutor(); this.defaultSocksProxyAddress = nettyClientConfig.getDefaultSocksProxyAddress(); int bossThreadCount = nettyClientConfig.getBossThreadCount(); int workerThreadCount = nettyClientConfig.getWorkerThreadCount(); NioWorkerPool workerPool = new NioWorkerPool(workerExecutor, workerThreadCount, ThreadNameDeterminer.CURRENT); NioClientBossPool bossPool = new NioClientBossPool(bossExecutor, bossThreadCount, timer, ThreadNameDeterminer.CURRENT); this.channelFactory = new NioClientSocketChannelFactory(bossPool, workerPool); }
NioClientBossPool nioClientBossPool = new NioClientBossPool(e, 1, new HashedWheelTimer(), ThreadNameDeterminer.CURRENT); NioWorkerPool nioWorkerPool = new NioWorkerPool(config.getExecutorService(), numWorkers, ThreadNameDeterminer.CURRENT); socketChannelFactory = new NioClientSocketChannelFactory(nioClientBossPool, nioWorkerPool);