/** * 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); }
/** * Create a new instance * * @param bossExecutor the {@link Executor} to use for server the {@link NioServerBoss} * @param bossCount the number of {@link NioServerBoss} instances this {@link NioServerBossPool} will hold * @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null} * if you not want to set one explicit. */ public NioServerBossPool(Executor bossExecutor, int bossCount, ThreadNameDeterminer determiner) { super(bossExecutor, bossCount, false); this.determiner = determiner; init(); }
raftNetworkClient.stop(); serverBossPool.shutdown(); clientBossPool.shutdown(); workerPool.shutdown();
/** * 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);