Search in sources :

Example 1 with Task

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

the class ZKSplitLogManagerCoordination method heartbeat.

private void heartbeat(String path, int new_version, ServerName workerName) {
    Task task = findOrCreateOrphanTask(path);
    if (new_version != task.last_version) {
        if (task.isUnassigned()) {
            LOG.info("task " + path + " acquired by " + workerName);
        }
        task.heartbeat(EnvironmentEdgeManager.currentTime(), new_version, workerName);
        SplitLogCounters.tot_mgr_heartbeat.incrementAndGet();
    } else {
    // duplicate heartbeats - heartbeats w/o zk node version
    // changing - are possible. The timeout thread does
    // getDataSetWatch() just to check whether a node still
    // exists or not
    }
    return;
}
Also used : SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Task(org.apache.hadoop.hbase.master.SplitLogManager.Task)

Example 2 with Task

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

the class ZKSplitLogManagerCoordination method nodeDataChanged.

@Override
public void nodeDataChanged(String path) {
    Task task;
    task = details.getTasks().get(path);
    if (task != null || ZKSplitLog.isRescanNode(watcher, path)) {
        if (task != null) {
            task.heartbeatNoDetails(EnvironmentEdgeManager.currentTime());
        }
        getDataSetWatch(path, zkretries);
    }
}
Also used : SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Task(org.apache.hadoop.hbase.master.SplitLogManager.Task)

Example 3 with Task

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

the class ZKSplitLogManagerCoordination method setDone.

private void setDone(String path, TerminationStatus status) {
    Task task = details.getTasks().get(path);
    if (task == null) {
        if (!ZKSplitLog.isRescanNode(watcher, path)) {
            SplitLogCounters.tot_mgr_unacquired_orphan_done.incrementAndGet();
            LOG.debug("unacquired orphan task is done " + path);
        }
    } else {
        synchronized (task) {
            if (task.status == IN_PROGRESS) {
                if (status == SUCCESS) {
                    SplitLogCounters.tot_mgr_log_split_success.incrementAndGet();
                    LOG.info("Done splitting " + path);
                } else {
                    SplitLogCounters.tot_mgr_log_split_err.incrementAndGet();
                    LOG.warn("Error splitting " + path);
                }
                task.status = status;
                if (task.batch != null) {
                    synchronized (task.batch) {
                        if (status == SUCCESS) {
                            task.batch.done++;
                        } else {
                            task.batch.error++;
                        }
                        task.batch.notify();
                    }
                }
            }
        }
    }
    // delete the task node in zk. It's an async
    // call and no one is blocked waiting for this node to be deleted. All
    // task names are unique (log.<timestamp>) there is no risk of deleting
    // a future task.
    // if a deletion fails, TimeoutMonitor will retry the same deletion later
    deleteNode(path, zkretries);
    return;
}
Also used : SplitLogTask(org.apache.hadoop.hbase.SplitLogTask) Task(org.apache.hadoop.hbase.master.SplitLogManager.Task)

Example 4 with Task

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

the class TestSplitLogManager method testUnassignedOrphan.

@Test(timeout = 180000)
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(), this.mode);
    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.get());
    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)

Example 5 with Task

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

the class TestSplitLogManager method testOrphanTaskAcquisition.

@Test(timeout = 180000)
public void testOrphanTaskAcquisition() throws Exception {
    LOG.info("TestOrphanTaskAcquisition");
    String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
    SplitLogTask slt = new SplitLogTask.Owned(master.getServerName(), this.mode);
    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 = System.currentTimeMillis();
    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)

Aggregations

SplitLogTask (org.apache.hadoop.hbase.SplitLogTask)7 Task (org.apache.hadoop.hbase.master.SplitLogManager.Task)7 Test (org.junit.Test)2