Program: 80303
Project: 80303
Buggy source:
/** 
 * Run all jobs added to JobControl.
 */
public void run() throws IOException {
  List<ControlledJob> jobsWithoutIds=this.jc.getWaitingJobList();
  int totalNeededMRJobs=jobsWithoutIds.size();
  LOG.info("String_Node_Str",jobsWithoutIds.size());
  Thread jcThread=new Thread(this.jc,"String_Node_Str");
  jcThread.start();
  JobClient jobClient=new JobClient(new JobConf(new Configuration()));
  double lastProg=-1;
  Set<String> sucessfulJobs=new HashSet<String>();
  while (!this.jc.allFinished()) {
    try {
      jcThread.join(1000);
    }
 catch (    InterruptedException ignore) {
      Thread.currentThread().interrupt();
    }
    List<ControlledJob> jobsAssignedIdInThisRun=new ArrayList<ControlledJob>(totalNeededMRJobs);
    for (    ControlledJob job : jobsWithoutIds) {
      if (job.getJob().getJobID() != null) {
        jobsAssignedIdInThisRun.add(job);
        LOG.info("String_Node_Str",job.getJob().getJobID().toString());
      }
 else {
      }
    }
    jobsWithoutIds.removeAll(jobsAssignedIdInThisRun);
    List<ControlledJob> runningJobs=jc.getRunningJobList();
    for (    ControlledJob controlledJob : runningJobs) {
      String jobId=controlledJob.getJob().getJobID().toString();
      Counters counters=controlledJob.getJob().getCounters();
      Counter doneMaster=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.MASTER_SUCCESS);
      Counter doneWorkers=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.DONE_WORKERS);
      if ((doneMaster != null && doneMaster.getValue() > 0) || (doneWorkers != null && doneWorkers.getValue() > 0)) {
        Long initTime=firstMasterSuccessTimeMap.get(jobId);
        if (initTime == null) {
          firstMasterSuccessTimeMap.put(jobId,System.currentTimeMillis());
        }
 else {
          if (System.currentTimeMillis() - initTime >= 2 * 60 * 1000L) {
            killedSuccessJobSet.add(jobId);
            killJob(controlledJob.getJob().getConfiguration(),jobId,"String_Node_Str");
            try {
              Thread.sleep(1 * 1000L);
            }
 catch (            InterruptedException e) {
              Thread.currentThread().interrupt();
            }
          }
        }
      }
    }
    List<ControlledJob> successfulJobs=jc.getSuccessfulJobList();
    for (    ControlledJob controlledJob : successfulJobs) {
      String jobId=controlledJob.getJob().getJobID().toString();
      if (!sucessfulJobs.contains(jobId)) {
        LOG.info("String_Node_Str",jobId);
        sucessfulJobs.add(jobId);
      }
    }
    List<ControlledJob> failedJobs=jc.getFailedJobList();
    for (    ControlledJob controlledJob : failedJobs) {
      String failedJobId=controlledJob.getJob().getJobID().toString();
      if (killedSuccessJobSet.contains(failedJobId)) {
        continue;
      }
      if (!this.failedCheckingJobs.contains(failedJobId)) {
        this.failedCheckingJobs.add(failedJobId);
        String jobName=controlledJob.getJob().getJobName();
        Integer jobIndex=this.jobIndexMap.get(jobName);
        Integer runTimes=this.jobRunningTimes.get(jobIndex);
        if (runTimes <= 1) {
          LOG.warn("String_Node_Str",jobName);
          Job newJob=createJob(this.jobIndexParams.get(jobIndex));
          this.jc.addJob(new ControlledJob(newJob,null));
          this.jobRunningTimes.put(jobIndex,runTimes + 1);
          this.jobIndexMap.put(newJob.getJobName(),jobIndex);
          jobsWithoutIds=this.jc.getWaitingJobList();
        }
 else {
          LOG.warn("String_Node_Str",jobName);
        }
      }
    }
    double prog=calculateProgress(jc,jobClient) / totalNeededMRJobs;
    notifyProgress(prog,lastProg);
    lastProg=prog;
    try {
      Thread.sleep(2 * 1000);
    }
 catch (    InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  List<ControlledJob> successfulJobs=jc.getSuccessfulJobList();
  List<ControlledJob> failedJobs=jc.getFailedJobList();
  LOG.debug("String_Node_Str",successfulJobs.size(),failedJobs.size(),totalNeededMRJobs);
  for (  ControlledJob controlledJob : successfulJobs) {
    LOG.info("String_Node_Str");
    LOG.info("String_Node_Str",controlledJob);
  }
  if (totalNeededMRJobs == successfulJobs.size()) {
    LOG.info("String_Node_Str");
    failedJobs=jc.getFailedJobList();
    if (failedJobs != null && failedJobs.size() > 0) {
      for (      ControlledJob controlledJob : failedJobs) {
        Counters counters=controlledJob.getJob().getCounters();
        if (counters != null) {
          Counter doneMaster=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.MASTER_SUCCESS);
          Counter doneWorkers=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.DONE_WORKERS);
          if ((doneMaster != null && doneMaster.getValue() > 0) || (doneWorkers != null && doneWorkers.getValue() > 0)) {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",toFakedStateString(controlledJob));
          }
 else {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",controlledJob);
          }
        }
      }
    }
  }
 else {
    failedJobs=jc.getFailedJobList();
    if (failedJobs != null && failedJobs.size() > 0) {
      for (      ControlledJob controlledJob : failedJobs) {
        Counters counters=controlledJob.getJob().getCounters();
        if (counters != null) {
          Counter doneWorkers=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.DONE_WORKERS);
          if (doneWorkers != null && doneWorkers.getValue() > 0) {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",toFakedStateString(controlledJob));
          }
 else {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",controlledJob);
          }
        }
      }
    }
  }
  this.jc.stop();
}

