|
@@ -900,6 +900,117 @@ public class TestRecovery {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Test(timeout=30000)
|
|
|
+ public void testRecoveryWithoutShuffleSecret() throws Exception {
|
|
|
+
|
|
|
+ int runCount = 0;
|
|
|
+ MRApp app = new MRAppNoShuffleSecret(2, 1, false,
|
|
|
+ this.getClass().getName(), true, ++runCount);
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ conf.setBoolean("mapred.mapper.new-api", true);
|
|
|
+ conf.setBoolean("mapred.reducer.new-api", true);
|
|
|
+ conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
|
|
|
+ conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
|
|
+ Job job = app.submit(conf);
|
|
|
+ app.waitForState(job, JobState.RUNNING);
|
|
|
+ //all maps would be running
|
|
|
+ Assert.assertEquals("No of tasks not correct",
|
|
|
+ 3, job.getTasks().size());
|
|
|
+ Iterator<Task> it = job.getTasks().values().iterator();
|
|
|
+ Task mapTask1 = it.next();
|
|
|
+ Task mapTask2 = it.next();
|
|
|
+ Task reduceTask = it.next();
|
|
|
+
|
|
|
+ // all maps must be running
|
|
|
+ app.waitForState(mapTask1, TaskState.RUNNING);
|
|
|
+ app.waitForState(mapTask2, TaskState.RUNNING);
|
|
|
+
|
|
|
+ TaskAttempt task1Attempt = mapTask1.getAttempts().values().iterator().next();
|
|
|
+ TaskAttempt task2Attempt = mapTask2.getAttempts().values().iterator().next();
|
|
|
+
|
|
|
+ //before sending the TA_DONE, event make sure attempt has come to
|
|
|
+ //RUNNING state
|
|
|
+ app.waitForState(task1Attempt, TaskAttemptState.RUNNING);
|
|
|
+ app.waitForState(task2Attempt, TaskAttemptState.RUNNING);
|
|
|
+
|
|
|
+ // reduces must be in NEW state
|
|
|
+ Assert.assertEquals("Reduce Task state not correct",
|
|
|
+ TaskState.RUNNING, reduceTask.getReport().getTaskState());
|
|
|
+
|
|
|
+ //send the done signal to the 1st map attempt
|
|
|
+ app.getContext().getEventHandler().handle(
|
|
|
+ new TaskAttemptEvent(
|
|
|
+ task1Attempt.getID(),
|
|
|
+ TaskAttemptEventType.TA_DONE));
|
|
|
+
|
|
|
+ //wait for first map task to complete
|
|
|
+ app.waitForState(mapTask1, TaskState.SUCCEEDED);
|
|
|
+
|
|
|
+ //stop the app
|
|
|
+ app.stop();
|
|
|
+
|
|
|
+ //in recovery the 1st map should NOT be recovered from previous run
|
|
|
+ //since the shuffle secret was not provided with the job credentials
|
|
|
+ //and had to be rolled per app attempt
|
|
|
+ app = new MRAppNoShuffleSecret(2, 1, false,
|
|
|
+ this.getClass().getName(), false, ++runCount);
|
|
|
+ conf = new Configuration();
|
|
|
+ conf.setBoolean(MRJobConfig.MR_AM_JOB_RECOVERY_ENABLE, true);
|
|
|
+ conf.setBoolean("mapred.mapper.new-api", true);
|
|
|
+ conf.setBoolean("mapred.reducer.new-api", true);
|
|
|
+ conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
|
|
+ conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
|
|
|
+ job = app.submit(conf);
|
|
|
+ app.waitForState(job, JobState.RUNNING);
|
|
|
+ //all maps would be running
|
|
|
+ Assert.assertEquals("No of tasks not correct",
|
|
|
+ 3, job.getTasks().size());
|
|
|
+ it = job.getTasks().values().iterator();
|
|
|
+ mapTask1 = it.next();
|
|
|
+ mapTask2 = it.next();
|
|
|
+ reduceTask = it.next();
|
|
|
+
|
|
|
+ app.waitForState(mapTask1, TaskState.RUNNING);
|
|
|
+ app.waitForState(mapTask2, TaskState.RUNNING);
|
|
|
+
|
|
|
+ task2Attempt = mapTask2.getAttempts().values().iterator().next();
|
|
|
+ //before sending the TA_DONE, event make sure attempt has come to
|
|
|
+ //RUNNING state
|
|
|
+ app.waitForState(task2Attempt, TaskAttemptState.RUNNING);
|
|
|
+
|
|
|
+ //send the done signal to the 2nd map task
|
|
|
+ app.getContext().getEventHandler().handle(
|
|
|
+ new TaskAttemptEvent(
|
|
|
+ mapTask2.getAttempts().values().iterator().next().getID(),
|
|
|
+ TaskAttemptEventType.TA_DONE));
|
|
|
+
|
|
|
+ //wait to get it completed
|
|
|
+ app.waitForState(mapTask2, TaskState.SUCCEEDED);
|
|
|
+
|
|
|
+ //verify first map task is still running
|
|
|
+ app.waitForState(mapTask1, TaskState.RUNNING);
|
|
|
+
|
|
|
+ //send the done signal to the 2nd map task
|
|
|
+ app.getContext().getEventHandler().handle(
|
|
|
+ new TaskAttemptEvent(
|
|
|
+ mapTask1.getAttempts().values().iterator().next().getID(),
|
|
|
+ TaskAttemptEventType.TA_DONE));
|
|
|
+
|
|
|
+ //wait to get it completed
|
|
|
+ app.waitForState(mapTask1, TaskState.SUCCEEDED);
|
|
|
+
|
|
|
+ //wait for reduce to be running before sending done
|
|
|
+ app.waitForState(reduceTask, TaskState.RUNNING);
|
|
|
+ //send the done signal to the reduce
|
|
|
+ app.getContext().getEventHandler().handle(
|
|
|
+ new TaskAttemptEvent(
|
|
|
+ reduceTask.getAttempts().values().iterator().next().getID(),
|
|
|
+ TaskAttemptEventType.TA_DONE));
|
|
|
+
|
|
|
+ app.waitForState(job, JobState.SUCCEEDED);
|
|
|
+ app.verifyCompleted();
|
|
|
+ }
|
|
|
+
|
|
|
private void writeBadOutput(TaskAttempt attempt, Configuration conf)
|
|
|
throws Exception {
|
|
|
TaskAttemptContext tContext = new TaskAttemptContextImpl(conf,
|
|
@@ -1019,6 +1130,18 @@ public class TestRecovery {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ static class MRAppNoShuffleSecret extends MRAppWithHistory {
|
|
|
+ public MRAppNoShuffleSecret(int maps, int reduces, boolean autoComplete,
|
|
|
+ String testName, boolean cleanOnStart, int startCount) {
|
|
|
+ super(maps, reduces, autoComplete, testName, cleanOnStart, startCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void downloadTokensAndSetupUGI(Configuration conf) {
|
|
|
+ // do NOT put a shuffle secret in the job credentials
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] arg) throws Exception {
|
|
|
TestRecovery test = new TestRecovery();
|
|
|
test.testCrashed();
|