|
24 | 24 | import org.apache.ratis.thirdparty.io.grpc.stub.AbstractStub; |
25 | 25 | import org.apache.ratis.thirdparty.io.netty.channel.ChannelOption; |
26 | 26 | import org.apache.ratis.thirdparty.io.netty.channel.WriteBufferWaterMark; |
27 | | -import org.apache.ratis.thirdparty.io.netty.channel.nio.NioEventLoopGroup; |
28 | | -import org.apache.ratis.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; |
29 | 27 | import org.apache.ratis.thirdparty.io.netty.handler.ssl.SslContext; |
30 | 28 | import org.slf4j.Logger; |
31 | 29 | import org.slf4j.LoggerFactory; |
@@ -62,21 +60,17 @@ void release() { |
62 | 60 | } |
63 | 61 |
|
64 | 62 | private final List<PooledStub<S>> pool; |
65 | | - private final NioEventLoopGroup elg; |
66 | 63 | private final int size; |
67 | 64 |
|
68 | 65 | GrpcStubPool(RaftPeer target, int n, Function<ManagedChannel, S> stubFactory, SslContext sslContext) { |
69 | | - this(target, n, stubFactory, sslContext, Math.max(2, Runtime.getRuntime().availableProcessors() / 2), 16); |
| 66 | + this(target, n, stubFactory, sslContext, 16); |
70 | 67 | } |
71 | 68 |
|
72 | 69 | GrpcStubPool(RaftPeer target, int n, Function<ManagedChannel, S> stubFactory, SslContext sslContext, |
73 | | - int elgThreads, int maxInflightPerConn) { |
74 | | - this.elg = new NioEventLoopGroup(elgThreads); |
| 70 | + int maxInflightPerConn) { |
75 | 71 | ArrayList<PooledStub<S>> tmp = new ArrayList<>(n); |
76 | 72 | for (int i = 0; i < n; i++) { |
77 | 73 | NettyChannelBuilder channelBuilder = NettyChannelBuilder.forTarget(target.getAddress()) |
78 | | - .eventLoopGroup(elg) |
79 | | - .channelType(NioSocketChannel.class) |
80 | 74 | .keepAliveTime(30, TimeUnit.SECONDS) |
81 | 75 | .keepAliveWithoutCalls(true) |
82 | 76 | .idleTimeout(24, TimeUnit.HOURS) |
@@ -112,6 +106,5 @@ public void close() { |
112 | 106 | for (PooledStub<S> p : pool) { |
113 | 107 | p.ch.shutdown(); |
114 | 108 | } |
115 | | - elg.shutdownGracefully(); |
116 | 109 | } |
117 | 110 | } |
0 commit comments