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.moshi.receptionist.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/*from w w w . j a v a 2s . com*/ public Thread newThread(Runnable r) { return new Thread(r, "NettyServerWorkerThread_" + this.threadIndex.incrementAndGet()); } }); ServerBootstrap childHandler = // this.serverBootstrap.group(this.eventLoopGroup, new NioEventLoopGroup()) .channel(NioServerSocketChannel.class) // .option(ChannelOption.SO_BACKLOG, 1024) // .option(ChannelOption.SO_REUSEADDR, true) // .childOption(ChannelOption.TCP_NODELAY, true) // .childOption(ChannelOption.SO_SNDBUF, NettySystemConfig.SocketSndbufSize) // .childOption(ChannelOption.SO_RCVBUF, NettySystemConfig.SocketRcvbufSize) .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 (NettySystemConfig.NettyPooledByteBufAllocatorEnable) { // ???? 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.mpush.client.gateway.GatewayClient.java
License:Apache License
@Override protected void initOptions(Bootstrap b) { super.initOptions(b); if (snd_buf.gateway_client > 0) b.option(ChannelOption.SO_SNDBUF, snd_buf.gateway_client); if (rcv_buf.gateway_client > 0) b.option(ChannelOption.SO_RCVBUF, rcv_buf.gateway_client); }
From source file:com.mpush.client.gateway.GatewayUDPConnector.java
License:Apache License
@Override protected void initOptions(Bootstrap b) { super.initOptions(b); b.option(ChannelOption.IP_MULTICAST_LOOP_DISABLED, true); b.option(ChannelOption.IP_MULTICAST_TTL, 255); if (snd_buf.gateway_client > 0) b.option(ChannelOption.SO_SNDBUF, snd_buf.gateway_client); if (rcv_buf.gateway_client > 0) b.option(ChannelOption.SO_RCVBUF, rcv_buf.gateway_client); }
From source file:com.mpush.core.server.ConnectionServer.java
License:Apache License
@Override protected void initOptions(ServerBootstrap b) { super.initOptions(b); b.option(ChannelOption.SO_BACKLOG, 1024); /**/*w ww .jav a 2 s . co m*/ * TCP???? * NettyChannelOptionSO_SNDBUFSO_RCVBUF * ????????32K? */ if (snd_buf.connect_server > 0) b.childOption(ChannelOption.SO_SNDBUF, snd_buf.connect_server); if (rcv_buf.connect_server > 0) b.childOption(ChannelOption.SO_RCVBUF, rcv_buf.connect_server); /** * ?????????? * ??????????????? * ???????? * ???????? * ?????? * ???NettyChannelOutboundBuffer * buffernetty?channel write?buffer???????(?channelbuffer) * ??32(32?)32? * ?(?TCP??) * ??buffer???(?swap?linux killer) * ?channel?channel?active? * * ChannelOutboundBuffer???? * buffer??channelisWritable??false * buffer??isWritable??trueisWritablefalse???? * ???64K?32K??????? */ b.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(connect_server_low, connect_server_high)); }
From source file:com.mpush.core.server.GatewayServer.java
License:Apache License
@Override protected void initOptions(ServerBootstrap b) { super.initOptions(b); if (snd_buf.gateway_server > 0) b.childOption(ChannelOption.SO_SNDBUF, snd_buf.gateway_server); if (rcv_buf.gateway_server > 0) b.childOption(ChannelOption.SO_RCVBUF, rcv_buf.gateway_server); /**//w w w .j av a 2 s. co m * ?????????? * ??????????????? * ???????? * ???????? * ?????? * ???NettyChannelOutboundBuffer * buffernetty?channel write?buffer???????(?channelbuffer) * ??32(32?)32? * ?(?TCP??) * ??buffer???(?swap?linux killer) * ?channel?channel?active? * * ChannelOutboundBuffer???? * buffer??channelisWritable??false * buffer??isWritable??trueisWritablefalse???? * ???64K?32K??????? */ if (gateway_server_low > 0 && gateway_server_high > 0) { b.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(gateway_server_low, gateway_server_high)); } }
From source file:com.mpush.core.server.GatewayUDPConnector.java
License:Apache License
@Override protected void initOptions(Bootstrap b) { super.initOptions(b); b.option(ChannelOption.IP_MULTICAST_LOOP_DISABLED, true);//?????IP???IP_MULTICAST_LOOP???? b.option(ChannelOption.IP_MULTICAST_TTL, 255);//IP_MULTICAST_TTL?TTL0255 //b.option(ChannelOption.IP_MULTICAST_IF, null);//IP_MULTICAST_IF???????,?addr?IP?INADDR_ANY??? //b.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(32 * 1024, 1024 * 1024)); if (snd_buf.gateway_server > 0) b.option(ChannelOption.SO_SNDBUF, snd_buf.gateway_server); if (rcv_buf.gateway_server > 0) b.option(ChannelOption.SO_RCVBUF, rcv_buf.gateway_server); }
From source file:com.mpush.core.server.WebSocketServer.java
License:Apache License
@Override protected void initOptions(ServerBootstrap b) { super.initOptions(b); b.option(ChannelOption.SO_BACKLOG, 1024); b.childOption(ChannelOption.SO_SNDBUF, 32 * 1024); b.childOption(ChannelOption.SO_RCVBUF, 32 * 1024); }
From source file:com.mpush.test.client.ConnClientBoot.java
License:Apache License
@Override protected void doStart(Listener listener) throws Throwable { ServiceDiscoveryFactory.create().syncStart(); CacheManagerFactory.create().init(); this.workerGroup = new NioEventLoopGroup(); this.bootstrap = new Bootstrap(); bootstrap.group(workerGroup)// .option(ChannelOption.TCP_NODELAY, true)// .option(ChannelOption.SO_REUSEADDR, true)// .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)// .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 60 * 1000) .option(ChannelOption.SO_RCVBUF, 5 * 1024 * 1024).channel(NioSocketChannel.class); bootstrap.handler(new ChannelInitializer<SocketChannel>() { // (4) @Override/* w ww . j a va2s . c o m*/ public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("decoder", new PacketDecoder()); ch.pipeline().addLast("encoder", PacketEncoder.INSTANCE); ch.pipeline().addLast("handler", new ConnClientChannelHandler()); } }); listener.onSuccess(); }
From source file:com.navercorp.nbasearc.gcp.PhysicalConnection.java
License:Apache License
static PhysicalConnection create(String ip, int port, SingleThreadEventLoop eventLoop, Gateway gw, int reconnectInterval) { final PhysicalConnection pc = new PhysicalConnection(ip, port, eventLoop, gw, reconnectInterval); pc.b.group(eventLoop.getEventLoopGroup()).channel(NioSocketChannel.class) .option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.SO_KEEPALIVE, true).option(ChannelOption.SO_LINGER, 0) .option(ChannelOption.SO_SNDBUF, SOCKET_BUFFER).option(ChannelOption.SO_RCVBUF, SOCKET_BUFFER) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT) .handler(new ChannelInitializer<SocketChannel>() { @Override//from w ww. j a v a2 s . c om protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(pc.new PhysicalConnectionHandler()); } }); return pc; }
From source file:com.navercorp.pinpoint.grpc.server.ServerFactory.java
License:Apache License
private void setupServerOption(final NettyServerBuilder builder) { // TODO @see PinpointServerAcceptor builder.withChildOption(ChannelOption.TCP_NODELAY, true); builder.withChildOption(ChannelOption.SO_REUSEADDR, true); builder.withChildOption(ChannelOption.SO_RCVBUF, this.serverOption.getReceiveBufferSize()); builder.withChildOption(ChannelOption.SO_BACKLOG, this.serverOption.getBacklogQueueSize()); builder.withChildOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.serverOption.getConnectTimeout()); final WriteBufferWaterMark writeBufferWaterMark = new WriteBufferWaterMark( this.serverOption.getWriteBufferLowWaterMark(), this.serverOption.getWriteBufferHighWaterMark()); builder.withChildOption(ChannelOption.WRITE_BUFFER_WATER_MARK, writeBufferWaterMark); builder.handshakeTimeout(this.serverOption.getHandshakeTimeout(), TimeUnit.MILLISECONDS); builder.flowControlWindow(this.serverOption.getFlowControlWindow()); builder.maxInboundMessageSize(this.serverOption.getMaxInboundMessageSize()); builder.maxHeaderListSize(this.serverOption.getMaxHeaderListSize()); builder.keepAliveTime(this.serverOption.getKeepAliveTime(), TimeUnit.MILLISECONDS); builder.keepAliveTimeout(this.serverOption.getKeepAliveTimeout(), TimeUnit.MILLISECONDS); builder.permitKeepAliveTime(this.serverOption.getPermitKeepAliveTimeout(), TimeUnit.MILLISECONDS); builder.permitKeepAliveWithoutCalls(this.serverOption.isPermitKeepAliveWithoutCalls()); builder.maxConnectionIdle(this.serverOption.getMaxConnectionIdle(), TimeUnit.MILLISECONDS); builder.maxConnectionAge(this.serverOption.getMaxConnectionAge(), TimeUnit.MILLISECONDS); builder.maxConnectionAgeGrace(this.serverOption.getMaxConnectionAgeGrace(), TimeUnit.MILLISECONDS); builder.maxConcurrentCallsPerConnection(this.serverOption.getMaxConcurrentCallsPerConnection()); if (logger.isInfoEnabled()) { logger.info("Set serverOption {}. name={}, hostname={}, port={}", serverOption, name, hostname, port); }// www . ja va 2 s . c om }