Program: 4656
Project: 4656
Buggy source:
private void reportMapredStats(Counters jobCounters) throws IOException, InterruptedException {
  JobStatus jobStatus=jobConf.getStatus();
  float mapProgress=jobStatus.getMapProgress();
  int runningMappers=0;
  int runningReducers=0;
  for (  TaskReport tr : jobConf.getTaskReports(TaskType.MAP)) {
    reportMapTaskMetrics(tr);
    runningMappers+=tr.getRunningTaskAttemptIds().size();
  }
  for (  TaskReport tr : jobConf.getTaskReports(TaskType.REDUCE)) {
    reportReduceTaskMetrics(tr);
    runningReducers+=tr.getRunningTaskAttemptIds().size();
  }
  int memoryPerMapper=jobConf.getConfiguration().getInt(Job.MAP_MEMORY_MB,Job.DEFAULT_MAP_MEMORY_MB);
  int memoryPerReducer=jobConf.getConfiguration().getInt(Job.REDUCE_MEMORY_MB,Job.DEFAULT_REDUCE_MEMORY_MB);
  long mapInputRecords=getTaskCounter(jobCounters,TaskCounter.MAP_INPUT_RECORDS);
  long mapOutputRecords=getTaskCounter(jobCounters,TaskCounter.MAP_OUTPUT_RECORDS);
  long mapOutputBytes=getTaskCounter(jobCounters,TaskCounter.MAP_OUTPUT_BYTES);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_COMPLETION,(long)(mapProgress * 100));
  mapperMetrics.gauge(MapReduceMetrics.METRIC_INPUT_RECORDS,mapInputRecords);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_OUTPUT_RECORDS,mapOutputRecords);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_BYTES,mapOutputBytes);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_USED_CONTAINERS,runningMappers);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_USED_MEMORY,runningMappers * memoryPerMapper);
  LOG.trace("String_Node_Str",(int)(mapProgress * 100),runningMappers,runningMappers * memoryPerMapper);
  float reduceProgress=jobStatus.getReduceProgress();
  long reduceInputRecords=getTaskCounter(jobCounters,TaskCounter.REDUCE_INPUT_RECORDS);
  long reduceOutputRecords=getTaskCounter(jobCounters,TaskCounter.REDUCE_OUTPUT_RECORDS);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_COMPLETION,(long)(reduceProgress * 100));
  reducerMetrics.gauge(MapReduceMetrics.METRIC_INPUT_RECORDS,reduceInputRecords);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_OUTPUT_RECORDS,reduceOutputRecords);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_USED_CONTAINERS,runningReducers);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_USED_MEMORY,runningReducers * memoryPerReducer);
  LOG.trace("String_Node_Str",(int)(reduceProgress * 100),runningReducers,runningReducers * memoryPerReducer);
}

Fixed version (ground truth):
private void reportMapredStats(Counters jobCounters) throws IOException, InterruptedException {
  JobStatus jobStatus=jobConf.getStatus();
  float mapProgress=jobStatus.getMapProgress();
  int runningMappers=0;
  int runningReducers=0;
  for (  TaskReport tr : jobConf.getTaskReports(TaskType.MAP)) {
    runningMappers+=tr.getRunningTaskAttemptIds().size();
  }
  for (  TaskReport tr : jobConf.getTaskReports(TaskType.REDUCE)) {
    runningReducers+=tr.getRunningTaskAttemptIds().size();
  }
  int memoryPerMapper=jobConf.getConfiguration().getInt(Job.MAP_MEMORY_MB,Job.DEFAULT_MAP_MEMORY_MB);
  int memoryPerReducer=jobConf.getConfiguration().getInt(Job.REDUCE_MEMORY_MB,Job.DEFAULT_REDUCE_MEMORY_MB);
  long mapInputRecords=getTaskCounter(jobCounters,TaskCounter.MAP_INPUT_RECORDS);
  long mapOutputRecords=getTaskCounter(jobCounters,TaskCounter.MAP_OUTPUT_RECORDS);
  long mapOutputBytes=getTaskCounter(jobCounters,TaskCounter.MAP_OUTPUT_BYTES);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_COMPLETION,(long)(mapProgress * 100));
  mapperMetrics.gauge(MapReduceMetrics.METRIC_INPUT_RECORDS,mapInputRecords);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_OUTPUT_RECORDS,mapOutputRecords);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_BYTES,mapOutputBytes);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_USED_CONTAINERS,runningMappers);
  mapperMetrics.gauge(MapReduceMetrics.METRIC_USED_MEMORY,runningMappers * memoryPerMapper);
  LOG.trace("String_Node_Str",(int)(mapProgress * 100),runningMappers,runningMappers * memoryPerMapper);
  float reduceProgress=jobStatus.getReduceProgress();
  long reduceInputRecords=getTaskCounter(jobCounters,TaskCounter.REDUCE_INPUT_RECORDS);
  long reduceOutputRecords=getTaskCounter(jobCounters,TaskCounter.REDUCE_OUTPUT_RECORDS);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_COMPLETION,(long)(reduceProgress * 100));
  reducerMetrics.gauge(MapReduceMetrics.METRIC_INPUT_RECORDS,reduceInputRecords);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_OUTPUT_RECORDS,reduceOutputRecords);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_USED_CONTAINERS,runningReducers);
  reducerMetrics.gauge(MapReduceMetrics.METRIC_USED_MEMORY,runningReducers * memoryPerReducer);
  LOG.trace("String_Node_Str",(int)(reduceProgress * 100),runningReducers,runningReducers * memoryPerReducer);
}