From 8e9ad2d7af31422a8e9e44d2b804c87865958a8b Mon Sep 17 00:00:00 2001 From: Hui Fei Date: Mon, 22 Nov 2021 10:05:21 +0800 Subject: [PATCH] Revert "HADOOP-17995. Stale record should be remove when DataNodePeerMetrics#dumpSendPacketDownstreamAvgInfoAsJson (#3630)" (#3697) --- .../hadoop/metrics2/lib/MutableRollingAverages.java | 7 ++----- .../hdfs/server/datanode/TestDataNodePeerMetrics.java | 10 ---------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRollingAverages.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRollingAverages.java index 3217add651..193ed0f71d 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRollingAverages.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRollingAverages.java @@ -179,11 +179,8 @@ public void snapshot(MetricsRecordBuilder builder, boolean all) { long totalCount = 0; for (final SumAndCount sumAndCount : entry.getValue()) { - if (Time.monotonicNow() - sumAndCount.getSnapshotTimeStamp() - < recordValidityMs) { - totalCount += sumAndCount.getCount(); - totalSum += sumAndCount.getSum(); - } + totalCount += sumAndCount.getCount(); + totalSum += sumAndCount.getSum(); } if (totalCount != 0) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodePeerMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodePeerMetrics.java index 9ea8a08a76..41fb41f480 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodePeerMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodePeerMetrics.java @@ -122,16 +122,10 @@ public void testRemoveStaleRecord() throws Exception { GenericTestUtils.waitFor( () -> rollingAverages.getStats(numSamples).size() > 0, 500, 5000); assertEquals(3, rollingAverages.getStats(numSamples).size()); - String json = peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson(); - for (String peerAddr : peerAddrList) { - assertThat(json, containsString(peerAddr)); - } /* wait for stale report to be removed */ GenericTestUtils.waitFor( () -> rollingAverages.getStats(numSamples).isEmpty(), 500, 10000); assertEquals(0, rollingAverages.getStats(numSamples).size()); - json = peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson(); - assertEquals("{}", json); /* dn can report peer metrics normally when it added back to cluster */ for (String peerAddr : peerAddrList) { @@ -144,10 +138,6 @@ public void testRemoveStaleRecord() throws Exception { GenericTestUtils.waitFor( () -> rollingAverages.getStats(numSamples).size() > 0, 500, 10000); assertEquals(3, rollingAverages.getStats(numSamples).size()); - json = peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson(); - for (String peerAddr : peerAddrList) { - assertThat(json, containsString(peerAddr)); - } } /**