Skip to content

Commit 3ecaa39

Browse files
wzhallrightwangzhaohui8
andauthored
HDFS-16181. [SBN Read] Fix display of JournalNode metric RpcRequestCacheMissAmount (#3317)
Co-authored-by: wangzhaohui8 <wangzhaohui8@jd.com>
1 parent b8f7c75 commit 3ecaa39

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ public GetJournaledEditsResponseProto getJournaledEdits(long sinceTxId,
773773
.setEditLog(output.toByteString())
774774
.build();
775775
} catch (JournaledEditsCache.CacheMissException cme) {
776-
metrics.rpcRequestCacheMissAmount.add(cme.getCacheMissAmount());
776+
metrics.addRpcRequestCacheMissAmount(cme.getCacheMissAmount());
777777
throw cme;
778778
}
779779
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalMetrics.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,7 @@ class JournalMetrics {
5151
@Metric("Number of bytes served via RPC")
5252
MutableCounterLong bytesServedViaRpc;
5353

54-
@Metric
55-
MutableStat rpcRequestCacheMissAmount = new MutableStat(
56-
"RpcRequestCacheMissAmount", "Number of RPC requests unable to be " +
57-
"served due to lack of availability in cache, and how many " +
58-
"transactions away the request was from being in the cache.",
59-
"Misses", "Txns");
54+
private MutableStat rpcRequestCacheMissAmount;
6055

6156
@Metric("Number of RPC requests with zero edits returned")
6257
MutableCounterLong rpcEmptyResponses;
@@ -87,6 +82,11 @@ class JournalMetrics {
8782
"syncs" + interval + "s",
8883
"Journal sync time", "ops", "latencyMicros", interval);
8984
}
85+
rpcRequestCacheMissAmount = registry
86+
.newStat("RpcRequestCacheMissAmount", "Number of RPC requests unable to be " +
87+
"served due to lack of availability in cache, and how many " +
88+
"transactions away the request was from being in the cache.",
89+
"Misses", "Txns");
9090
}
9191

9292
public static JournalMetrics create(Journal j) {
@@ -149,4 +149,8 @@ public MutableCounterLong getNumEditLogsSynced() {
149149
public void incrNumEditLogsSynced() {
150150
numEditLogsSynced.incr();
151151
}
152+
153+
public void addRpcRequestCacheMissAmount(long cacheMissAmount) {
154+
rpcRequestCacheMissAmount.add(cacheMissAmount);
155+
}
152156
}

0 commit comments

Comments
 (0)