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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/metrics/ReconTaskStatusCounter.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 com.google.common.annotations.VisibleForTesting;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.recon.api.types.ReconTaskStatusStat;
+
+import static 
org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_OM_SNAPSHOT_TASK_INTERVAL_DEFAULT;
+import static 
org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_OM_SNAPSHOT_TASK_INTERVAL_DELAY;
+import static 
org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_TASK_STATUS_COUNTER_CYCLES_LIMIT;
+import static 
org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_TASK_STATUS_COUNTER_CYCLES_LIMIT_DEFAULT;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+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_COUNTER_CYCLES_LIMIT} which defaults
+ * to '5' times {@link 
org.apache.hadoop.ozone.recon.ReconServerConfigKeys#OZONE_RECON_OM_SNAPSHOT_TASK_INTERVAL_DELAY}
+ * Each task is mapped to a {@link ReconTaskStatusStat} instance to store the 
counts.
+ */
+@Singleton
+public class ReconTaskStatusCounter {
+  // Stores the configurable timeout duration i.e. the TTL of the counts
+  private final long timeoutDuration;
+
+  // Task name is mapped from the enum to a Pair of <count of successful runs, 
count of failed runs>
+  private final Map<String, ReconTaskStatusStat> taskStatusCounter = new 
ConcurrentHashMap<>();
+
+  @Inject
+  public ReconTaskStatusCounter(OzoneConfiguration conf) {
+    // Get the number of cycles of OM sync task for which we want to store the 
count
+    int countCycles = conf.getInt(
+        OZONE_RECON_TASK_STATUS_COUNTER_CYCLES_LIMIT,

Review Comment:
   We do not need keep history of last 5 status, its like customized 
implementation of metrics via recon api.



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