List of usage examples for io.netty.channel ChannelOption SO_SNDBUF
ChannelOption SO_SNDBUF
To view the source code for io.netty.channel ChannelOption SO_SNDBUF.
Click Source Link
From source file:tachyon.worker.netty.NettyDataServer.java
License:Apache License
private ServerBootstrap createBootstrap() { final ServerBootstrap boot = createBootstrapOfType( mTachyonConf.getEnum(Constants.WORKER_NETWORK_NETTY_CHANNEL, ChannelType.class)); // use pooled buffers boot.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); boot.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); // set write buffer // this is the default, but its recommended to set it in case of change in future netty. boot.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, (int) mTachyonConf.getBytes(Constants.WORKER_NETTY_WATERMARK_HIGH)); boot.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, (int) mTachyonConf.getBytes(Constants.WORKER_NETTY_WATERMARK_LOW)); // more buffer settings on Netty socket option, one can tune them by specifying // properties, e.g.: // tachyon.worker.network.netty.backlog=50 // tachyon.worker.network.netty.buffer.send=64KB // tachyon.worker.network.netty.buffer.receive=64KB if (mTachyonConf.containsKey(Constants.WORKER_NETTY_BACKLOG)) { boot.option(ChannelOption.SO_BACKLOG, mTachyonConf.getInt(Constants.WORKER_NETTY_BACKLOG)); }//ww w .j a v a2s . com if (mTachyonConf.containsKey(Constants.WORKER_NETTY_SEND_BUFFER)) { boot.option(ChannelOption.SO_SNDBUF, (int) mTachyonConf.getBytes(Constants.WORKER_NETTY_SEND_BUFFER)); } if (mTachyonConf.containsKey(Constants.WORKER_NETTY_RECEIVE_BUFFER)) { boot.option(ChannelOption.SO_RCVBUF, (int) mTachyonConf.getBytes(Constants.WORKER_NETTY_RECEIVE_BUFFER)); } return boot; }
From source file:tonivade.redis.RedisClient.java
License:Open Source License
public void start() { workerGroup = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); initHandler = new RedisInitializerHandler(this); connectionHandler = new RedisConnectionHandler(this); bootstrap = new Bootstrap().group(workerGroup).channel(NioSocketChannel.class) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .option(ChannelOption.SO_RCVBUF, BUFFER_SIZE).option(ChannelOption.SO_SNDBUF, BUFFER_SIZE) .option(ChannelOption.SO_KEEPALIVE, true).handler(initHandler); try {/*from www . j a va 2 s .co m*/ connect(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:tonivade.redis.RedisServer.java
License:Open Source License
public void start() { bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); acceptHandler = new RedisInitializerHandler(this); connectionHandler = new RedisConnectionHandler(this); bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(acceptHandler) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .option(ChannelOption.SO_RCVBUF, BUFFER_SIZE).option(ChannelOption.SO_SNDBUF, BUFFER_SIZE) .childOption(ChannelOption.SO_KEEPALIVE, true) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); future = bootstrap.bind(host, port); // Bind and start to accept incoming connections. future.syncUninterruptibly();// w ww . j a va2s . c o m LOGGER.info(() -> "server started: " + host + ":" + port); }
From source file:weekend.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 w ww . j a va2 s. co m public Thread newThread(Runnable r) { return new Thread(r, "NettyClientWorkerThread_" + this.threadIndex.incrementAndGet()); } }); this.bootstrap.group(this.eventLoopGroup).channel(NioSocketChannel.class)// // .option(ChannelOption.TCP_NODELAY, true) // .option(ChannelOption.SO_SNDBUF, NettySystemConfig.SocketSndbufSize) // .option(ChannelOption.SO_RCVBUF, NettySystemConfig.SocketRcvbufSize) // .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(); } }