Search in sources :

Example 36 with TaskAttempt

use of org.apache.tez.dag.app.dag.TaskAttempt 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 37 with TaskAttempt

use of org.apache.tez.dag.app.dag.TaskAttempt 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)

Example 38 with TaskAttempt

use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.

the class LegacyTaskRuntimeEstimator method storedPerAttemptValue.

private long storedPerAttemptValue(Map<TaskAttempt, AtomicLong> data, TezTaskAttemptID attemptID) {
    Task task = vertex.getTask(attemptID.getTaskID());
    if (task == null) {
        return -1L;
    }
    TaskAttempt taskAttempt = task.getAttempt(attemptID);
    if (taskAttempt == null) {
        return -1L;
    }
    AtomicLong estimate = data.get(taskAttempt);
    return estimate == null ? -1L : estimate.get();
}
Also used : Task(org.apache.tez.dag.app.dag.Task) AtomicLong(java.util.concurrent.atomic.AtomicLong) TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt)

Example 39 with TaskAttempt

use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.

the class StartEndTimesBase method updateAttempt.

@Override
public void updateAttempt(TezTaskAttemptID attemptID, TaskAttemptState state, long timestamp) {
    Task task = vertex.getTask(attemptID.getTaskID());
    if (task == null) {
        return;
    }
    Long boxedStart = startTimes.get(attemptID);
    long start = boxedStart == null ? Long.MIN_VALUE : boxedStart;
    TaskAttempt taskAttempt = task.getAttempt(attemptID);
    if (taskAttempt.getState() == TaskAttemptState.SUCCEEDED) {
        boolean isNew = false;
        // is this  a new success?
        synchronized (doneTasks) {
            if (!doneTasks.contains(task)) {
                doneTasks.add(task);
                isNew = true;
            }
        }
        // local data] we only count the first one.
        if (isNew) {
            long finish = timestamp;
            if (start > 1L && finish > 1L && start <= finish) {
                long duration = finish - start;
                taskStatistics.add(duration);
            }
        }
    }
}
Also used : Task(org.apache.tez.dag.app.dag.Task) TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt)

Aggregations

TaskAttempt (org.apache.tez.dag.app.dag.TaskAttempt)39 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)20 TezVertexID (org.apache.tez.dag.records.TezVertexID)20 Test (org.junit.Test)18 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)13 Configuration (org.apache.hadoop.conf.Configuration)12 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)12 Priority (org.apache.hadoop.yarn.api.records.Priority)12 Resource (org.apache.hadoop.yarn.api.records.Resource)12 TezDAGID (org.apache.tez.dag.records.TezDAGID)12 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 Container (org.apache.hadoop.yarn.api.records.Container)11 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)11 AppContext (org.apache.tez.dag.app.AppContext)11 ClusterInfo (org.apache.tez.dag.app.ClusterInfo)11 ContainerHeartbeatHandler (org.apache.tez.dag.app.ContainerHeartbeatHandler)11 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)11 AMRMClientAsyncForTest (org.apache.tez.dag.app.rm.TestTaskSchedulerHelpers.AMRMClientAsyncForTest)11 AMRMClientForTest (org.apache.tez.dag.app.rm.TestTaskSchedulerHelpers.AMRMClientForTest)11 CapturingEventHandler (org.apache.tez.dag.app.rm.TestTaskSchedulerHelpers.CapturingEventHandler)11