Program: 130253
Project: 130253
Buggy source:
private void setMemPhaseResourceUsage(List<TaskOutputDetails> taskDetails,Map<Long,IntervalStats> statsMap,JobOutput jobOutput,String jobID,PhaseType phase) throws UnknownHostException {
  IntervalStats intervalStats;
  List<Float> cpuPer;
  List<Float> memPer;
  float maxPhaseMem=0;
  float totalPhaseCpu=0;
  int interval=0;
  Map<NodeSystemStats,Float> memStatsMap=new HashMap<NodeSystemStats,Float>();
  int minStartPoint=-1, maxEndPoint=0;
  YamlLoader yamlLoader=(YamlLoader)loader;
  YamlConfig yamlConfig=(YamlConfig)yamlLoader.getYamlConfiguration();
  Remoter remoter=RemotingUtil.getRemoter(yamlLoader,null);
  CommandWritableBuilder builder=new CommandWritableBuilder();
  String remoteHadoop=RemotingUtil.getHadoopHome(remoter,yamlConfig) + File.separator;
  String user=yamlConfig.getMaster().getUser();
  SupportedHadoopDistributions hadoopVersion=RemotingUtil.getHadoopVersion(yamlConfig);
  String logsHistory=changeLogHistoryPathAccToHadoopVersion(remoteHadoop,hadoopVersion,user);
  String command=jobID + RemotingConstants.SINGLE_SPACE + logsHistory;
  builder.addCommand(command,false,null,CommandType.FS).setApiInvokeHints(ApiInvokeHintsEnum.GET_HADOOP_CONFIG);
  String configFilePath=(String)remoter.fireCommandAndGetObjectResponse(builder.getCommandWritable());
  String destinationReceiveDir=RemotingUtil.copyAndGetHadoopConfigurationFilePath(configFilePath,loader);
  for (  TaskOutputDetails tod : taskDetails) {
    String location=convertHostNameToIP(tod.getLocation());
    float mem=tod.getResourceUsageMetrics().getPhysicalMemoryUsage();
    minStartPoint=setMinStartPoint(minStartPoint,tod.getStartPoint());
    long start=minStartPoint;
    maxEndPoint=setMaxEndPoint(maxEndPoint,tod.getEndPoint());
    long end=maxEndPoint;
    long startPt=Math.max(start,DELAY_INTERVAL);
    float memoryStats=0.0f;
    String jvmChildOpts=null;
    if (PhaseType.REDUCE.equals(phase)) {
      jvmChildOpts=RemotingUtil.parseConfiguration(destinationReceiveDir,"String_Node_Str");
      if (jvmChildOpts == null) {
        jvmChildOpts=RemotingUtil.parseConfiguration(destinationReceiveDir,"String_Node_Str");
      }
    }
 else {
      jvmChildOpts=RemotingUtil.parseConfiguration(destinationReceiveDir,"String_Node_Str");
      if (jvmChildOpts == null) {
        jvmChildOpts=RemotingUtil.parseConfiguration(destinationReceiveDir,"String_Node_Str");
      }
    }
    if (jvmChildOpts != null) {
      int childOptsVal=ConfigurationUtil.getJavaOptsinMB(jvmChildOpts);
      memoryStats=((mem / (childOptsVal * 1024 * 1024)) * 100);
      int avg=(int)(tod.getEndPoint() - startPt) / 2;
      interval=(int)(avg + startPt);
      maxPhaseMem=setMaxPhaseMemory(memoryStats,maxPhaseMem);
    }
  }
  if (statsMap.containsKey(interval)) {
    intervalStats=statsMap.get(interval);
    cpuPer=intervalStats.getCpuStats();
    memPer=intervalStats.getMemStats();
  }
 else {
    intervalStats=new IntervalStats();
    cpuPer=new ArrayList<Float>();
    memPer=new ArrayList<Float>();
  }
  setIntervalStats(statsMap,0.0f,maxPhaseMem,intervalStats,cpuPer,memPer,interval);
}

