-
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 15 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 |
|---|---|---|
|
|
@@ -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,18 @@ 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."); | ||
| balancedSpaceTolerance = | ||
| DFS_NAMENODE_AVAILABLE_SPACE_BLOCK_RACK_FAULT_TOLERANT_PLACEMENT_POLICY_BALANCED_SPACE_TOLERANCE_DEFAULT; | ||
| } | ||
|
|
||
| balancedPreference = (int) (100 * balancedPreferencePercent); | ||
| } | ||
|
|
||
|
|
@@ -118,7 +137,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; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @prasad-acit ,seems more clear for the warning message