xichen01 commented on code in PR #5791:
URL: https://github.com/apache/ozone/pull/5791#discussion_r1471498647


##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -2480,26 +2488,45 @@ public void setTimes(OzoneObj obj, String keyName, long 
mtime, long atime)
     ozoneManagerClient.setTimes(builder.build(), mtime, atime);
   }
 
+  private ExecutorService createThreadPoolExecutor(
+      int corePoolSize, int maximumPoolSize, String threadNameFormat) {
+    return new ThreadPoolExecutor(corePoolSize, maximumPoolSize,
+        60, TimeUnit.SECONDS, new SynchronousQueue<>(),
+        new ThreadFactoryBuilder()
+            .setNameFormat(threadNameFormat)
+            .build(),
+        new ThreadPoolExecutor.CallerRunsPolicy());
+  }
+
   public ExecutorService getECReconstructExecutor() {
-    // local ref to a volatile to ensure access
-    // to a completed initialized object
-    ExecutorService executor = ecReconstructExecutor;
-    if (executor == null) {
+    ExecutorService localRef = ecReconstructExecutor;
+    if (localRef == null) {
       synchronized (this) {
-        executor = ecReconstructExecutor;
-        if (executor == null) {
-          ecReconstructExecutor = new ThreadPoolExecutor(
-              EC_RECONSTRUCT_STRIPE_READ_POOL_MIN_SIZE,
+        localRef = ecReconstructExecutor;
+        if (localRef == null) {
+          localRef = 
createThreadPoolExecutor(EC_RECONSTRUCT_STRIPE_READ_POOL_MIN_SIZE,
               clientConfig.getEcReconstructStripeReadPoolLimit(),
-              60, TimeUnit.SECONDS, new SynchronousQueue<>(),
-              new ThreadFactoryBuilder()
-                  .setNameFormat("ec-reconstruct-reader-TID-%d")
-                  .build(),
-              new ThreadPoolExecutor.CallerRunsPolicy());
-          executor = ecReconstructExecutor;
+              "ec-reconstruct-reader-TID-%d");
+          ecReconstructExecutor = localRef;
+        }
+      }
+    }
+    return localRef;
+  }
+
+  public ExecutorService getECWriteThreadPool() {
+    ExecutorService localRef = ecWriteExecutor;
+    if (localRef == null) {
+      synchronized (this) {
+        localRef = ecWriteExecutor;
+        if (localRef == null) {
+          localRef = createThreadPoolExecutor(EC_WRITE_POOL_MIN_SIZE,
+              clientConfig.getEcClientWritePoolLimit(),

Review Comment:
   Do you means `Executors.newCachedThreadPool()`? But an unlimited threads 
likely to consume too much client-side performance; after all, it is possible 
that a user's client is not necessarily configured to be very strong



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