public EventLoopGroup workerGroup() { return channelConfiguration.workerGroup(); }
public XioServer build() { log.debug("Building"); serverBootstrap.group(channelConfig.bossGroup(), channelConfig.workerGroup()); serverBootstrap.channel(channelConfig.channel()); final XioServerInstrumentation instrumentation = new XioServerInstrumentation(); serverBootstrap.childHandler(pipelineAssembler.build(instrumentation)); ChannelFuture future = serverBootstrap.bind(); future.awaitUninterruptibly(); if (future.isSuccess()) { instrumentation.addressBound = (InetSocketAddress) future.channel().localAddress(); } else { log.error("Couldn't bind channel", future.cause()); throw new RuntimeException(future.cause()); } return new XioServer(future.channel(), instrumentation, config, state); } }
/** * This method will configure a boss EventLoopGroup, a worker EventLoopGroup and a ServerChannel * for use by a server. It will try to use Epoll if it's available. * * @param bossThreads spawn in number of boss threads * @param bossNameFormat uses String to the boss thread names * @param workerThreads spawn int number of worker threads * @param workerNameFormat uses String to set the worker thread names * @return ClientChannelConfiguration */ public static ServerChannelConfiguration serverConfig( int bossThreads, String bossNameFormat, int workerThreads, String workerNameFormat) { EventLoopGroup bossGroup; EventLoopGroup workerGroup; Class<? extends ServerChannel> channelClass; if (Epoll.isAvailable()) { bossGroup = new EpollEventLoopGroup(bossThreads, threadFactory(bossNameFormat)); workerGroup = new EpollEventLoopGroup(workerThreads, threadFactory(workerNameFormat)); channelClass = EpollServerSocketChannel.class; } else { bossGroup = new NioEventLoopGroup(bossThreads, threadFactory(bossNameFormat)); workerGroup = new NioEventLoopGroup(workerThreads, threadFactory(workerNameFormat)); channelClass = NioServerSocketChannel.class; } return new ServerChannelConfiguration(bossGroup, workerGroup, channelClass); } }