Checks whether the job represented by the execution graph has the status <code>CANCELED</code> or
<code>FAILED</code>.

@return <code>true</code> if the job has the status <code>CANCELED</code> or <code>FAILED</code>,
<code>false</code> otherwise
516961
private boolean jobHasFailedOrCanceledStatus() {

		final Iterator<ExecutionVertex> it = new ExecutionGraphIterator(this, true);

		while (it.hasNext()) {

			final ExecutionState state = it.next().getExecutionState();

			if (state != ExecutionState.CANCELED && state != ExecutionState.FAILED && state != ExecutionState.FINISHED) {
				return false;
			}
		}

		return true;
	}
9148
boolean detectLongRunningJob(long currentTime, Job job) {
		if(job.status() == JobStatus.RUNNING && !longRunningJobs.containsKey(job)) {
			int jobExecutionsCount = job.executionsCount();
			Long jobStartedtimeInMillis = job.lastExecutionStartedTimeInMillis();
			Thread threadRunningJob = job.threadRunningJob();

			if(jobStartedtimeInMillis != null
				&& threadRunningJob != null
				&& currentTime - jobStartedtimeInMillis > detectionThresholdInMillis) {
				logger.warn(
					"Job '{}' is still running after {}ms (detection threshold = {}ms), stack trace = {}",
					job.name(),
					currentTime - jobStartedtimeInMillis,
					detectionThresholdInMillis,
					Stream
						.of(threadRunningJob.getStackTrace())
						.map(StackTraceElement::toString)
						.collect(Collectors.joining("\n  "))
				);

				longRunningJobs.put(
					job,
					new LongRunningJobInfo(jobStartedtimeInMillis, jobExecutionsCount)
				);

				return true;
			}
		}
		return false;
	}
1087847
@Override public boolean onExceptionalCompletion(Throwable ex, CountedCompleter caller){
      Futures fs = new Futures();
      if( _job != null ) {
        UKV.remove(_job.destination_key,fs);
        UKV.remove(_job._progress,fs);
        // Find & remove all partially-built output vecs & chunks
        if( _job._mfpt != null ) _job._mfpt.onExceptionCleanup(fs);
      }
      // Assume the input is corrupt - or already partially deleted after
      // parsing.  Nuke it all - no partial Vecs lying around.
      for( Key k : _keys ) UKV.remove(k,fs);
      fs.blockForPending();
      // As soon as the job is canceled, threads blocking on the job will
      // wake up.  Better have all cleanup done first!
      if( _job != null ) _job.cancel(ex);
      return true;
    }
853121
public boolean compile(Job job) throws IOException {
        boolean result;

        currentJob = job;
        result = compileCurrent();
        currentJob = null;
        return result;
    }
1148933
@VisibleForTesting
	public boolean containsJob(JobID jobId) {
		Preconditions.checkState(JobLeaderService.State.STARTED == state, "The service is currently not running.");

		return jobLeaderServices.containsKey(jobId);
	}
216743
public boolean isWeaklyConnected() {

		final AbstractJobVertex[] reachable = getAllReachableJobVertices();
		final AbstractJobVertex[] all = getAllJobVertices();

		// Check if number if reachable vertices matches number of registered vertices
		if (reachable.length != all.length) {
			return false;
		}

		final HashMap<JobVertexID, AbstractJobVertex> tmp = new HashMap<JobVertexID, AbstractJobVertex>();
		for (int i = 0; i < reachable.length; i++) {
			tmp.put(reachable[i].getID(), reachable[i]);
		}

		// Check if all is subset of reachable
		for (int i = 0; i < all.length; i++) {
			if (!tmp.containsKey(all[i].getID())) {
				return false;
			}
		}

		// Check if reachable is a subset of all
		for (int i = 0; i < reachable.length; i++) {
			if (!includedInJobGraph(reachable[i].getID())) {
				return false;
			}
		}

		return true;
	}
849543
def exception(self):
    

    if self.__state in (Job.PENDING, Job.RUNNING):
      raise self.InvalidState('job is {0}'.format(self.__state))
    elif self.__state == Job.ERROR:
      assert self.__exception is not None
      return self.__exception
    elif self.__state in (Job.RUNNING, Job.SUCCESS, Job.CANCELLED):
      assert self.__exception is None
      return None
    else:
      raise RuntimeError('invalid job state {0!r}'.format(self.__state))
