code: private List<SimulatorEvent> processHeartbeatEvent(HeartbeatEvent event) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Processing heartbeat event " + event);
      }
      
      long now = event.getTimeStamp();
      
      // Create the TaskTrackerStatus to report
      progressTaskStatuses(now);
      List<TaskStatus> taskStatuses = collectAndCloneTaskStatuses();
      boolean askForNewTask = (usedMapSlots < maxMapSlots ||
                               usedReduceSlots < maxReduceSlots);
  
      // 0 means failures == 0 here. Undocumented in TaskTracker, but does not 
      // seem to be used at all in org.apache.hadoop.mapred .
      TaskTrackerStatus taskTrackerStatus = 
        new SimulatorTaskTrackerStatus(taskTrackerName, hostName, httpPort, 
            taskStatuses, 0, 
            maxMapSlots, maxReduceSlots, now);
      
      // This is the right, and only, place to release bookkeping memory held 
      // by completed tasks: after collectAndCloneTaskStatuses() and before 
      // heartbeat().
      // The status of TIPs to be purged is already cloned & copied to
      // taskStatuses for reporting
      // We shouldn't run the gc after heartbeat() since  KillTaskAction might 
      // produce new completed tasks that we have not yet reported back and 
      // don't want to purge immediately.
      garbageCollectCompletedTasks();
      
      // Transmit the heartbeat 
      HeartbeatResponse response = null;
      try {
        response = 
          jobTracker.heartbeat(taskTrackerStatus, false, firstHeartbeat, 
                               askForNewTask, heartbeatResponseId);
      } catch (IOException ioe) {
        throw new IllegalStateException("Internal error", ioe);
      }
      firstHeartbeat = false;
  
      // The heartbeat got through successfully!
      heartbeatResponseId = response.getResponseId();
  
      // Process the heartbeat response
      List<SimulatorEvent> events = handleHeartbeatResponse(response, now);
      
      // Next heartbeat
      events.add(new HeartbeatEvent(this, now + response.getHeartbeatInterval()));
  
      return events;
    }
docs: Transmits a heartbeat event to the jobtracker and processes the response.
  
  @param event HeartbeatEvent to process
  @return list of new events generated in response