You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "swamirishi (via GitHub)" <gi...@apache.org> on 2025/11/28 06:15:49 UTC

[PR] HDDS-14020. Use forkjoin pool instead of thread pool on background service [ozone]

swamirishi opened a new pull request, #9390:
URL: https://github.com/apache/ozone/pull/9390

   ## What changes were proposed in this pull request?
   Currently both background task and shutdown acquire a synchronized lock which can lead to a deadlock on shutdown which means the threadPool shutdown takes time unnecessarily. The synchronized block on task was taken to ensure there are no parallel tasks that run together. 
   This patch removes the unnecessary synchronized calls and converts the ThreadPoolExecutor to a fork join pool. Instead of hacking around with the wait logic present at the start of a periodic task to avoid deadlock in case of a single threaded background service we can use a forkJoin pool to fork on to background and task and join all the forked task to implement the wait. 
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-14020
   
   ## How was this patch tested?
   Existing tests should be sufficient


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "smengcl (via GitHub)" <gi...@apache.org>.
smengcl commented on code in PR #9390:
URL: https://github.com/apache/ozone/pull/9390#discussion_r2739047394


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundTask.java:
##########
@@ -18,16 +18,56 @@
 package org.apache.hadoop.hdds.utils;
 
 import java.util.concurrent.Callable;
+import java.util.concurrent.RecursiveTask;
 
 /**
  * A task thread to run by {@link BackgroundService}.
  */
