devabhishekpal commented on code in PR #7517:
URL: https://github.com/apache/ozone/pull/7517#discussion_r1869001756


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/metrics/ReconTaskStatusCounter.java:
##########
@@ -0,0 +1,127 @@
+package org.apache.hadoop.ozone.recon.metrics;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+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;
+
+public class ReconTaskStatusCounter {
+  private static ReconTaskStatusCounter instance;
+  private final long timeoutDuration;
+
+  public enum ReconTasks {
+    ContainerHealthTask,
+    ContainerKeyMapperTask,
+    ContainerSizeCountTask,
+    FileSizeCountTask,
+    NSSummaryTask,
+    OmDeltaRequest,
+    OmTableInsightTask,
+    OmSnapshotRequest,
+    PipelineSyncTask,
+    ReconScmTask
+  }
+
+  static long initializationTime = 0L;
+
+  static Map<ReconTasks, Pair<Integer, Integer>> taskStatusCounter= 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()) {
+      taskStatusCounter.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() {
+    if (null == instance) {
+      instance = new ReconTaskStatusCounter();
+    }
+    return instance;
+  }
+
+  /**
+   * Update the counter's success/failure count based on the task class passed
+   * @param clazz An instance of {@link Class} of the task for which we want 
to update the counter
+   * @param successful Whether the task was successful or not
+   */
+  public void updateCounter(Class<?> clazz, boolean successful) {

Review Comment:
   Removed in 
[5248373](https://github.com/apache/ozone/pull/7517/commits/5248373fede0a47e1475ef14730e4b443445b55d)



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java:
##########
@@ -85,7 +88,7 @@ public void registerTask(ReconOmTask task) {
     taskFailureCounter.put(taskName, new AtomicInteger(0));
     // Create DB record for the task.
     ReconTaskStatus reconTaskStatusRecord = new ReconTaskStatus(taskName,
-        0L, 0L);
+        0L, 0L, null);

Review Comment:
   Addressed in 
[5248373](https://github.com/apache/ozone/pull/7517/commits/5248373fede0a47e1475ef14730e4b443445b55d)



##########
hadoop-ozone/recon-codegen/src/main/java/org/hadoop/ozone/recon/schema/ReconTaskSchemaDefinition.java:
##########
@@ -64,6 +64,7 @@ private void createReconTaskStatusTable(Connection conn) {
         .column("task_name", SQLDataType.VARCHAR(766).nullable(false))
         .column("last_updated_timestamp", SQLDataType.BIGINT)
         .column("last_updated_seq_number", SQLDataType.BIGINT)
+        .column("last_task_successful", SQLDataType.BIT)

Review Comment:
   Addressed in 
[5248373](https://github.com/apache/ozone/pull/7517/commits/5248373fede0a47e1475ef14730e4b443445b55d)



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