예제 #1
0
  private synchronized void remove(LinkedList<Job> jobs) {
    for (Job job : jobs) {
      if (job.getStatus().equals(JobStatus.PENDING)) {
        if (this.pendingJobs.containsKey(job.getJob())) {
          this.pendingJobs.get(job.getJob()).remove(job);
        }
      }
    }

    this.jobs.removeAll(jobs);
    this.finishedJobs.removeAll(jobs);
  }
예제 #2
0
  @Override
  public synchronized void store(Job job) {
    int index = this.jobs.indexOf(job);
    if (index != -1) {
      this.jobs.set(index, job);
    } else {
      this.jobs.add(job);
    }

    if (job.getStatus().equals(JobStatus.PENDING)) {
      if (!this.pendingJobs.containsKey(job.getJob())) {
        this.pendingJobs.put(job.getJob(), new LinkedList<>());
      }
      this.pendingJobs.get(job.getJob()).add(job);
    } else if (this.pendingJobs.get(job.getJob()) != null
        && this.pendingJobs.get(job.getJob()).contains(job)) {
      this.pendingJobs.get(job.getJob()).remove(job);
    }

    if (job.getEndTime() != null) {
      this.finishedJobs.add(job);
    }
  }