ArafatKhan2198 commented on code in PR #8856:
URL: https://github.com/apache/ozone/pull/8856#discussion_r2240222264


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTask.java:
##########
@@ -210,10 +267,46 @@ public TaskResult reprocess(OMMetadataManager 
omMetadataManager) {
           TimeUnit.NANOSECONDS.toMillis(endTime - startTime);
 
       // Log performance metrics
-      LOG.info("Task execution time: {} milliseconds", durationInMillis);
+      LOG.info("NSSummary reprocess execution time: {} milliseconds", 
durationInMillis);
+      
+      // Reset state to IDLE on successful completion
+      if (success) {
+        REBUILD_STATE.set(RebuildState.IDLE);
+        LOG.info("NSSummary tree reprocess completed successfully with unified 
control.");
+      }

Review Comment:
   State reset only happens on success.
   Shouldn't we always reset to either IDLE or FAILED in finally block ?



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java:
##########
@@ -111,6 +109,43 @@ public class ReconUtils {
   public ReconUtils() {
   }
 
+  /**
+   * Get the current rebuild state of NSSummary tree.
+   * Delegates to NSSummaryTask's unified control mechanism.
+   * 
+   * @return current RebuildState from NSSummaryTask
+   */
+  public static org.apache.hadoop.ozone.recon.tasks.NSSummaryTask.RebuildState 
getNSSummaryRebuildState() {
+    return org.apache.hadoop.ozone.recon.tasks.NSSummaryTask.getRebuildState();
+  }
+
+  /**
+   * Convenience method to trigger asynchronous NSSummary tree rebuild.
+   * Uses the unified control mechanism in NSSummaryTask.
+   * 
+   * @param reconNamespaceSummaryManager The namespace summary manager
+   * @param omMetadataManager The OM metadata manager
+   * @return true if rebuild was triggered successfully, false otherwise
+   */
+  public static boolean triggerAsyncNSSummaryRebuild(
+      ReconNamespaceSummaryManager reconNamespaceSummaryManager,
+      ReconOMMetadataManager omMetadataManager) {
+    
+    // Submit rebuild task to single thread executor for async execution
+    NSSUMMARY_REBUILD_EXECUTOR.submit(() -> {

Review Comment:
   Method returns boolean but doesn't use unified control state.
   We can add the state to RUNNING state. 
   
   ```
   public static boolean triggerAsyncNSSummaryRebuild(...) {
     RebuildState currentState = NSSummaryTask.getRebuildState();
     if (currentState == RebuildState.RUNNING) {
       log.info("NSSummary rebuild already in progress");
       return false;
     }
     
     NSSUMMARY_REBUILD_EXECUTOR.submit(() -> {
       // ... async work
     });
     return true;
   }
   ```



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java:
##########
@@ -111,6 +109,43 @@ public class ReconUtils {
   public ReconUtils() {
   }
 
+  /**
+   * Get the current rebuild state of NSSummary tree.
+   * Delegates to NSSummaryTask's unified control mechanism.
+   * 
+   * @return current RebuildState from NSSummaryTask
+   */
+  public static org.apache.hadoop.ozone.recon.tasks.NSSummaryTask.RebuildState 
getNSSummaryRebuildState() {
+    return org.apache.hadoop.ozone.recon.tasks.NSSummaryTask.getRebuildState();
+  }
+
+  /**
+   * Convenience method to trigger asynchronous NSSummary tree rebuild.
+   * Uses the unified control mechanism in NSSummaryTask.
+   * 
+   * @param reconNamespaceSummaryManager The namespace summary manager
+   * @param omMetadataManager The OM metadata manager
+   * @return true if rebuild was triggered successfully, false otherwise
+   */
+  public static boolean triggerAsyncNSSummaryRebuild(
+      ReconNamespaceSummaryManager reconNamespaceSummaryManager,
+      ReconOMMetadataManager omMetadataManager) {
+    
+    // Submit rebuild task to single thread executor for async execution
+    NSSUMMARY_REBUILD_EXECUTOR.submit(() -> {
+      try {
+        // This will go through NSSummaryTask's unified control mechanism
+        reconNamespaceSummaryManager.rebuildNSSummaryTree(omMetadataManager);
+        log.info("Async NSSummary tree rebuild completed successfully.");
+      } catch (Exception e) {
+        log.error("Async NSSummary tree rebuild failed.", e);
+      }
+    });
+    
+    log.info("Async NSSummary tree rebuild triggered successfully.");
+    return true;

Review Comment:
   Always returns true regardless of actual state?



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