|
@@ -2,6 +2,8 @@ package wei.yigulu.netty;
|
|
|
|
|
|
|
|
|
import io.netty.bootstrap.Bootstrap;
|
|
|
+import io.netty.buffer.PooledByteBufAllocator;
|
|
|
+import io.netty.channel.AdaptiveRecvByteBufAllocator;
|
|
|
import io.netty.channel.ChannelFutureListener;
|
|
|
import io.netty.channel.ChannelOption;
|
|
|
import io.netty.channel.EventLoopGroup;
|
|
@@ -112,7 +114,7 @@ public abstract class AbstractTcpMasterBuilder extends AbstractMasterBuilder {
|
|
|
@Override
|
|
|
public EventLoopGroup getOrCreateWorkGroup() {
|
|
|
if (this.workGroup == null || this.workGroup.isShutdown()) {
|
|
|
- this.workGroup = new NioEventLoopGroup();
|
|
|
+ this.workGroup = new NioEventLoopGroup(2);
|
|
|
}
|
|
|
return this.workGroup;
|
|
|
}
|
|
@@ -126,6 +128,8 @@ public abstract class AbstractTcpMasterBuilder extends AbstractMasterBuilder {
|
|
|
.channel(NioSocketChannel.class)
|
|
|
.handler(getOrCreateChannelInitializer());
|
|
|
bootstrap.option(ChannelOption.SO_KEEPALIVE, false);
|
|
|
+ bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
|
|
+ bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, AdaptiveRecvByteBufAllocator.DEFAULT);
|
|
|
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000);
|
|
|
}
|
|
|
return this.bootstrap;
|