Search in sources :

Example 11 with TaskTAttemptEvent

use of org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent in project hadoop by apache.

the class TestTaskImpl method runSpeculativeTaskAttemptSucceeds.

private void runSpeculativeTaskAttemptSucceeds(TaskEventType firstAttemptFinishEvent) {
    TaskId taskId = getNewTaskID();
    scheduleTaskAttempt(taskId);
    launchTaskAttempt(getLastAttempt().getAttemptId());
    updateLastAttemptState(TaskAttemptState.RUNNING);
    // Add a speculative task attempt that succeeds
    mockTask.handle(new TaskTAttemptEvent(getLastAttempt().getAttemptId(), TaskEventType.T_ADD_SPEC_ATTEMPT));
    launchTaskAttempt(getLastAttempt().getAttemptId());
    commitTaskAttempt(getLastAttempt().getAttemptId());
    mockTask.handle(new TaskTAttemptEvent(getLastAttempt().getAttemptId(), TaskEventType.T_ATTEMPT_SUCCEEDED));
    // The task should now have succeeded
    assertTaskSucceededState();
    // Now complete the first task attempt, after the second has succeeded
    mockTask.handle(new TaskTAttemptEvent(taskAttempts.get(0).getAttemptId(), firstAttemptFinishEvent));
    // The task should still be in the succeeded state
    assertTaskSucceededState();
    // The task should contain speculative a task attempt
    assertTaskAttemptAvataar(Avataar.SPECULATIVE);
}
Also used : TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) TaskTAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent)

Example 12 with TaskTAttemptEvent

use of org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent in project hadoop by apache.

the class TestTaskImpl method testKillAttemptForSuccessfulTask.

@Test
public /**
   * Kill map attempt for succeeded map task
   * {@link TaskState#SUCCEEDED}->{@link TaskState#SCHEDULED}
   */
void testKillAttemptForSuccessfulTask() {
    LOG.info("--- START: testKillAttemptForSuccessfulTask ---");
    mockTask = createMockTask(TaskType.MAP);
    TaskId taskId = getNewTaskID();
    scheduleTaskAttempt(taskId);
    launchTaskAttempt(getLastAttempt().getAttemptId());
    commitTaskAttempt(getLastAttempt().getAttemptId());
    mockTask.handle(new TaskTAttemptEvent(getLastAttempt().getAttemptId(), TaskEventType.T_ATTEMPT_SUCCEEDED));
    assertTaskSucceededState();
    mockTask.handle(new TaskTAttemptKilledEvent(getLastAttempt().getAttemptId(), true));
    assertEquals(TaskAttemptEventType.TA_RESCHEDULE, taskAttemptEventHandler.lastTaskAttemptEvent.getType());
    assertTaskScheduledState();
}
Also used : TaskTAttemptKilledEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptKilledEvent) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) TaskTAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent) Test(org.junit.Test)

Example 13 with TaskTAttemptEvent

use of org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent in project hadoop by apache.

the class TestTaskImpl method failRunningTaskAttempt.

private void failRunningTaskAttempt(TaskAttemptId attemptId) {
    mockTask.handle(new TaskTAttemptEvent(attemptId, TaskEventType.T_ATTEMPT_FAILED));
    assertTaskRunningState();
}
Also used : TaskTAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent)

Example 14 with TaskTAttemptEvent

use of org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent in project hadoop by apache.

the class TestTaskImpl method testSpeculativeMapFailedFetchFailure.

@Test
public void testSpeculativeMapFailedFetchFailure() {
    // Setup a scenario where speculative task wins, first attempt succeeds
    mockTask = createMockTask(TaskType.MAP);
    runSpeculativeTaskAttemptSucceeds(TaskEventType.T_ATTEMPT_FAILED);
    assertEquals(2, taskAttempts.size());
    // speculative attempt retroactively fails from fetch failures
    mockTask.handle(new TaskTAttemptEvent(taskAttempts.get(1).getAttemptId(), TaskEventType.T_ATTEMPT_FAILED));
    assertTaskScheduledState();
    assertEquals(3, taskAttempts.size());
}
Also used : TaskTAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent) Test(org.junit.Test)

Example 15 with TaskTAttemptEvent

use of org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent in project hadoop by apache.

the class TestTaskImpl method testCountersWithSpeculation.

@Test
public void testCountersWithSpeculation() {
    mockTask = new MockTaskImpl(jobId, partition, dispatcher.getEventHandler(), remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount, metrics, appContext, TaskType.MAP) {

        @Override
        protected int getMaxAttempts() {
            return 1;
        }
    };
    TaskId taskId = getNewTaskID();
    scheduleTaskAttempt(taskId);
    launchTaskAttempt(getLastAttempt().getAttemptId());
    updateLastAttemptState(TaskAttemptState.RUNNING);
    MockTaskAttemptImpl baseAttempt = getLastAttempt();
    // add a speculative attempt
    mockTask.handle(new TaskTAttemptEvent(getLastAttempt().getAttemptId(), TaskEventType.T_ADD_SPEC_ATTEMPT));
    launchTaskAttempt(getLastAttempt().getAttemptId());
    updateLastAttemptState(TaskAttemptState.RUNNING);
    MockTaskAttemptImpl specAttempt = getLastAttempt();
    assertEquals(2, taskAttempts.size());
    Counters specAttemptCounters = new Counters();
    Counter cpuCounter = specAttemptCounters.findCounter(TaskCounter.CPU_MILLISECONDS);
    cpuCounter.setValue(1000);
    specAttempt.setCounters(specAttemptCounters);
    // have the spec attempt succeed but second attempt at 1.0 progress as well
    commitTaskAttempt(specAttempt.getAttemptId());
    specAttempt.setProgress(1.0f);
    specAttempt.setState(TaskAttemptState.SUCCEEDED);
    mockTask.handle(new TaskTAttemptEvent(specAttempt.getAttemptId(), TaskEventType.T_ATTEMPT_SUCCEEDED));
    assertEquals(TaskState.SUCCEEDED, mockTask.getState());
    baseAttempt.setProgress(1.0f);
    Counters taskCounters = mockTask.getCounters();
    assertEquals("wrong counters for task", specAttemptCounters, taskCounters);
}
Also used : TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) Counter(org.apache.hadoop.mapreduce.Counter) TaskCounter(org.apache.hadoop.mapreduce.TaskCounter) TaskTAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent) Counters(org.apache.hadoop.mapreduce.Counters) Test(org.junit.Test)

Aggregations

TaskTAttemptEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent)16 Test (org.junit.Test)11 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)7 TaskEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskEvent)4 Configuration (org.apache.hadoop.conf.Configuration)2 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)2 TaskAttempt (org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)2 TaskTAttemptKilledEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptKilledEvent)2 Counter (org.apache.hadoop.mapreduce.Counter)1 Counters (org.apache.hadoop.mapreduce.Counters)1 OutputCommitter (org.apache.hadoop.mapreduce.OutputCommitter)1 TaskCounter (org.apache.hadoop.mapreduce.TaskCounter)1 JobHistoryEvent (org.apache.hadoop.mapreduce.jobhistory.JobHistoryEvent)1 TaskAttemptUnsuccessfulCompletionEvent (org.apache.hadoop.mapreduce.jobhistory.TaskAttemptUnsuccessfulCompletionEvent)1 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)1 TaskAttemptId (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId)1 CommitterEventHandler (org.apache.hadoop.mapreduce.v2.app.commit.CommitterEventHandler)1 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)1 JobEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent)1 JobTaskEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobTaskEvent)1