From eb1e30395b3b413d8366653ba7269f20174bc81b Mon Sep 17 00:00:00 2001 From: Lei Yang Date: Sat, 26 Oct 2024 02:29:43 -0700 Subject: [PATCH] HDFS-17644:Add log when a node selection is rejected by BPP UpgradeDomain (#7109) --- .../blockmanagement/BlockPlacementPolicyDefault.java | 7 ++++--- .../BlockPlacementPolicyWithUpgradeDomain.java | 3 +++ 2 files changed, 7 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 8020d7c45b37a..0958aaf5b816c 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 @@ -80,7 +80,7 @@ protected StringBuilder initialValue() { private static final BlockPlacementStatus ONE_RACK_PLACEMENT = new BlockPlacementStatusDefault(1, 1, 1); - private enum NodeNotChosenReason { + protected enum NodeNotChosenReason { NOT_IN_SERVICE("the node is not in service"), NODE_STALE("the node is stale"), NODE_TOO_BUSY("the node is too busy"), @@ -88,7 +88,8 @@ private enum NodeNotChosenReason { TOO_MANY_NODES_ON_RACK("the rack has too many chosen nodes"), NOT_ENOUGH_STORAGE_SPACE("not enough storage space to place the block"), NO_REQUIRED_STORAGE_TYPE("required storage types are unavailable"), - NODE_SLOW("the node is too slow"); + NODE_SLOW("the node is too slow"), + NODE_NOT_CONFORM_TO_UD("the node doesn't conform to upgrade domain policy"); private final String text; @@ -980,7 +981,7 @@ private static void logNodeIsNotChosen(DatanodeDescriptor node, logNodeIsNotChosen(node, reason, null); } - private static void logNodeIsNotChosen(DatanodeDescriptor node, + protected static void logNodeIsNotChosen(DatanodeDescriptor node, NodeNotChosenReason reason, String reasonDetails) { assert reason != null; if (LOG.isDebugEnabled()) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithUpgradeDomain.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithUpgradeDomain.java index 37fb9714858ef..5ff9865cb5a14 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithUpgradeDomain.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithUpgradeDomain.java @@ -74,6 +74,9 @@ protected boolean isGoodDatanode(DatanodeDescriptor node, Set upgradeDomains = getUpgradeDomains(results); if (upgradeDomains.contains(node.getUpgradeDomain())) { isGoodTarget = false; + logNodeIsNotChosen(node, NodeNotChosenReason.NODE_NOT_CONFORM_TO_UD, + "(The node's upgrade domain: " + node.getUpgradeDomain() + + " is already chosen)"); } } }