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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ReconReplicationManager.java:
##########
@@ -0,0 +1,521 @@
+/*
+ * 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 java.io.IOException;
+import java.time.Clock;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.scm.PlacementPolicy;
+import org.apache.hadoop.hdds.scm.container.ContainerID;
+import org.apache.hadoop.hdds.scm.container.ContainerInfo;
+import org.apache.hadoop.hdds.scm.container.ContainerManager;
+import org.apache.hadoop.hdds.scm.container.ContainerNotFoundException;
+import org.apache.hadoop.hdds.scm.container.ContainerReplica;
+import org.apache.hadoop.hdds.scm.container.replication.NoOpsReplicationQueue;
+import org.apache.hadoop.hdds.scm.container.replication.ReplicationManager;
+import org.apache.hadoop.hdds.scm.container.replication.ReplicationQueue;
+import org.apache.hadoop.hdds.scm.ha.SCMContext;
+import org.apache.hadoop.hdds.scm.node.NodeManager;
+import org.apache.hadoop.hdds.server.events.EventPublisher;
+import 
org.apache.hadoop.ozone.recon.persistence.ContainerHealthSchemaManagerV2;
+import 
org.apache.hadoop.ozone.recon.persistence.ContainerHealthSchemaManagerV2.UnhealthyContainerRecordV2;
+import 
org.apache.ozone.recon.schema.ContainerSchemaDefinitionV2.UnHealthyContainerStates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Recon-specific extension of SCM's ReplicationManager.
+ *
+ * <p><b>Key Differences from SCM:</b></p>
+ * <ol>
+ *   <li>Uses NoOpsContainerReplicaPendingOps stub (no pending operations 
tracking)</li>
+ *   <li>Overrides processAll() to capture ALL container health states (no 
100-sample limit)</li>
+ *   <li>Stores results in Recon's UNHEALTHY_CONTAINERS_V2 table</li>
+ *   <li>Does not issue replication commands (read-only monitoring)</li>
+ * </ol>
+ *
+ * <p><b>Why This Works Without PendingOps:</b></p>
+ * <p>SCM's health check logic uses a two-phase approach:
+ * <ul>
+ *   <li><b>Phase 1 (Health Determination):</b> Calls 
isSufficientlyReplicated(false)
+ *       which ignores pending operations. This phase determines the health 
state.</li>
+ *   <li><b>Phase 2 (Command Deduplication):</b> Calls 
isSufficientlyReplicated(true)
+ *       which considers pending operations. This phase decides whether to 
enqueue
+ *       new commands.</li>
+ * </ul>
+ * Since Recon only needs Phase 1 (health determination) and doesn't issue 
commands,
+ * the stub PendingOps does not cause false positives.</p>
+ *
+ * @see NoOpsContainerReplicaPendingOps
+ * @see ReconReplicationManagerReport
+ */
+public class ReconReplicationManager extends ReplicationManager {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(ReconReplicationManager.class);
+
+  private final ContainerHealthSchemaManagerV2 healthSchemaManager;
+  private final ContainerManager containerManager;
+
+  /**
+   * Immutable wiring context for ReconReplicationManager initialization.
+   */
+  public static final class InitContext {
+    private final ReplicationManagerConfiguration rmConf;
+    private final ConfigurationSource conf;
+    private final ContainerManager containerManager;
+    private final PlacementPolicy ratisContainerPlacement;
+    private final PlacementPolicy ecContainerPlacement;
+    private final EventPublisher eventPublisher;
+    private final SCMContext scmContext;
+    private final NodeManager nodeManager;
+    private final Clock clock;
+
+    private InitContext(Builder builder) {
+      this.rmConf = builder.rmConf;
+      this.conf = builder.conf;
+      this.containerManager = builder.containerManager;
+      this.ratisContainerPlacement = builder.ratisContainerPlacement;
+      this.ecContainerPlacement = builder.ecContainerPlacement;
+      this.eventPublisher = builder.eventPublisher;
+      this.scmContext = builder.scmContext;
+      this.nodeManager = builder.nodeManager;
+      this.clock = builder.clock;
+    }
+
+    public static Builder newBuilder() {
+      return new Builder();
+    }
+
+    /**
+     * Builder for creating {@link InitContext} instances.
+     */
+    public static final class Builder {

Review Comment:
   Lombok?



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