yandrey321 commented on code in PR #9258:
URL: https://github.com/apache/ozone/pull/9258#discussion_r2833793905


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTaskV2.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.recon.fsck;
+
+import javax.inject.Inject;
+import org.apache.hadoop.ozone.recon.scm.ReconScmTask;
+import org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade;
+import org.apache.hadoop.ozone.recon.tasks.ReconTaskConfig;
+import 
org.apache.hadoop.ozone.recon.tasks.updater.ReconTaskStatusUpdaterManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * V2 implementation of Container Health Task using Local ReplicationManager.
+ *
+ * <p><b>Solution:</b></p>
+ * <ul>
+ *   <li>Uses Recon's local ReplicationManager (not RPC to SCM)</li>
+ *   <li>Calls processAll() once to check all containers in batch</li>
+ *   <li>ReplicationManager uses stub PendingOps 
(NoOpsContainerReplicaPendingOps)</li>
+ *   <li>No false positives despite stub - health determination ignores 
pending ops</li>
+ *   <li>All database operations handled inside ReconReplicationManager</li>
+ * </ul>
+ *
+ * <p><b>Benefits over RPC call to SCM 3:</b></p>
+ * <ul>
+ *   <li>Zero RPC overhead (no per-container calls to SCM)</li>
+ *   <li>Zero SCM load</li>
+ *   <li>Simpler code - single method call</li>
+ *   <li>Perfect accuracy (proven via code analysis)</li>
+ *   <li>Captures ALL container health states (no 100-sample limit)</li>
+ * </ul>
+ *
+ * @see ReconReplicationManager
+ * @see NoOpsContainerReplicaPendingOps
+ */
+public class ContainerHealthTaskV2 extends ReconScmTask {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(ContainerHealthTaskV2.class);
+
+  private final ReconStorageContainerManagerFacade reconScm;
+  private final long interval;
+
+  @Inject
+  public ContainerHealthTaskV2(
+      ReconTaskConfig reconTaskConfig,
+      ReconTaskStatusUpdaterManager taskStatusUpdaterManager,
+      ReconStorageContainerManagerFacade reconScm) {
+    super(taskStatusUpdaterManager);
+    this.reconScm = reconScm;
+    this.interval = 
reconTaskConfig.getMissingContainerTaskInterval().toMillis();
+    LOG.info("Initialized ContainerHealthTaskV2 with Local ReplicationManager, 
interval={}ms",
+        interval);
+  }
+
+  @Override
+  protected void run() {
+    while (canRun()) {
+      try {
+        initializeAndRunTask();
+
+        // Wait before next run using configured interval
+        synchronized (this) {
+          wait(interval);
+        }
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        LOG.info("ContainerHealthTaskV2 interrupted");
+        break;
+      } catch (Exception e) {
+        LOG.error("Error in ContainerHealthTaskV2", e);
+      }
+    }
+  }
+
+  /**
+   * Main task execution - uses Recon's local ReplicationManager.
+   *
+   * <p>Simply calls processAll() on ReconReplicationManager, which:
+   * <ul>
+   *   <li>Processes all containers in batch using inherited health check 
chain</li>
+   *   <li>Captures ALL unhealthy containers (no 100-sample limit)</li>
+   *   <li>Stores results in UNHEALTHY_CONTAINERS_V2 table</li>
+   * </ul>
+   */
+  @Override
+  protected void runTask() throws Exception {
+    LOG.info("ContainerHealthTaskV2 starting - using local 
ReplicationManager");
+
+    // Get Recon's ReplicationManager (actually a ReconReplicationManager 
instance)
+    ReconReplicationManager reconRM =
+        (ReconReplicationManager) reconScm.getReplicationManager();
+
+    // Call processAll() ONCE - processes all containers in batch!
+    // This:
+    // 1. Runs health checks on all containers using inherited SCM logic
+    // 2. Captures ALL unhealthy containers (no sampling)
+    // 3. Stores all health states in database
+    reconRM.processAll();
+
+    LOG.info("ContainerHealthTaskV2 completed successfully");

Review Comment:
   should also expose 'runtime' metric and log end-start time



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