204895
def is_finalizable(self):
        """"""

        composite_state = self.dependent_on_composite_state()
        if not composite_state.all_finished:
            return False

        if self.job_record is None:
            self.tree.timetable.assign_job_record(self)

        children_processed = all([child.job_record.is_finished for child in self.children.values()])

        return children_processed and self.job_record.is_active
462107
protected boolean isFailure(ExecutionResult result) {
    if (result.isNonResult())
      return false;
    else if (policy instanceof FailurePolicy)
      return ((FailurePolicy) policy).isFailure(result);
    else
      return result.getFailure() != null;
  }
784688
protected void jobFinished(Throwable error)
    {
        this.lock.lock();

        try {
            if (this.status instanceof AbstractJobStatus) {
                // Store error
                ((AbstractJobStatus) this.status).setError(error);
            }

            // Give a chance to any listener to do custom action associated to the job
            this.observationManager.notify(new JobFinishingEvent(getRequest().getId(), getType(), this.request), this,
                error);

            if (getRequest().isVerbose()) {
                if (getStatus().getRequest().getId() != null) {
                    this.logger.info(LOG_END_ID, "Finished job of type [{}] with identifier [{}]", getType(),
                        getStatus().getRequest().getId());
                } else {
                    this.logger.info(LOG_END, "Finished job of type [{}]", getType());
                }
            }

            if (this.status instanceof AbstractJobStatus) {
                // Indicate when the job ended
                ((AbstractJobStatus) this.status).setEndDate(new Date());

                // Stop updating job status (progress, log, etc.)
                ((AbstractJobStatus) this.status).stopListening();

                // Update job state
                ((AbstractJobStatus) this.status).setState(JobStatus.State.FINISHED);
            }

            // Release threads waiting for job being done
            this.finishedCondition.signalAll();

            // Remove the job from the current jobs context
            this.jobContext.popCurrentJob();

            // Store the job status
            try {
                if (this.request.getId() != null) {
                    this.store.storeAsync(this.status);
                }
            } catch (Throwable t) {
                this.logger.warn(LOG_STATUS_STORE_FAILED, "Failed to store job status [{}]", this.status, t);
            }
        } finally {
            this.lock.unlock();

            // Notify listener that job is fully finished
            this.observationManager.notify(new JobFinishedEvent(getRequest().getId(), getType(), this.request), this,
                error);
        }
    }
190722
@Override
	public CompletableFuture<Void> onStop() {
		log.info("Stopping the JobMaster for job {}({}).", jobGraph.getName(), jobGraph.getJobID());

		// disconnect from all registered TaskExecutors
		final Set<ResourceID> taskManagerResourceIds = new HashSet<>(registeredTaskManagers.keySet());
		final FlinkException cause = new FlinkException("Stopping JobMaster for job " + jobGraph.getName() +
			'(' + jobGraph.getJobID() + ").");

		for (ResourceID taskManagerResourceId : taskManagerResourceIds) {
			disconnectTaskManager(taskManagerResourceId, cause);
		}

		taskManagerHeartbeatManager.stop();
		resourceManagerHeartbeatManager.stop();

		// make sure there is a graceful exit
		suspendExecution(new FlinkException("JobManager is shutting down."));

		// shut down will internally release all registered slots
		slotPool.close();

		return CompletableFuture.completedFuture(null);
	}
260620
public synchronized boolean delete(final Job job) {
        // if already shutdown in the process of shutdown, there is no
        // need to remove Jobs as they will never be executed.
        if (shutdown) {
            return false;
        }
        int i = findIndex(job);
        if (i != -1) {
            ScheduledJobEntry se = (ScheduledJobEntry) jobList.remove(i);
            if (se.job != job) { // this should never happen
                new IllegalStateException("Internal programming error");
            }
            // if the job is the first on the list,
            // then notify the scheduler thread to schedule a new job
            if (i == 0) {
                this.notifyAll();
            }
            return true;
        } else {
            return false;
        }
    }
