List of usage examples for io.netty.channel ChannelOption SO_RCVBUF
ChannelOption SO_RCVBUF
To view the source code for io.netty.channel ChannelOption SO_RCVBUF.
Click Source Link
From source file:com.diwayou.hybrid.remoting.netty.NettyRemotingClient.java
License:Apache License
@Override public void start() { this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(// nettyClientConfig.getClientWorkerThreads(), // new ThreadFactory() { private AtomicInteger threadIndex = new AtomicInteger(0); @Override//from ww w . j a v a 2s. c om public Thread newThread(Runnable r) { return new Thread(r, "NettyClientWorkerThread_" + this.threadIndex.incrementAndGet()); } }); Bootstrap handler = this.bootstrap.group(this.eventLoopGroupWorker).channel(NioSocketChannel.class)// // .option(ChannelOption.TCP_NODELAY, true) // .option(ChannelOption.SO_KEEPALIVE, false) // .option(ChannelOption.SO_SNDBUF, nettyClientConfig.getClientSocketSndBufSize()) // .option(ChannelOption.SO_RCVBUF, nettyClientConfig.getClientSocketRcvBufSize()) // .handler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(// defaultEventExecutorGroup, // new NettyEncoder(), // new NettyDecoder(), // new IdleStateHandler(0, 0, nettyClientConfig.getClientChannelMaxIdleTimeSeconds()), // new NettyConnetManageHandler(), // new NettyClientHandler()); } }); // ?1?? this.timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { NettyRemotingClient.this.scanResponseTable(); } catch (Exception e) { log.error("scanResponseTable exception", e); } } }, 1000 * 3, 1000); if (this.channelEventListener != null) { this.nettyEventExecuter.start(); } }
From source file:com.diwayou.hybrid.remoting.netty.NettyRemotingServer.java
License:Apache License
@Override public void start() { this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(// nettyServerConfig.getServerWorkerThreads(), // new ThreadFactory() { private AtomicInteger threadIndex = new AtomicInteger(0); @Override/* w ww . j ava 2 s. c o m*/ public Thread newThread(Runnable r) { return new Thread(r, "NettyServerWorkerThread_" + this.threadIndex.incrementAndGet()); } }); ServerBootstrap childHandler = // this.serverBootstrap.group(this.eventLoopGroupBoss, this.eventLoopGroupWorker) .channel(NioServerSocketChannel.class) // .option(ChannelOption.SO_BACKLOG, 1024) // .option(ChannelOption.SO_REUSEADDR, true) // .option(ChannelOption.SO_KEEPALIVE, false) // .childOption(ChannelOption.TCP_NODELAY, true) // .option(ChannelOption.SO_SNDBUF, nettyServerConfig.getServerSocketSndBufSize()) // .option(ChannelOption.SO_RCVBUF, nettyServerConfig.getServerSocketRcvBufSize()) // .localAddress(new InetSocketAddress(this.nettyServerConfig.getListenPort())) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast( // defaultEventExecutorGroup, // new NettyEncoder(), // new NettyDecoder(), // new IdleStateHandler(0, 0, nettyServerConfig.getServerChannelMaxIdleTimeSeconds()), // new NettyConnetManageHandler(), // new NettyServerHandler()); } }); if (nettyServerConfig.isServerPooledByteBufAllocatorEnable()) { // ???? childHandler.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); } try { ChannelFuture sync = this.serverBootstrap.bind().sync(); InetSocketAddress addr = (InetSocketAddress) sync.channel().localAddress(); this.port = addr.getPort(); } catch (InterruptedException e1) { throw new RuntimeException("this.serverBootstrap.bind().sync() InterruptedException", e1); } if (this.channelEventListener != null) { this.nettyEventExecuter.start(); } // ?1?? this.timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { NettyRemotingServer.this.scanResponseTable(); } catch (Exception e) { log.error("scanResponseTable exception", e); } } }, 1000 * 3, 1000); }
From source file:com.ebay.jetstream.http.netty.client.HttpClient.java
License:MIT License
private void createChannelPipeline() { if (isPipelineCreated()) return;//from www . j a v a 2s . c om m_workerGroup = new NioEventLoopGroup(getConfig().getNumWorkers(), new NameableThreadFactory("Jetstream-HttpClientWorker")); m_bootstrap = new Bootstrap(); m_bootstrap.group(m_workerGroup).channel(NioSocketChannel.class).option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.SO_KEEPALIVE, false) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, getConfig().getConnectionTimeoutInSecs()) .handler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("timeout", new IdleStateHandler(0, getConfig().getIdleTimeoutInSecs(), 0)); ch.pipeline().addLast("decoder", new HttpResponseDecoder()); ch.pipeline().addLast("decompressor", new HttpContentDecompressor()); ch.pipeline().addLast("encoder", new HttpRequestEncoder()); ch.pipeline().addLast("aggregator", new HttpObjectAggregator(m_config.getMaxContentLength())); ch.pipeline().addLast(m_httpRequestHandler); } }); if (getConfig().getRvcBufSz() > 0) { m_bootstrap.option(ChannelOption.SO_RCVBUF, (int) getConfig().getRvcBufSz()); } if (getConfig().getSendBufSz() > 0) { m_bootstrap.option(ChannelOption.SO_SNDBUF, (int) getConfig().getSendBufSz()); } createdPipeline(); }
From source file:com.ebay.jetstream.http.netty.server.Acceptor.java
License:MIT License
/** * @param rxSessionHandler/*from www .ja v a2 s.co m*/ * @throws Exception */ public void bind(final HttpRequestHandler httpReqHandler, final HttpServerStatisticsHandler statisticsHandler) throws Exception { m_bossGroup = new NioEventLoopGroup(1, new NameableThreadFactory("NettyHttpServerAcceptor")); m_workerGroup = new NioEventLoopGroup(m_numIoProcessors, new NameableThreadFactory("NettyHttpServerWorker")); try { m_serverbootstrap = new ServerBootstrap(); m_serverbootstrap.group(m_bossGroup, m_workerGroup).channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("timeout", new IdleStateHandler((int) m_readIdleTimeout, 0, 0)); ch.pipeline().addLast("stats", statisticsHandler); ch.pipeline().addLast("decoder", new HttpRequestDecoder()); ch.pipeline().addLast("encoder", new HttpResponseEncoder()); ch.pipeline().addLast("decompressor", new HttpContentDecompressor()); ch.pipeline().addLast("deflater", new HttpContentCompressor(1)); ch.pipeline().addLast("aggregator", new HttpObjectAggregator(m_maxContentLength)); if (m_maxKeepAliveRequests > 0 || m_maxKeepAliveTimeout > 0) { ch.pipeline().addLast("keepAliveHandler", new KeepAliveHandler(m_maxKeepAliveRequests, m_maxKeepAliveTimeout)); } ch.pipeline().addLast("handler", httpReqHandler); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.SO_KEEPALIVE, false); if (m_config.getRvcBufSz() > 0) { m_serverbootstrap.childOption(ChannelOption.SO_RCVBUF, (int) m_config.getRvcBufSz()); } if (m_config.getSendBufSz() > 0) { m_serverbootstrap.childOption(ChannelOption.SO_SNDBUF, (int) m_config.getSendBufSz()); } } catch (Exception t) { throw t; } m_acceptorSocket = new InetSocketAddress(m_ipAddress, m_tcpPort); m_serverbootstrap.bind(m_acceptorSocket).sync(); if (!m_ipAddress.isLoopbackAddress() && !m_ipAddress.isAnyLocalAddress()) { // Add lookback if not bind m_localAcceptorSocket = new InetSocketAddress("127.0.0.1", m_tcpPort); m_serverbootstrap.bind(m_localAcceptorSocket).sync(); } }
From source file:com.ebay.jetstream.messaging.transport.netty.eventconsumer.Acceptor.java
License:MIT License
/** * @param rxSessionHandler/* w ww . j ava 2 s. co m*/ * @throws Exception */ public void bind(EventProducerSessionHandler rxSessionHandler) throws Exception { m_rxSessionHandler = rxSessionHandler; m_bossGroup = new NioEventLoopGroup(1, new NameableThreadFactory("NettyAcceptor-" + m_tc.getTransportName())); m_workerGroup = new NioEventLoopGroup(m_numIoProcessors, new NameableThreadFactory("NettyReceiver-" + m_tc.getTransportName())); try { m_serverbootstrap = new ServerBootstrap(); m_serverbootstrap.group(m_bossGroup, m_workerGroup).channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addFirst("msghandler", m_rxSessionHandler); StreamMessageDecoder decoder = new StreamMessageDecoder( ClassResolvers.weakCachingConcurrentResolver(null)); ch.pipeline().addBefore("msghandler", "msgdecoder", decoder); ch.pipeline().addBefore("msgdecoder", "kryoEcnoder", new KryoObjectEncoder()); ch.pipeline().addBefore("kryoEcnoder", "msgencoder", new NettyObjectEncoder()); if (m_enableCompression) { ch.pipeline().addBefore("msgencoder", "decompressor", new MessageDecompressionHandler(false, 250000)); ch.pipeline().addBefore("decompressor", "idleTimeoutHandler", new IdleStateHandler((int) m_readIdleTimeout, 0, 0)); } else ch.pipeline().addBefore("msgencoder", "idleTimeoutHandler", new IdleStateHandler((int) m_readIdleTimeout, 0, 0)); } }).option(ChannelOption.SO_BACKLOG, 128) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000) .childOption(ChannelOption.SO_KEEPALIVE, isTcpKeepAlive()); if (m_tc.getReceivebuffersize() > 0) { m_serverbootstrap.childOption(ChannelOption.SO_RCVBUF, m_tc.getReceivebuffersize()); } if (m_tc.getSendbuffersize() > 0) { m_serverbootstrap.childOption(ChannelOption.SO_SNDBUF, m_tc.getSendbuffersize()); } } catch (Exception t) { throw t; } // we are given a port from DNS. We will check if it is taken. If it is // we will increment the port # by 10 and keep trying 10 times. // adding this feature so that we can operate the cluster on a single // node. Very useful for debugging and also for demos. int retryCount = 20; int port = m_tcpPort; while (retryCount-- > 0) { if (isPortAvailable(port)) break; port += 1; } if (retryCount == 0) return; // we did not find a port to bind m_tcpPort = port; LOGGER.info("Acceptor bound to port" + m_tcpPort); }
From source file:com.ebay.jetstream.messaging.transport.netty.eventproducer.EventProducer.java
License:MIT License
/** * //from w w w .j a v a2 s . c om */ private void createChannelPipeline() { m_group = new NioEventLoopGroup(m_transportConfig.getNumConnectorIoProcessors(), new NameableThreadFactory("NettySender-" + m_transportConfig.getTransportName())); m_bootstrap = new Bootstrap(); m_bootstrap.group(m_group).channel(NioSocketChannel.class).option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.SO_KEEPALIVE, m_transportConfig.getTcpKeepAlive()) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, m_transportConfig.getConnectionTimeoutInSecs() * 1000) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .handler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { StreamMessageDecoder decoder = new StreamMessageDecoder(ClassResolvers.cacheDisabled(null)); if (m_autoFlushHandler != null) { ch.pipeline().addLast(new EventConsumerStatisticsHandler(), new MessageCompressionHandler(), new IdleStateHandler(m_transportConfig.getIdleTimeoutInSecs(), 0, 0), m_autoFlushHandler, decoder, new NettyObjectEncoder(), new KryoObjectEncoder(), m_ecSessionHandler); } else { ch.pipeline().addLast(new EventConsumerStatisticsHandler(), new MessageCompressionHandler(), decoder, new NettyObjectEncoder(), new KryoObjectEncoder(), m_ecSessionHandler); } } }); if (m_transportConfig.getReceivebuffersize() > 0) { m_bootstrap.option(ChannelOption.SO_RCVBUF, m_transportConfig.getReceivebuffersize()); } if (m_transportConfig.getSendbuffersize() > 0) { m_bootstrap.option(ChannelOption.SO_SNDBUF, m_transportConfig.getSendbuffersize()); } }
From source file:com.gemstone.gemfire.redis.GemFireRedisServer.java
License:Apache License
/** * Helper method to start the server listening for connections. The * server is bound to the port specified by {@link GemFireRedisServer#serverPort} * // w w w. j a v a 2 s.co m * @throws IOException * @throws InterruptedException */ private void startRedisServer() throws IOException, InterruptedException { ThreadFactory selectorThreadFactory = new ThreadFactory() { private final AtomicInteger counter = new AtomicInteger(); @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("GemFireRedisServer-SelectorThread-" + counter.incrementAndGet()); t.setDaemon(true); return t; } }; ThreadFactory workerThreadFactory = new ThreadFactory() { private final AtomicInteger counter = new AtomicInteger(); @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("GemFireRedisServer-WorkerThread-" + counter.incrementAndGet()); return t; } }; bossGroup = null; workerGroup = null; Class<? extends ServerChannel> socketClass = null; if (singleThreadPerConnection) { bossGroup = new OioEventLoopGroup(Integer.MAX_VALUE, selectorThreadFactory); workerGroup = new OioEventLoopGroup(Integer.MAX_VALUE, workerThreadFactory); socketClass = OioServerSocketChannel.class; } else { bossGroup = new NioEventLoopGroup(this.numSelectorThreads, selectorThreadFactory); workerGroup = new NioEventLoopGroup(this.numWorkerThreads, workerThreadFactory); socketClass = NioServerSocketChannel.class; } InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem(); String pwd = system.getConfig().getRedisPassword(); final byte[] pwdB = Coder.stringToBytes(pwd); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(socketClass).childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { if (logger.fineEnabled()) logger.fine("GemFireRedisServer-Connection established with " + ch.remoteAddress()); ChannelPipeline p = ch.pipeline(); p.addLast(ByteToCommandDecoder.class.getSimpleName(), new ByteToCommandDecoder()); p.addLast(ExecutionHandlerContext.class.getSimpleName(), new ExecutionHandlerContext(ch, cache, regionCache, GemFireRedisServer.this, pwdB)); } }).option(ChannelOption.SO_REUSEADDR, true).option(ChannelOption.SO_RCVBUF, getBufferSize()) .childOption(ChannelOption.SO_KEEPALIVE, true) .childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, GemFireRedisServer.connectTimeoutMillis) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); // Bind and start to accept incoming connections. ChannelFuture f = b.bind(new InetSocketAddress(getBindAddress(), serverPort)).sync(); if (this.logger.infoEnabled()) { String logMessage = "GemFireRedisServer started {" + getBindAddress() + ":" + serverPort + "}, Selector threads: " + this.numSelectorThreads; if (this.singleThreadPerConnection) logMessage += ", One worker thread per connection"; else logMessage += ", Worker threads: " + this.numWorkerThreads; this.logger.info(logMessage); } this.serverChannel = f.channel(); }
From source file:com.github.milenkovicm.kafka.connection.AbstractKafkaBroker.java
License:Apache License
public AbstractKafkaBroker(String hostname, int port, String topicName, EventLoopGroup workerGroup, ProducerProperties properties) { this.hostname = hostname; this.port = port; this.topicName = topicName; this.workerGroup = workerGroup; this.properties = properties; this.bootstrap = new Bootstrap(); this.bootstrap.group(this.workerGroup); this.bootstrap.channel(NioSocketChannel.class); this.bootstrap.option(ChannelOption.TCP_NODELAY, true); this.bootstrap.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, properties.get(ProducerProperties.NETTY_HIGH_WATERMARK)); this.bootstrap.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, properties.get(ProducerProperties.NETTY_LOW_WATERMARK)); this.bootstrap.option(ChannelOption.SO_KEEPALIVE, true); if (properties.get(ProducerProperties.SO_TIMEOUT) > 0) { this.bootstrap.option(ChannelOption.SO_TIMEOUT, 0); }//w ww . jav a 2s . c o m if (properties.get(ProducerProperties.SO_RCVBUF) > 0) { this.bootstrap.option(ChannelOption.SO_RCVBUF, 0); } if (properties.get(ProducerProperties.SO_SNDBUF) > 0) { this.bootstrap.option(ChannelOption.SO_SNDBUF, 0); } this.bootstrap.handler(pipeline()); }
From source file:com.github.sparkfy.network.server.TransportServer.java
License:Apache License
private void init(String hostToBind, int portToBind) { IOMode ioMode = IOMode.valueOf(conf.ioMode()); EventLoopGroup bossGroup = NettyUtils.createEventLoop(ioMode, conf.serverThreads(), "shuffle-server"); EventLoopGroup workerGroup = bossGroup; PooledByteBufAllocator allocator = NettyUtils.createPooledByteBufAllocator(conf.preferDirectBufs(), true /* allowCache */, conf.serverThreads()); bootstrap = new ServerBootstrap().group(bossGroup, workerGroup) .channel(NettyUtils.getServerChannelClass(ioMode)).option(ChannelOption.ALLOCATOR, allocator) .childOption(ChannelOption.ALLOCATOR, allocator); if (conf.backLog() > 0) { bootstrap.option(ChannelOption.SO_BACKLOG, conf.backLog()); }//from ww w. ja v a 2 s . com if (conf.receiveBuf() > 0) { bootstrap.childOption(ChannelOption.SO_RCVBUF, conf.receiveBuf()); } if (conf.sendBuf() > 0) { bootstrap.childOption(ChannelOption.SO_SNDBUF, conf.sendBuf()); } bootstrap.childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { RpcHandler rpcHandler = appRpcHandler; for (TransportServerBootstrap bootstrap : bootstraps) { rpcHandler = bootstrap.doBootstrap(ch, rpcHandler); } context.initializePipeline(ch, rpcHandler); } }); InetSocketAddress address = hostToBind == null ? new InetSocketAddress(portToBind) : new InetSocketAddress(hostToBind, portToBind); channelFuture = bootstrap.bind(address); channelFuture.syncUninterruptibly(); port = ((InetSocketAddress) channelFuture.channel().localAddress()).getPort(); logger.debug("Shuffle server started on port :" + port); }
From source file:com.googlecode.protobuf.pro.duplex.example.DuplexPingPongClient.java
License:Apache License
public static void main(String[] args) throws Exception { if (args.length != 8) { System.err.println(/*from www . j av a2s. c o m*/ "usage: <serverHostname> <serverPort> <clientHostname> <clientPort> <ssl=Y/N> <nodelay=Y/N> <compress=Y/N> <payloadSizeBytes>"); System.exit(-1); } String serverHostname = args[0]; int serverPort = Integer.parseInt(args[1]); String clientHostname = args[2]; int clientPort = Integer.parseInt(args[3]); boolean secure = "Y".equals(args[4]); boolean nodelay = "Y".equals(args[5]); boolean compress = "Y".equals(args[6]); int payloadSize = Integer.parseInt(args[7]); log.info("DuplexPingPongClient port=" + clientPort + " ssl=" + (secure ? "Y" : "N") + " nodelay=" + (nodelay ? "Y" : "N") + " compress=" + (compress ? "Y" : "N") + " payloadSizeBytes=" + payloadSize); PeerInfo client = new PeerInfo(clientHostname, clientPort); PeerInfo server = new PeerInfo(serverHostname, serverPort); RpcServerCallExecutor executor = new ThreadPoolCallExecutor(3, 100); DuplexTcpClientPipelineFactory clientFactory = new DuplexTcpClientPipelineFactory(); clientFactory.setClientInfo(client); // forces a local port nr. clientFactory.setConnectResponseTimeoutMillis(10000); clientFactory.setRpcServerCallExecutor(executor); clientFactory.setCompression(compress); if (secure) { RpcSSLContext sslCtx = new RpcSSLContext(); sslCtx.setKeystorePassword("changeme"); sslCtx.setKeystorePath("./lib/client.keystore"); sslCtx.setTruststorePassword("changeme"); sslCtx.setTruststorePath("./lib/truststore"); sslCtx.init(); clientFactory.setSslContext(sslCtx); } NullLogger logger = new NullLogger(); clientFactory.setRpcLogger(logger); RpcTimeoutExecutor timeoutExecutor = new TimeoutExecutor(1, 5); RpcTimeoutChecker checker = new TimeoutChecker(); checker.setTimeoutExecutor(timeoutExecutor); checker.startChecking(clientFactory.getRpcClientRegistry()); CleanShutdownHandler shutdownHandler = new CleanShutdownHandler(); shutdownHandler.addResource(executor); shutdownHandler.addResource(checker); shutdownHandler.addResource(timeoutExecutor); // setup a RPC event listener - it just logs what happens RpcConnectionEventNotifier rpcEventNotifier = new RpcConnectionEventNotifier(); RpcConnectionEventListener listener = new RpcConnectionEventListener() { @Override public void connectionReestablished(RpcClientChannel clientChannel) { log.info("connectionReestablished " + clientChannel); } @Override public void connectionOpened(RpcClientChannel clientChannel) { log.info("connectionOpened " + clientChannel); } @Override public void connectionLost(RpcClientChannel clientChannel) { log.info("connectionLost " + clientChannel); } @Override public void connectionChanged(RpcClientChannel clientChannel) { log.info("connectionChanged " + clientChannel); } }; rpcEventNotifier.setEventListener(listener); clientFactory.registerConnectionEventListener(rpcEventNotifier); // Configure the client to provide a Pong Service in both blocking an non blocking varieties BlockingService bPongService = BlockingPongService .newReflectiveBlockingService(new PingPongServiceFactory.BlockingPongServer()); clientFactory.getRpcServiceRegistry().registerService(bPongService); Service nbPongService = NonBlockingPongService .newReflectiveService(new PingPongServiceFactory.NonBlockingPongServer()); clientFactory.getRpcServiceRegistry().registerService(nbPongService); // we give the client a blocking and non blocking (pong capable) Ping Service BlockingService bPingService = BlockingPingService .newReflectiveBlockingService(new PingPongServiceFactory.BlockingPongingPingServer()); clientFactory.getRpcServiceRegistry().registerService(bPingService); Service nbPingService = NonBlockingPingService .newReflectiveService(new PingPongServiceFactory.NonBlockingPongingPingServer()); clientFactory.getRpcServiceRegistry().registerService(nbPingService); Bootstrap bootstrap = new Bootstrap(); bootstrap.group(new NioEventLoopGroup()); bootstrap.handler(clientFactory); bootstrap.channel(NioSocketChannel.class); bootstrap.option(ChannelOption.TCP_NODELAY, nodelay); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000); bootstrap.option(ChannelOption.SO_SNDBUF, 1048576); bootstrap.option(ChannelOption.SO_RCVBUF, 1048576); shutdownHandler.addResource(bootstrap.group()); try { clientFactory.peerWith(server, bootstrap); while (true) { new ShortTests().execute(clientFactory.getRpcClientRegistry()); new AllClientTests().execute(clientFactory.getRpcClientRegistry()); new ClientPerformanceTests().execute(clientFactory.getRpcClientRegistry()); Thread.sleep(60000); } } catch (Throwable e) { log.error("Throwable.", e); } finally { System.exit(0); } }