@@ -626,6 +626,115 @@ public void testOutputRecoveryMapsOnly() throws Exception {
626626 validateOutput ();
627627 }
628628
629+ @ Test
630+ public void testRecoveryWithOldCommiter () throws Exception {
631+ int runCount = 0 ;
632+ MRApp app = new MRAppWithHistory (1 , 2 , false , this .getClass ().getName (),
633+ true , ++runCount );
634+ Configuration conf = new Configuration ();
635+ conf .setBoolean ("mapred.mapper.new-api" , false );
636+ conf .setBoolean ("mapred.reducer.new-api" , false );
637+ conf .setBoolean (MRJobConfig .JOB_UBERTASK_ENABLE , false );
638+ conf .set (FileOutputFormat .OUTDIR , outputDir .toString ());
639+ Job job = app .submit (conf );
640+ app .waitForState (job , JobState .RUNNING );
641+ Assert .assertEquals ("No of tasks not correct" ,
642+ 3 , job .getTasks ().size ());
643+ Iterator <Task > it = job .getTasks ().values ().iterator ();
644+ Task mapTask1 = it .next ();
645+ Task reduceTask1 = it .next ();
646+
647+ // all maps must be running
648+ app .waitForState (mapTask1 , TaskState .RUNNING );
649+
650+ TaskAttempt task1Attempt1 = mapTask1 .getAttempts ().values ().iterator ()
651+ .next ();
652+
653+ //before sending the TA_DONE, event make sure attempt has come to
654+ //RUNNING state
655+ app .waitForState (task1Attempt1 , TaskAttemptState .RUNNING );
656+
657+ //send the done signal to the map
658+ app .getContext ().getEventHandler ().handle (
659+ new TaskAttemptEvent (
660+ task1Attempt1 .getID (),
661+ TaskAttemptEventType .TA_DONE ));
662+
663+ //wait for map task to complete
664+ app .waitForState (mapTask1 , TaskState .SUCCEEDED );
665+
666+ // Verify the shuffle-port
667+ Assert .assertEquals (5467 , task1Attempt1 .getShufflePort ());
668+
669+ app .waitForState (reduceTask1 , TaskState .RUNNING );
670+ TaskAttempt reduce1Attempt1 = reduceTask1 .getAttempts ().values ().iterator ().next ();
671+
672+ // write output corresponding to reduce1
673+ writeOutput (reduce1Attempt1 , conf );
674+
675+ //send the done signal to the 1st reduce
676+ app .getContext ().getEventHandler ().handle (
677+ new TaskAttemptEvent (
678+ reduce1Attempt1 .getID (),
679+ TaskAttemptEventType .TA_DONE ));
680+
681+ //wait for first reduce task to complete
682+ app .waitForState (reduceTask1 , TaskState .SUCCEEDED );
683+
684+ //stop the app before the job completes.
685+ app .stop ();
686+
687+ //rerun
688+ //in rerun the map will be recovered from previous run
689+ app = new MRAppWithHistory (1 , 2 , false , this .getClass ().getName (), false ,
690+ ++runCount );
691+ conf = new Configuration ();
692+ conf .setBoolean (MRJobConfig .MR_AM_JOB_RECOVERY_ENABLE , true );
693+ conf .setBoolean ("mapred.mapper.new-api" , false );
694+ conf .setBoolean ("mapred.reducer.new-api" , false );
695+ conf .set (FileOutputFormat .OUTDIR , outputDir .toString ());
696+ conf .setBoolean (MRJobConfig .JOB_UBERTASK_ENABLE , false );
697+ job = app .submit (conf );
698+ app .waitForState (job , JobState .RUNNING );
699+ Assert .assertEquals ("No of tasks not correct" ,
700+ 3 , job .getTasks ().size ());
701+ it = job .getTasks ().values ().iterator ();
702+ mapTask1 = it .next ();
703+ reduceTask1 = it .next ();
704+ Task reduceTask2 = it .next ();
705+
706+ // map will be recovered, no need to send done
707+ app .waitForState (mapTask1 , TaskState .SUCCEEDED );
708+
709+ // Verify the shuffle-port after recovery
710+ task1Attempt1 = mapTask1 .getAttempts ().values ().iterator ().next ();
711+ Assert .assertEquals (5467 , task1Attempt1 .getShufflePort ());
712+
713+ // first reduce will be recovered, no need to send done
714+ app .waitForState (reduceTask1 , TaskState .SUCCEEDED );
715+
716+ app .waitForState (reduceTask2 , TaskState .RUNNING );
717+
718+ TaskAttempt reduce2Attempt = reduceTask2 .getAttempts ().values ()
719+ .iterator ().next ();
720+ //before sending the TA_DONE, event make sure attempt has come to
721+ //RUNNING state
722+ app .waitForState (reduce2Attempt , TaskAttemptState .RUNNING );
723+
724+ //send the done signal to the 2nd reduce task
725+ app .getContext ().getEventHandler ().handle (
726+ new TaskAttemptEvent (
727+ reduce2Attempt .getID (),
728+ TaskAttemptEventType .TA_DONE ));
729+
730+ //wait to get it completed
731+ app .waitForState (reduceTask2 , TaskState .SUCCEEDED );
732+
733+ app .waitForState (job , JobState .SUCCEEDED );
734+ app .verifyCompleted ();
735+ validateOutput ();
736+ }
737+
629738 private void writeBadOutput (TaskAttempt attempt , Configuration conf )
630739 throws Exception {
631740 TaskAttemptContext tContext = new TaskAttemptContextImpl (conf ,
0 commit comments