use of org.apache.hadoop.hdfs.server.datanode.DiskBalancer in project hadoop by apache.
the class TestDiskBalancerWithMockMover method testCancelDiskBalancerPlan.
/**
* Test Cancel Plan.
*
* @throws Exception
*/
@Test
public void testCancelDiskBalancerPlan() throws Exception {
MockMoverHelper mockMoverHelper = new MockMoverHelper().invoke();
NodePlan plan = mockMoverHelper.getPlan();
DiskBalancer balancer = mockMoverHelper.getBalancer();
// ask block mover to delay execution
mockMoverHelper.getBlockMover().setSleep();
executeSubmitPlan(plan, balancer);
String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson);
balancer.cancelPlan(planID);
DiskBalancerWorkStatus status = balancer.queryWorkStatus();
assertEquals(DiskBalancerWorkStatus.Result.PLAN_CANCELLED, status.getResult());
executeSubmitPlan(plan, balancer);
// Send a Wrong cancellation request.
char first = planID.charAt(0);
first++;
thrown.expect(DiskBalancerException.class);
thrown.expect(new DiskBalancerResultVerifier(DiskBalancerException.Result.NO_SUCH_PLAN));
balancer.cancelPlan(planID.replace(planID.charAt(0), first));
// Now cancel the real one
balancer.cancelPlan(planID);
// unblock mover.
mockMoverHelper.getBlockMover().clearSleep();
status = balancer.queryWorkStatus();
assertEquals(DiskBalancerWorkStatus.Result.PLAN_CANCELLED, status.getResult());
}
use of org.apache.hadoop.hdfs.server.datanode.DiskBalancer in project hadoop by apache.
the class TestDiskBalancerWithMockMover method testSubmitWithOlderPlan.
@Test
public void testSubmitWithOlderPlan() throws Exception {
final long millisecondInAnHour = 1000 * 60 * 60L;
MockMoverHelper mockMoverHelper = new MockMoverHelper().invoke();
NodePlan plan = mockMoverHelper.getPlan();
DiskBalancer balancer = mockMoverHelper.getBalancer();
plan.setTimeStamp(Time.now() - (32 * millisecondInAnHour));
thrown.expect(DiskBalancerException.class);
thrown.expect(new DiskBalancerResultVerifier(DiskBalancerException.Result.OLD_PLAN_SUBMITTED));
executeSubmitPlan(plan, balancer);
}
use of org.apache.hadoop.hdfs.server.datanode.DiskBalancer in project hadoop by apache.
the class TestDiskBalancerWithMockMover method testDiskBalancerEnabled.
/**
* Checks that Enable flag works correctly.
*
* @throws DiskBalancerException
*/
@Test
public void testDiskBalancerEnabled() throws DiskBalancerException {
Configuration conf = new HdfsConfiguration();
conf.setBoolean(DFSConfigKeys.DFS_DISK_BALANCER_ENABLED, true);
TestMover blockMover = new TestMover(cluster.getDataNodes().get(0).getFSDataset());
DiskBalancer balancer = new DiskBalancerBuilder(conf).setMover(blockMover).build();
DiskBalancerWorkStatus status = balancer.queryWorkStatus();
assertEquals(NO_PLAN, status.getResult());
}
use of org.apache.hadoop.hdfs.server.datanode.DiskBalancer in project hadoop by apache.
the class TestDiskBalancerWithMockMover method testCustomBandwidth.
/**
* Test Custom bandwidth.
*
* @throws Exception
*/
@Test
public void testCustomBandwidth() throws Exception {
MockMoverHelper mockMoverHelper = new MockMoverHelper().invoke();
NodePlan plan = mockMoverHelper.getPlan();
DiskBalancer balancer = mockMoverHelper.getBalancer();
for (Step step : plan.getVolumeSetPlans()) {
MoveStep tempStep = (MoveStep) step;
tempStep.setBandwidth(100);
}
executeSubmitPlan(plan, balancer);
DiskBalancerWorkStatus status = balancer.queryWorkStatus();
assertNotNull(status);
DiskBalancerWorkStatus.DiskBalancerWorkEntry entry = balancer.queryWorkStatus().getCurrentState().get(0);
assertEquals(100L, entry.getWorkItem().getBandwidth());
}
use of org.apache.hadoop.hdfs.server.datanode.DiskBalancer in project hadoop by apache.
the class TestDiskBalancerWithMockMover method testSubmitWithNullPlan.
@Test
public void testSubmitWithNullPlan() throws Exception {
MockMoverHelper mockMoverHelper = new MockMoverHelper().invoke();
NodePlan plan = mockMoverHelper.getPlan();
DiskBalancer balancer = mockMoverHelper.getBalancer();
String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson);
thrown.expect(DiskBalancerException.class);
thrown.expect(new DiskBalancerResultVerifier(DiskBalancerException.Result.INVALID_PLAN));
balancer.submitPlan(planID, 1, "no-plan-file.json", null, false);
}
Aggregations