From 7012986fc3d2534898b718a2297ad12adb5c95a6 Mon Sep 17 00:00:00 2001 From: hfutatzhanghb Date: Wed, 6 Mar 2024 16:59:00 +0800 Subject: [PATCH] HDFS-17345. Add a metrics to record block report generating cost time. (#6475). Contributed by farmmamba. Reviewed-by: Shuyan Zhang Signed-off-by: Shuyan Zhang --- .../hadoop-common/src/site/markdown/Metrics.md | 2 ++ .../apache/hadoop/hdfs/server/datanode/BPServiceActor.java | 1 + .../hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md b/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md index cb2b48d60f..b75523b08a 100644 --- a/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md +++ b/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md @@ -458,6 +458,8 @@ Each metrics record contains tags such as SessionId and Hostname as additional i | `BlockReportsAvgTime` | Average time of block report operations in milliseconds | | `BlockReports`*ServiceId*`-`*NNId*`NumOps` | Total number of block report operations to specific serviceId and nnId | | `BlockReports`*ServiceId*`-`*NNId*`AvgTime` | Average time of block report operations to specific serviceId and nnId in milliseconds | +| `BlockReportsCreateCostMillsNumOps` | Total number of block report creating operations | +| `BlockReportsCreateCostMillsAvgTime` | Average time of block report creating operations in milliseconds | | `IncrementalBlockReportsNumOps` | Total number of incremental block report operations | | `IncrementalBlockReportsAvgTime` | Average time of incremental block report operations in milliseconds | | `IncrementalBlockReports`*ServiceId*`-`*NNId*`NumOps` | Total number of incremental block report operations to specific serviceId and nnId | diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java index 13ff9549e0..462b9df3c9 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java @@ -452,6 +452,7 @@ List blockReport(long fullBrLeaseId) throws IOException { // Log the block report processing stats from Datanode perspective long brSendCost = monotonicNow() - brSendStartTime; long brCreateCost = brSendStartTime - brCreateStartTime; + dn.getMetrics().addBlockReportCreateCost(brCreateCost); dn.getMetrics().addBlockReport(brSendCost, getRpcMetricSuffix()); final int nCmds = cmds.size(); LOG.info((success ? "S" : "Uns") + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java index 77e6dab067..d5fcfc9544 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java @@ -132,6 +132,7 @@ public class DataNodeMetrics { @Metric MutableRate heartbeatsTotal; @Metric MutableRate lifelines; @Metric MutableRate blockReports; + @Metric private MutableRate blockReportsCreateCostMills; @Metric MutableRate incrementalBlockReports; @Metric MutableRate cacheReports; @Metric MutableRate packetAckRoundTripTimeNanos; @@ -321,6 +322,10 @@ public void addBlockReport(long latency, String rpcMetricSuffix) { } } + public void addBlockReportCreateCost(long latency) { + blockReportsCreateCostMills.add(latency); + } + public void addIncrementalBlockReport(long latency, String rpcMetricSuffix) { incrementalBlockReports.add(latency);