From c01207ce4971169675773d1e026da2428dac4d7b Mon Sep 17 00:00:00 2001 From: Tony Wang Date: Fri, 8 Sep 2023 17:15:32 +0800 Subject: [PATCH] add check that detailedHoldTimeMetrics should not be null if metric is enabled --- .../apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java | 5 +++++ 1 file changed, 5 insertions(+) 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 e510bd625e738..bdf7f68343b68 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 @@ -32,6 +32,7 @@ import org.apache.hadoop.ipc.Server; import org.apache.hadoop.log.LogThrottlingHelper; import org.apache.hadoop.metrics2.lib.MutableRatesWithAggregation; +import org.apache.hadoop.util.Preconditions; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Timer; @@ -160,6 +161,10 @@ public Long initialValue() { FSNamesystem.LOG.info("Detailed lock hold time metrics enabled: " + this.metricsEnabled); this.detailedHoldTimeMetrics = detailedHoldTimeMetrics; + if (metricsEnabled) { + Preconditions.checkArgument(detailedHoldTimeMetrics != null, + "Detailed lock hold time metrics enabled, detailed hold time metric should not be null!"); + } } public void readLock() {