code: private List<SimulatorEvent> handleHeartbeatResponse(HeartbeatResponse response,
                                                long now) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Handling heartbeat response " + response);
      }
  
      List<SimulatorEvent> events = new ArrayList<SimulatorEvent>();  
      TaskTrackerAction[] actions = response.getActions();
      for (TaskTrackerAction action : actions) {
        List<SimulatorEvent> actionEvents;
        if (action instanceof SimulatorLaunchTaskAction) {
          actionEvents = handleSimulatorLaunchTaskAction(
              (SimulatorLaunchTaskAction)action, now);            
        } else if(action instanceof KillTaskAction) {
          actionEvents = handleKillTaskAction((KillTaskAction)action, now);
        } else if(action instanceof AllMapsCompletedTaskAction) {
          // our extra task action for notifying the reducers
          actionEvents = handleAllMapsCompletedTaskAction(
              (AllMapsCompletedTaskAction)action, now);
        } else {
          // Should never get here.
          // CommitTaskAction is not implemented in the simulator
          // LaunchTaskAction has to be SimulatorLaunchTaskAction
          throw new UnsupportedOperationException("Unimplemented TaskAction: "
              + action);
        }
        events.addAll(actionEvents);
      }
      return events;
    }
docs: Handles the HeartbeatResponse received from the job tracker upon
  heartbeat(). Dispatches to handle*Action() methods.
  
  @param response HeartbeatResponse received from the job tracker
  @param now current simulation time
  @return list of new events generated in response to the task actions