Periodically checks status of running map-reduce jobs.
767511
public void doMonitor() {
    while (running) {
      String[] keys = null;
      // Make a copy of the names of the current jobs.
      synchronized(jobs) {
        keys = jobs.keySet().toArray(new String[0]);
      }

      // Check all the jobs. We do not want to block access to `jobs`
      // because that will prevent new jobs from being added.
      // This is safe because JobMonitor.run is the only code that can
      // remove a job from `jobs`. Thus all elements in `keys` will have
      // valid values.
      Map<String, List<DistRaid>> finishedJobs =
        new HashMap<String, List<DistRaid>>();

      for (String key: keys) {
        // For each policy being monitored, get the list of jobs running.
        DistRaid[] jobListCopy = null;
        synchronized(jobs) {
          List<DistRaid> jobList = jobs.get(key);
          synchronized(jobList) {
            jobListCopy = jobList.toArray(new DistRaid[jobList.size()]);
          }
        }
        // The code that actually contacts the JobTracker is not synchronized,
        // it uses copies of the list of jobs.
        for (DistRaid job: jobListCopy) {
          // Check each running job.
          try {
            boolean complete = job.checkComplete();
            if (complete) {
              addJob(finishedJobs, key, job);
              if (job.successful()) {
                jobsSucceeded++;
              }
            } else if (System.currentTimeMillis() -
                job.getStartTime() > maximumRunningTime){
              // If the job is running for more than one day
              throw new Exception("Job " + job.getJobID() + 
                  " is hanging more than " + maximumRunningTime/1000
                  + " seconds. Kill it");
            }
          } catch (Exception e) {
            // If there was an error, consider the job finished.
            addJob(finishedJobs, key, job);
            try {
              job.killJob();
            } catch (Exception ee) {
              LOG.error(ee);
            }
          }
        }
      }

      if (finishedJobs.size() > 0) {
        for (String key: finishedJobs.keySet()) {
          List<DistRaid> finishedJobList = finishedJobs.get(key);
          // Iterate through finished jobs and remove from jobs.
          // removeJob takes care of locking.
          for (DistRaid job: finishedJobList) {
            addCounter(raidProgress, job, INT_CTRS);
            removeJob(jobs, key, job);
            addJob(history, key, job);
            // delete the temp directory 
            job.cleanUp();
          }
        }
      }

      try {
        Thread.sleep(jobMonitorInterval);
      } catch (InterruptedException ie) {
      }
    }
  }
132591
def done?
      return (
        get_jobs_by_status(Executor::STATUS_NONE).size == 0 &&
        get_jobs_by_status(Executor::STATUS_RUNNING).size == 0 &&
        get_jobs_by_status(Executor::STATUS_DONE).size > 0
      )
    end
538525
def is_running(self, is_stopped):
        '''  '''
        if is_stopped and self.is_stopped():
            return False

        return faspmanager2.isRunning(self.get_transfer_id())
1065582
public boolean isRestartScheduled() {
        for (UpdateCenterJob job : getJobs()) {
            if (job instanceof RestartJenkinsJob) {
                RestartJenkinsJob.RestartJenkinsJobStatus status = ((RestartJenkinsJob) job).status;
                if (status instanceof RestartJenkinsJob.Pending
                        || status instanceof RestartJenkinsJob.Running) {
                    return true;
                }
            }
        }
        return false;
    }
401543
def status(self):
        """"""
        # If there is no script it is either ready or a lost duplicate #
        if not self.script_path.exists:
            if self.name in     jobs.names: return "DUPLICATE"
            if self.name not in jobs.names: return "READY"
        # It is submitted already #
        if self.name in jobs.names:
            if jobs[self.name]['type'] == 'queued':  return "QUEUED"
            if jobs[self.name]['type'] == 'running': return "RUNNING"
        # So the script exists for sure but it is not in the queue #
        if not self.kwargs['out_file'].exists: return "ABORTED"
        # Let's look in log file #
        if 'CANCELED'          in self.log_tail: return "CANCELLED"
        if 'slurmstepd: error' in self.log_tail: return "CANCELLED"
        # It all looks good #
        if 'SLURM: end at'     in self.log_tail: return "FINISHED"
        # At this point we have no idea #
        return "INTERUPTED"
740616
def _IsCronJobFailing(self, cron_job):
    """"""
    status = cron_job.Get(cron_job.Schema.LAST_RUN_STATUS)
    if status is None:
      return False

    return status.status != rdf_cronjobs.CronJobRunStatus.Status.OK
1024461
def pending_tasks(self, res):
        ""
        jobs, lock = self._jobs
        with lock:
            return jobs[res].copy()
1364535
def running(self, offset=0, count=25):
        ''''''
        return self.client('jobs', 'running', self.name, offset, count)
