-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-16277 improve decision in AvailableSpaceBlockPlacementPolicy #3559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
3c51579
a449d04
d4f968b
d522abf
de633b8
e71e324
0ed2dd8
6ec0b22
e91f9fd
44e4785
dbfd21b
3af5420
91b8d43
b9bcef2
77ab40d
e47e0cf
7d5be4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
|
|
||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_KEY; | ||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_DEFAULT; | ||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_KEY; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.EnumMap; | ||
|
|
@@ -37,6 +39,7 @@ | |
| import org.apache.hadoop.net.NetworkTopology; | ||
| import org.apache.hadoop.net.Node; | ||
|
|
||
|
|
||
| /** | ||
| * Space balanced block placement policy. | ||
| */ | ||
|
|
@@ -47,6 +50,8 @@ public class AvailableSpaceBlockPlacementPolicy extends | |
| private static final Random RAND = new Random(); | ||
| private int balancedPreference = | ||
| (int) (100 * DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_DEFAULT); | ||
| private int balancedSpaceTolerance = | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| private boolean optimizeLocal; | ||
|
|
||
| @Override | ||
|
|
@@ -59,9 +64,14 @@ public void initialize(Configuration conf, FSClusterStats stats, | |
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_DEFAULT); | ||
|
|
||
| LOG.info("Available space block placement policy initialized: " | ||
| + DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_KEY | ||
| + DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_KEY | ||
| + " = " + balancedPreferencePercent); | ||
|
|
||
| balancedSpaceTolerance = | ||
| conf.getInt( | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_KEY, | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT); | ||
|
|
||
| optimizeLocal = conf.getBoolean( | ||
| DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCE_LOCAL_NODE_KEY, | ||
| DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCE_LOCAL_NODE_DEFAULT); | ||
|
|
@@ -77,6 +87,17 @@ public void initialize(Configuration conf, FSClusterStats stats, | |
| + " is less than 0.5 so datanodes with more used percent will" | ||
| + " receive more block allocations."); | ||
| } | ||
|
|
||
| if (balancedSpaceTolerance >= 20 || balancedSpaceTolerance <= 0) { | ||
|
GuoPhilipse marked this conversation as resolved.
Outdated
|
||
| LOG.warn("The value of " | ||
| + DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_KEY | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great, if you can print the use configured value here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks @prasad-acit ,seems more clear for the warning message |
||
| + " is invalid, Default value " + | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT | ||
| + " will be used instead. Increases tolerance of" | ||
| + " placing blocks on Datanodes with similar disk space used "); | ||
| balancedSpaceTolerance = | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| } | ||
| balancedPreference = (int) (100 * balancedPreferencePercent); | ||
| } | ||
|
|
||
|
|
@@ -183,7 +204,7 @@ private DatanodeDescriptor select(DatanodeDescriptor a, DatanodeDescriptor b, | |
| protected int compareDataNode(final DatanodeDescriptor a, | ||
| final DatanodeDescriptor b, boolean isBalanceLocal) { | ||
| if (a.equals(b) | ||
| || Math.abs(a.getDfsUsedPercent() - b.getDfsUsedPercent()) < 5 || (( | ||
| || Math.abs(a.getDfsUsedPercent() - b.getDfsUsedPercent()) < balancedSpaceTolerance || (( | ||
| isBalanceLocal && a.getDfsUsedPercent() < 50))) { | ||
| return 0; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,9 @@ | |
| import java.util.Random; | ||
|
|
||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_DEFAULT; | ||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_RACK_FAULT_TOLERANT_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_KEY; | ||
| import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_RACK_FAULT_TOLERANT_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_KEY; | ||
|
|
||
| /** | ||
| * Space balanced rack fault tolerant block placement policy. | ||
|
|
@@ -45,7 +47,8 @@ public class AvailableSpaceRackFaultTolerantBlockPlacementPolicy | |
| private static final Random RAND = new Random(); | ||
| private int balancedPreference = (int) (100 | ||
| * DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_DEFAULT); | ||
|
|
||
| private int balancedSpaceTolerance = | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| @Override | ||
| public void initialize(Configuration conf, FSClusterStats stats, | ||
| NetworkTopology clusterMap, Host2NodesMap host2datanodeMap) { | ||
|
|
@@ -54,6 +57,10 @@ public void initialize(Configuration conf, FSClusterStats stats, | |
| DFS_NAMENODE_AVAILABLE_SPACE_RACK_FAULT_TOLERANT_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_KEY, | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_DEFAULT); | ||
|
|
||
| balancedSpaceTolerance = conf.getInt( | ||
| DFS_NAMENODE_AVAILABLE_SPACE_RACK_FAULT_TOLERANT_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_KEY, | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constants exceed the length lead to length issue, can be shrinked. BLOCK_PLACEMENT_POLICY => BPP can be used. Other places already large, atleast new code we can target.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @prasad-acit for your advice ,it should be used for total new code , for now, if we cut ir for short, the variable name meaning may not that clear,maybe we can igonre it, and apply the short name as far as possible in furture. |
||
|
|
||
| LOG.info("Available space rack fault tolerant block placement policy " | ||
| + "initialized: " | ||
| + DFSConfigKeys.DFS_NAMENODE_AVAILABLE_SPACE_RACK_FAULT_TOLERANT_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_PREFERENCE_FRACTION_KEY | ||
|
|
@@ -70,6 +77,19 @@ public void initialize(Configuration conf, FSClusterStats stats, | |
| + " is less than 0.5 so datanodes with more used percent will" | ||
| + " receive more block allocations."); | ||
| } | ||
|
|
||
|
|
||
| if (balancedSpaceTolerance >= 20 || balancedSpaceTolerance <= 0) { | ||
| LOG.warn("The value of " | ||
| + DFS_NAMENODE_AVAILABLE_SPACE_RACK_FAULT_TOLERANT_BLOCK_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_KEY | ||
| + " is invalid, Default value " + | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT | ||
| + " will be used instead. Increases tolerance of" | ||
| + " placing blocks on Datanodes with similar disk space used "); | ||
|
GuoPhilipse marked this conversation as resolved.
Outdated
|
||
| balancedSpaceTolerance = | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| } | ||
|
|
||
| balancedPreference = (int) (100 * balancedPreferencePercent); | ||
| } | ||
|
|
||
|
|
@@ -118,7 +138,7 @@ private DatanodeDescriptor select(DatanodeDescriptor a, | |
| protected int compareDataNode(final DatanodeDescriptor a, | ||
| final DatanodeDescriptor b) { | ||
| if (a.equals(b) | ||
| || Math.abs(a.getDfsUsedPercent() - b.getDfsUsedPercent()) < 5) { | ||
| || Math.abs(a.getDfsUsedPercent() - b.getDfsUsedPercent()) < balancedSpaceTolerance) { | ||
| return 0; | ||
| } | ||
| return a.getDfsUsedPercent() < b.getDfsUsedPercent() ? -1 : 1; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.