assertEquals("Trackers not reserved for the job : maps",
2, job.getNumReservedTaskTrackersForMaps());
assertEquals("Trackers not reserved for the job : reduces",
2, job.getNumReservedTaskTrackersForReduces());
ClusterMetrics metrics = jobTracker.getClusterMetrics();
assertEquals("reserved map slots do not match",
4, metrics.getReservedMapSlots());
assertEquals("reserved reduce slots do not match",
4, metrics.getReservedReduceSlots());
/*
* FakeJobInProgress.findMapTask does not handle
* task failures. So working around it by failing
* reduce and blacklisting tracker.
* Then finish the map task later.
*/
TaskAttemptID mTid = job.findMapTask(trackers[0]);
TaskAttemptID rTid = job.findReduceTask(trackers[0]);
//Task should blacklist the tasktracker.
job.failTask(rTid);
assertEquals("Tracker 0 not blacklisted for the job", 1,
job.getBlackListedTrackers().size());
assertEquals("Extra Trackers reserved for the job : maps",
1, job.getNumReservedTaskTrackersForMaps());
assertEquals("Extra Trackers reserved for the job : reduces",
1, job.getNumReservedTaskTrackersForReduces());
metrics = jobTracker.getClusterMetrics();
assertEquals("reserved map slots do not match",
2, metrics.getReservedMapSlots());
assertEquals("reserved reduce slots do not match",
2, metrics.getReservedReduceSlots());
//Finish the map task on the tracker 1. Finishing it here to work
//around bug in the FakeJobInProgress object
job.finishTask(mTid);
mTid = job.findMapTask(trackers[1]);
rTid = job.findReduceTask(trackers[1]);
job.finishTask(mTid);
job.finishTask(rTid);
rTid = job.findReduceTask(trackers[1]);
job.finishTask(rTid);
assertEquals("Job didnt complete successfully complete", job.getStatus()
.getRunState(), JobStatus.SUCCEEDED);
assertEquals("Trackers not unreserved for the job : maps",
0, job.getNumReservedTaskTrackersForMaps());
assertEquals("Trackers not unreserved for the job : reduces",
0, job.getNumReservedTaskTrackersForReduces());
metrics = jobTracker.getClusterMetrics();
assertEquals("reserved map slots do not match",
0, metrics.getReservedMapSlots());
assertEquals("reserved reduce slots do not match",
0, metrics.getReservedReduceSlots());
}