From 2f73ac1c14dde86a5c0b86f9272cf98084478994 Mon Sep 17 00:00:00 2001 From: wangzhaohui <32935220+wzhallright@users.noreply.github.com> Date: Thu, 16 Sep 2021 00:56:51 +0800 Subject: [PATCH] HDFS-16181. [SBN Read] Fix display of JournalNode metric RpcRequestCacheMissAmount (#3317) Co-authored-by: wangzhaohui8 (cherry picked from commit 232fd7cae170de8c6b52c14841a47dca8735c6d2) --- .../hadoop/hdfs/qjournal/server/Journal.java | 2 +- .../hdfs/qjournal/server/JournalMetrics.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java index 238a000afc..1f256415ba 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java @@ -773,7 +773,7 @@ public GetJournaledEditsResponseProto getJournaledEdits(long sinceTxId, .setEditLog(output.toByteString()) .build(); } catch (JournaledEditsCache.CacheMissException cme) { - metrics.rpcRequestCacheMissAmount.add(cme.getCacheMissAmount()); + metrics.addRpcRequestCacheMissAmount(cme.getCacheMissAmount()); throw cme; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalMetrics.java index 7d271f3665..3499da98dc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalMetrics.java @@ -51,12 +51,7 @@ class JournalMetrics { @Metric("Number of bytes served via RPC") MutableCounterLong bytesServedViaRpc; - @Metric - MutableStat rpcRequestCacheMissAmount = new MutableStat( - "RpcRequestCacheMissAmount", "Number of RPC requests unable to be " + - "served due to lack of availability in cache, and how many " + - "transactions away the request was from being in the cache.", - "Misses", "Txns"); + private MutableStat rpcRequestCacheMissAmount; @Metric("Number of RPC requests with zero edits returned") MutableCounterLong rpcEmptyResponses; @@ -87,6 +82,11 @@ class JournalMetrics { "syncs" + interval + "s", "Journal sync time", "ops", "latencyMicros", interval); } + rpcRequestCacheMissAmount = registry + .newStat("RpcRequestCacheMissAmount", "Number of RPC requests unable to be " + + "served due to lack of availability in cache, and how many " + + "transactions away the request was from being in the cache.", + "Misses", "Txns"); } public static JournalMetrics create(Journal j) { @@ -149,4 +149,8 @@ public MutableCounterLong getNumEditLogsSynced() { public void incrNumEditLogsSynced() { numEditLogsSynced.incr(); } + + public void addRpcRequestCacheMissAmount(long cacheMissAmount) { + rpcRequestCacheMissAmount.add(cacheMissAmount); + } }