Search in sources :

Example 1 with DiskBalancer

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());
}
Also used : NodePlan(org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan) DiskBalancer(org.apache.hadoop.hdfs.server.datanode.DiskBalancer) DiskBalancerWorkStatus(org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus) Test(org.junit.Test)

Example 2 with DiskBalancer

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);
}
Also used : NodePlan(org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan) DiskBalancer(org.apache.hadoop.hdfs.server.datanode.DiskBalancer) Test(org.junit.Test)

Example 3 with DiskBalancer

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());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) DiskBalancer(org.apache.hadoop.hdfs.server.datanode.DiskBalancer) DiskBalancerWorkStatus(org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) Test(org.junit.Test)

Example 4 with DiskBalancer

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());
}
Also used : NodePlan(org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan) DiskBalancer(org.apache.hadoop.hdfs.server.datanode.DiskBalancer) Step(org.apache.hadoop.hdfs.server.diskbalancer.planner.Step) MoveStep(org.apache.hadoop.hdfs.server.diskbalancer.planner.MoveStep) DiskBalancerWorkStatus(org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus) MoveStep(org.apache.hadoop.hdfs.server.diskbalancer.planner.MoveStep) Test(org.junit.Test)

Example 5 with DiskBalancer

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);
}
Also used : NodePlan(org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan) DiskBalancer(org.apache.hadoop.hdfs.server.datanode.DiskBalancer) Test(org.junit.Test)

Aggregations

DiskBalancer (org.apache.hadoop.hdfs.server.datanode.DiskBalancer)10 Test (org.junit.Test)10 NodePlan (org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan)8 DiskBalancerWorkStatus (org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus)3 Configuration (org.apache.hadoop.conf.Configuration)2 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)2 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MoveStep (org.apache.hadoop.hdfs.server.diskbalancer.planner.MoveStep)1 Step (org.apache.hadoop.hdfs.server.diskbalancer.planner.Step)1