diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 4247ea688f..cba53a38bc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -371,6 +371,8 @@ Release 2.8.0 - UNRELEASED HDFS-7671. hdfs user guide should point to the common rack awareness doc. (Kai Sasaki via aajisaka) + HDFS-8009. Signal congestion on the DataNode. (wheat9) + OPTIMIZATIONS BUG FIXES 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 071aba1feb..50dccb825d 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 @@ -354,6 +354,9 @@ public static InetSocketAddress createSocketAddr(String target) { private String dnUserName = null; private SpanReceiverHost spanReceiverHost; + private static final int NUM_CORES = Runtime.getRuntime() + .availableProcessors(); + private static final double CONGESTION_RATIO = 1.5; /** * Creates a dummy DataNode for testing purpose. @@ -484,8 +487,13 @@ public Collection getReconfigurableProperties() { * */ public PipelineAck.ECN getECN() { - return pipelineSupportECN ? PipelineAck.ECN.SUPPORTED : PipelineAck.ECN - .DISABLED; + if (!pipelineSupportECN) { + return PipelineAck.ECN.DISABLED; + } + double load = ManagementFactory.getOperatingSystemMXBean() + .getSystemLoadAverage(); + return load > NUM_CORES * CONGESTION_RATIO ? PipelineAck.ECN.CONGESTED : + PipelineAck.ECN.SUPPORTED; } /**