diff --git a/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md b/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md index cb2b48d60f839..38723ac2a1794 100644 --- a/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md +++ b/hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md @@ -257,6 +257,7 @@ Each metrics record contains tags such as ProcessName, SessionId, and Hostname a | `EditLogTailIntervalAvgTime` | Average time of intervals between edit log tailings by standby NameNode in milliseconds | | `EditLogTailInterval`*num*`s(50/75/90/95/99)thPercentileLatency` | The 50/75/90/95/99th percentile of time between edit log tailings by standby NameNode in milliseconds (*num* seconds granularity). Percentile measurement is off by default, by watching no intervals. The intervals are specified by `dfs.metrics.percentiles.intervals`. | | `PendingEditsCount` | Current number of pending edits | +| `PendingSyncEditsCount` | Current number of pending sync edits | FSNamesystem ------------ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java index 115e9485fa0a9..949f6c52a3e38 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java @@ -244,8 +244,8 @@ private Edit dequeueEdit() throws InterruptedException { @Override public void run() { try { + NameNodeMetrics metrics = NameNode.getNameNodeMetrics(); while (true) { - NameNodeMetrics metrics = NameNode.getNameNodeMetrics(); boolean doSync; Edit edit = dequeueEdit(); if (edit != null) { @@ -258,6 +258,7 @@ public void run() { doSync = !syncWaitQ.isEmpty(); metrics.setPendingEditsCount(0); } + metrics.setPendingSyncEditsCount(syncWaitQ.size()); if (doSync) { // normally edit log exceptions cause the NN to terminate, but tests // relying on ExitUtil.terminate need to see the exception. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java index f0cf00238b5ee..94350508e9e92 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java @@ -89,6 +89,8 @@ public class NameNodeMetrics { MutableCounterLong blockOpsBatched; @Metric("Number of pending edits") MutableGaugeInt pendingEditsCount; + @Metric("Number of pending sync edits") + MutableGaugeInt pendingSyncEditsCount; @Metric("Number of delete blocks Queued") MutableGaugeInt deleteBlocksQueued; @Metric("Number of pending deletion blocks") @@ -365,6 +367,10 @@ public void setPendingEditsCount(int size) { pendingEditsCount.set(size); } + public void setPendingSyncEditsCount(int size) { + pendingSyncEditsCount.set(size); + } + public void addTransaction(long latency) { transactions.add(latency); }