619841
private <Q, R> void recordFinalStatus(JobIdentifier<Q, R> jobId, JobStatus<Q, R> jobStatus) {
        try {
            _jobStatusDAO.updateJobStatus(jobId, jobStatus);
        } catch (Exception e) {
            _log.error("Failed to record final status for job: [id={}, status={}]", jobId, jobStatus.getStatus(), e);
        }
    }
1008240
public boolean shutdown() {

	if (url != null) {
	    logger.debug("Trying to shutdown gass server directly...");
	    try {
		GlobusURL u = new GlobusURL(url);
		GassServer.shutdown(this.cred, u);
	    } catch(Exception e) {
		logger.debug("gass server shutdown failed", e);
	    }

	    try {
		gassJobListener.reset();
		int status = gassJobListener.waitFor(1000*60);
		if (status == GramJob.STATUS_FAILED ||
		    status == GramJob.STATUS_DONE) {
		    // shutdown successful
		    reset();
		    return true;
		}
	    } catch(InterruptedException e) {
		logger.debug("", e);
	    }
	}

	// otherwise just cancel the job.

	if (job == null) return true;

	logger.debug("Canceling gass server job.");

	try {
	    job.cancel();
	    reset();
	    return true;
	} catch(Exception e) {
	    return false;
	}

    }
732088
protected boolean jobTooOld(final JobInfo jobInfo, final JobDefinition jobDefinition) {
        final Optional<OffsetDateTime> stopped = jobInfo.getStopped();
        if (stopped.isPresent() && jobDefinition.maxAge().isPresent()) {
            final OffsetDateTime deadlineToRerun = stopped.get().plus(jobDefinition.maxAge().get());
            return deadlineToRerun.isBefore(now());
        }

        return false;
    }
940970
protected StatusDetail toStatusDetail(final List<JobInfo> jobInfos,
                                          final JobDefinition jobDefinition) {
        final Status status;
        final String message;
        final JobInfo currentJob = jobInfos.get(0);
        final JobInfo lastJob = (!currentJob.getStopped().isPresent() && currentJob.getStatus() == JobStatus.OK && jobInfos.size() > 1) ? jobInfos.get(1) : jobInfos.get(0);
        final JobMeta jobMeta = getJobMeta(jobDefinition.jobType());
        long numFailedJobs = getNumFailedJobs(jobInfos);
        if (!jobMeta.isDisabled()) {
            switch (lastJob.getStatus()) {
                case OK:
                case SKIPPED:
                    if (jobTooOld(lastJob, jobDefinition)) {
                        status = WARNING;
                        message = jobAgeMessage(jobDefinition);
                    } else if (numFailedJobs > maxFailedJobs) {
                        status = WARNING;
                        message = format(TOO_MANY_JOBS_FAILED_MESSAGE, numFailedJobs, jobInfos.size());
                    } else {
                        status = OK;
                        message = SUCCESS_MESSAGE;
                    }
                    break;
                case ERROR:
                    if (numFailedJobs > maxFailedJobs) {
                        status = ERROR;
                    } else {
                        status = WARNING;
                    }
                    if (numberOfJobs == 1 && maxFailedJobs <= 1) {
                        message = ERROR_MESSAGE;
                    } else {
                        message = format(TOO_MANY_JOBS_FAILED_MESSAGE, numFailedJobs, jobInfos.size());
                    }
                    break;

                case DEAD:
                default:
                    status = WARNING;
                    message = DEAD_MESSAGE;
            }
        } else {
            status = OK;
            message = format(JOB_DEACTIVATED_MESSAGE, jobMeta.getDisabledComment());
        }
        return StatusDetail.statusDetail(
                jobDefinition.jobName(),
                status,
                message,
                asList(
                        link(REL_JOB, String.format("%s/jobs/%s", managementContextPath, lastJob.getJobId()), "Details")
                ),
                runningDetailsFor(lastJob)
        );
    }
910997
def get_status(self):
        
        if self.n_total == 0:
            return JobStatus.no_job
        elif self.n_done == self.n_total:
            return JobStatus.done
        elif self.n_failed > 0:
            # If more that a quater of the jobs fail, fail the whole thing
            if self.n_failed > self.n_total / 4.:
                return JobStatus.failed
            return JobStatus.partial_failed
        elif self.n_running > 0:
            return JobStatus.running
        elif self.n_pending > 0:
            return JobStatus.pending
        return JobStatus.ready