/** * Create a new instance. * * @param bossExecutor * the {@link Executor} which will execute the boss threads * @param bossCount * the number of boss threads * @param workerPool * the {@link WorkerPool} which will be used to obtain the {@link NioWorker} that execute * the I/O worker threads */ public NioServerSocketChannelFactory( Executor bossExecutor, int bossCount, WorkerPool<NioWorker> workerPool) { this(new NioServerBossPool(bossExecutor, bossCount, null), workerPool); }
/** * Creates a new boss pool. */ public BossPool build() { return new NioServerBossPool(Executors.newCachedThreadPool(), bossCount, new CamelNettyThreadNameDeterminer(pattern, name)); } }
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)); } }; }
serverBossPool = new NioServerBossPool(ioExecutorService, 1); clientBossPool = new NioClientBossPool(ioExecutorService, 1); workerPool = new NioWorkerPool(ioExecutorService, 3);
NioServerBossPool serverBossPool = new NioServerBossPool(newCachedThreadPool(), 1); NioWorkerPool workerPool = new NioWorkerPool(newCachedThreadPool(), 1); sharedWorkerPool = new ShareableWorkerPool<>(workerPool);