Search in sources :

Example 1 with TaskEvent

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

the class TaskImpl method handle.

@Override
public void handle(TaskEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing " + event.getTaskID() + " of type " + event.getType());
    }
    try {
        writeLock.lock();
        TaskStateInternal oldState = getInternalState();
        try {
            stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state for " + this.taskId, e);
            internalError(event.getType());
        }
        if (oldState != getInternalState()) {
            LOG.info(taskId + " Task Transitioned from " + oldState + " to " + getInternalState());
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : TaskStateInternal(org.apache.hadoop.mapreduce.v2.app.job.TaskStateInternal) InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException)

Example 2 with TaskEvent

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

the class DefaultSpeculator method addSpeculativeAttempt.

//Add attempt to a given Task.
protected void addSpeculativeAttempt(TaskId taskID) {
    LOG.info("DefaultSpeculator.addSpeculativeAttempt -- we are speculating " + taskID);
    eventHandler.handle(new TaskEvent(taskID, TaskEventType.T_ADD_SPEC_ATTEMPT));
    mayHaveSpeculated.add(taskID);
}
Also used : TaskEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskEvent)

Example 3 with TaskEvent

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

the class TestTaskImpl method scheduleTaskAttempt.

private void scheduleTaskAttempt(TaskId taskId) {
    mockTask.handle(new TaskEvent(taskId, TaskEventType.T_SCHEDULE));
    assertTaskScheduledState();
    assertTaskAttemptAvataar(Avataar.VIRGIN);
}
Also used : TaskEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskEvent)

Example 4 with TaskEvent

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

the class TestTaskImpl method testKillSuccessfulTask.

@Test
public void testKillSuccessfulTask() {
    LOG.info("--- START: testKillSuccesfulTask ---");
    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 TaskEvent(taskId, TaskEventType.T_KILL));
    assertTaskSucceededState();
}
Also used : TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) TaskEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskEvent) TaskTAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent) Test(org.junit.Test)

Example 5 with TaskEvent

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

the class TestTaskAttempt method containerKillBeforeAssignment.

private void containerKillBeforeAssignment(boolean scheduleAttempt) throws Exception {
    MockEventHandler eventHandler = new MockEventHandler();
    ApplicationId appId = ApplicationId.newInstance(1, 2);
    JobId jobId = MRBuilderUtils.newJobId(appId, 1);
    TaskId taskId = MRBuilderUtils.newTaskId(jobId, 1, TaskType.MAP);
    TaskAttemptImpl taImpl = new MapTaskAttemptImpl(taskId, 1, eventHandler, mock(Path.class), 1, mock(TaskSplitMetaInfo.class), new JobConf(), mock(TaskAttemptListener.class), mock(Token.class), new Credentials(), SystemClock.getInstance(), mock(AppContext.class));
    if (scheduleAttempt) {
        taImpl.handle(new TaskAttemptEvent(taImpl.getID(), TaskAttemptEventType.TA_SCHEDULE));
    }
    taImpl.handle(new TaskAttemptKillEvent(taImpl.getID(), "", true));
    assertEquals("Task attempt is not in KILLED state", taImpl.getState(), TaskAttemptState.KILLED);
    assertEquals("Task attempt's internal state is not KILLED", taImpl.getInternalState(), TaskAttemptStateInternal.KILLED);
    assertFalse("InternalError occurred", eventHandler.internalError);
    TaskEvent event = eventHandler.lastTaskEvent;
    assertEquals(TaskEventType.T_ATTEMPT_KILLED, event.getType());
    // In NEW state, new map attempt should not be rescheduled.
    assertFalse(((TaskTAttemptKilledEvent) event).getRescheduleAttempt());
}
Also used : Path(org.apache.hadoop.fs.Path) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) TaskAttemptListener(org.apache.hadoop.mapreduce.v2.app.TaskAttemptListener) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MapTaskAttemptImpl(org.apache.hadoop.mapred.MapTaskAttemptImpl) Token(org.apache.hadoop.security.token.Token) TaskAttemptEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent) TaskEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskEvent) TaskSplitMetaInfo(org.apache.hadoop.mapreduce.split.JobSplit.TaskSplitMetaInfo) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) MapTaskAttemptImpl(org.apache.hadoop.mapred.MapTaskAttemptImpl) TaskAttemptKillEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptKillEvent) JobConf(org.apache.hadoop.mapred.JobConf) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) Credentials(org.apache.hadoop.security.Credentials)

Aggregations

TaskEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskEvent)12 Test (org.junit.Test)8 Configuration (org.apache.hadoop.conf.Configuration)5 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)5 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)4 TaskAttempt (org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)4 TaskAttemptEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent)4 TaskTAttemptEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskTAttemptEvent)4 MapTaskAttemptImpl (org.apache.hadoop.mapred.MapTaskAttemptImpl)2 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)2 TaskAttemptId (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId)2 JobTaskEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobTaskEvent)2 TaskAttemptKillEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptKillEvent)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Path (org.apache.hadoop.fs.Path)1 JobConf (org.apache.hadoop.mapred.JobConf)1 OutputCommitter (org.apache.hadoop.mapreduce.OutputCommitter)1 TaskSplitMetaInfo (org.apache.hadoop.mapreduce.split.JobSplit.TaskSplitMetaInfo)1 AMInfo (org.apache.hadoop.mapreduce.v2.api.records.AMInfo)1