MAPREDUCE-4784. TestRecovery occasionally fails. Contributed by Haibo Chen
(cherry picked from commit af508605a9
)
Conflicts:
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestRecovery.java
This commit is contained in:
parent
320be1b3c6
commit
f70f522e80
|
@ -35,6 +35,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -180,7 +181,10 @@ public class TestRecovery {
|
||||||
Iterator<TaskAttempt> itr = mapTask1.getAttempts().values().iterator();
|
Iterator<TaskAttempt> itr = mapTask1.getAttempts().values().iterator();
|
||||||
itr.next();
|
itr.next();
|
||||||
TaskAttempt task1Attempt2 = itr.next();
|
TaskAttempt task1Attempt2 = itr.next();
|
||||||
|
|
||||||
|
// wait for the second task attempt to be assigned.
|
||||||
|
waitForContainerAssignment(task1Attempt2);
|
||||||
|
|
||||||
// This attempt will automatically fail because of the way ContainerLauncher
|
// This attempt will automatically fail because of the way ContainerLauncher
|
||||||
// is setup
|
// is setup
|
||||||
// This attempt 'disappears' from JobHistory and so causes MAPREDUCE-3846
|
// This attempt 'disappears' from JobHistory and so causes MAPREDUCE-3846
|
||||||
|
@ -317,6 +321,21 @@ public class TestRecovery {
|
||||||
// available in the failed attempt should be available here
|
// available in the failed attempt should be available here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for a task attempt to be assigned a container to.
|
||||||
|
* @param task1Attempt2 the task attempt to wait for its container assignment
|
||||||
|
* @throws TimeoutException if times out
|
||||||
|
* @throws InterruptedException if interrupted
|
||||||
|
*/
|
||||||
|
public static void waitForContainerAssignment(final TaskAttempt task1Attempt2)
|
||||||
|
throws TimeoutException, InterruptedException {
|
||||||
|
GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
||||||
|
@Override public Boolean get() {
|
||||||
|
return task1Attempt2.getAssignedContainerID() != null;
|
||||||
|
}
|
||||||
|
}, 10, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AM with 3 maps and 0 reduce. AM crashes after the first two tasks finishes
|
* AM with 3 maps and 0 reduce. AM crashes after the first two tasks finishes
|
||||||
* and recovers completely and succeeds in the second generation.
|
* and recovers completely and succeeds in the second generation.
|
||||||
|
@ -1197,14 +1216,9 @@ public class TestRecovery {
|
||||||
TaskAttempt task1Attempt1 = t1it.next();
|
TaskAttempt task1Attempt1 = t1it.next();
|
||||||
TaskAttempt task1Attempt2 = t1it.next();
|
TaskAttempt task1Attempt2 = t1it.next();
|
||||||
TaskAttempt task2Attempt = mapTask2.getAttempts().values().iterator().next();
|
TaskAttempt task2Attempt = mapTask2.getAttempts().values().iterator().next();
|
||||||
final TaskAttempt t2a = task2Attempt;
|
|
||||||
|
|
||||||
// wait for the second task attempt to be assigned.
|
// wait for the second task attempt to be assigned.
|
||||||
GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
waitForContainerAssignment(task1Attempt2);
|
||||||
@Override public Boolean get() {
|
|
||||||
return t2a.getAssignedContainerID() != null;
|
|
||||||
}
|
|
||||||
}, 10, 10000);
|
|
||||||
ContainerId t1a2contId = task1Attempt2.getAssignedContainerID();
|
ContainerId t1a2contId = task1Attempt2.getAssignedContainerID();
|
||||||
|
|
||||||
LOG.info(t1a2contId.toString());
|
LOG.info(t1a2contId.toString());
|
||||||
|
|
Loading…
Reference in New Issue