Search in sources :

Example 26 with TaskAttempt

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

the class TestAMWebController method createMockAttempt.

private TaskAttempt createMockAttempt(String attemptIDStr, TaskAttemptState status, float progress) {
    TaskAttempt mockAttempt = mock(TaskAttempt.class);
    doReturn(TezTaskAttemptID.fromString(attemptIDStr)).when(mockAttempt).getID();
    doReturn(status).when(mockAttempt).getState();
    doReturn(progress).when(mockAttempt).getProgress();
    TezCounters counters = new TezCounters();
    counters.addGroup("g1", "g1");
    counters.addGroup("g2", "g2");
    counters.addGroup("g3", "g3");
    counters.addGroup("g4", "g4");
    counters.findCounter("g1", "g1_c1").setValue(101);
    counters.findCounter("g1", "g1_c2").setValue(102);
    counters.findCounter("g2", "g2_c3").setValue(103);
    counters.findCounter("g2", "g2_c4").setValue(104);
    counters.findCounter("g3", "g3_c5").setValue(105);
    counters.findCounter("g3", "g3_c6").setValue(106);
    doReturn(counters).when(mockAttempt).getCounters();
    return mockAttempt;
}
Also used : TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 27 with TaskAttempt

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

the class TestAMWebController method createMockAttempts.

private List<TaskAttempt> createMockAttempts() {
    TaskAttempt mockAttempt1 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_0", TaskAttemptState.RUNNING, 0.33f);
    TaskAttempt mockAttempt2 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_1", TaskAttemptState.SUCCEEDED, 1.0f);
    TaskAttempt mockAttempt3 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_2", TaskAttemptState.FAILED, .8f);
    TaskAttempt mockAttempt4 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_3", TaskAttemptState.SUCCEEDED, .8f);
    List<TaskAttempt> attempts = Arrays.asList(mockAttempt1, mockAttempt2, mockAttempt3, mockAttempt4);
    return attempts;
}
Also used : TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt)

Example 28 with TaskAttempt

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

the class AMWebController method getAttemptsInfo.

/**
 * Renders the response JSON for attemptsInfo API
 * The JSON will have an array of attempt objects under the key attempts.
 */
public void getAttemptsInfo() {
    if (!setupResponse()) {
        return;
    }
    DAG dag = checkAndGetDAGFromRequest();
    if (dag == null) {
        return;
    }
    int limit = MAX_QUERIED;
    try {
        limit = getQueryParamInt(WebUIService.LIMIT);
    } catch (NumberFormatException e) {
    // Ignore
    }
    List<TaskAttempt> attempts = getRequestedAttempts(dag, limit);
    if (attempts == null) {
        return;
    }
    Map<String, Set<String>> counterNames = getCounterListFromRequest();
    ArrayList<Map<String, Object>> attemptsInfo = new ArrayList<Map<String, Object>>();
    for (TaskAttempt a : attempts) {
        Map<String, Object> attemptInfo = new HashMap<String, Object>();
        attemptInfo.put("id", a.getID().toString());
        attemptInfo.put("progress", Float.toString(a.getProgress()));
        attemptInfo.put("status", a.getState().toString());
        try {
            TezCounters counters = a.getCounters();
            Map<String, Map<String, Long>> counterMap = constructCounterMapInfo(counters, counterNames);
            if (counterMap != null && !counterMap.isEmpty()) {
                attemptInfo.put("counters", counterMap);
            }
        } catch (LimitExceededException e) {
        // Ignore
        // TODO: add an error message instead for counter key
        }
        attemptsInfo.add(attemptInfo);
    }
    renderJSON(ImmutableMap.of("attempts", attemptsInfo));
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DAG(org.apache.tez.dag.app.dag.DAG) TezCounters(org.apache.tez.common.counters.TezCounters) LimitExceededException(org.apache.tez.common.counters.LimitExceededException) TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) TreeMap(java.util.TreeMap)

Example 29 with TaskAttempt

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

the class TaskImpl method addAndScheduleAttempt.

// This is always called in the Write Lock
private void addAndScheduleAttempt(TezTaskAttemptID schedulingCausalTA) {
    TaskAttempt attempt = createAttempt(attempts.size(), schedulingCausalTA);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Created attempt " + attempt.getID());
    }
    switch(attempts.size()) {
        case 0:
            attempts = Collections.singletonMap(attempt.getID(), attempt);
            break;
        case 1:
            Map<TezTaskAttemptID, TaskAttempt> newAttempts = new LinkedHashMap<TezTaskAttemptID, TaskAttempt>(maxFailedAttempts);
            newAttempts.putAll(attempts);
            attempts = newAttempts;
            Preconditions.checkArgument(attempts.put(attempt.getID(), attempt) == null, attempt.getID() + " already existed");
            break;
        default:
            Preconditions.checkArgument(attempts.put(attempt.getID(), attempt) == null, attempt.getID() + " already existed");
            break;
    }
    // TODO: Recovery
    /*
    // Update nextATtemptNumber
    if (taskAttemptsFromPreviousGeneration.isEmpty()) {
      ++nextAttemptNumber;
    } else {
      // There are still some TaskAttempts from previous generation, use them
      nextAttemptNumber =
          taskAttemptsFromPreviousGeneration.remove(0).getAttemptId().getId();
    }
    */
    this.taskAttemptStatus.put(attempt.getID().getId(), false);
    // schedule the nextAttemptNumber
    // send event to DAG to assign priority and schedule the attempt with global
    // picture in mind
    eventHandler.handle(new DAGEventSchedulerUpdate(DAGEventSchedulerUpdate.UpdateType.TA_SCHEDULE, attempt));
}
Also used : TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) DAGEventSchedulerUpdate(org.apache.tez.dag.app.dag.event.DAGEventSchedulerUpdate) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with TaskAttempt

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

the class TaskImpl method getLaunchTime.

// this is always called in read/write lock
private long getLaunchTime() {
    long taskLaunchTime = 0;
    boolean launchTimeSet = false;
    for (TaskAttempt at : attempts.values()) {
        // select the least launch time of all attempts
        long attemptLaunchTime = at.getLaunchTime();
        if (attemptLaunchTime != 0 && !launchTimeSet) {
            // For the first non-zero launch time
            launchTimeSet = true;
            taskLaunchTime = attemptLaunchTime;
        } else if (attemptLaunchTime != 0 && taskLaunchTime > attemptLaunchTime) {
            taskLaunchTime = attemptLaunchTime;
        }
    }
    if (!launchTimeSet) {
        return this.scheduledTime;
    }
    return taskLaunchTime;
}
Also used : 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