Search in sources :

Example 26 with SplitLogTask

use of org.apache.hadoop.hbase.SplitLogTask in project hbase by apache.

the class TestSplitLogManager method testTaskCreation.

/**
 * Test whether the splitlog correctly creates a task in zookeeper
 */
@Test
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 27 with SplitLogTask

use of org.apache.hadoop.hbase.SplitLogTask in project hbase by apache.

the class TestSplitLogManager method testOrphanTaskAcquisition.

@Test
public void testOrphanTaskAcquisition() throws Exception {
    LOG.info("TestOrphanTaskAcquisition");
    String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
    SplitLogTask slt = new SplitLogTask.Owned(master.getServerName());
    zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    slm = new SplitLogManager(master, conf);
    waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to / 2);
    Task task = findOrCreateOrphanTask(tasknode);
    assertTrue(task.isOrphan());
    waitForCounter(tot_mgr_heartbeat, 0, 1, to / 2);
    assertFalse(task.isUnassigned());
    long curt = EnvironmentEdgeManager.currentTime();
    assertTrue((task.last_update <= curt) && (task.last_update > (curt - 1000)));
    LOG.info("waiting for manager to resubmit the orphan task");
    waitForCounter(tot_mgr_resubmit, 0, 1, to + to / 2);
    assertTrue(task.isUnassigned());
    waitForCounter(tot_mgr_rescan, 0, 1, to + to / 2);
}
Also used : SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Task(org.apache.hadoop.hbase.master.SplitLogManager.Task) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Test(org.junit.Test)

Example 28 with SplitLogTask

use of org.apache.hadoop.hbase.SplitLogTask in project hbase by apache.

the class TestSplitLogManager method testUnassignedOrphan.

@Test
public void testUnassignedOrphan() throws Exception {
    LOG.info("TestUnassignedOrphan - an unassigned task is resubmitted at" + " startup");
    String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
    // create an unassigned orphan task
    SplitLogTask slt = new SplitLogTask.Unassigned(master.getServerName());
    zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    int version = ZKUtil.checkExists(zkw, tasknode);
    slm = new SplitLogManager(master, conf);
    waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to / 2);
    Task task = findOrCreateOrphanTask(tasknode);
    assertTrue(task.isOrphan());
    assertTrue(task.isUnassigned());
    // wait for RESCAN node to be created
    waitForCounter(tot_mgr_rescan, 0, 1, to / 2);
    Task task2 = findOrCreateOrphanTask(tasknode);
    assertTrue(task == task2);
    LOG.debug("task = " + task);
    assertEquals(1L, tot_mgr_resubmit.sum());
    assertEquals(1, task.incarnation.get());
    assertEquals(0, task.unforcedResubmits.get());
    assertTrue(task.isOrphan());
    assertTrue(task.isUnassigned());
    assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
Also used : SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Task(org.apache.hadoop.hbase.master.SplitLogManager.Task) SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Test(org.junit.Test)

Aggregations

SplitLogTask (org.apache.hadoop.hbase.SplitLogTask)28 Test (org.junit.Test)19 ServerName (org.apache.hadoop.hbase.ServerName)17 TaskBatch (org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch)9 KeeperException (org.apache.zookeeper.KeeperException)6 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)4 Stat (org.apache.zookeeper.data.Stat)3 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2 Configuration (org.apache.hadoop.conf.Configuration)2 Path (org.apache.hadoop.fs.Path)2 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)2 Task (org.apache.hadoop.hbase.master.SplitLogManager.Task)2 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 RecoveryMode (org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode)1