devmadhuu commented on code in PR #9258: URL: https://github.com/apache/ozone/pull/9258#discussion_r2836193262
########## 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); Review Comment: Probably then, this needs to be consistent with other ReconSCM tasks as well. We can do later in other PR. -- 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]
