Ejemplo n.º 1
0
  @Override
  public void waitForJobs(UUID id) {

    JobMetadata job = this.findJob(id);

    if (job == null) return;

    while (job.getStatus().isActive()) {
      Thread.yield();
    }
  }
Ejemplo n.º 2
0
  @Override
  public synchronized List<JobMetadata> findJobsByStatus(JobStatus... statusList) {

    List<JobMetadata> found = new ArrayList<JobMetadata>();

    for (JobMetadata job : jobs) {
      for (JobStatus status : statusList) {
        if (job.getStatus() == status) {
          found.add(job);
        }
      }
    }

    Collections.reverse(found);
    return found;
  }
Ejemplo n.º 3
0
  @Override
  public void waitForJobs(Class type) {

    int active;
    do {
      active = 0;
      List<JobMetadata> jobs = this.findJobsByType(type);
      for (JobMetadata job : jobs) {
        if (job.getStatus().isActive()) {
          active++;
        }
      }

      if (active > 0) Thread.yield();

    } while (active > 0);
  }
Ejemplo n.º 4
0
  /** Helpfull method to display the state of the job queue */
  public synchronized String toString() {

    StringBuilder string = new StringBuilder();

    for (JobMetadata job : jobs) {
      string.append(job.getId());
      string.append(": ");
      string.append(job.getStatus().name());
      string.append(", ");
      string.append(job.getProgress().toString());

      if (job.getOwnerId() != null) {
        string.append(" (");
        string.append(job.getOwnerId());
        string.append(")");
      }
      string.append("\n");
    }

    return string.toString();
  }