Fixed version (ground truth):
private void setMemPhaseResourceUsage(List<TaskOutputDetails> taskDetails,Map<Long,IntervalStats> statsMap,JobOutput jobOutput,String jobID,PhaseType phase) throws UnknownHostException {
  IntervalStats intervalStats;
  List<Float> cpuPer;
  List<Float> memPer;
  float maxPhaseMem=0;
  float totalPhaseCpu=0;
  int interval=0;
  Map<NodeSystemStats,Float> memStatsMap=new HashMap<NodeSystemStats,Float>();
  int minStartPoint=-1, maxEndPoint=0;
  YamlLoader yamlLoader=(YamlLoader)loader;
  YamlConfig yamlConfig=(YamlConfig)yamlLoader.getYamlConfiguration();
  Remoter remoter=RemotingUtil.getRemoter(yamlLoader,null);
  CommandWritableBuilder builder=new CommandWritableBuilder();
  String remoteHadoop=RemotingUtil.getHadoopHome(remoter,yamlConfig) + File.separator;
  String user=yamlConfig.getMaster().getUser();
  SupportedHadoopDistributions hadoopVersion=RemotingUtil.getHadoopVersion(yamlConfig);
  String logsHistory=changeLogHistoryPathAccToHadoopVersion(remoteHadoop,hadoopVersion,user);
  String command=jobID + RemotingConstants.SINGLE_SPACE + logsHistory;
  builder.addCommand(command,false,null,CommandType.FS).setApiInvokeHints(ApiInvokeHintsEnum.GET_HADOOP_CONFIG);
  String configFilePath=(String)remoter.fireCommandAndGetObjectResponse(builder.getCommandWritable());
  String fileName=configFilePath.substring(configFilePath.lastIndexOf(File.separator) + 1);
  configFilePath=configFilePath.substring(0,configFilePath.lastIndexOf(File.separator) + 1);
  String configurationFilePath=RemotingUtil.copyAndGetConfigurationFilePath(loader,configFilePath,fileName) + File.separator + fileName;
  for (  TaskOutputDetails tod : taskDetails) {
    String location=convertHostNameToIP(tod.getLocation());
    float mem=tod.getResourceUsageMetrics().getPhysicalMemoryUsage();
    minStartPoint=setMinStartPoint(minStartPoint,tod.getStartPoint());
    long start=minStartPoint;
    maxEndPoint=setMaxEndPoint(maxEndPoint,tod.getEndPoint());
    long end=maxEndPoint;
    long startPt=Math.max(start,DELAY_INTERVAL);
    float memoryStats=0.0f;
    String jvmChildOpts=null;
    if (PhaseType.REDUCE.equals(phase)) {
      jvmChildOpts=RemotingUtil.parseConfiguration(configurationFilePath,"String_Node_Str");
      if (jvmChildOpts == null) {
        jvmChildOpts=RemotingUtil.parseConfiguration(configurationFilePath,"String_Node_Str");
      }
    }
 else {
      jvmChildOpts=RemotingUtil.parseConfiguration(configurationFilePath,"String_Node_Str");
      if (jvmChildOpts == null) {
        jvmChildOpts=RemotingUtil.parseConfiguration(configurationFilePath,"String_Node_Str");
      }
    }
    if (jvmChildOpts != null) {
      int childOptsVal=ConfigurationUtil.getJavaOptsinMB(jvmChildOpts);
      memoryStats=((mem / (childOptsVal * 1024 * 1024)) * 100);
      int avg=(int)(tod.getEndPoint() - startPt) / 2;
      interval=(int)(avg + startPt);
      maxPhaseMem=setMaxPhaseMemory(memoryStats,maxPhaseMem);
    }
  }
  if (statsMap.containsKey(interval)) {
    intervalStats=statsMap.get(interval);
    cpuPer=intervalStats.getCpuStats();
    memPer=intervalStats.getMemStats();
  }
 else {
    intervalStats=new IntervalStats();
    cpuPer=new ArrayList<Float>();
    memPer=new ArrayList<Float>();
  }
  setIntervalStats(statsMap,0.0f,maxPhaseMem,intervalStats,cpuPer,memPer,interval);
}