devabhishekpal commented on code in PR #7517: URL: https://github.com/apache/ozone/pull/7517#discussion_r1870695849
########## hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLastTaskStatusUpgradeAction.java: ########## @@ -0,0 +1,76 @@ +/* + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.upgrade; + +import org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade; +import org.jooq.DSLContext; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; + +import static org.hadoop.ozone.recon.codegen.SqlDbUtils.COLUMN_EXISTS_CHECK; +import static org.hadoop.ozone.recon.codegen.SqlDbUtils.TABLE_EXISTS_CHECK; +import static org.hadoop.ozone.recon.schema.ReconTaskSchemaDefinition.RECON_TASK_STATUS_TABLE_NAME; + + +/** + * Handles the upgrade for {@link org.hadoop.ozone.recon.schema.ReconTaskSchemaDefinition} + * in case of missing <code>last_task_successful</code> and <code>current_task_run_status</code> columns. + */ +@UpgradeActionRecon(feature = ReconLayoutFeature.TASK_STATUS_COLUMN_ADDITION, + type = ReconUpgradeAction.UpgradeActionType.FINALIZE) +public class ReconLastTaskStatusUpgradeAction implements ReconUpgradeAction { + + public static final Logger LOG = LoggerFactory.getLogger(ReconLastTaskStatusUpgradeAction.class); + + @Override + public void execute(ReconStorageContainerManagerFacade scmFacade) throws SQLException { + DataSource dataSource = scmFacade.getDataSource(); + try (Connection conn = dataSource.getConnection()) { + if (!TABLE_EXISTS_CHECK.test(conn, RECON_TASK_STATUS_TABLE_NAME)) { + return; + } + DSLContext dslContext = DSL.using(conn); + + if (!COLUMN_EXISTS_CHECK.apply(conn, RECON_TASK_STATUS_TABLE_NAME, "last_task_run_status") + && !COLUMN_EXISTS_CHECK.apply(conn, RECON_TASK_STATUS_TABLE_NAME, "current_task_run_status")) { Review Comment: Added the appropriate comment regarding the check and a TODO for the proper revert/fix which should go in as a part of the framework fix in HDDS-11846 ########## hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/metrics/ReconTaskStatusCounter.java: ########## @@ -0,0 +1,141 @@ +/* + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.metrics; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; + +import static org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_TASK_STATUS_STORAGE_DURATION; +import static org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_TASK_STATUS_STORAGE_DURATION_DEFAULT; + +import java.util.EnumMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * This class contains definitions and implementation of Recon Task Status counters + * For each task we maintain a count of the successes and the failures. + * This count is stored for a configurable + * {@link org.apache.hadoop.ozone.recon.ReconServerConfigKeys#OZONE_RECON_TASK_STATUS_STORAGE_DURATION} + * which defaults to 30 minutes. + * Each task is mapped to a {@link Pair} of <code>{no. of successful runs, no. of failed runs}</code> + */ +public class ReconTaskStatusCounter { + + // Stores an instance of this class to maintain state across calls + private static ReconTaskStatusCounter instance; + // Stores the configurable timeout duration i.e. the TTL of the counts + private final long timeoutDuration; + + /** + * {@link Enum} to store the various tasks that are run in Recon. + */ + public enum ReconTasks { + ContainerHealthTask, + ContainerKeyMapperTask, + ContainerSizeCountTask, + FileSizeCountTask, + NSSummaryTask, + OmDeltaRequest, + OmTableInsightTask, + OmSnapshotRequest, + PipelineSyncTask, + ReconScmTask Review Comment: Removed in [90c1997](https://github.com/apache/ozone/pull/7517/commits/90c1997d1a1c2906198d2117542ba2fa10869a56) -- 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]
