List of usage examples for io.netty.channel ChannelOption RCVBUF_ALLOCATOR
ChannelOption RCVBUF_ALLOCATOR
To view the source code for io.netty.channel ChannelOption RCVBUF_ALLOCATOR.
Click Source Link
From source file:io.vertx.core.http.impl.HttpClientImpl.java
License:Open Source License
private void applyConnectionOptions(Bootstrap bootstrap) { bootstrap.option(ChannelOption.TCP_NODELAY, options.isTcpNoDelay()); if (options.getSendBufferSize() != -1) { bootstrap.option(ChannelOption.SO_SNDBUF, options.getSendBufferSize()); }//ww w . ja v a 2 s.c o m if (options.getReceiveBufferSize() != -1) { bootstrap.option(ChannelOption.SO_RCVBUF, options.getReceiveBufferSize()); bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(options.getReceiveBufferSize())); } bootstrap.option(ChannelOption.SO_LINGER, options.getSoLinger()); if (options.getTrafficClass() != -1) { bootstrap.option(ChannelOption.IP_TOS, options.getTrafficClass()); } bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, options.getConnectTimeout()); bootstrap.option(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); bootstrap.option(ChannelOption.SO_KEEPALIVE, options.isTcpKeepAlive()); bootstrap.option(ChannelOption.SO_REUSEADDR, options.isReuseAddress()); }
From source file:io.vertx.core.net.impl.NetClientBase.java
License:Open Source License
private void applyConnectionOptions(Bootstrap bootstrap) { if (options.getLocalAddress() != null) { bootstrap.localAddress(options.getLocalAddress(), 0); }//from w w w . j a v a2s. c o m bootstrap.option(ChannelOption.TCP_NODELAY, options.isTcpNoDelay()); if (options.getSendBufferSize() != -1) { bootstrap.option(ChannelOption.SO_SNDBUF, options.getSendBufferSize()); } if (options.getReceiveBufferSize() != -1) { bootstrap.option(ChannelOption.SO_RCVBUF, options.getReceiveBufferSize()); bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(options.getReceiveBufferSize())); } if (options.getSoLinger() != -1) { bootstrap.option(ChannelOption.SO_LINGER, options.getSoLinger()); } if (options.getTrafficClass() != -1) { bootstrap.option(ChannelOption.IP_TOS, options.getTrafficClass()); } bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, options.getConnectTimeout()); bootstrap.option(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); bootstrap.option(ChannelOption.SO_KEEPALIVE, options.isTcpKeepAlive()); }
From source file:io.vertx.core.net.impl.NetServerBase.java
License:Open Source License
/** * Apply the connection option to the server. * * @param bootstrap the Netty server bootstrap *///from ww w . j a v a2s .c o m protected void applyConnectionOptions(ServerBootstrap bootstrap) { bootstrap.childOption(ChannelOption.TCP_NODELAY, options.isTcpNoDelay()); if (options.getSendBufferSize() != -1) { bootstrap.childOption(ChannelOption.SO_SNDBUF, options.getSendBufferSize()); } if (options.getReceiveBufferSize() != -1) { bootstrap.childOption(ChannelOption.SO_RCVBUF, options.getReceiveBufferSize()); bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(options.getReceiveBufferSize())); } if (options.getSoLinger() != -1) { bootstrap.option(ChannelOption.SO_LINGER, options.getSoLinger()); } if (options.getTrafficClass() != -1) { bootstrap.childOption(ChannelOption.IP_TOS, options.getTrafficClass()); } bootstrap.childOption(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); bootstrap.childOption(ChannelOption.SO_KEEPALIVE, options.isTcpKeepAlive()); bootstrap.option(ChannelOption.SO_REUSEADDR, options.isReuseAddress()); if (options.getAcceptBacklog() != -1) { bootstrap.option(ChannelOption.SO_BACKLOG, options.getAcceptBacklog()); } }
From source file:io.vertx.core.net.impl.transport.Transport.java
License:Open Source License
public void configure(ClientOptionsBase options, Bootstrap bootstrap) { if (options.getLocalAddress() != null) { bootstrap.localAddress(options.getLocalAddress(), 0); }//w w w. j a v a2 s . c o m bootstrap.option(ChannelOption.TCP_NODELAY, options.isTcpNoDelay()); if (options.getSendBufferSize() != -1) { bootstrap.option(ChannelOption.SO_SNDBUF, options.getSendBufferSize()); } if (options.getReceiveBufferSize() != -1) { bootstrap.option(ChannelOption.SO_RCVBUF, options.getReceiveBufferSize()); bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(options.getReceiveBufferSize())); } if (options.getSoLinger() != -1) { bootstrap.option(ChannelOption.SO_LINGER, options.getSoLinger()); } if (options.getTrafficClass() != -1) { bootstrap.option(ChannelOption.IP_TOS, options.getTrafficClass()); } bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, options.getConnectTimeout()); bootstrap.option(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); bootstrap.option(ChannelOption.SO_KEEPALIVE, options.isTcpKeepAlive()); bootstrap.option(ChannelOption.SO_REUSEADDR, options.isReuseAddress()); }
From source file:io.vertx.core.net.impl.transport.Transport.java
License:Open Source License
public void configure(NetServerOptions options, ServerBootstrap bootstrap) { bootstrap.childOption(ChannelOption.TCP_NODELAY, options.isTcpNoDelay()); if (options.getSendBufferSize() != -1) { bootstrap.childOption(ChannelOption.SO_SNDBUF, options.getSendBufferSize()); }/*w w w. j av a 2 s .c om*/ if (options.getReceiveBufferSize() != -1) { bootstrap.childOption(ChannelOption.SO_RCVBUF, options.getReceiveBufferSize()); bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(options.getReceiveBufferSize())); } if (options.getSoLinger() != -1) { bootstrap.childOption(ChannelOption.SO_LINGER, options.getSoLinger()); } if (options.getTrafficClass() != -1) { bootstrap.childOption(ChannelOption.IP_TOS, options.getTrafficClass()); } bootstrap.childOption(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); bootstrap.childOption(ChannelOption.SO_KEEPALIVE, options.isTcpKeepAlive()); bootstrap.option(ChannelOption.SO_REUSEADDR, options.isReuseAddress()); if (options.getAcceptBacklog() != -1) { bootstrap.option(ChannelOption.SO_BACKLOG, options.getAcceptBacklog()); } }
From source file:lunarion.cluster.coordinator.server.CoordinatorServer.java
License:Open Source License
public void bind(int port) throws InterruptedException { ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .childOption(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(64, 1024, 65536 * 512)) //.childHandler(new ChildChannelHandler()) .childHandler(new CoordinatorServerChannelInitializer(co, logger)) .option(ChannelOption.SO_BACKLOG, 1024).childOption(ChannelOption.SO_KEEPALIVE, true); Channel ch = bootstrap.bind(port).sync().channel(); System.err//from ww w . j a va2s . co m .println(Timer.currentTime() + "[INFO]: coordinator server channel binded at port: " + port + '.'); logger.info(Timer.currentTime() + " [COORDINATOR INFO]: coordinator server channel binded at port: " + port + '.'); ch.closeFuture().sync(); /* * Bind and start to accept incoming connections. */ // ChannelFuture future = bootstrap.bind(port).sync(); /* * Wait until the server socket is closed. * In this example, this does not happen, but you can do that to gracefully * shut down your server. */ // future.channel().closeFuture().sync(); }
From source file:lunarion.node.LunarDBServerStandAlone.java
License:Open Source License
public void bind(int port) throws InterruptedException { ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .childOption(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(64, 1024, 65536 * 512)) .option(ChannelOption.SO_BACKLOG, 1024).option(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.SO_KEEPALIVE, true) .childHandler(new LunarDBServerChannelInitializer(node_tc)); Channel ch = bootstrap.bind(port).sync().channel(); System.err.println(Timer.currentTime() + " DB node server channel binded at port: " + port + '.'); logger.info(Timer.currentTime() + " [NODE INFO]: DB node server channel binded at port: " + port + '.'); ch.closeFuture().sync();/*www . j av a2 s . c om*/ /* * Bind and start to accept incoming connections. */ // ChannelFuture future = bootstrap.bind(port).sync(); /* * Wait until the server socket is closed. * In this example, this does not happen, but you can do that to gracefully * shut down your server. */ // future.channel().closeFuture().sync(); }
From source file:lunarion.node.requester.LunarDBClient.java
License:Open Source License
public ChannelFuture connect(String host, int port) throws Exception { group = new NioEventLoopGroup(); client_handler = new ClientHandler(internal); try {/*from ww w . jav a 2s . c o m*/ Bootstrap client_bootstrap = new Bootstrap(); client_bootstrap.group(group).channel(NioSocketChannel.class) .option(ChannelOption.SO_SNDBUF, 1024 * 1024) .option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(64, 1024, 65536 * 512)) //.option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.SO_KEEPALIVE, true).handler(new ClientChannelInitializer(client_handler)); //ChannelFuture cf = client_bootstrap.connect(host, port).sync(); ChannelFuture cf = client_bootstrap.connect(host, port); channel_list.add(cf); cf.addListener(new ChannelFutureListener() { public void operationComplete(final ChannelFuture channelFuture) throws Exception { if (channelFuture.isSuccess()) { ClientHandler handler = channelFuture.channel().pipeline().get(ClientHandler.class); client_handler = handler; } } }); connected.set(true); connected_host_ip = host; connected_port = port; return cf; } finally { // group.shutdownGracefully(); } }
From source file:mmo.client.connection.ServerConnection.java
License:Apache License
/** * Opens connection to server. This method must be called explicitly. *//* ww w . j ava 2s. c o m*/ public void open() { new Bootstrap().group(notificationGroup).channel(NioSocketChannel.class) .handler(new NotificationInitializer()) .option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(16384)) .option(ChannelOption.TCP_NODELAY, true).connect(this.host, this.port); new Bootstrap().group(dataGroup).channel(NioSocketChannel.class).handler(new DataInitializer()) .option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(16384)) .option(ChannelOption.TCP_NODELAY, true).connect(this.host, this.port); }
From source file:mmo.server.Server.java
License:Open Source License
public void run(String host, int port) { parentGroup = new NioEventLoopGroup(); childGroup = new NioEventLoopGroup(); new ServerBootstrap().group(parentGroup, childGroup).channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new HttpServerCodec(), // new HttpObjectAggregator(65536), // routeHandlerProvider.get()); }/*from ww w .j a va2 s. c om*/ }).option(ChannelOption.TCP_NODELAY, true).childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(16384)).bind(host, port) .addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { L.error("Error setting up server channel: {}", future.cause(), null); new Thread(() -> { // TODO shutdown program // gracefuller try { shutdown(); } catch (InterruptedException e) { e.printStackTrace(); } finally { System.exit(1); } }).start(); } } }); }