Skip to content

Commit dbf73e1

Browse files
authored
HADOOP-18364. All method metrics related to the RPC protocol should be initialized. (#4624). Contributed by Shuyan Zhang.
Reviewed-by: Erik Krogen <xkrogen@apache.org> Reviewed-by: Chao Sun <sunchao@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
1 parent 8eebf40 commit dbf73e1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRatesWithAggregation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void init(Class<?> protocol) {
7272
return;
7373
}
7474
protocolCache.add(protocol);
75-
for (Method method : protocol.getDeclaredMethods()) {
75+
for (Method method : protocol.getMethods()) {
7676
String name = method.getName();
7777
LOG.debug(name);
7878
addMetricIfNotExists(name);

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNameNodeMetrics.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
import java.util.EnumSet;
4949
import java.util.List;
5050
import java.util.Random;
51+
52+
import org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer;
53+
import org.apache.hadoop.ipc.metrics.RpcDetailedMetrics;
5154
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
5255

5356
import org.slf4j.Logger;
@@ -1128,4 +1131,14 @@ public void testEditLogTailing() throws Exception {
11281131
}
11291132

11301133
}
1134+
1135+
@Test
1136+
public void testNNRPCMetricIntegrity() {
1137+
RpcDetailedMetrics metrics =
1138+
((NameNodeRpcServer) cluster.getNameNode()
1139+
.getRpcServer()).getClientRpcServer().getRpcDetailedMetrics();
1140+
MetricsRecordBuilder rb = getMetrics(metrics.name());
1141+
// CommitBlockSynchronizationNumOps should exist.
1142+
assertCounter("CommitBlockSynchronizationNumOps", 0L, rb);
1143+
}
11311144
}

0 commit comments

Comments
 (0)