// create TaskTrackerStatus and send heartbeats
sendHeartbeats(list);
// assert ClusterMetrics
ClusterMetrics metrics = jobTracker.getClusterMetrics();
assertEquals("occupied map slots do not match", mapSlotsPerTask,
metrics.getOccupiedMapSlots());
assertEquals("occupied reduce slots do not match", reduceSlotsPerTask,
metrics.getOccupiedReduceSlots());
assertEquals("map slot capacities do not match",
mapSlotsPerTracker * trackers.length,
metrics.getMapSlotCapacity());
assertEquals("reduce slot capacities do not match",
reduceSlotsPerTracker * trackers.length,
metrics.getReduceSlotCapacity());
assertEquals("running map tasks do not match", 1,
metrics.getRunningMaps());
assertEquals("running reduce tasks do not match", 1,
metrics.getRunningReduces());
// assert the values in ClusterStatus also
ClusterStatus stat = client.getClusterStatus();
assertEquals("running map tasks do not match", 1,
stat.getMapTasks());
assertEquals("running reduce tasks do not match", 1,
stat.getReduceTasks());
assertEquals("map slot capacities do not match",
mapSlotsPerTracker * trackers.length,
stat.getMaxMapTasks());
assertEquals("reduce slot capacities do not match",
reduceSlotsPerTracker * trackers.length,
stat.getMaxReduceTasks());
// send a heartbeat finishing only a map and check
// counts are updated.
list.clear();
addMapTaskAttemptToList(list, mapSlotsPerTask, TaskStatus.State.SUCCEEDED);
addReduceTaskAttemptToList(list,
reduceSlotsPerTask, TaskStatus.State.RUNNING);
sendHeartbeats(list);
metrics = jobTracker.getClusterMetrics();
assertEquals(0, metrics.getOccupiedMapSlots());
assertEquals(reduceSlotsPerTask, metrics.getOccupiedReduceSlots());
// send a heartbeat finishing the reduce task also.
list.clear();
addReduceTaskAttemptToList(list,
reduceSlotsPerTask, TaskStatus.State.SUCCEEDED);
sendHeartbeats(list);
metrics = jobTracker.getClusterMetrics();
assertEquals(0, metrics.getOccupiedReduceSlots());
}