From 64ad0298d441559951bc9589a40f8aab17c93a5f Mon Sep 17 00:00:00 2001 From: Brahma Reddy Battula Date: Wed, 29 Aug 2018 08:29:50 +0530 Subject: [PATCH] HDFS-13854. RBF: The ProcessingAvgTime and ProxyAvgTime should display by JMX with ms unit. Contributed by yanghuafeng. --- .../federation/metrics/FederationRPCMetrics.java | 13 ++----------- .../metrics/FederationRPCPerformanceMonitor.java | 15 +++++---------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java index 9ab4e5addb..cce4b86ce1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java @@ -85,15 +85,6 @@ public static FederationRPCMetrics create(Configuration conf, new FederationRPCMetrics(conf, rpcServer)); } - /** - * Convert nanoseconds to milliseconds. - * @param ns Time in nanoseconds. - * @return Time in milliseconds. - */ - private static double toMs(double ns) { - return ns / 1000000; - } - /** * Reset the metrics system. */ @@ -230,7 +221,7 @@ public void addProxyTime(long time) { @Override public double getProxyAvg() { - return toMs(proxy.lastStat().mean()); + return proxy.lastStat().mean(); } @Override @@ -250,7 +241,7 @@ public void addProcessingTime(long time) { @Override public double getProcessingAvg() { - return toMs(processing.lastStat().mean()); + return processing.lastStat().mean(); } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCPerformanceMonitor.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCPerformanceMonitor.java index 2c2741e559..15725d14ce 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCPerformanceMonitor.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCPerformanceMonitor.java @@ -35,6 +35,8 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; +import static org.apache.hadoop.util.Time.monotonicNow; + /** * Customizable RPC performance monitor. Receives events from the RPC server * and aggregates them via JMX. @@ -120,12 +122,12 @@ public void resetPerfCounters() { @Override public void startOp() { - START_TIME.set(this.getNow()); + START_TIME.set(monotonicNow()); } @Override public long proxyOp() { - PROXY_TIME.set(this.getNow()); + PROXY_TIME.set(monotonicNow()); long processingTime = getProcessingTime(); if (processingTime >= 0) { metrics.addProcessingTime(processingTime); @@ -188,13 +190,6 @@ public void routerFailureLocked() { metrics.incrRouterFailureLocked(); } - /** - * Get current time. - * @return Current time in nanoseconds. - */ - private long getNow() { - return System.nanoTime(); - } /** * Get time between we receiving the operation and sending it to the Namenode. @@ -214,7 +209,7 @@ private long getProcessingTime() { */ private long getProxyTime() { if (PROXY_TIME.get() != null && PROXY_TIME.get() > 0) { - return getNow() - PROXY_TIME.get(); + return monotonicNow() - PROXY_TIME.get(); } return -1; }