* @throws Exception
*/
private void singleQMultipleJobs1()
throws Exception {
ControlledMapReduceJobRunner jobRunner1 =
ControlledMapReduceJobRunner.getControlledMapReduceJobRunner(
getJobConf(), 16, 0);
ControlledMapReduceJobRunner jobRunner2 =
ControlledMapReduceJobRunner.getControlledMapReduceJobRunner(
getJobConf(), 12, 0);
jobRunner1.start();
ControlledMapReduceJob controlledJob1 = jobRunner1.getJob();
JobID jobID1 = jobRunner1.getJobID();
JobInProgress jip1 = getJobTracker().getJob(jobID1);
ControlledMapReduceJob.waitTillNTasksStartRunning(jip1, true, 12);
// Confirm that the rest of the tasks are not running and waiting for slots
// to be freed.
waitTillAllSlotsAreOccupied(true);
// Now start the second job.
jobRunner2.start();
JobID jobID2 = jobRunner2.getJobID();
ControlledMapReduceJob controlledJob2 = jobRunner2.getJob();
JobInProgress jip2 = getJobTracker().getJob(jobID2);
LOG.info("Trying to finish 2 map");
controlledJob1.finishNTasks(true, 2);
ControlledMapReduceJob.waitTillNTotalTasksFinish(jip1, true, 2);
assertTrue("Number of maps finished", jip1.finishedMaps() == 2);
ControlledMapReduceJob.waitTillNTasksStartRunning(jip1, true, 12);
waitTillAllSlotsAreOccupied(true);
LOG.info("Trying to finish 2 more maps");
controlledJob1.finishNTasks(true, 2);
ControlledMapReduceJob.waitTillNTotalTasksFinish(jip1, true, 4);
assertTrue("Number of maps finished", jip1.finishedMaps() == 4);
ControlledMapReduceJob.waitTillNTasksStartRunning(jip1, true, 12);
waitTillAllSlotsAreOccupied(true);
// All tasks of Job1 started running/finished. Now job2 should start
LOG.info("Trying to finish 2 more maps");
controlledJob1.finishNTasks(true, 2);
ControlledMapReduceJob.waitTillNTotalTasksFinish(jip1, true, 6);
assertTrue("Number of maps finished", jip1.finishedMaps() == 6);
ControlledMapReduceJob.waitTillNTasksStartRunning(jip1, true, 10);
ControlledMapReduceJob.waitTillNTasksStartRunning(jip2, true, 2);
waitTillAllSlotsAreOccupied(true);
ControlledMapReduceJob.assertNumTasksRunning(jip1, true, 10);
ControlledMapReduceJob.assertNumTasksRunning(jip2, true, 2);
LOG.info("Trying to finish 10 more maps and hence job1");
controlledJob1.finishNTasks(true, 10);
ControlledMapReduceJob.waitTillNTotalTasksFinish(jip1, true, 16);
assertTrue("Number of maps finished", jip1.finishedMaps() == 16);
ControlledMapReduceJob.waitTillNTasksStartRunning(jip2, true, 12);
controlledJob1.finishJob();
waitTillAllSlotsAreOccupied(true);
ControlledMapReduceJob.assertNumTasksRunning(jip1, true, 0);
ControlledMapReduceJob.assertNumTasksRunning(jip2, true, 12);
// Finish job2 also
controlledJob2.finishJob();
ControlledMapReduceJob.waitTillNTotalTasksFinish(jip2, true, 12);
ControlledMapReduceJob.assertNumTasksRunning(jip2, true, 0);
jobRunner1.join();
jobRunner2.join();
}