sodonnel commented on a change in pull request #2382:
URL: https://github.com/apache/ozone/pull/2382#discussion_r676525524



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManagerMetrics.java
##########
@@ -0,0 +1,161 @@
+/**
+ * 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.hdds.scm.container.replication;
+
+import org.apache.hadoop.hdds.scm.container.ReplicationManager;
+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.MutableCounterLong;
+import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
+import org.apache.hadoop.ozone.OzoneConsts;
+
+/**
+ * Class contains metrics related to ReplicationManager.
+ */
+@Metrics(about = "Replication Manager Metrics", context = OzoneConsts.OZONE)
+public final class ReplicationManagerMetrics {
+
+  public static final String METRICS_SOURCE_NAME =
+      ReplicationManagerMetrics.class.getSimpleName();
+
+  @Metric("Tracked inflight container replication requests.")
+  private MutableGaugeLong inflightReplication;
+
+  @Metric("Tracked inflight container deletion requests.")
+  private MutableGaugeLong inflightDeletion;
+
+  @Metric("Tracked inflight container move requests.")
+  private MutableGaugeLong inflightMove;
+
+  @Metric("Number of replication commands sent.")
+  private MutableCounterLong numReplicationCmdsSent;
+
+  @Metric("Number of replication commands completed.")
+  private MutableCounterLong numReplicationCmdsCompleted;
+
+  @Metric("Number of replication commands timeout.")
+  private MutableCounterLong numReplicationCmdsTimeout;
+
+  @Metric("Number of deletion commands sent.")
+  private MutableCounterLong numDeletionCmdsSent;
+
+  @Metric("Number of deletion commands completed.")
+  private MutableCounterLong numDeletionCmdsCompleted;
+
+  @Metric("Number of deletion commands timeout.")
+  private MutableCounterLong numDeletionCmdsTimeout;
+
+  @Metric("Number of replication bytes total.")
+  private MutableCounterLong numReplicationBytesTotal;
+
+  @Metric("Number of replication bytes completed.")
+  private MutableCounterLong numReplicationBytesCompleted;
+
+  private ReplicationManager replicationManager;
+
+  public ReplicationManagerMetrics(ReplicationManager manager) {
+    this.replicationManager = manager;
+  }
+
+  public static ReplicationManagerMetrics create(ReplicationManager manager) {
+    return DefaultMetricsSystem.instance().register(METRICS_SOURCE_NAME,
+        "SCM Replication manager (closed container replication) related "
+            + "metrics",
+        new ReplicationManagerMetrics(manager));

Review comment:
       In general I prefer to avoid singletons, as they can make testing 
difficult, especially around Mini-Cluster tests.
   
   I think its reasonable for a RM restart to reset the counts to zero, as it 
is a new instance. A RM restart should only happen in tests, as to restart it 
in a real cluster, you must restart all of SCM.




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