Search in sources :

Example 31 with TaskAttemptEventSchedule

use of org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule in project tez by apache.

the class TestTaskImpl method testSucceededAttemptStatusWithRetroActiveFailures.

@SuppressWarnings("rawtypes")
@Test
public void testSucceededAttemptStatusWithRetroActiveFailures() throws InterruptedException {
    TezTaskID taskId = getNewTaskID();
    scheduleTaskAttempt(taskId);
    MockTaskAttemptImpl firstMockTaskAttempt = mockTask.getAttemptList().get(0);
    launchTaskAttempt(firstMockTaskAttempt.getID());
    mockTask.handle(createTaskTAAddSpecAttempt(mockTask.getLastAttempt().getID()));
    MockTaskAttemptImpl secondMockTaskAttempt = mockTask.getAttemptList().get(1);
    launchTaskAttempt(secondMockTaskAttempt.getID());
    firstMockTaskAttempt.handle(new TaskAttemptEventSchedule(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), 10, 10));
    secondMockTaskAttempt.handle(new TaskAttemptEventSchedule(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString()), 10, 10));
    firstMockTaskAttempt.handle(new TaskAttemptEventSubmitted(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), mockContainer.getId()));
    secondMockTaskAttempt.handle(new TaskAttemptEventSubmitted(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString()), mockContainer.getId()));
    secondMockTaskAttempt.handle(new TaskAttemptEventStartedRemotely(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString())));
    firstMockTaskAttempt.handle(new TaskAttemptEventStartedRemotely(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString())));
    secondMockTaskAttempt.handle(new TaskAttemptEvent(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString()), TaskAttemptEventType.TA_DONE));
    firstMockTaskAttempt.handle(new TaskAttemptEvent(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), TaskAttemptEventType.TA_DONE));
    mockTask.handle(new TaskEventTASucceeded(secondMockTaskAttempt.getID()));
    mockTask.handle(new TaskEventTASucceeded(firstMockTaskAttempt.getID()));
    assertTrue("Attempts should have succeeded!", firstMockTaskAttempt.getInternalState() == TaskAttemptStateInternal.SUCCEEDED && secondMockTaskAttempt.getInternalState() == TaskAttemptStateInternal.SUCCEEDED);
    assertEquals("Task should have no uncompleted attempts!", 0, mockTask.getUncompletedAttemptsCount());
    assertTrue("Task should have Succeeded!", mockTask.getState() == TaskState.SUCCEEDED);
    // Failing the attempt that finished after the task was marked succeeded, should not schedule another attempt
    failAttempt(firstMockTaskAttempt, 0, 0);
    assertTaskSucceededState();
    // Failing the attempt that allowed the task to succeed, should schedule another attempt
    failAttempt(secondMockTaskAttempt, 1, 1);
    assertTaskScheduledState();
}
Also used : TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) TaskAttemptEventSubmitted(org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted) TaskEventTASucceeded(org.apache.tez.dag.app.dag.event.TaskEventTASucceeded) TezTaskID(org.apache.tez.dag.records.TezTaskID) TaskAttemptEventStartedRemotely(org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely) Test(org.junit.Test)

Example 32 with TaskAttemptEventSchedule

use of org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule in project tez by apache.

the class DAGSchedulerNaturalOrderControlled method scheduleTaskEx.

// TODO Does ordering matter - it currently depends on the order returned by vertex.getOutput*
@Override
public void scheduleTaskEx(DAGEventSchedulerUpdate event) {
    TaskAttempt attempt = event.getAttempt();
    Vertex vertex = dag.getVertex(attempt.getVertexID());
    int vertexDistanceFromRoot = vertex.getDistanceFromRoot();
    // natural priority. Handles failures and retries.
    int priorityLowLimit = ((vertexDistanceFromRoot + 1) * dag.getTotalVertices() * 3) + (vertex.getVertexId().getId() * 3);
    int priorityHighLimit = priorityLowLimit - 2;
    TaskAttemptEventSchedule attemptEvent = new TaskAttemptEventSchedule(attempt.getID(), priorityLowLimit, priorityHighLimit);
    taskAttemptSeen(vertex.getName(), attempt.getID());
    if (vertexAlreadyScheduled(vertex)) {
        // Vertex previously marked ready for scheduling.
        if (LOG.isDebugEnabled()) {
            LOG.debug("Scheduling " + attempt.getID() + " between priorityLow: " + priorityLowLimit + " and priorityHigh: " + priorityHighLimit);
        }
        sendEvent(attemptEvent);
        // A new taks coming in here could send us over the enough tasks scheduled limit.
        processDownstreamVertices(vertex);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Attempting to schedule vertex: " + vertex.getLogIdentifier() + " due to schedule event");
        }
        boolean scheduled = trySchedulingVertex(vertex);
        if (scheduled) {
            LOG.info("Scheduled vertex: " + vertex.getLogIdentifier());
            // If ready to be scheduled, send out pending events and the current event.
            // Send events out for this vertex first. Then try scheduling downstream vertices.
            sendEventsForVertex(vertex.getName());
            sendEvent(attemptEvent);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Processing downstream vertices for vertex: " + vertex.getLogIdentifier());
            }
            processDownstreamVertices(vertex);
        } else {
            pendingEvents.put(vertex.getName(), attemptEvent);
        }
    }
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule)

Example 33 with TaskAttemptEventSchedule

use of org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule in project tez by apache.

the class DAGSchedulerNaturalOrder method scheduleTaskEx.

@Override
public void scheduleTaskEx(DAGEventSchedulerUpdate event) {
    TaskAttempt attempt = event.getAttempt();
    Vertex vertex = dag.getVertex(attempt.getVertexID());
    int vertexDistanceFromRoot = vertex.getDistanceFromRoot();
    // natural priority. Handles failures and retries.
    int priorityLowLimit = ((vertexDistanceFromRoot + 1) * dag.getTotalVertices() * 3) + (vertex.getVertexId().getId() * 3);
    int priorityHighLimit = priorityLowLimit - 2;
    if (LOG.isDebugEnabled()) {
        LOG.debug("Scheduling " + attempt.getID() + " between priorityLow: " + priorityLowLimit + " and priorityHigh: " + priorityHighLimit);
    }
    TaskAttemptEventSchedule attemptEvent = new TaskAttemptEventSchedule(attempt.getID(), priorityLowLimit, priorityHighLimit);
    sendEvent(attemptEvent);
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule)

Aggregations

TaskAttemptEventSchedule (org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule)33 Test (org.junit.Test)31 TezTaskID (org.apache.tez.dag.records.TezTaskID)26 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)24 TaskAttemptEventSubmitted (org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted)24 Configuration (org.apache.hadoop.conf.Configuration)23 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)23 TaskAttemptEventStartedRemotely (org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely)23 TaskAttemptEvent (org.apache.tez.dag.app.dag.event.TaskAttemptEvent)21 Container (org.apache.hadoop.yarn.api.records.Container)20 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)20 NodeId (org.apache.hadoop.yarn.api.records.NodeId)20 SystemClock (org.apache.hadoop.yarn.util.SystemClock)20 TaskHeartbeatHandler (org.apache.tez.dag.app.TaskHeartbeatHandler)20 ContainerHeartbeatHandler (org.apache.tez.dag.app.ContainerHeartbeatHandler)19 AMContainerMap (org.apache.tez.dag.app.rm.container.AMContainerMap)19 ContainerContextMatcher (org.apache.tez.dag.app.rm.container.ContainerContextMatcher)19 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)19 TaskStatusUpdateEvent (org.apache.tez.runtime.api.events.TaskStatusUpdateEvent)19 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)19