Skip to content

Commit 46d4b51

Browse files
authored
HDFS-15814. Make some parameters configurable for DataNodeDiskMetrics for branch-3.3 (#3021)
1 parent 3751672 commit 46d4b51

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,14 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
655655
public static final long
656656
DFS_DATANODE_PEER_METRICS_MIN_OUTLIER_DETECTION_SAMPLES_DEFAULT =
657657
1000;
658+
public static final String DFS_DATANODE_MIN_OUTLIER_DETECTION_DISKS_KEY =
659+
"dfs.datanode.min.outlier.detection.disks";
660+
public static final long DFS_DATANODE_MIN_OUTLIER_DETECTION_DISKS_DEFAULT =
661+
5L;
662+
public static final String DFS_DATANODE_SLOWDISK_LOW_THRESHOLD_MS_KEY =
663+
"dfs.datanode.slowdisk.low.threshold.ms";
664+
public static final long DFS_DATANODE_SLOWDISK_LOW_THRESHOLD_MS_DEFAULT =
665+
20L;
658666
public static final String DFS_DATANODE_HOST_NAME_KEY =
659667
HdfsClientConfigKeys.DeprecatedKeys.DFS_DATANODE_HOST_NAME_KEY;
660668
public static final String DFS_NAMENODE_CHECKPOINT_DIR_KEY =

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ void startDataNode(List<StorageLocation> dataDirectories,
14581458

14591459
if (dnConf.diskStatsEnabled) {
14601460
diskMetrics = new DataNodeDiskMetrics(this,
1461-
dnConf.outliersReportIntervalMs);
1461+
dnConf.outliersReportIntervalMs, getConf());
14621462
}
14631463
}
14641464

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeDiskMetrics.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package org.apache.hadoop.hdfs.server.datanode.metrics;
1919

20+
import org.apache.hadoop.conf.Configuration;
21+
import org.apache.hadoop.hdfs.DFSConfigKeys;
2022
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
2123
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
2224
import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
@@ -48,8 +50,6 @@ public class DataNodeDiskMetrics {
4850
DataNodeDiskMetrics.class);
4951

5052
private DataNode dn;
51-
private final long MIN_OUTLIER_DETECTION_DISKS = 5;
52-
private final long SLOW_DISK_LOW_THRESHOLD_MS = 20;
5353
private final long detectionInterval;
5454
private volatile boolean shouldRun;
5555
private OutlierDetector slowDiskDetector;
@@ -61,11 +61,27 @@ public class DataNodeDiskMetrics {
6161
// code, status should not be overridden by daemon thread.
6262
private boolean overrideStatus = true;
6363

64-
public DataNodeDiskMetrics(DataNode dn, long diskOutlierDetectionIntervalMs) {
64+
/**
65+
* Minimum number of disks to run outlier detection.
66+
*/
67+
private final long minOutlierDetectionDisks;
68+
/**
69+
* Threshold in milliseconds below which a disk is definitely not slow.
70+
*/
71+
private final long lowThresholdMs;
72+
73+
public DataNodeDiskMetrics(DataNode dn, long diskOutlierDetectionIntervalMs,
74+
Configuration conf) {
6575
this.dn = dn;
6676
this.detectionInterval = diskOutlierDetectionIntervalMs;
67-
slowDiskDetector = new OutlierDetector(MIN_OUTLIER_DETECTION_DISKS,
68-
SLOW_DISK_LOW_THRESHOLD_MS);
77+
minOutlierDetectionDisks =
78+
conf.getLong(DFSConfigKeys.DFS_DATANODE_MIN_OUTLIER_DETECTION_DISKS_KEY,
79+
DFSConfigKeys.DFS_DATANODE_MIN_OUTLIER_DETECTION_DISKS_DEFAULT);
80+
lowThresholdMs =
81+
conf.getLong(DFSConfigKeys.DFS_DATANODE_SLOWDISK_LOW_THRESHOLD_MS_KEY,
82+
DFSConfigKeys.DFS_DATANODE_SLOWDISK_LOW_THRESHOLD_MS_DEFAULT);
83+
slowDiskDetector =
84+
new OutlierDetector(minOutlierDetectionDisks, lowThresholdMs);
6985
shouldRun = true;
7086
startDiskOutlierDetectionThread();
7187
}

hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,22 @@
23742374
</description>
23752375
</property>
23762376

2377+
<property>
2378+
<name>dfs.datanode.min.outlier.detection.disks</name>
2379+
<value>5</value>
2380+
<description>
2381+
Minimum number of disks to run outlier detection.
2382+
</description>
2383+
</property>
2384+
2385+
<property>
2386+
<name>dfs.datanode.slowdisk.low.threshold.ms</name>
2387+
<value>20</value>
2388+
<description>
2389+
Threshold in milliseconds below which a disk is definitely not slow.
2390+
</description>
2391+
</property>
2392+
23772393
<property>
23782394
<name>hadoop.user.group.metrics.percentiles.intervals</name>
23792395
<value></value>

0 commit comments

Comments
 (0)