-public interface BackgroundTask extends Callable<BackgroundTaskResult> {
+public abstract class BackgroundTask extends RecursiveTask<BackgroundTask.BackgroundTaskForkResult>

Review Comment:
   Since this one is closed. I've raised https://github.com/apache/ozone/pull/9686 that addressed the comment above.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #9390:
URL: https://github.com/apache/ozone/pull/9390#discussion_r2575566273


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundTask.java:
##########
@@ -18,16 +18,56 @@
 package org.apache.hadoop.hdds.utils;
 
 import java.util.concurrent.Callable;
+import java.util.concurrent.RecursiveTask;
 
 /**
  * A task thread to run by {@link BackgroundService}.
  */
-public interface BackgroundTask extends Callable<BackgroundTaskResult> {
+public abstract class BackgroundTask extends RecursiveTask<BackgroundTask.BackgroundTaskForkResult>

Review Comment:
   need not change BackgroundTask, but encapsulate in inside ForkJoinTask as transient and can be scheduled. This avoid changing all other place due to change in framework. Externally, its just Runnable task.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java:
##########
@@ -138,84 +138,148 @@ protected void execTaskCompletion() { }
    * Run one or more background tasks concurrently.
    * Wait until all tasks to return the result.
    */
-  public class PeriodicalTask implements Runnable {
-    @Override
-    public void run() {
-      // wait for previous set of tasks to complete
-      try {
-        future.join();
-      } catch (RuntimeException e) {
-        LOG.error("Background service execution failed.", e);
-      } finally {
-        execTaskCompletion();
-      }
+  public class PeriodicalTask extends RecursiveAction {
+    private int numberOfLoops;
+    private final Queue<BackgroundTask> tasksInFlight;
+    private final AtomicBoolean isShutdown;
 
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Running background service : {}", serviceName);
+    public PeriodicalTask(int numberOfLoops) {
+      this.numberOfLoops = numberOfLoops;
+      this.tasksInFlight = new LinkedList<>();
+      this.isShutdown = BackgroundService.this.isShutdown;
+    }
+
+    private boolean waitForNextInterval() {
+
+      if (numberOfLoops > 0) {
+        numberOfLoops--;
+        if (numberOfLoops == 0) {
+          return false;
+        }
       }
-      BackgroundTaskQueue tasks = getTasks();
-      if (tasks.isEmpty()) {
-        // No task found, or some problems to init tasks
-        // return and retry in next interval.
-        return;
+      // Check if the executor has been shutdown during task execution.
+      if (!isShutdown.get()) {
+        synchronized (BackgroundService.this) {
+          // Get the shutdown flag again after acquiring the lock.
+          if (isShutdown.get()) {
+            return false;
+          }
+          try {
+            BackgroundService.this.wait(intervalInMillis);
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            LOG.warn("Interrupted while waiting for next interval.", e);
+            return false;
+          }
+        }
       }
+      return !isShutdown.get();
+    }
+
+    @Override
+    public void compute() {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        LOG.debug("Running background service : {}", serviceName);
       }
-      synchronized (BackgroundService.this) {
+      boolean runAgain = true;
+      do {
+        future = new CompletableFuture<>();
+        BackgroundTaskQueue tasks = getTasks(true);
+        if (tasks.isEmpty()) {
+          // No task found, or some problems to init tasks
+          // return and retry in next interval.
+          continue;

Review Comment:
   this can cause continuous loop as directly jump to while condition without waitForNextInterval()



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java:
##########
@@ -138,84 +138,148 @@ protected void execTaskCompletion() { }
    * Run one or more background tasks concurrently.
    * Wait until all tasks to return the result.
    */
-  public class PeriodicalTask implements Runnable {
-    @Override
-    public void run() {
-      // wait for previous set of tasks to complete
-      try {
-        future.join();
-      } catch (RuntimeException e) {
-        LOG.error("Background service execution failed.", e);
-      } finally {
-        execTaskCompletion();
-      }
+  public class PeriodicalTask extends RecursiveAction {
+    private int numberOfLoops;
+    private final Queue<BackgroundTask> tasksInFlight;
+    private final AtomicBoolean isShutdown;
 
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Running background service : {}", serviceName);
+    public PeriodicalTask(int numberOfLoops) {
+      this.numberOfLoops = numberOfLoops;
+      this.tasksInFlight = new LinkedList<>();
+      this.isShutdown = BackgroundService.this.isShutdown;
+    }
+
+    private boolean waitForNextInterval() {
+
+      if (numberOfLoops > 0) {
+        numberOfLoops--;
+        if (numberOfLoops == 0) {
+          return false;
+        }
       }
-      BackgroundTaskQueue tasks = getTasks();
-      if (tasks.isEmpty()) {
-        // No task found, or some problems to init tasks
-        // return and retry in next interval.
-        return;
+      // Check if the executor has been shutdown during task execution.
+      if (!isShutdown.get()) {
+        synchronized (BackgroundService.this) {
+          // Get the shutdown flag again after acquiring the lock.
+          if (isShutdown.get()) {
+            return false;
+          }
+          try {
+            BackgroundService.this.wait(intervalInMillis);
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            LOG.warn("Interrupted while waiting for next interval.", e);
+            return false;
+          }
+        }
       }
+      return !isShutdown.get();
+    }
+
+    @Override
+    public void compute() {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        LOG.debug("Running background service : {}", serviceName);
       }
-      synchronized (BackgroundService.this) {
+      boolean runAgain = true;
+      do {
+        future = new CompletableFuture<>();
+        BackgroundTaskQueue tasks = getTasks(true);
+        if (tasks.isEmpty()) {
+          // No task found, or some problems to init tasks
+          // return and retry in next interval.
+          continue;
+        }
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        }
+
         while (!tasks.isEmpty()) {
           BackgroundTask task = tasks.poll();
-          future = future.thenCombine(CompletableFuture.runAsync(() -> {
-            long startTime = System.nanoTime();
-            try {
-              BackgroundTaskResult result = task.call();
-              if (LOG.isDebugEnabled()) {
-                LOG.debug("task execution result size {}", result.getSize());
-              }
-            } catch (Throwable e) {
-              LOG.error("Background task execution failed", e);
-              if (e instanceof Error) {
-                throw (Error) e;
-              }
-            } finally {
-              long endTime = System.nanoTime();
-              if (endTime - startTime > serviceTimeoutInNanos) {
-                LOG.warn("{} Background task execution took {}ns > {}ns(timeout)",
-                    serviceName, endTime - startTime, serviceTimeoutInNanos);
-              }
+          // Fork and submit the task back to executor.
+          task.fork();
+          tasksInFlight.offer(task);
+        }
+
+        while (!tasksInFlight.isEmpty()) {
+          BackgroundTask taskInFlight = tasksInFlight.poll();
+          // Join the tasks forked before and wait for the result one by one.
+          BackgroundTask.BackgroundTaskForkResult result = taskInFlight.join();

Review Comment:
   Do the task is cancellable? if crosses certain time



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java:
##########
@@ -138,84 +138,148 @@ protected void execTaskCompletion() { }
    * Run one or more background tasks concurrently.
    * Wait until all tasks to return the result.
    */
-  public class PeriodicalTask implements Runnable {
-    @Override
-    public void run() {
-      // wait for previous set of tasks to complete
-      try {
-        future.join();
-      } catch (RuntimeException e) {
-        LOG.error("Background service execution failed.", e);
-      } finally {
-        execTaskCompletion();
-      }
+  public class PeriodicalTask extends RecursiveAction {
+    private int numberOfLoops;
+    private final Queue<BackgroundTask> tasksInFlight;
+    private final AtomicBoolean isShutdown;
 
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Running background service : {}", serviceName);
+    public PeriodicalTask(int numberOfLoops) {
+      this.numberOfLoops = numberOfLoops;
+      this.tasksInFlight = new LinkedList<>();
+      this.isShutdown = BackgroundService.this.isShutdown;
+    }
+
+    private boolean waitForNextInterval() {
+
+      if (numberOfLoops > 0) {
+        numberOfLoops--;
+        if (numberOfLoops == 0) {
+          return false;
+        }
       }
-      BackgroundTaskQueue tasks = getTasks();
-      if (tasks.isEmpty()) {
-        // No task found, or some problems to init tasks
-        // return and retry in next interval.
-        return;
+      // Check if the executor has been shutdown during task execution.
+      if (!isShutdown.get()) {
+        synchronized (BackgroundService.this) {
+          // Get the shutdown flag again after acquiring the lock.
+          if (isShutdown.get()) {
+            return false;
+          }
+          try {
+            BackgroundService.this.wait(intervalInMillis);
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            LOG.warn("Interrupted while waiting for next interval.", e);
+            return false;
+          }
+        }
       }
+      return !isShutdown.get();
+    }
+
+    @Override
+    public void compute() {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        LOG.debug("Running background service : {}", serviceName);
       }
-      synchronized (BackgroundService.this) {
+      boolean runAgain = true;
+      do {
+        future = new CompletableFuture<>();
+        BackgroundTaskQueue tasks = getTasks(true);
+        if (tasks.isEmpty()) {
+          // No task found, or some problems to init tasks
+          // return and retry in next interval.
+          continue;
+        }
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        }
+
         while (!tasks.isEmpty()) {
           BackgroundTask task = tasks.poll();
-          future = future.thenCombine(CompletableFuture.runAsync(() -> {
-            long startTime = System.nanoTime();
-            try {
-              BackgroundTaskResult result = task.call();
-              if (LOG.isDebugEnabled()) {
-                LOG.debug("task execution result size {}", result.getSize());
-              }
-            } catch (Throwable e) {
-              LOG.error("Background task execution failed", e);
-              if (e instanceof Error) {
-                throw (Error) e;
-              }
-            } finally {
-              long endTime = System.nanoTime();
-              if (endTime - startTime > serviceTimeoutInNanos) {
-                LOG.warn("{} Background task execution took {}ns > {}ns(timeout)",
-                    serviceName, endTime - startTime, serviceTimeoutInNanos);
-              }
+          // Fork and submit the task back to executor.
+          task.fork();
+          tasksInFlight.offer(task);
+        }
+
+        while (!tasksInFlight.isEmpty()) {
+          BackgroundTask taskInFlight = tasksInFlight.poll();
+          // Join the tasks forked before and wait for the result one by one.
+          BackgroundTask.BackgroundTaskForkResult result = taskInFlight.join();
+          // Check for exception first in the task execution.
+          if (result.getThrowable() != null) {
+            LOG.error("Background task execution failed", result.getThrowable());
+          } else {
+            if (LOG.isDebugEnabled()) {
+              LOG.debug("task execution result size {}", result.getResult().getSize());
             }
-          }, exec).exceptionally(e -> null), (Void1, Void) -> null);
+          }
+          if (result.getTotalExecutionTime() > serviceTimeoutInNanos) {
+            LOG.warn("{} Background task execution took {}ns > {}ns(timeout)",
+                serviceName, result.getTotalExecutionTime(), serviceTimeoutInNanos);
+          }
         }
-      }
+        future.complete(null);

Review Comment:
   unable to get use of future here



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9390:
URL: https://github.com/apache/ozone/pull/9390#issuecomment-3712531271

   This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "smengcl (via GitHub)" <gi...@apache.org>.
smengcl commented on PR #9390:
URL: https://github.com/apache/ozone/pull/9390#issuecomment-3747095422

   @sumitagrawl Would you like to take another look?


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #9390:
URL: https://github.com/apache/ozone/pull/9390#discussion_r2579117162


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java:
##########
@@ -138,84 +138,148 @@ protected void execTaskCompletion() { }
    * Run one or more background tasks concurrently.
    * Wait until all tasks to return the result.
    */
-  public class PeriodicalTask implements Runnable {
-    @Override
-    public void run() {
-      // wait for previous set of tasks to complete
-      try {
-        future.join();
-      } catch (RuntimeException e) {
-        LOG.error("Background service execution failed.", e);
-      } finally {
-        execTaskCompletion();
-      }
+  public class PeriodicalTask extends RecursiveAction {
+    private int numberOfLoops;
+    private final Queue<BackgroundTask> tasksInFlight;
+    private final AtomicBoolean isShutdown;
 
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Running background service : {}", serviceName);
+    public PeriodicalTask(int numberOfLoops) {
+      this.numberOfLoops = numberOfLoops;
+      this.tasksInFlight = new LinkedList<>();
+      this.isShutdown = BackgroundService.this.isShutdown;
+    }
+
+    private boolean waitForNextInterval() {
+
+      if (numberOfLoops > 0) {
+        numberOfLoops--;
+        if (numberOfLoops == 0) {
+          return false;
+        }
       }
-      BackgroundTaskQueue tasks = getTasks();
-      if (tasks.isEmpty()) {
-        // No task found, or some problems to init tasks
-        // return and retry in next interval.
-        return;
+      // Check if the executor has been shutdown during task execution.
+      if (!isShutdown.get()) {
+        synchronized (BackgroundService.this) {
+          // Get the shutdown flag again after acquiring the lock.
+          if (isShutdown.get()) {
+            return false;
+          }
+          try {
+            BackgroundService.this.wait(intervalInMillis);
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            LOG.warn("Interrupted while waiting for next interval.", e);
+            return false;
+          }
+        }
       }
+      return !isShutdown.get();
+    }
+
+    @Override
+    public void compute() {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        LOG.debug("Running background service : {}", serviceName);
       }
-      synchronized (BackgroundService.this) {
+      boolean runAgain = true;
+      do {
+        future = new CompletableFuture<>();
+        BackgroundTaskQueue tasks = getTasks(true);
+        if (tasks.isEmpty()) {
+          // No task found, or some problems to init tasks
+          // return and retry in next interval.
+          continue;
+        }
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Number of background tasks to execute : {}", tasks.size());
+        }
+
         while (!tasks.isEmpty()) {
           BackgroundTask task = tasks.poll();
-          future = future.thenCombine(CompletableFuture.runAsync(() -> {
-            long startTime = System.nanoTime();
-            try {
-              BackgroundTaskResult result = task.call();
-              if (LOG.isDebugEnabled()) {
-                LOG.debug("task execution result size {}", result.getSize());
-              }
-            } catch (Throwable e) {
-              LOG.error("Background task execution failed", e);
-              if (e instanceof Error) {
-                throw (Error) e;
-              }
-            } finally {
-              long endTime = System.nanoTime();
-              if (endTime - startTime > serviceTimeoutInNanos) {
-                LOG.warn("{} Background task execution took {}ns > {}ns(timeout)",
-                    serviceName, endTime - startTime, serviceTimeoutInNanos);
-              }
+          // Fork and submit the task back to executor.
+          task.fork();
+          tasksInFlight.offer(task);
+        }
+
+        while (!tasksInFlight.isEmpty()) {
+          BackgroundTask taskInFlight = tasksInFlight.poll();
+          // Join the tasks forked before and wait for the result one by one.
+          BackgroundTask.BackgroundTaskForkResult result = taskInFlight.join();

Review Comment:
   We can implement something if we want to. But this is not supported even today.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9390:
URL: https://github.com/apache/ozone/pull/9390#issuecomment-3747087436

   Thank you for your contribution. This PR is being closed due to inactivity. If needed, feel free to reopen it.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #9390: HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService
URL: https://github.com/apache/ozone/pull/9390


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #9390:
URL: https://github.com/apache/ozone/pull/9390#discussion_r2591852435


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundTask.java:
##########
@@ -18,16 +18,56 @@
 package org.apache.hadoop.hdds.utils;
 
 import java.util.concurrent.Callable;
+import java.util.concurrent.RecursiveTask;
 
 /**
  * A task thread to run by {@link BackgroundService}.
  */
-public interface BackgroundTask extends Callable<BackgroundTaskResult> {
+public abstract class BackgroundTask extends RecursiveTask<BackgroundTask.BackgroundTaskForkResult>

Review Comment:
   We can do like below, please check... BackgroundTaskForkJoin will not be exposed.
   ```
   public class BackgroundTaskForkJoin extends RecursiveTask<BackgroundTaskForkJoin.BackgroundTaskForkResult> {
     private static final long serialVersionUID = 1L;
     private final transient BackgroundTask backgroundTask;
     
     public BackgroundTaskForkJoin(BackgroundTask backgroundTask) {
       this.backgroundTask = backgroundTask;
     }
     
     public static class BackgroundTaskForkResult {
       ...
     }
   }
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use forkjoin pool instead of a ScheduledThreadPoolExecutor on background service [ozone]

Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on PR #9390:
URL: https://github.com/apache/ozone/pull/9390#issuecomment-3588179216

   @SaketaChalamchala do you wanna review this?


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on PR #9390:
URL: https://github.com/apache/ozone/pull/9390#issuecomment-3597921694

   @rnblough 


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-14020. Use ForkJoinPool instead of a ScheduledThreadPoolExecutor in BackgroundService [ozone]

Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #9390:
URL: https://github.com/apache/ozone/pull/9390#discussion_r2575610140


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BackgroundTask.java:
##########
@@ -18,16 +18,56 @@
 package org.apache.hadoop.hdds.utils;
 
 import java.util.concurrent.Callable;
+import java.util.concurrent.RecursiveTask;
 
 /**
  * A task thread to run by {@link BackgroundService}.
  */
-public interface BackgroundTask extends Callable<BackgroundTaskResult> {
+public abstract class BackgroundTask extends RecursiveTask<BackgroundTask.BackgroundTaskForkResult>

Review Comment:
   The external task has to be a recursive task otherwise forkjoin pool cannot work



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org