From ea3cb12ec80210fcad985e9cfc37d129afec888b Mon Sep 17 00:00:00 2001 From: hfutatzhanghb Date: Sun, 8 Oct 2023 10:36:09 +0800 Subject: [PATCH] HDFS-17171. CONGESTION_RATIO should be configurable (#5996) Reviewed-by: Ayush Saxena Signed-off-by: Tao Li --- .../java/org/apache/hadoop/hdfs/DFSConfigKeys.java | 3 ++- .../apache/hadoop/hdfs/server/datanode/DataNode.java | 12 ++++++++++-- .../hadoop-hdfs/src/main/resources/hdfs-default.xml | 8 ++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java index 8a3b9b9bda..6b7e4fdb40 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java @@ -1573,6 +1573,8 @@ public class DFSConfigKeys extends CommonConfigurationKeys { public static final boolean DFS_PIPELINE_ECN_ENABLED_DEFAULT = false; public static final String DFS_PIPELINE_SLOWNODE_ENABLED = "dfs.pipeline.slownode"; public static final boolean DFS_PIPELINE_SLOWNODE_ENABLED_DEFAULT = false; + public static final String DFS_PIPELINE_CONGESTION_RATIO = "dfs.pipeline.congestion.ratio"; + public static final double DFS_PIPELINE_CONGESTION_RATIO_DEFAULT = 1.5; // Key Provider Cache Expiry public static final String DFS_DATANODE_BLOCK_PINNING_ENABLED = @@ -2042,5 +2044,4 @@ public class DFSConfigKeys extends CommonConfigurationKeys { public static final long DFS_LEASE_HARDLIMIT_DEFAULT = HdfsClientConfigKeys.DFS_LEASE_HARDLIMIT_DEFAULT; - } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 4ade6ada72..4613d37f60 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -462,7 +462,7 @@ public static InetSocketAddress createSocketAddr(String target) { private final Tracer tracer; private static final int NUM_CORES = Runtime.getRuntime() .availableProcessors(); - private static final double CONGESTION_RATIO = 1.5; + private final double congestionRatio; private DiskBalancer diskBalancer; private DataSetLockManager dataSetLockManager; @@ -515,6 +515,10 @@ private static Tracer createTracer(Configuration conf) { volumeChecker = new DatasetVolumeChecker(conf, new Timer()); this.xferService = HadoopExecutors.newCachedThreadPool(new Daemon.DaemonFactory()); + double congestionRationTmp = conf.getDouble(DFSConfigKeys.DFS_PIPELINE_CONGESTION_RATIO, + DFSConfigKeys.DFS_PIPELINE_CONGESTION_RATIO_DEFAULT); + this.congestionRatio = congestionRationTmp > 0 ? + congestionRationTmp : DFSConfigKeys.DFS_PIPELINE_CONGESTION_RATIO_DEFAULT; } /** @@ -614,6 +618,10 @@ public Map load(String key) { new DataTransferThrottler(100, ecReconstuctReadBandwidth) : null; this.ecReconstuctWriteThrottler = ecReconstuctWriteBandwidth > 0 ? new DataTransferThrottler(100, ecReconstuctWriteBandwidth) : null; + double congestionRationTmp = conf.getDouble(DFSConfigKeys.DFS_PIPELINE_CONGESTION_RATIO, + DFSConfigKeys.DFS_PIPELINE_CONGESTION_RATIO_DEFAULT); + this.congestionRatio = congestionRationTmp > 0 ? + congestionRationTmp : DFSConfigKeys.DFS_PIPELINE_CONGESTION_RATIO_DEFAULT; } @Override // ReconfigurableBase @@ -1070,7 +1078,7 @@ public PipelineAck.ECN getECN() { } double load = ManagementFactory.getOperatingSystemMXBean() .getSystemLoadAverage(); - return load > NUM_CORES * CONGESTION_RATIO ? PipelineAck.ECN.CONGESTED : + return load > NUM_CORES * congestionRatio ? PipelineAck.ECN.CONGESTED : PipelineAck.ECN.SUPPORTED; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml index 1135b98c6b..678908d901 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml @@ -5619,6 +5619,14 @@ + + dfs.pipeline.congestion.ratio + 1.5 + + The ratio which is used to compute congestion load. + + + dfs.qjournal.accept-recovery.timeout.ms 120000