adoroszlai commented on a change in pull request #2498:
URL: https://github.com/apache/ozone/pull/2498#discussion_r710396341
##########
File path:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java
##########
@@ -57,22 +67,52 @@
private int port;
+ private int poolSize;
+
+ private int queueLimit;
+
+ private ThreadPoolExecutor executor;
+
+ private EventLoopGroup eventLoopGroup;
+
public ReplicationServer(
ContainerController controller,
ReplicationConfig replicationConfig,
- SecurityConfig secConf,
- CertificateClient caClient
- ) {
+ SecurityConfig secConf, DatanodeConfiguration dnConfig,
+ CertificateClient caClient) {
this.secConf = secConf;
this.caClient = caClient;
this.controller = controller;
this.port = replicationConfig.getPort();
+ this.poolSize = dnConfig.getReplicationMaxStreams();
+ this.queueLimit = dnConfig.getReplicationQueueLimit();
init();
}
public void init() {
+ executor = new ThreadPoolExecutor(
+ poolSize, poolSize, 60, TimeUnit.SECONDS,
+ new LinkedBlockingQueue<>(queueLimit),
+ new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("ReplicationServerExecutor-%d")
+ .build());
+
+ Class channelType;
Review comment:
Nit:
```suggestion
Class<? extends ServerChannel> channelType;
```
(+ import)
##########
File path:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java
##########
@@ -57,22 +67,52 @@
private int port;
+ private int poolSize;
+
+ private int queueLimit;
+
+ private ThreadPoolExecutor executor;
+
+ private EventLoopGroup eventLoopGroup;
+
public ReplicationServer(
ContainerController controller,
ReplicationConfig replicationConfig,
- SecurityConfig secConf,
- CertificateClient caClient
- ) {
+ SecurityConfig secConf, DatanodeConfiguration dnConfig,
+ CertificateClient caClient) {
this.secConf = secConf;
this.caClient = caClient;
this.controller = controller;
this.port = replicationConfig.getPort();
+ this.poolSize = dnConfig.getReplicationMaxStreams();
+ this.queueLimit = dnConfig.getReplicationQueueLimit();
init();
}
public void init() {
+ executor = new ThreadPoolExecutor(
+ poolSize, poolSize, 60, TimeUnit.SECONDS,
+ new LinkedBlockingQueue<>(queueLimit),
+ new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("ReplicationServerExecutor-%d")
+ .build());
+
+ Class channelType;
+
+ if (Epoll.isAvailable()) {
+ eventLoopGroup = new EpollEventLoopGroup(poolSize * 2);
+ channelType = EpollServerDomainSocketChannel.class;
+ } else {
+ eventLoopGroup = new NioEventLoopGroup(poolSize * 2);
+ channelType = NioServerSocketChannel.class;
+ }
+
NettyServerBuilder nettyServerBuilder = NettyServerBuilder.forPort(port)
.maxInboundMessageSize(OzoneConsts.OZONE_SCM_CHUNK_MAX_SIZE)
+ .workerEventLoopGroup(eventLoopGroup)
+ .bossEventLoopGroup(eventLoopGroup)
+ .channelType(channelType)
Review comment:
Can you please explain why setting channel type and event loop group are
needed? Based on `NettyServerBuilder#channelType` javadoc this is the same as
the default behavior:
```
Specifies the channel type to use, by default we use {@code
EpollServerSocketChannel} if
available, otherwise using {@link NioServerSocketChannel}.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]