devmadhuu commented on code in PR #10384:
URL: https://github.com/apache/ozone/pull/10384#discussion_r3380100807
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/metrics/ReconScmContainerSyncMetrics.java:
##########
@@ -17,50 +17,78 @@
package org.apache.hadoop.ozone.recon.metrics;
+import com.google.common.base.CaseFormat;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.metrics2.MetricsCollector;
+import org.apache.hadoop.metrics2.MetricsInfo;
+import org.apache.hadoop.metrics2.MetricsRecordBuilder;
+import org.apache.hadoop.metrics2.MetricsSource;
import org.apache.hadoop.metrics2.MetricsSystem;
-import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
-import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
-import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
+import org.apache.hadoop.metrics2.lib.Interns;
import org.apache.hadoop.ozone.OzoneConsts;
/**
- * Metrics for Recon SCM targeted sync execution.
+ * Metrics for Recon SCM container sync execution.
*/
@InterfaceAudience.Private
@Metrics(about = "Recon SCM Container Sync Metrics", context =
OzoneConsts.OZONE)
-public final class ReconScmContainerSyncMetrics {
+public final class ReconScmContainerSyncMetrics implements MetricsSource {
private static final String SOURCE_NAME =
ReconScmContainerSyncMetrics.class.getSimpleName();
+ private static final HddsProtos.LifeCycleState[] SYNC_STATES = {
+ HddsProtos.LifeCycleState.OPEN,
+ HddsProtos.LifeCycleState.QUASI_CLOSED,
+ HddsProtos.LifeCycleState.CLOSED,
+ HddsProtos.LifeCycleState.DELETED
+ };
+
+ private static final MetricsInfo SCM_CONTAINER_SYNC_STATUS = Interns.info(
+ "scmContainerSyncStatus",
+ "SCM container sync status: 0=idle, 1=in progress, 2=success,
3=failure");
+
+ private static final MetricsInfo SCM_CONTAINER_SYNC_DURATION_MS =
Interns.info(
+ "scmContainerSyncDurationMs",
+ "Time taken by the SCM container sync in milliseconds");
+
/**
- * No targeted sync has run yet, or the latest scheduler cycle did not run
one.
- */
- public static final int TARGETED_SYNC_STATUS_IDLE = 0;
- /**
- * Targeted sync is currently running.
+ * SCM container sync is currently running.
*/
- public static final int TARGETED_SYNC_STATUS_IN_PROGRESS = 1;
+ public static final int SCM_CONTAINER_SYNC_STATUS_IN_PROGRESS = 1;
/**
- * The last targeted sync completed successfully.
+ * SCM container sync completed successfully.
*/
- public static final int TARGETED_SYNC_STATUS_SUCCESS = 2;
+ public static final int SCM_CONTAINER_SYNC_STATUS_SUCCESS = 2;
/**
- * The last targeted sync completed with one or more failed passes.
+ * SCM container sync completed with one or more failed passes.
*/
- public static final int TARGETED_SYNC_STATUS_FAILURE = 3;
-
- @Metric(about = "Targeted sync status: 0=idle, 1=in progress, "
- + "2=success, 3=failure")
- private MutableGaugeInt targetedSyncStatus;
+ public static final int SCM_CONTAINER_SYNC_STATUS_FAILURE = 3;
- @Metric(about = "Time taken by the last targeted sync in milliseconds")
- private MutableGaugeLong lastTargetedSyncDurationMs;
+ private final AtomicInteger scmContainerSyncStatus = new AtomicInteger();
+ private final AtomicLong scmContainerSyncDurationMs = new AtomicLong();
+ private final Map<HddsProtos.LifeCycleState, AtomicLong>
+ containerSyncDurationMs;
+ private final Map<HddsProtos.LifeCycleState, AtomicLong>
+ containerCountDrift;
+ private final Map<HddsProtos.LifeCycleState, MetricsInfo>
+ containerSyncDurationMetricInfo;
Review Comment:
`containerSyncDurationMetricInfo` is different from
`containerSyncDurationMs`.
`containerSyncDurationMetricInfo` is populated once in the constructor
through `initSyncDurationMetricInfo()`. It stores the Metrics2 metadata for
each state-specific gauge, i.e. the metric name and description such as
`openContainerSyncDurationMs`. `containerSyncDurationMs` stores the actual
gauge values as `AtomicLong`s. These values are updated from
ReconStorageContainerSyncHelper.updateContainerSyncDuration(...)` after each
sync pass.
So `containerSyncDurationMetricInfo` is used by `getMetrics()` to tell
Metrics2 what gauge to emit, while `containerSyncDurationMs` provides the value
for that gauge.
--
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]