Beispiel #1
0
  /**
   * @param jobId
   * @param mailService
   */
  private void checkJobStatus(String jobId, MailService mailService) {
    CloudVmStatusContainer container = tracker.getVmStatusForJob(jobId);
    LOG.info(
        "Checking Job Status to see if we can kill reporting instances. Container=" + container);
    if (container != null) {
      if (container.getEndTime() != null) {
        JobInstanceDao dao = new JobInstanceDao();
        // hack to see if this is an automatino job

        // set the status of the JobInstance to finished.
        JobInstance finishedJob = dao.findById(Integer.valueOf(jobId));
        if (finishedJob.getEndTime() == null) {
          finishedJob.setEndTime(new Date());
          finishedJob.setStatus(JobQueueStatus.Completed);
          dao.saveOrUpdate(finishedJob);
        }
        List<JobQueueStatus> statuses =
            Arrays.asList(new JobQueueStatus[] {JobQueueStatus.Running, JobQueueStatus.Starting});
        List<JobInstance> instances = dao.getForStatus(statuses);
        LOG.info(
            "Checking Job Status to see if we can kill reporting instances. found running instances: "
                + instances.size());
        boolean killModal = true;
        boolean killNonRegional = true;

        for (JobInstance job : instances) {
          CloudVmStatusContainer statusForJob =
              tracker.getVmStatusForJob(Integer.toString(job.getId()));
          if (!jobId.equals(Integer.toString(job.getId()))
              && statusForJob != null
              && statusForJob.getEndTime() == null) {
            LOG.info("Found another job that is not finished: " + job);
          }
        }
        if (killNonRegional || killModal) {
          for (CloudVmStatusContainer statusForJob : tracker.getAllJobs()) {
            if (statusForJob.getEndTime() == null
                && !NumberUtils.isNumber(statusForJob.getJobId())) {
              killNonRegional = false;
              killModal = false;
              LOG.info(
                  "Cannot kill Reporting instances because of automation job id: "
                      + statusForJob.getJobId());
            }
          }
        }
      } else {
        LOG.info("Container does not have end time set so cannot kill reporting instaces.");
      }
    }
  }
Beispiel #2
0
 /** @{inheritDoc */
 public CloudVmStatusContainer getVmStatusForJob(String jobId) {
   return tracker.getVmStatusForJob(jobId);
 }