zhangshuyan0 commented on code in PR #4624:
URL: https://github.com/apache/hadoop/pull/4624#discussion_r933975418
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRatesWithAggregation.java:
##########
@@ -71,11 +74,20 @@ public void init(Class<?> protocol) {
if (protocolCache.contains(protocol)) {
return;
}
- protocolCache.add(protocol);
- for (Method method : protocol.getDeclaredMethods()) {
- String name = method.getName();
- LOG.debug(name);
- addMetricIfNotExists(name);
+
+ List<Class<?>> protocols = new ArrayList<>();
+ protocols.add(protocol);
+ if (protocol.getDeclaredMethods().length == 0) {
+ protocols.addAll(Arrays.asList(protocol.getInterfaces()));
+ }
+
+ for (Class<?> pClass : protocols) {
+ protocolCache.add(pClass);
+ for (Method method : pClass.getDeclaredMethods()) {
+ String name = method.getName();
+ LOG.debug(name);
+ addMetricIfNotExists(name);
+ }
Review Comment:
If we pass XXXProtocol or XXXTranslatorPB, everything will be ok. However,
it seems more complex to change related code in RPC server. So I use
getMethods() finally.
I enriched the content of testNNRpcMetricsWithNonHA(). When the
MiniDFSCluster starts, datanode will call versionRequest(), so the metrics of
all methods in DatanodeProtocol should be initialized, including
CommitBlockSynchronizationNumOps. Please give a check, thanks.
--
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]