From fef6a535dceee468ac8b79603e3ce0ac8701b7eb Mon Sep 17 00:00:00 2001 From: Symious Date: Fri, 15 Oct 2021 16:51:15 +0800 Subject: [PATCH] HDFS-16275. Enable considerLoad for localWrite --- .../server/blockmanagement/BlockPlacementPolicyDefault.java | 2 +- .../blockmanagement/TestReplicationPolicyConsiderLoad.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java index c16fe59f596e6..37efe6730a99f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java @@ -621,7 +621,7 @@ protected DatanodeStorageInfo chooseLocalOrFavoredStorage( (DatanodeDescriptor) localOrFavoredNode; // otherwise try local machine first if (excludedNodes.add(localOrFavoredNode) // was not in the excluded list - && isGoodDatanode(localDatanode, maxNodesPerRack, false, + && isGoodDatanode(localDatanode, maxNodesPerRack, considerLoad, results, avoidStaleNodes)) { for (Iterator> iter = storageTypes .entrySet().iterator(); iter.hasNext(); ) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestReplicationPolicyConsiderLoad.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestReplicationPolicyConsiderLoad.java index fef0b45f39cc8..0f5fbbbd78e33 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestReplicationPolicyConsiderLoad.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestReplicationPolicyConsiderLoad.java @@ -137,7 +137,7 @@ public void testConsiderLoadFactor() throws IOException { BlockManagerTestUtil.getStorageReportsForDatanode(dataNodes[0]), dataNodes[0].getCacheCapacity(), dataNodes[0].getCacheUsed(), - 5, 0, null); + 15, 0, null); dnManager.getHeartbeatManager().updateHeartbeat(dataNodes[1], BlockManagerTestUtil.getStorageReportsForDatanode(dataNodes[1]), dataNodes[1].getCacheCapacity(), @@ -163,7 +163,7 @@ public void testConsiderLoadFactor() throws IOException { BlockManagerTestUtil.getStorageReportsForDatanode(dataNodes[5]), dataNodes[5].getCacheCapacity(), dataNodes[5].getCacheUsed(), - 15, 0, null); + 5, 0, null); //Add values in above heartbeats double load = 5 + 10 + 15 + 10 + 15 + 5; // Call chooseTarget()