241908
function isRunning(specs) {
  return specs.dataset.some(coll => {
    return coll.contents.some(e => {
      return ['ready', 'queued', 'running', 'interrupted'].includes(e.status);
    });
  });
}
870246
private void startActiveMonitoring(final StatusAggregator aggregator) {

    	log.info("Starting application health monitoring in ACTIVE mode");

    	ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {

			@Override
			public Thread newThread(Runnable r) {
				Thread t = new Thread(r,"SocketTransport App Health Monitor");
				t.setDaemon(true);
				return t;
			}
		});

    	executor.scheduleWithFixedDelay(new Runnable() {

			@Override
			public void run() {
                try {
                    boolean healthy = !Status.FAIL.equals(aggregator.getStatus());

                    setStatus(healthy ? Status.OK : Status.FAIL);
                }
                catch (Exception e) {
                    log.warn("Error whilst setting health status",e);
                }
			}
		}, monitorInterval, monitorInterval, TimeUnit.MILLISECONDS);
    }
661614
function () {
        if (job.pull_requests < worker_count) {
            return false;
        }
        for (var i = 0; i < worker_count; i++) {
            if (!job.worker_complete[i]) {
                return false;
            }
        }
        return true;
    }
979961
public synchronized TaskStatus findFinishedMap(int mapId) {
    TaskInProgress tip = maps[mapId];
    if (tip.isComplete()) {
      TaskStatus[] statuses = tip.getTaskStatuses();
      for(int i=0; i < statuses.length; i++) {
        if (statuses[i].getRunState() == TaskStatus.State.SUCCEEDED) {
          return statuses[i];
        }
      }
    }
    return null;
  }
545817
private void notifyIfStopped() {
        if (isAcceptingNewJobs() || !this.runningTasksFutures.isEmpty()) {
            return;
        }
        final File stoppedFile = new File(this.workingDirectories.getWorking(), "stopped");
        try {
            LOGGER.info("The print has finished processing jobs and can now stop");
            stoppedFile.createNewFile();
        } catch (IOException e) {
            LOGGER.warn("Cannot create the {} file", stoppedFile, e);
        }
    }
1098414
public void startChecking() {
        // synchronize with other attempts to update the running task
        synchronized(runningTaskLock){
            // check if not already active
            if(runningTask == null) {
                // only activate if at least one stop criterion has been set
                if(!stopCriteria.isEmpty()){
                    // schedule periodical check
                    runningTask = new StopCriterionCheckTask();
                    runningTaskFuture = SCHEDULER.scheduleWithFixedDelay(runningTask, period, period, periodTimeUnit);
                    // log
                    LOGGER.debug("Stop criterion checker for search {} activated", search);
                }
            } else {
                // issue a warning
                LOGGER.warn("Attempted to activate already active stop criterion checker for search {}", search);
            }
        }
    }
855077
private void checkInProgressWork() {
        inProgressWorkQueue.addAll(db().getAllInprogressTasks());
        StatusTrail st = null;        
        while ((st = inProgressWorkQueue.removeFirst()) != null) {
            if (st.getTaskId() == null) {
                 log.info("Found task with null taskId {}.", st);
                 st.setStatus(JobStatus.not_done).setAttemptsDone(0).setGivenUp(0);
                 db().updateStatusTrail(st);
                 log.info("Marked the status as not done to ensure it is resubmitted {}", st);
                 continue;
            }
            switch(druidDriver.pollIndexerTaskStatus(st.getTaskId())) {
                case SUCCESS:
                    newWorkQueue.remove(st);// Make sure.
                    st.setStatus(JobStatus.done);
                    st.setAttemptsDone(st.getAttemptsDone() + 1);// This will also set givenUp.
                    db().updateStatusTrail(st);
                    log.info("Task {} succeeded.", st);                    
                    break;
                case FAILED:
                    newWorkQueue.remove(st);// Make sure.
                    st.setStatus(JobStatus.not_done);
                    st.setAttemptsDone(st.getAttemptsDone() + 1);// This will also set givenUp.
                    db().updateStatusTrail(st);
                    log.info("Task {} failed.", st);
                    break;
                case RUNNING:
                    log.info("Task {} in progress.", st);
                    break;
                case UNKNOWN:
                    log.info("Task {} status unknown.", st);
                    break;
            }            
        }
    }
99459
def on_finish(self, exc=None):
        """"""
        super(GarbageCollector, self).on_finish(exc)
        self._cycles_left -= 1
        if self._cycles_left <= 0:
            num_collected = gc.collect()
            self._cycles_left = self.collection_cycle
            LOGGER.debug('garbage collection run, %d objects evicted',
                         num_collected)
1149912
protected synchronized void scheduleReduce(TaskInProgress tip) {
    runningReduceTaskStats.add(0.0f);
    runningTaskCopyProcessingRateStats.add(0.0f);
    runningTaskSortProcessingRateStats.add(0.0f);
    runningTaskReduceProcessingRateStats.add(0.0f);
    if (runningReduces == null) {
      LOG.warn("Running cache for reducers missing!! "
               + "Job details are missing.");
      return;
    }
    runningReduces.add(tip);
  }