Search in sources :

Example 6 with TaskBatch

use of org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch in project hbase by apache.

the class TestSplitLogManager method testTaskResigned.

@Test(timeout = 180000)
public void testTaskResigned() throws Exception {
    LOG.info("TestTaskResigned - resubmit task node once in RESIGNED state");
    assertEquals(tot_mgr_resubmit.get(), 0);
    slm = new SplitLogManager(master, conf);
    assertEquals(tot_mgr_resubmit.get(), 0);
    TaskBatch batch = new TaskBatch();
    String tasknode = submitTaskAndWait(batch, "foo/1");
    assertEquals(tot_mgr_resubmit.get(), 0);
    final ServerName worker1 = ServerName.valueOf("worker1,1,1");
    assertEquals(tot_mgr_resubmit.get(), 0);
    SplitLogTask slt = new SplitLogTask.Resigned(worker1, this.mode);
    assertEquals(tot_mgr_resubmit.get(), 0);
    ZKUtil.setData(zkw, tasknode, slt.toByteArray());
    ZKUtil.checkExists(zkw, tasknode);
    // Could be small race here.
    if (tot_mgr_resubmit.get() == 0) {
        waitForCounter(tot_mgr_resubmit, 0, 1, to / 2);
    }
    assertEquals(tot_mgr_resubmit.get(), 1);
    byte[] taskstate = ZKUtil.getData(zkw, tasknode);
    slt = SplitLogTask.parseFrom(taskstate);
    assertTrue(slt.isUnassigned(master.getServerName()));
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) TaskBatch(org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Test(org.junit.Test)

Example 7 with TaskBatch

use of org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch in project hbase by apache.

the class TestSplitLogManager method testRescanCleanup.

@Test(timeout = 180000)
public void testRescanCleanup() throws Exception {
    LOG.info("TestRescanCleanup - ensure RESCAN nodes are cleaned up");
    slm = new SplitLogManager(master, conf);
    TaskBatch batch = new TaskBatch();
    String tasknode = submitTaskAndWait(batch, "foo/1");
    int version = ZKUtil.checkExists(zkw, tasknode);
    final ServerName worker1 = ServerName.valueOf("worker1,1,1");
    SplitLogTask slt = new SplitLogTask.Owned(worker1, this.mode);
    ZKUtil.setData(zkw, tasknode, slt.toByteArray());
    waitForCounter(tot_mgr_heartbeat, 0, 1, to / 2);
    waitForCounter(new Expr() {

        @Override
        public long eval() {
            return (tot_mgr_resubmit.get() + tot_mgr_resubmit_failed.get());
        }
    }, 0, 1, // wait long enough
    5 * 60000);
    Assert.assertEquals("Could not run test. Lost ZK connection?", 0, tot_mgr_resubmit_failed.get());
    int version1 = ZKUtil.checkExists(zkw, tasknode);
    assertTrue(version1 > version);
    byte[] taskstate = ZKUtil.getData(zkw, tasknode);
    slt = SplitLogTask.parseFrom(taskstate);
    assertTrue(slt.isUnassigned(master.getServerName()));
    waitForCounter(tot_mgr_rescan_deleted, 0, 1, to / 2);
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) TaskBatch(org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Test(org.junit.Test)

Example 8 with TaskBatch

use of org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch in project hbase by apache.

the class TestSplitLogManager method testTaskCreation.

/**
   * Test whether the splitlog correctly creates a task in zookeeper
   * @throws Exception
   */
@Test(timeout = 180000)
public void testTaskCreation() throws Exception {
    LOG.info("TestTaskCreation - test the creation of a task in zk");
    slm = new SplitLogManager(master, conf);
    TaskBatch batch = new TaskBatch();
    String tasknode = submitTaskAndWait(batch, "foo/1");
    byte[] data = ZKUtil.getData(zkw, tasknode);
    SplitLogTask slt = SplitLogTask.parseFrom(data);
    LOG.info("Task node created " + slt.toString());
    assertTrue(slt.isUnassigned(master.getServerName()));
}
Also used : TaskBatch(org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Test(org.junit.Test)

Example 9 with TaskBatch

use of org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch in project hbase by apache.

the class TestSplitLogManager method testDeadWorker.

@Test(timeout = 180000)
public void testDeadWorker() throws Exception {
    LOG.info("testDeadWorker");
    conf.setLong("hbase.splitlog.max.resubmit", 0);
    slm = new SplitLogManager(master, conf);
    TaskBatch batch = new TaskBatch();
    String tasknode = submitTaskAndWait(batch, "foo/1");
    int version = ZKUtil.checkExists(zkw, tasknode);
    final ServerName worker1 = ServerName.valueOf("worker1,1,1");
    SplitLogTask slt = new SplitLogTask.Owned(worker1, this.mode);
    ZKUtil.setData(zkw, tasknode, slt.toByteArray());
    if (tot_mgr_heartbeat.get() == 0)
        waitForCounter(tot_mgr_heartbeat, 0, 1, to / 2);
    slm.handleDeadWorker(worker1);
    if (tot_mgr_resubmit.get() == 0)
        waitForCounter(tot_mgr_resubmit, 0, 1, to + to / 2);
    if (tot_mgr_resubmit_dead_server_task.get() == 0) {
        waitForCounter(tot_mgr_resubmit_dead_server_task, 0, 1, to + to / 2);
    }
    int version1 = ZKUtil.checkExists(zkw, tasknode);
    assertTrue(version1 > version);
    byte[] taskstate = ZKUtil.getData(zkw, tasknode);
    slt = SplitLogTask.parseFrom(taskstate);
    assertTrue(slt.isUnassigned(master.getServerName()));
    return;
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) TaskBatch(org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Test(org.junit.Test)

Example 10 with TaskBatch

use of org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch in project hbase by apache.

the class TestSplitLogManager method testUnassignedTimeout.

@Test(timeout = 180000)
public void testUnassignedTimeout() throws Exception {
    LOG.info("TestUnassignedTimeout - iff all tasks are unassigned then" + " resubmit");
    // create an orphan task in OWNED state
    String tasknode1 = ZKSplitLog.getEncodedNodeName(zkw, "orphan/1");
    final ServerName worker1 = ServerName.valueOf("worker1,1,1");
    SplitLogTask slt = new SplitLogTask.Owned(worker1, this.mode);
    zkw.getRecoverableZooKeeper().create(tasknode1, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    slm = new SplitLogManager(master, conf);
    waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to / 2);
    // submit another task which will stay in unassigned mode
    TaskBatch batch = new TaskBatch();
    submitTaskAndWait(batch, "foo/1");
    // keep updating the orphan owned node every to/2 seconds
    for (int i = 0; i < (3 * to) / 100; i++) {
        Thread.sleep(100);
        final ServerName worker2 = ServerName.valueOf("worker1,1,1");
        slt = new SplitLogTask.Owned(worker2, this.mode);
        ZKUtil.setData(zkw, tasknode1, slt.toByteArray());
    }
    // since we have stopped heartbeating the owned node therefore it should
    // get resubmitted
    LOG.info("waiting for manager to resubmit the orphan task");
    waitForCounter(tot_mgr_resubmit, 0, 1, to + to / 2);
    // now all the nodes are unassigned. manager should post another rescan
    waitForCounter(tot_mgr_resubmit_unassigned, 0, 1, 2 * to + to / 2);
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) TaskBatch(org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch) Test(org.junit.Test)

Aggregations

TaskBatch (org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch)10 Test (org.junit.Test)10 SplitLogTask (org.apache.hadoop.hbase.SplitLogTask)9 ServerName (org.apache.hadoop.hbase.ServerName)8 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 Table (org.apache.hadoop.hbase.client.Table)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 MasterThread (org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread)1 RegionServerThread (org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread)1 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)1 Ignore (org.junit.Ignore)1