jojochuang commented on a change in pull request #3198:
URL: https://github.com/apache/hadoop/pull/3198#discussion_r670240464
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java
##########
@@ -1603,6 +1603,70 @@ public void testSetProtocolEngine() {
assertTrue(rpcEngine instanceof StoppedRpcEngine);
}
+ @Test
+ public void testRpcMetricsInNanos() throws Exception {
+ final Server server;
+ TestRpcService proxy = null;
+
+ final int interval = 1;
+ conf.setBoolean(CommonConfigurationKeys.
+ RPC_METRICS_QUANTILE_ENABLE, true);
+ conf.set(CommonConfigurationKeys.
+ RPC_METRICS_PERCENTILES_INTERVALS_KEY, "" + interval);
+ conf.set(CommonConfigurationKeys.RPC_METRICS_TIME_UNIT, "NANOSECONDS");
+
+ server = setupTestServer(conf, 5);
+ String testUser = "testUserInNanos";
+ UserGroupInformation anotherUser =
+ UserGroupInformation.createRemoteUser(testUser);
+ TestRpcService proxy2 =
+ anotherUser.doAs((PrivilegedAction<TestRpcService>) () -> {
+ try {
+ return RPC.getProxy(TestRpcService.class, 0,
+ server.getListenerAddress(), conf);
+ } catch (IOException e) {
+ e.printStackTrace();
Review comment:
Let's use a logger to record it rather than printing to stderr?
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java
##########
@@ -97,10 +98,25 @@
public String name() { return name; }
public static RpcMetrics create(Server server, Configuration conf) {
+ setMetricTimeUnit(conf);
RpcMetrics m = new RpcMetrics(server, conf);
return DefaultMetricsSystem.instance().register(m.name, null, m);
}
+ private static void setMetricTimeUnit(Configuration conf) {
Review comment:
this can be error-prone because a process can have multiple Server
binding at different ports at the same time.
So metricsTimeUnit is initialized multiple times for each Server creation.
Hopefully they end up using the same metric unit. Otherwise this could
hypothetically create confusion later on.
--
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]