/** * Create a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss threads * @param bossCount * the number of boss threads * @param workerExecutor * the {@link Executor} which will execute the I/O worker threads * @param workerCount * the maximum number of I/O worker threads */ public NioServerSocketChannelFactory( Executor bossExecutor, int bossCount, Executor workerExecutor, int workerCount) { this(bossExecutor, bossCount, new NioWorkerPool(workerExecutor, workerCount)); }
public NioWorkerPool(Executor workerExecutor, int workerCount, ThreadNameDeterminer determiner) { super(workerExecutor, workerCount, false); this.determiner = determiner; init(); }
workerPool.shutdown(); sharedWorkerPool.shutdown(); sharedWorkerPool.destroy();
/** * Creates a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss thread * @param workerExecutor * the {@link Executor} which will execute the worker threads * @param bossCount * the maximum number of boss threads * @param workerCount * the maximum number of I/O worker threads */ public NioClientSocketChannelFactory( Executor bossExecutor, Executor workerExecutor, int bossCount, int workerCount) { this(bossExecutor, bossCount, new NioWorkerPool(workerExecutor, workerCount)); }
public NioWorkerPool(Executor workerExecutor, int workerCount, ThreadNameDeterminer determiner) { super(workerExecutor, workerCount, false); this.determiner = determiner; init(); }
); final NioWorkerPool workerPool = new NioWorkerPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
/** * Creates a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss thread * @param workerExecutor * the {@link Executor} which will execute the worker threads * @param bossCount * the maximum number of boss threads * @param workerCount * the maximum number of I/O worker threads */ public NioClientSocketChannelFactory( Executor bossExecutor, Executor workerExecutor, int bossCount, int workerCount) { this(bossExecutor, bossCount, new NioWorkerPool(workerExecutor, workerCount)); }
/** * Create a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss threads * @param bossCount * the number of boss threads * @param workerExecutor * the {@link Executor} which will execute the I/O worker threads * @param workerCount * the maximum number of I/O worker threads */ public NioServerSocketChannelFactory( Executor bossExecutor, int bossCount, Executor workerExecutor, int workerCount) { this(bossExecutor, bossCount, new NioWorkerPool(workerExecutor, workerCount)); }
public NioWorkerPool getWorkerPool() { //This is a correct implementation of double-checked locking idiom NioWorkerPool result = workerPool; if (result == null) { synchronized (this) { result = workerPool; if (result == null) { ExecutorService corePool = Executors.newFixedThreadPool(corePoolSize, new VertxThreadFactory("vert.x-core-thread-")); workerPool = result = new NioWorkerPool(corePool, corePoolSize); } } } return result; }
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 worker pool. */ public WorkerPool build() { int count = workerCount > 0 ? workerCount : NettyHelper.DEFAULT_IO_THREADS; workerPool = new NioWorkerPool(Executors.newCachedThreadPool(), count, new CamelNettyThreadNameDeterminer(pattern, name)); return workerPool; } }
NioWorkerPool workerPool = new NioWorkerPool(Executors.newCachedThreadPool(), 20, new ThreadNameDeterminer() { @Override public String determineThreadName(String currentThreadName,String proposedThreadName) throws Exception {
public void start() { bossExecutor = nettyServerConfig.getBossExecutor(); int bossThreadCount = nettyServerConfig.getBossThreadCount(); ioWorkerExecutor = nettyServerConfig.getWorkerExecutor(); int ioWorkerThreadCount = nettyServerConfig.getWorkerThreadCount(); channelFactory = new NioServerSocketChannelFactory(new NioServerBossPool(bossExecutor, bossThreadCount, ThreadNameDeterminer.CURRENT), new NioWorkerPool(ioWorkerExecutor, ioWorkerThreadCount, ThreadNameDeterminer.CURRENT)); start(channelFactory); }
/** * Returns a {@link ServerBootstrap} instance for the named transport. */ @Override public synchronized ServerBootstrap newServerBootstrap() throws Exception { ServerSocketChannelFactory serverChannelFactory = this.serverChannelFactory; if (serverChannelFactory == null) { Executor bossExecutor = executorServiceFactory.newExecutorService("boss.server"); NioServerBossPool bossPool = new NioServerBossPool(bossExecutor, 1); Executor workerExecutor = executorServiceFactory.newExecutorService("worker.server"); NioWorkerPool workerPool = new NioWorkerPool(workerExecutor, 1); serverChannelFactory = new NioServerSocketChannelFactory(bossPool, workerPool); // unshared channelFactories.add(serverChannelFactory); } return new ServerBootstrap(serverChannelFactory) { @Override public ChannelFuture bindAsync(SocketAddress localAddress) { return super.bindAsync(toInetSocketAddress(localAddress)); } }; }
); final NioWorkerPool workerPool = new NioWorkerPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
); final NioWorkerPool workerPool = new NioWorkerPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
); final NioWorkerPool workerPool = new NioWorkerPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
); final NioWorkerPool workerPool = new NioWorkerPool( Executors.newCachedThreadPool( new ThreadFactoryBuilder()
config.getInt("hbase.workers.size") : Runtime.getRuntime().availableProcessors() * 2; final NioWorkerPool worker_pool = new NioWorkerPool(executor, num_workers, new WorkerThreadNamer()); return new NioClientSocketChannelFactory(boss_pool, worker_pool);