ptlrs commented on code in PR #10125:
URL: https://github.com/apache/ozone/pull/10125#discussion_r3158850732


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/DirectoryDeletingService.java:
##########
@@ -251,16 +251,35 @@ public void shutdown() {
   @Override
   public synchronized void start() {
     if (deletionThreadPool == null || deletionThreadPool.isShutdown() || 
deletionThreadPool.isTerminated()) {
-      this.deletionThreadPool = new ThreadPoolExecutor(0, 
numberOfParallelThreadsPerStore,
-          super.getIntervalMillis(), TimeUnit.MILLISECONDS, new 
LinkedBlockingDeque<>(Integer.MAX_VALUE));
+      this.deletionThreadPool = 
createDeletionThreadPool(numberOfParallelThreadsPerStore);
     }
     super.start();
   }
 
+  private ThreadPoolExecutor createDeletionThreadPool(int threadCount) {
+    long intervalMillis = super.getIntervalMillis();
+    ThreadPoolExecutor pool = new ThreadPoolExecutor(
+        threadCount, threadCount, intervalMillis,
+        TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(Integer.MAX_VALUE));
+    if (intervalMillis > 0) {
+      pool.allowCoreThreadTimeOut(true);
+    }
+    return pool;
+  }
+
   private boolean isThreadPoolActive(ExecutorService threadPoolExecutor) {
     return threadPoolExecutor != null && !threadPoolExecutor.isShutdown() && 
!threadPoolExecutor.isTerminated();
   }
 
+  private synchronized int getNumberOfParallelThreadsPerStore() {
+    return numberOfParallelThreadsPerStore;
+  }

Review Comment:
   `getNumberOfParallelThreadsPerStore` should be an `AtomicInteger` to ensure 
access to that variable is consistently thread safe. 
   
   An added benefit is that this synchronized method can be removed. It is 
being called in only one place.
   
   



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