Gets successors of the given job by walking the job graph recursively.
        Any successor in alreadySeenSuccessors is ignored and not traversed.
        Returns the set of found successors. This set is added to alreadySeenSuccessors.
332727
def getSuccessors(jobGraph, alreadySeenSuccessors, jobStore):
        
        successors = set()
        def successorRecursion(jobGraph):
            # For lists of successors
            for successorList in jobGraph.stack:

                # For each successor in list of successors
                for successorJobNode in successorList:

                    # If successor not already visited
                    if successorJobNode.jobStoreID not in alreadySeenSuccessors:

                        # Add to set of successors
                        successors.add(successorJobNode.jobStoreID)
                        alreadySeenSuccessors.add(successorJobNode.jobStoreID)

                        # Recurse if job exists
                        # (job may not exist if already completed)
                        if jobStore.exists(successorJobNode.jobStoreID):
                            successorRecursion(jobStore.load(successorJobNode.jobStoreID))

        successorRecursion(jobGraph)  # Recurse from jobGraph

        return successors
43787
int findIndex(final Job job) {
        int size = jobList.size();
        boolean found = false;

        int i = 0;
        for (; i < size; i++) {
            ScheduledJobEntry se = (ScheduledJobEntry) jobList.get(i);
            if (se.job == job) {
                found = true;
                break;
            }
        }
        if (found) {
            return i;
        } else {
            return -1;
        }
    }
995628
def expand_node_predecessors(universe, graph, node: BaseEntity) -> None:
    
    skip_successors = set()
    for successor in universe.successors(node):
        if successor in graph:
            skip_successors.add(successor)
            continue

        graph.add_node(successor, **universe.nodes[successor])

    graph.add_edges_from(
        (source, successor, key, data)
        for source, successor, key, data in universe.out_edges(node, data=True, keys=True)
        if successor not in skip_successors
    )

    update_node_helper(universe, graph)
    update_metadata(universe, graph)
1344907
def _processFailedSuccessors(self, jobGraph):
        """"""

        if jobGraph.jobStoreID in self.toilState.servicesIssued:
            # The job has services running, signal for them to be killed
            # once they are killed then the jobGraph will be re-added to
            # the updatedJobs set and then scheduled to be removed
            logger.debug("Telling job: %s to terminate its services due to successor failure",
                         jobGraph.jobStoreID)
            self.serviceManager.killServices(self.toilState.servicesIssued[jobGraph.jobStoreID],
                                             error=True)
        elif jobGraph.jobStoreID in self.toilState.successorCounts:
            # The job has non-service jobs running wait for them to finish
            # the job will be re-added to the updated jobs when these jobs
            # are done
            logger.debug("Job %s with ID: %s with failed successors still has successor jobs running",
                         jobGraph, jobGraph.jobStoreID)
        elif jobGraph.checkpoint is not None and jobGraph.remainingRetryCount > 1:
            # If the job is a checkpoint and has remaining retries then reissue it.
            # The logic behind using > 1 rather than > 0 here: Since this job has
            # been tried once (without decreasing its retry count as the job
            # itself was successful), and its subtree failed, it shouldn't be retried
            # unless it has more than 1 try.
            logger.warn('Job: %s is being restarted as a checkpoint after the total '
                        'failure of jobs in its subtree.', jobGraph.jobStoreID)
            self.issueJob(JobNode.fromJobGraph(jobGraph))
        else:
            # Mark it totally failed
            logger.debug("Job %s is being processed as completely failed", jobGraph.jobStoreID)
            self.processTotallyFailedJob(jobGraph)
298371
public void connectToPredecessors(Map<IntermediateDataSetID, IntermediateResult> intermediateDataSets) throws JobException {

		List<JobEdge> inputs = jobVertex.getInputs();

		if (LOG.isDebugEnabled()) {
			LOG.debug(String.format("Connecting ExecutionJobVertex %s (%s) to %d predecessors.", jobVertex.getID(), jobVertex.getName(), inputs.size()));
		}

		for (int num = 0; num < inputs.size(); num++) {
			JobEdge edge = inputs.get(num);

			if (LOG.isDebugEnabled()) {
				if (edge.getSource() == null) {
					LOG.debug(String.format("Connecting input %d of vertex %s (%s) to intermediate result referenced via ID %s.",
							num, jobVertex.getID(), jobVertex.getName(), edge.getSourceId()));
				} else {
					LOG.debug(String.format("Connecting input %d of vertex %s (%s) to intermediate result referenced via predecessor %s (%s).",
							num, jobVertex.getID(), jobVertex.getName(), edge.getSource().getProducer().getID(), edge.getSource().getProducer().getName()));
				}
			}

			// fetch the intermediate result via ID. if it does not exist, then it either has not been created, or the order
			// in which this method is called for the job vertices is not a topological order
			IntermediateResult ires = intermediateDataSets.get(edge.getSourceId());
			if (ires == null) {
				throw new JobException("Cannot connect this job graph to the previous graph. No previous intermediate result found for ID "
						+ edge.getSourceId());
			}

			this.inputs.add(ires);

			int consumerIndex = ires.registerConsumer();

			for (int i = 0; i < parallelism; i++) {
				ExecutionVertex ev = taskVertices[i];
				ev.connectSource(num, ires, edge, consumerIndex);
			}
		}
	}
