hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From inigo...@apache.org
Subject [5/5] hadoop git commit: HDFS-13686. Add overall metrics for FSNamesystemLock. Contributed by Lukas Majercak.
Date Fri, 15 Jun 2018 23:01:28 GMT
HDFS-13686. Add overall metrics for FSNamesystemLock. Contributed by Lukas Majercak.

(cherry picked from commit d31a3ce767d3bb68bdbb4f36d45600eab9f4f8b7)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/0c1c26aa
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/0c1c26aa
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/0c1c26aa

Branch: refs/heads/branch-2.9
Commit: 0c1c26aa2c5036abaf20b22476379a5d93340f90
Parents: 22a020c
Author: Inigo Goiri <inigoiri@apache.org>
Authored: Fri Jun 15 15:59:19 2018 -0700
Committer: Inigo Goiri <inigoiri@apache.org>
Committed: Fri Jun 15 16:01:01 2018 -0700

----------------------------------------------------------------------
 .../hdfs/server/namenode/FSNamesystemLock.java     | 17 ++++++++++++-----
 .../hdfs/server/namenode/TestFSNamesystemLock.java | 10 ++++++++--
 2 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/0c1c26aa/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
index eea7088..33c6168 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
@@ -107,6 +107,8 @@ class FSNamesystemLock {
   private static final String WRITE_LOCK_METRIC_PREFIX = "FSNWriteLock";
   private static final String LOCK_METRIC_SUFFIX = "Nanos";
 
+  private static final String OVERALL_METRIC_NAME = "Overall";
+
   FSNamesystemLock(Configuration conf,
       MutableRatesWithAggregation detailedHoldTimeMetrics) {
     this(conf, detailedHoldTimeMetrics, new Timer());
@@ -299,12 +301,17 @@ class FSNamesystemLock {
    */
   private void addMetric(String operationName, long value, boolean isWrite) {
     if (metricsEnabled) {
-      String metricName =
-          (isWrite ? WRITE_LOCK_METRIC_PREFIX : READ_LOCK_METRIC_PREFIX) +
-          org.apache.commons.lang.StringUtils.capitalize(operationName) +
-          LOCK_METRIC_SUFFIX;
-      detailedHoldTimeMetrics.add(metricName, value);
+      String opMetric = getMetricName(operationName, isWrite);
+      detailedHoldTimeMetrics.add(opMetric, value);
+
+      String overallMetric = getMetricName(OVERALL_METRIC_NAME, isWrite);
+      detailedHoldTimeMetrics.add(overallMetric, value);
     }
   }
 
+  private static String getMetricName(String operationName, boolean isWrite) {
+    return (isWrite ? WRITE_LOCK_METRIC_PREFIX : READ_LOCK_METRIC_PREFIX) +
+        org.apache.commons.lang.StringUtils.capitalize(operationName) +
+        LOCK_METRIC_SUFFIX;
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/0c1c26aa/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
index 7f9746d..1c2cf33 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
@@ -332,7 +332,7 @@ public class TestFSNamesystemLock {
     FSNamesystemLock fsLock = new FSNamesystemLock(conf, rates, timer);
 
     fsLock.readLock();
-    timer.advanceNanos(1200000);
+    timer.advanceNanos(1300000);
     fsLock.readUnlock("foo");
     fsLock.readLock();
     timer.advanceNanos(2400000);
@@ -352,12 +352,18 @@ public class TestFSNamesystemLock {
     MetricsRecordBuilder rb = MetricsAsserts.mockMetricsRecordBuilder();
     rates.snapshot(rb, true);
 
-    assertGauge("FSNReadLockFooNanosAvgTime", 1800000.0, rb);
+    assertGauge("FSNReadLockFooNanosAvgTime", 1850000.0, rb);
     assertCounter("FSNReadLockFooNanosNumOps", 2L, rb);
     assertGauge("FSNReadLockBarNanosAvgTime", 2000000.0, rb);
     assertCounter("FSNReadLockBarNanosNumOps", 1L, rb);
     assertGauge("FSNWriteLockBazNanosAvgTime", 1000000.0, rb);
     assertCounter("FSNWriteLockBazNanosNumOps", 1L, rb);
+
+    // Overall
+    assertGauge("FSNReadLockOverallNanosAvgTime", 1900000.0, rb);
+    assertCounter("FSNReadLockOverallNanosNumOps", 3L, rb);
+    assertGauge("FSNWriteLockOverallNanosAvgTime", 1000000.0, rb);
+    assertCounter("FSNWriteLockOverallNanosNumOps", 1L, rb);
   }
 
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message