Program: 7681
Project: 7681
Buggy source:
private void reportStats(BasicMapReduceContext context) throws IOException, InterruptedException {
  float mapProgress=jobConf.getStatus().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=context.getSpecification().getMapperMemoryMB();
  int memoryPerReducer=context.getSpecification().getReducerMemoryMB();
  long mapInputRecords=getTaskCounter(jobConf,TaskCounter.MAP_INPUT_RECORDS);
  long mapOutputRecords=getTaskCounter(jobConf,TaskCounter.MAP_OUTPUT_RECORDS);
  long mapOutputBytes=getTaskCounter(jobConf,TaskCounter.MAP_OUTPUT_BYTES);
  context.getSystemMapperMetrics().gauge("String_Node_Str",(int)(mapProgress * 100));
  context.getSystemMapperMetrics().gauge("String_Node_Str",(int)mapInputRecords);
  context.getSystemMapperMetrics().gauge("String_Node_Str",(int)mapOutputRecords);
  context.getSystemMapperMetrics().gauge("String_Node_Str",(int)mapOutputBytes);
  context.getSystemMapperMetrics().gauge("String_Node_Str",runningMappers);
  context.getSystemMapperMetrics().gauge("String_Node_Str",runningMappers * memoryPerMapper);
  LOG.trace("String_Node_Str",(int)(mapProgress * 100),mapInputRecords,mapOutputRecords,mapOutputBytes,runningMappers,runningMappers * memoryPerMapper);
  float reduceProgress=jobConf.getStatus().getReduceProgress();
  long reduceInputRecords=getTaskCounter(jobConf,TaskCounter.REDUCE_INPUT_RECORDS);
  long reduceOutputRecords=getTaskCounter(jobConf,TaskCounter.REDUCE_OUTPUT_RECORDS);
  context.getSystemReducerMetrics().gauge("String_Node_Str",(int)(reduceProgress * 100));
  context.getSystemReducerMetrics().gauge("String_Node_Str",(int)reduceInputRecords);
  context.getSystemReducerMetrics().gauge("String_Node_Str",(int)reduceOutputRecords);
  context.getSystemReducerMetrics().gauge("String_Node_Str",runningReducers);
  context.getSystemReducerMetrics().gauge("String_Node_Str",runningReducers * memoryPerReducer);
  LOG.trace("String_Node_Str",(int)(reduceProgress * 100),reduceInputRecords,reduceOutputRecords,runningReducers,runningReducers * memoryPerReducer);
}

Fixed version (ground truth):
private void reportStats(BasicMapReduceContext context) throws IOException, InterruptedException {
  float mapProgress=jobConf.getStatus().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=context.getSpecification().getMapperMemoryMB();
  int memoryPerReducer=context.getSpecification().getReducerMemoryMB();
  long mapInputRecords=getTaskCounter(jobConf,TaskCounter.MAP_INPUT_RECORDS);
  long mapOutputRecords=getTaskCounter(jobConf,TaskCounter.MAP_OUTPUT_RECORDS);
  long mapOutputBytes=getTaskCounter(jobConf,TaskCounter.MAP_OUTPUT_BYTES);
  context.getSystemMapperMetrics().gauge(METRIC_COMPLETION,(int)(mapProgress * 100));
  context.getSystemMapperMetrics().gauge(METRIC_INPUT_RECORDS,(int)mapInputRecords - previousMapStats.get(METRIC_INPUT_RECORDS));
  context.getSystemMapperMetrics().gauge(METRIC_OUTPUT_RECORDS,(int)mapOutputRecords - previousMapStats.get(METRIC_OUTPUT_RECORDS));
  context.getSystemMapperMetrics().gauge(METRIC_BYTES,(int)mapOutputBytes - previousMapStats.get(METRIC_BYTES));
  context.getSystemMapperMetrics().gauge(METRIC_USED_CONTAINERS,runningMappers);
  context.getSystemMapperMetrics().gauge(METRIC_USED_MEMORY,runningMappers * memoryPerMapper);
  previousMapStats.put(METRIC_INPUT_RECORDS,(int)mapInputRecords);
  previousMapStats.put(METRIC_OUTPUT_RECORDS,(int)mapOutputRecords);
  previousMapStats.put(METRIC_BYTES,(int)mapOutputBytes);
  LOG.trace("String_Node_Str",(int)(mapProgress * 100),mapInputRecords,mapOutputRecords,mapOutputBytes,runningMappers,runningMappers * memoryPerMapper);
  float reduceProgress=jobConf.getStatus().getReduceProgress();
  long reduceInputRecords=getTaskCounter(jobConf,TaskCounter.REDUCE_INPUT_RECORDS);
  long reduceOutputRecords=getTaskCounter(jobConf,TaskCounter.REDUCE_OUTPUT_RECORDS);
  context.getSystemReducerMetrics().gauge(METRIC_COMPLETION,(int)(reduceProgress * 100));
  context.getSystemReducerMetrics().gauge(METRIC_INPUT_RECORDS,(int)reduceInputRecords - previousReduceStats.get(METRIC_INPUT_RECORDS));
  context.getSystemReducerMetrics().gauge(METRIC_OUTPUT_RECORDS,(int)reduceOutputRecords - previousReduceStats.get(METRIC_OUTPUT_RECORDS));
  context.getSystemReducerMetrics().gauge(METRIC_USED_CONTAINERS,runningReducers);
  context.getSystemReducerMetrics().gauge(METRIC_USED_MEMORY,runningReducers * memoryPerReducer);
  previousReduceStats.put(METRIC_INPUT_RECORDS,(int)reduceInputRecords);
  previousReduceStats.put(METRIC_OUTPUT_RECORDS,(int)reduceOutputRecords);
  LOG.trace("String_Node_Str",(int)(reduceProgress * 100),reduceInputRecords,reduceOutputRecords,runningReducers,runningReducers * memoryPerReducer);
}