adoroszlai commented on a change in pull request #2498:
URL: https://github.com/apache/ozone/pull/2498#discussion_r773939981



##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java
##########
@@ -109,12 +150,14 @@ public void start() throws IOException {
     }
 
     port = server.getPort();
-
   }
 
   public void stop() {
     try {
-      server.shutdown().awaitTermination(10L, TimeUnit.SECONDS);
+      eventLoopGroup.shutdownGracefully().sync();
+      executor.shutdown();
+      executor.awaitTermination(5L, TimeUnit.SECONDS);
+      server.shutdown().awaitTermination(5L, TimeUnit.SECONDS);

Review comment:
       Event loop group should be shutdown last (#2900 fixed similar problem in 
`XceiverServerGrpc`, introduced in #2824):
   
   ```suggestion
         executor.shutdown();
         executor.awaitTermination(5L, TimeUnit.SECONDS);
         server.shutdown().awaitTermination(5L, TimeUnit.SECONDS);
         eventLoopGroup.shutdownGracefully().sync();
   ```

##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java
##########
@@ -57,22 +68,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<? extends ServerChannel> channelType;
+
+    if (Epoll.isAvailable()) {
+      eventLoopGroup = new EpollEventLoopGroup(poolSize / 4);

Review comment:
       Can you please explain how 4 is derived?  (Magic number?)

##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java
##########
@@ -72,13 +72,25 @@
    */
   @Config(key = "replication.streams.limit",
       type = ConfigType.INT,
-      defaultValue = "10",
+      defaultValue = "12",
       tags = {DATANODE},
       description = "The maximum number of replication commands a single " +
           "datanode can execute simultaneously"
   )
   private int replicationMaxStreams = REPLICATION_MAX_STREAMS_DEFAULT;
 
+  /**
+   * The maximum number of replication requests.
+   */
+  @Config(key = "replication.queue.limit",

Review comment:
       Cany you please add this new config to 
`ReplicationServer#ReplicationConfig` instead of `DatanodeConfig`?  That is a 
more specific class for config related to replication.  If we also moved 
existing `replicationMaxStreams`, too, then we could avoid introducing 
`DatanodeConfiguration` in `ReplicationServer`?




-- 
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]

Reply via email to