protected TaskStateInternal getDefaultState(TaskImpl task) { return task.getInternalState(); } }
protected TaskStateInternal getDefaultState(TaskImpl task) { return task.getInternalState(); } }
protected TaskStateInternal getDefaultState(TaskImpl task) { return task.getInternalState(); } }
@Override public boolean isFinished() { readLock.lock(); try { // TODO: Use stateMachine level method? return (getInternalState() == TaskStateInternal.SUCCEEDED || getInternalState() == TaskStateInternal.FAILED || getInternalState() == TaskStateInternal.KILLED); } finally { readLock.unlock(); } }
@Override public boolean isFinished() { readLock.lock(); try { // TODO: Use stateMachine level method? return (getInternalState() == TaskStateInternal.SUCCEEDED || getInternalState() == TaskStateInternal.FAILED || getInternalState() == TaskStateInternal.KILLED); } finally { readLock.unlock(); } }
@Override public boolean isFinished() { readLock.lock(); try { // TODO: Use stateMachine level method? return (getInternalState() == TaskStateInternal.SUCCEEDED || getInternalState() == TaskStateInternal.FAILED || getInternalState() == TaskStateInternal.KILLED); } finally { readLock.unlock(); } }
@Override public TaskState getState() { readLock.lock(); try { return getExternalState(getInternalState()); } finally { readLock.unlock(); } }
private TaskStateInternal finished(TaskStateInternal finalState) { if (getInternalState() == TaskStateInternal.RUNNING) { metrics.endRunningTask(this); } return finalState; }
private TaskStateInternal finished(TaskStateInternal finalState) { if (getInternalState() == TaskStateInternal.RUNNING) { metrics.endRunningTask(this); } return finalState; }
@Override public TaskState getState() { readLock.lock(); try { return getExternalState(getInternalState()); } finally { readLock.unlock(); } }
@Override public TaskState getState() { readLock.lock(); try { return getExternalState(getInternalState()); } finally { readLock.unlock(); } }
private TaskStateInternal finished(TaskStateInternal finalState) { if (getInternalState() == TaskStateInternal.RUNNING) { metrics.endRunningTask(this); } return finalState; }
@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(); } }
@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(); } }
@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 (InvalidStateTransitonException 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(); } }
/** * {@link TaskState#KILL_WAIT} */ private void assertTaskKillWaitState() { assertEquals(TaskStateInternal.KILL_WAIT, mockTask.getInternalState()); }
@Override public TaskStateInternal transition(TaskImpl task, TaskEvent event) { TaskAttemptId taskAttemptId = ((TaskTAttemptEvent) event).getTaskAttemptID(); task.handleTaskAttemptCompletion(taskAttemptId, taCompletionEventStatus); task.finishedAttempts.add(taskAttemptId); // check whether all attempts are finished if (task.finishedAttempts.size() == task.attempts.size()) { if (task.historyTaskStartGenerated) { TaskFailedEvent taskFailedEvent = createTaskFailedEvent(task, null, finalState, null); // TODO JH verify failedAttempt null task.eventHandler.handle(new JobHistoryEvent(task.taskId.getJobId(), taskFailedEvent)); } else { LOG.debug("Not generating HistoryFinish event since start event not" + " generated for task: " + task.getID()); } task.eventHandler.handle( new JobTaskEvent(task.taskId, getExternalState(finalState))); return finalState; } return task.getInternalState(); } }
@Override public TaskStateInternal transition(TaskImpl task, TaskEvent event) { TaskAttemptId taskAttemptId = ((TaskTAttemptEvent) event).getTaskAttemptID(); task.handleTaskAttemptCompletion(taskAttemptId, taCompletionEventStatus); task.finishedAttempts.add(taskAttemptId); // check whether all attempts are finished if (task.finishedAttempts.size() == task.attempts.size()) { if (task.historyTaskStartGenerated) { TaskFailedEvent taskFailedEvent = createTaskFailedEvent(task, null, finalState, null); // TODO JH verify failedAttempt null task.eventHandler.handle(new JobHistoryEvent(task.taskId.getJobId(), taskFailedEvent)); } else { LOG.debug("Not generating HistoryFinish event since start event not" + " generated for task: " + task.getID()); } task.eventHandler.handle( new JobTaskEvent(task.taskId, getExternalState(finalState))); return finalState; } return task.getInternalState(); } }
public void waitForInternalState(TaskImpl task, TaskStateInternal finalState) throws Exception { int timeoutSecs = 0; TaskReport report = task.getReport(); TaskStateInternal iState = task.getInternalState(); while (!finalState.equals(iState) && timeoutSecs++ < 20) { System.out.println("Task Internal State is : " + iState + " Waiting for Internal state : " + finalState + " progress : " + report.getProgress()); Thread.sleep(500); report = task.getReport(); iState = task.getInternalState(); } System.out.println("Task Internal State is : " + iState); Assert.assertEquals("Task Internal state is not correct (timedout)", finalState, iState); }
@Override public TaskStateInternal transition(TaskImpl task, TaskEvent event) { TaskTAttemptEvent castEvent = (TaskTAttemptEvent) event; if (task.getInternalState() == TaskStateInternal.SUCCEEDED && !castEvent.getTaskAttemptID().equals(task.successfulAttempt)) { // don't allow a different task attempt to override a previous // succeeded state task.finishedAttempts.add(castEvent.getTaskAttemptID()); task.inProgressAttempts.remove(castEvent.getTaskAttemptID()); return TaskStateInternal.SUCCEEDED; } // a successful REDUCE task should not be overridden //TODO: consider moving it to MapTaskImpl if (!TaskType.MAP.equals(task.getType())) { LOG.error("Unexpected event for REDUCE task " + event.getType()); task.internalError(event.getType()); } // tell the job about the rescheduling task.eventHandler.handle( new JobMapTaskRescheduledEvent(task.taskId)); // super.transition is mostly coded for the case where an // UNcompleted task failed. When a COMPLETED task retroactively // fails, we have to let AttemptFailedTransition.transition // believe that there's no redundancy. unSucceed(task); // fake increase in Uncomplete attempts for super.transition task.inProgressAttempts.add(castEvent.getTaskAttemptID()); return super.transition(task, event); }