Fixed version (ground truth):
/** 
 * Run all jobs added to JobControl.
 */
public void run() throws IOException {
  List<ControlledJob> jobsWithoutIds=this.jc.getWaitingJobList();
  int totalNeededMRJobs=jobsWithoutIds.size();
  LOG.info("String_Node_Str",jobsWithoutIds.size());
  Thread jcThread=new Thread(this.jc,"String_Node_Str");
  jcThread.start();
  JobClient jobClient=new JobClient(new JobConf(new Configuration()));
  double lastProg=-1;
  Set<String> sucessfulJobs=new HashSet<String>();
  while (!this.jc.allFinished()) {
    try {
      jcThread.join(1000);
    }
 catch (    InterruptedException ignore) {
      Thread.currentThread().interrupt();
    }
    List<ControlledJob> jobsAssignedIdInThisRun=new ArrayList<ControlledJob>(totalNeededMRJobs);
    for (    ControlledJob job : jobsWithoutIds) {
      if (job.getJob().getJobID() != null) {
        jobsAssignedIdInThisRun.add(job);
        LOG.info("String_Node_Str",job.getJob().getJobID().toString());
      }
 else {
      }
    }
    jobsWithoutIds.removeAll(jobsAssignedIdInThisRun);
    List<ControlledJob> runningJobs=jc.getRunningJobList();
    for (    ControlledJob controlledJob : runningJobs) {
      String jobId=controlledJob.getJob().getJobID().toString();
      Counters counters=controlledJob.getJob().getCounters();
      Counter doneMaster=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.MASTER_SUCCESS);
      Counter doneWorkers=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.DONE_WORKERS);
      if ((doneMaster != null && doneMaster.getValue() > 0) || (doneWorkers != null && doneWorkers.getValue() > 0)) {
        Long initTime=firstMasterSuccessTimeMap.get(jobId);
        if (initTime == null) {
          firstMasterSuccessTimeMap.put(jobId,System.currentTimeMillis());
        }
 else {
          if (System.currentTimeMillis() - initTime >= 2 * 60 * 1000L) {
            killedSuccessJobSet.add(jobId);
            killJob(controlledJob.getJob().getConfiguration(),jobId,"String_Node_Str");
            try {
              Thread.sleep(1 * 1000L);
            }
 catch (            InterruptedException e) {
              Thread.currentThread().interrupt();
            }
          }
        }
      }
    }
    List<ControlledJob> successfulJobs=jc.getSuccessfulJobList();
    for (    ControlledJob controlledJob : successfulJobs) {
      String jobId=controlledJob.getJob().getJobID().toString();
      if (!sucessfulJobs.contains(jobId)) {
        LOG.info("String_Node_Str",jobId);
        sucessfulJobs.add(jobId);
      }
    }
    List<ControlledJob> failedJobs=jc.getFailedJobList();
    for (    ControlledJob controlledJob : failedJobs) {
      String failedJobId=controlledJob.getJob().getJobID().toString();
      if (killedSuccessJobSet.contains(failedJobId)) {
        continue;
      }
      if (!this.failedCheckingJobs.contains(failedJobId)) {
        this.failedCheckingJobs.add(failedJobId);
        String jobName=controlledJob.getJob().getJobName();
        Integer jobIndex=this.jobIndexMap.get(jobName);
        Integer runTimes=this.jobRunningTimes.get(jobIndex);
        if (runTimes <= 1) {
          LOG.warn("String_Node_Str",jobName);
          Job newJob=createJob(this.jobIndexParams.get(jobIndex));
          this.jc.addJob(new ControlledJob(newJob,null));
          this.jobRunningTimes.put(jobIndex,runTimes + 1);
          this.jobIndexMap.put(newJob.getJobName(),jobIndex);
          jobsWithoutIds=this.jc.getWaitingJobList();
        }
 else {
          LOG.warn("String_Node_Str",jobName);
        }
      }
    }
    double prog=calculateProgress(jc,jobClient) / totalNeededMRJobs;
    notifyProgress(prog,lastProg);
    lastProg=prog;
    try {
      Thread.sleep(2 * 1000);
    }
 catch (    InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  List<ControlledJob> successfulJobs=jc.getSuccessfulJobList();
  List<ControlledJob> failedJobs=jc.getFailedJobList();
  LOG.debug("String_Node_Str",successfulJobs.size(),failedJobs.size(),totalNeededMRJobs);
  for (  ControlledJob controlledJob : successfulJobs) {
    LOG.info("String_Node_Str");
    LOG.info("String_Node_Str",controlledJob);
  }
  if (totalNeededMRJobs == successfulJobs.size()) {
    LOG.info("String_Node_Str");
    failedJobs=jc.getFailedJobList();
    if (failedJobs != null && failedJobs.size() > 0) {
      for (      ControlledJob controlledJob : failedJobs) {
        Counters counters=controlledJob.getJob().getCounters();
        if (counters != null) {
          Counter doneMaster=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.MASTER_SUCCESS);
          Counter doneWorkers=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.DONE_WORKERS);
          if ((doneMaster != null && doneMaster.getValue() > 0) || (doneWorkers != null && doneWorkers.getValue() > 0)) {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",toFakedStateString(controlledJob));
          }
 else {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",controlledJob);
          }
        }
      }
    }
  }
 else {
    failedJobs=jc.getFailedJobList();
    if (failedJobs != null && failedJobs.size() > 0) {
      for (      ControlledJob controlledJob : failedJobs) {
        Counters counters=controlledJob.getJob().getCounters();
        if (counters != null) {
          Counter doneMaster=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.MASTER_SUCCESS);
          Counter doneWorkers=counters.findCounter(GuaguaMapReduceConstants.GUAGUA_STATUS,GuaguaMapReduceConstants.DONE_WORKERS);
          if ((doneMaster != null && doneMaster.getValue() > 0) || (doneWorkers != null && doneWorkers.getValue() > 0)) {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",toFakedStateString(controlledJob));
          }
 else {
            LOG.info("String_Node_Str");
            LOG.warn("String_Node_Str",controlledJob);
          }
        }
      }
    }
  }
  this.jc.stop();
}