|
@@ -141,7 +141,6 @@ public class TestTaskImpl {
|
|
|
|
|
|
private float progress = 0;
|
|
|
private TaskAttemptState state = TaskAttemptState.NEW;
|
|
|
- private TaskAttemptId attemptId;
|
|
|
private TaskType taskType;
|
|
|
|
|
|
public MockTaskAttemptImpl(TaskId taskId, int id, EventHandler eventHandler,
|
|
@@ -152,14 +151,11 @@ public class TestTaskImpl {
|
|
|
AppContext appContext, TaskType taskType) {
|
|
|
super(taskId, id, eventHandler, taskAttemptListener, jobFile, partition, conf,
|
|
|
dataLocations, committer, jobToken, credentials, clock, appContext);
|
|
|
- attemptId = Records.newRecord(TaskAttemptId.class);
|
|
|
- attemptId.setId(id);
|
|
|
- attemptId.setTaskId(taskId);
|
|
|
this.taskType = taskType;
|
|
|
}
|
|
|
|
|
|
public TaskAttemptId getAttemptId() {
|
|
|
- return attemptId;
|
|
|
+ return getID();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -561,4 +557,49 @@ public class TestTaskImpl {
|
|
|
mockTask = createMockTask(TaskType.REDUCE);
|
|
|
runSpeculativeTaskAttemptSucceeds(TaskEventType.T_ATTEMPT_COMMIT_PENDING);
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSpeculativeMapFetchFailure() {
|
|
|
+ // Setup a scenario where speculative task wins, first attempt killed
|
|
|
+ mockTask = createMockTask(TaskType.MAP);
|
|
|
+ runSpeculativeTaskAttemptSucceeds(TaskEventType.T_ATTEMPT_KILLED);
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSpeculativeMapMultipleSucceedFetchFailure() {
|
|
|
+ // Setup a scenario where speculative task wins, first attempt succeeds
|
|
|
+ mockTask = createMockTask(TaskType.MAP);
|
|
|
+ runSpeculativeTaskAttemptSucceeds(TaskEventType.T_ATTEMPT_SUCCEEDED);
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ @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());
|
|
|
+ }
|
|
|
}
|