1076350
def expand_node_successors(universe, graph, node: BaseEntity) -> None:
    
    skip_predecessors = set()
    for predecessor in universe.predecessors(node):
        if predecessor in graph:
            skip_predecessors.add(predecessor)
            continue

        graph.add_node(predecessor, **universe.nodes[predecessor])

    graph.add_edges_from(
        (predecessor, target, key, data)
        for predecessor, target, key, data in universe.in_edges(node, data=True, keys=True)
        if predecessor not in skip_predecessors
    )

    update_node_helper(universe, graph)
    update_metadata(universe, graph)
607418
def all_successors(self, node, skip_reached_fixedpoint=False):
        

        successors = set()

        stack = [ node ]
        while stack:
            n = stack.pop()
            successors.add(n)
            stack.extend(succ for succ in self.successors(n) if
                         succ not in successors and
                            (not skip_reached_fixedpoint or succ not in self._reached_fixedpoint)
                         )

        return successors
896326
def get_dependants(self, run):
        
        if run in self._graph.nodes():
            return list(self._graph.successors(run))
        else:
            return []
882960
function getNextJob(){
  let job = null;

  while(!job && queue.size() > 0){
    let id = queue.pop().id;
    job = map[id];
  }

  return (!!job)?job:null;
}
501490
private JobStory getNextJobFiltered() throws IOException {
    while (true) {
      ZombieJob job = producer.getNextJob();
      if (job == null) {
        return null;
      }
      if (job.getOutcome() == Pre21JobHistoryConstants.Values.KILLED) {
        continue;
      }
      if (job.getNumberMaps() == 0) {
        continue;
      }
      if (job.getNumLoggedMaps() == 0) {
        continue;
      }
      return job;
    }
  }
476863
def fromJobGraph(cls, jobGraph):
        
        return cls(jobStoreID=jobGraph.jobStoreID,
                   requirements=jobGraph._requirements,
                   command=jobGraph.command,
                   jobName=jobGraph.jobName,
                   unitName=jobGraph.unitName,
                   displayName=jobGraph.displayName,
                   predecessorNumber=jobGraph.predecessorNumber)
26688
def _serialiseJobGraph(self, jobGraph, jobStore, returnValues, firstJob):
        
        #Check if the job graph has created
        #any cycles of dependencies or has multiple roots
        self.checkJobGraphForDeadlocks()

        #Create the jobGraphs for followOns/children
        with jobStore.batch():
            jobsToJobGraphs = self._makeJobGraphs(jobGraph, jobStore)
        #Get an ordering on the jobs which we use for pickling the jobs in the
        #correct order to ensure the promises are properly established
        ordering = self.getTopologicalOrderingOfJobs()
        assert len(ordering) == len(jobsToJobGraphs)

        with jobStore.batch():
            # Temporarily set the jobStore locators for the promise call back functions
            for job in ordering:
                job.prepareForPromiseRegistration(jobStore)
                def setForServices(serviceJob):
                    serviceJob.prepareForPromiseRegistration(jobStore)
                    for childServiceJob in serviceJob.service._childServices:
                        setForServices(childServiceJob)
                for serviceJob in job._services:
                    setForServices(serviceJob)

            ordering.reverse()
            assert self == ordering[-1]
            if firstJob:
                #If the first job we serialise all the jobs, including the root job
                for job in ordering:
                    # Pickle the services for the job
                    job._serialiseServices(jobStore, jobsToJobGraphs[job], jobGraph)
                    # Now pickle the job
                    job._serialiseJob(jobStore, jobsToJobGraphs, jobGraph)
            else:
                #We store the return values at this point, because if a return value
                #is a promise from another job, we need to register the promise
                #before we serialise the other jobs
                self._fulfillPromises(returnValues, jobStore)
                #Pickle the non-root jobs
                for job in ordering[:-1]:
                    # Pickle the services for the job
                    job._serialiseServices(jobStore, jobsToJobGraphs[job], jobGraph)
                    # Pickle the job itself
                    job._serialiseJob(jobStore, jobsToJobGraphs, jobGraph)
                # Pickle any services for the job
                self._serialiseServices(jobStore, jobGraph, jobGraph)
199015
def getnjobs(self, key, **kwargs):
        

        return self.get(key, cast_func=parse_n_jobs, **kwargs)
819834
public List<OperableTrigger> getTriggersForJob(JobKey jobKey, T jedis) throws JobPersistenceException {
        final String jobTriggerSetKey = redisSchema.jobTriggersSetKey(jobKey);
        final Set<String> triggerHashKeys = jedis.smembers(jobTriggerSetKey);
        List<OperableTrigger> triggers = new ArrayList<>();
        for (String triggerHashKey : triggerHashKeys) {
            triggers.add(retrieveTrigger(redisSchema.triggerKey(triggerHashKey), jedis));
        }
        return  triggers;
    }
880802
public List<ManagementGroupVertex> getSuccessors() {

		final List<ManagementGroupVertex> successors = new ArrayList<ManagementGroupVertex>();

		for (ManagementGroupEdge edge : this.forwardEdges) {
			successors.add(edge.getTarget());
		}

		return successors;
	}
334615
def find_jobs(self, job_ids):
        """"""
        matched_jobs = []
        if self.skip:
            return matched_jobs

        json_data = self.download_queue(job_ids)
        if not json_data:
            return matched_jobs

        jobs = json_data["jobs"]
        for job in jobs:
            if (
                job.get("id") in job_ids
                and job.get("status", "").lower() not in _NOT_FINISHED_STATUSES
            ):
                matched_jobs.append(job)

        return matched_jobs
1340694
def get_jobs(self, recursive=True):
        
        if recursive:
            ret_dict = self.jobs.copy()
            for link in self._links.values():
                ret_dict.update(link.get_jobs(recursive))
            return ret_dict
        return self.jobs