Revert "HADOOP-17995. Stale record should be remove when DataNodePeerMetrics#dumpSendPacketDownstreamAvgInfoAsJson (#3630)" (#3697)

This commit is contained in:
Hui Fei 2021-11-22 10:05:21 +08:00 committed by GitHub
parent 3d1ca6f6dc
commit 8e9ad2d7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 15 deletions

View File

@ -179,12 +179,9 @@ public void snapshot(MetricsRecordBuilder builder, boolean all) {
long totalCount = 0; long totalCount = 0;
for (final SumAndCount sumAndCount : entry.getValue()) { for (final SumAndCount sumAndCount : entry.getValue()) {
if (Time.monotonicNow() - sumAndCount.getSnapshotTimeStamp()
< recordValidityMs) {
totalCount += sumAndCount.getCount(); totalCount += sumAndCount.getCount();
totalSum += sumAndCount.getSum(); totalSum += sumAndCount.getSum();
} }
}
if (totalCount != 0) { if (totalCount != 0) {
builder.addGauge(avgInfo, totalSum / totalCount); builder.addGauge(avgInfo, totalSum / totalCount);

View File

@ -122,16 +122,10 @@ public void testRemoveStaleRecord() throws Exception {
GenericTestUtils.waitFor( GenericTestUtils.waitFor(
() -> rollingAverages.getStats(numSamples).size() > 0, 500, 5000); () -> rollingAverages.getStats(numSamples).size() > 0, 500, 5000);
assertEquals(3, rollingAverages.getStats(numSamples).size()); 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 */ /* wait for stale report to be removed */
GenericTestUtils.waitFor( GenericTestUtils.waitFor(
() -> rollingAverages.getStats(numSamples).isEmpty(), 500, 10000); () -> rollingAverages.getStats(numSamples).isEmpty(), 500, 10000);
assertEquals(0, rollingAverages.getStats(numSamples).size()); assertEquals(0, rollingAverages.getStats(numSamples).size());
json = peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson();
assertEquals("{}", json);
/* dn can report peer metrics normally when it added back to cluster */ /* dn can report peer metrics normally when it added back to cluster */
for (String peerAddr : peerAddrList) { for (String peerAddr : peerAddrList) {
@ -144,10 +138,6 @@ public void testRemoveStaleRecord() throws Exception {
GenericTestUtils.waitFor( GenericTestUtils.waitFor(
() -> rollingAverages.getStats(numSamples).size() > 0, 500, 10000); () -> rollingAverages.getStats(numSamples).size() > 0, 500, 10000);
assertEquals(3, rollingAverages.getStats(numSamples).size()); assertEquals(3, rollingAverages.getStats(numSamples).size());
json = peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson();
for (String peerAddr : peerAddrList) {
assertThat(json, containsString(peerAddr));
}
} }
/** /**