adoroszlai commented on code in PR #7795:
URL: https://github.com/apache/ozone/pull/7795#discussion_r1938998104
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTask.java:
##########
@@ -101,21 +101,37 @@ public String getTaskName() {
@Override
public Pair<String, Boolean> process(OMUpdateEventBatch events) {
long startTime = System.currentTimeMillis();
- boolean success = nsSummaryTaskWithFSO.processWithFSO(events);
- if (!success) {
- LOG.error("processWithFSO failed.");
- }
- success = nsSummaryTaskWithLegacy.processWithLegacy(events);
- if (!success) {
- LOG.error("processWithLegacy failed.");
- }
- success = nsSummaryTaskWithOBS.processWithOBS(events);
- if (!success) {
- LOG.error("processWithOBS failed.");
+
+ // Thread pool to execute tasks concurrently
+ ExecutorService executorService = Executors.newFixedThreadPool(3);
Review Comment:
Creating a thread pool is heavy-weight, it should be reused.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTask.java:
##########
@@ -101,21 +101,37 @@ public String getTaskName() {
@Override
public Pair<String, Boolean> process(OMUpdateEventBatch events) {
long startTime = System.currentTimeMillis();
- boolean success = nsSummaryTaskWithFSO.processWithFSO(events);
- if (!success) {
- LOG.error("processWithFSO failed.");
- }
- success = nsSummaryTaskWithLegacy.processWithLegacy(events);
- if (!success) {
- LOG.error("processWithLegacy failed.");
- }
- success = nsSummaryTaskWithOBS.processWithOBS(events);
- if (!success) {
- LOG.error("processWithOBS failed.");
+
+ // Thread pool to execute tasks concurrently
+ ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+ // Create a list of tasks
+ List<Callable<Boolean>> tasks = new ArrayList<>();
+ tasks.add(() -> nsSummaryTaskWithFSO.processWithFSO(events));
+ tasks.add(() -> nsSummaryTaskWithLegacy.processWithLegacy(events));
+ tasks.add(() -> nsSummaryTaskWithOBS.processWithOBS(events));
+
+ try {
+ // Execute all tasks in parallel
+ List<Future<Boolean>> results = executorService.invokeAll(tasks);
+
+ // Check results and return failure if any task failed
+ for (Future<Boolean> result : results) {
+ if (!result.get()) {
+ LOG.error("One or more process tasks failed.");
+ return new ImmutablePair<>(getTaskName(), false);
Review Comment:
Wait for all results before returning.
--
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]