Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,16 @@ static private void printToScreen(List<NodePlan> plans) {
}

/**
* Sets user specified plan parameters.
* Sets user specified plan parameters (bandwidth, maxError, tolerancePercent).
* tolerancePercent is read from config so the plan propagated to the DataNode
* uses the same value (HDFS-17872).
*
* @param plans - list of plans.
*/
private void setPlanParams(List<NodePlan> plans) {
int tolerancePercent = getConf().getInt(
DFSConfigKeys.DFS_DISK_BALANCER_BLOCK_TOLERANCE,
DFSConfigKeys.DFS_DISK_BALANCER_BLOCK_TOLERANCE_DEFAULT);
for (NodePlan plan : plans) {
for (Step step : plan.getVolumeSetPlans()) {
if (this.bandwidth > 0) {
Expand All @@ -265,6 +270,8 @@ private void setPlanParams(List<NodePlan> plans) {
LOG.debug("Setting max error to {}", this.maxError);
step.setMaxDiskErrors(this.maxError);
}
LOG.debug("Setting tolerance percent to {}", tolerancePercent);
step.setTolerancePercent(tolerancePercent);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ public void testNodePlan() throws IOException {
assertThat(NodePlan.parseJson(json)).isNotNull();
}

/**
* HDFS-17872: Plan steps must carry tolerancePercent so the DataNode receives
* it. Verify serialization round-trip preserves tolerance percent.
*/
@Test
public void testPlanStepTolerancePercentInJson() throws IOException {
NodePlan nodePlan = new NodePlan("datanode1", 50070);
MoveStep moveStep = new MoveStep();
moveStep.setBandwidth(100);
moveStep.setBytesToMove(1024);
moveStep.setIdealStorage(0.5);
moveStep.setMaxDiskErrors(5);
moveStep.setTolerancePercent(15);
moveStep.setVolumeSetID("volumeSetId");
nodePlan.addStep(moveStep);
String json = nodePlan.toJson();
NodePlan parsed = NodePlan.parseJson(json);
assertThat(parsed.getVolumeSetPlans()).hasSize(1);
assertThat(parsed.getVolumeSetPlans().get(0).getTolerancePercent())
.describedAs("tolerancePercent should be propagated in plan JSON")
.isEqualTo(15);
}

@Test
public void testNodePlanWithDisallowedStep() throws Exception {
NodePlan nodePlan = new NodePlan("datanode1234", 1234);
Expand Down