guihecheng commented on a change in pull request #2382:
URL: https://github.com/apache/ozone/pull/2382#discussion_r667851808
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ReplicationManager.java
##########
@@ -353,12 +352,22 @@ private void processContainer(ContainerInfo container) {
*/
updateInflightAction(container, inflightReplication,
action -> replicas.stream()
- .anyMatch(r ->
r.getDatanodeDetails().equals(action.datanode)));
+ .anyMatch(r -> r.getDatanodeDetails().equals(action.datanode)),
+ ()-> metrics.incrNumReplicateCmdsTimeout(),
+ () -> {
+ metrics.incrNumReplicateCmdsCompleted();
+ metrics.incrNumReplicateBytesCompleted(container.getUsedBytes());
+ });
updateInflightAction(container, inflightDeletion,
action -> replicas.stream()
.noneMatch(r ->
- r.getDatanodeDetails().equals(action.datanode)));
+ r.getDatanodeDetails().equals(action.datanode)),
+ () -> metrics.incrNumDeleteCmdsTimeout(),
+ () -> metrics.incrNumDeleteCmdsCompleted());
+
+ metrics.setInflightReplication(inflightReplication.size());
+ metrics.setInflightDeletion(inflightDeletion.size());
Review comment:
Hmmm, I'll investigate whether there are some ways, the solution seems
not so direct because we have separated metrics into a separate class.
##########
File path:
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestReplicationManager.java
##########
@@ -394,6 +394,8 @@ public void testQuasiClosedContainerWithUnhealthyReplica()
Assert.assertTrue(datanodeCommandHandler.received(
SCMCommandProto.Type.deleteContainerCommand,
replicaOne.getDatanodeDetails()));
+ Assert.assertEquals(currentDeleteCommandCount + 1,
Review comment:
Sure, I'll try my best to cover more metrics, maybe it is not so direct
to simulate timeouts.
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ReplicationManager.java
##########
@@ -1028,6 +1047,8 @@ private void sendReplicateCommand(final ContainerInfo
container,
LOG.info("Sending replicate container command for container {}" +
" to datanode {} from datanodes {}",
container.containerID(), datanode, sources);
+ metrics.incrNumReplicateCmdsSent();
Review comment:
Yes, it should be updated after sent.
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManagerMetrics.java
##########
@@ -0,0 +1,158 @@
+/**
+ * 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.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("Number of replicate commands sent.")
+ private MutableCounterLong numReplicateCmdsSent;
Review comment:
OK, then I shall do changes to some existing codes to stay consistent
with the naming.
--
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]