devabhishekpal commented on code in PR #7517:
URL: https://github.com/apache/ozone/pull/7517#discussion_r1870828177
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/OzoneManagerServiceProviderImpl.java:
##########
@@ -225,25 +229,30 @@ public OzoneManagerServiceProviderImpl(
new ThreadFactoryBuilder().setNameFormat(threadNamePrefix +
"SyncOM-%d")
.build();
this.reconContext = reconContext;
+ this.deltaUpdateTaskStatus = new ReconTaskStatus(
+ OmSnapshotTaskName.OmDeltaRequest.name(),
+ 0L, 0L, 0, 0);
+ this.snapshotUpdateTaskStatus = new ReconTaskStatus(
+ OmSnapshotTaskName.OmSnapshotRequest.name(),
+ 0L, 0L, 0, 0);
Review Comment:
Changed this to initialize with the existing OM DB Sequence number, but this
is just the first initialization of the object.
In later calls we are overwriting the values as was the implementation
before.
In the previous implementation we were creating task status object just
before update. In this we are creating the object initially and wherever
required we update/overwrite the values.
##########
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
+ }
+
+ private long initializationTime = 0L;
+
+ // Task name is mapped from the enum to a Pair of <count of successful runs,
count of failed runs>
+ private static final Map<ReconTasks, Pair<Integer, Integer>>
TASK_STATUS_COUNTER = new EnumMap<>(ReconTasks.class);
+
+ public ReconTaskStatusCounter() {
+ OzoneConfiguration conf = new OzoneConfiguration();
+ timeoutDuration = conf.getTimeDuration(
+ OZONE_RECON_TASK_STATUS_STORAGE_DURATION,
+ OZONE_RECON_TASK_STATUS_STORAGE_DURATION_DEFAULT,
+ TimeUnit.MILLISECONDS
+ );
+
+ initializationTime = System.currentTimeMillis();
+ for (ReconTasks task: ReconTasks.values()) {
+ TASK_STATUS_COUNTER.put(task, Pair.of(0, 0));
+ }
+ }
+
+ /**
+ * Get an instance of <code>this</code> {@link ReconTaskStatusCounter} in
order to persist state
+ * of the task counters between multiple modules/packages.
+ * @return an instance of current {@link ReconTaskStatusCounter}
+ */
+ public static ReconTaskStatusCounter getCurrentInstance() {
Review Comment:
Addressed in
[ce8848c](https://github.com/apache/ozone/pull/7517/commits/ce8848c116c886de1522126abd592ddb05b8df57)
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java:
##########
@@ -69,6 +72,7 @@ public ReconTaskControllerImpl(OzoneConfiguration
configuration,
threadCount = configuration.getInt(OZONE_RECON_TASK_THREAD_COUNT_KEY,
OZONE_RECON_TASK_THREAD_COUNT_DEFAULT);
this.reconTaskStatusDao = reconTaskStatusDao;
+ taskStatusCounter = ReconTaskStatusCounter.getCurrentInstance();
Review Comment:
Addressed in
[ce8848c](https://github.com/apache/ozone/pull/7517/commits/ce8848c116c886de1522126abd592ddb05b8df57)
--
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]