Returns an {@link AbstractProjectAction} that matches the parser of this
selector.

@param job
the job to get the action from
@return the action that uses the parser of this selector, or
<code>null</code> if no such action is found
167669
public AbstractProjectAction<?> select(final Job<?, ?> job) {
        List<WarningsProjectAction> actions = job.getActions(WarningsProjectAction.class);
        for (WarningsProjectAction action : actions) {
            if (action.isInGroup(parserName)) {
                return action;
            }
        }
        if (actions.size() == 1) { // Fallback for 3.x release
            return actions.get(0);
        }
        return null;
    }
35321
@Override
	public JobExecutionResult execute(String jobName) throws Exception {
		Plan p = createProgramPlan(jobName);
		
		PlanExecutor executor = PlanExecutor.createLocalExecutor();
		initLogging();
		return executor.executePlan(p);
	}
1225293
public Future<String> queueJob(Callable<String> job) {
        Future<String> future = null;
        try {
            logger.debug("Queueing job {}", job);
            future = executor.submit(job);
        } catch (RejectedExecutionException e) {
            logger.error("Unable to queue a send-command-job! ", e);
        }
        checkQueueSize();
        return future;
    }
436460
@Override
	public JobExecutionResult execute(String jobName) throws Exception {
		if (executor == null) {
			startNewSession();
		}

		Plan p = createProgramPlan(jobName);

		// Session management is disabled, revert this commit to enable
		//p.setJobId(jobID);
		//p.setSessionTimeout(sessionTimeout);

		JobExecutionResult result = executor.executePlan(p);

		this.lastJobExecutionResult = result;
		return result;
	}
846599
@Override
  public TaskResult run() {
    log.info("Running planning job {} [{} {}]", this.planningJobId, this.applicationName, this.instanceName);
    this.jobTaskMetrics.updateTimeBetweenJobSubmissionAndExecution(this.jobPlusSysConfig);

    try (Closer closer = Closer.create()) {
      Optional<String> planningIdFromStateStore = this.jobsMapping.getPlanningJobId(jobName);

      long timeOut = PropertiesUtils.getPropAsLong(jobPlusSysConfig,
                                         GobblinClusterConfigurationKeys.HELIX_WORKFLOW_DELETE_TIMEOUT_SECONDS,
                                         GobblinClusterConfigurationKeys.DEFAULT_HELIX_WORKFLOW_DELETE_TIMEOUT_SECONDS) * 1000;

      if (planningIdFromStateStore.isPresent() && !planningIdFromStateStore.get().equals(this.planningJobId)) {
        return new TaskResult(TaskResult.Status.FAILED, "Exception occurred for job " + planningJobId
            + ": because planning job in state store has different id (" + planningIdFromStateStore.get() + ")");
      }

      while (true) {
        Optional<String> actualJobIdFromStateStore = this.jobsMapping.getActualJobId(jobName);
        if (actualJobIdFromStateStore.isPresent()) {
          String previousActualJobId = actualJobIdFromStateStore.get();
          if (HelixUtils.isJobFinished(previousActualJobId, previousActualJobId, this.jobHelixManager)) {
            log.info("Previous actual job {} [plan: {}] finished, will launch a new job.", previousActualJobId, this.planningJobId);
          } else {
            log.info("Previous actual job {} [plan: {}] not finished, kill it now.", previousActualJobId, this.planningJobId);
            try {
              HelixUtils.deleteWorkflow(previousActualJobId, this.jobHelixManager, timeOut);
            } catch (HelixException e) {
              log.error("Helix cannot delete previous actual job id {} within {} seconds.", previousActualJobId, timeOut / 1000);
              return new TaskResult(TaskResult.Status.FAILED, ExceptionUtils.getFullStackTrace(e));
            }
          }
        } else {
          log.info("No previous actual job [plan: {}]. First time run.", this.planningJobId);
        }

        String actualJobId = HelixJobsMapping.createActualJobId(jobPlusSysConfig);
        log.info("Planning job {} creates actual job {}", this.planningJobId, actualJobId);

        this.jobPlusSysConfig.setProperty(ConfigurationKeys.JOB_ID_KEY, actualJobId);

        this.launcher = createJobLauncher();

        this.jobsMapping.setActualJobId(jobName, this.planningJobId, this.launcher.getJobId());

        closer.register(launcher).launchJob(this.jobLauncherListener);

        if (!this.launcher.isEarlyStopped()) {
          break;
        } else {
          log.info("Planning job {} has more runs due to early stop.", this.planningJobId);
        }
      }
      log.info("Completing planning job {}", this.planningJobId);
      return new TaskResult(TaskResult.Status.COMPLETED, "");
    } catch (Exception e) {
      log.info("Failing planning job {}", this.planningJobId);
      return new TaskResult(TaskResult.Status.FAILED, "Exception occurred for job " + planningJobId + ":" + ExceptionUtils
          .getFullStackTrace(e));
    } finally {
      // always cleanup the job mapping for current job name.
      try {
        this.jobsMapping.deleteMapping(jobName);
      } catch (Exception e) {
        return new TaskResult(TaskResult.Status.FAILED,"Cannot delete jobs mapping for job : " + jobName);
      }
    }
  }
137182
@Override
    public String action(EntityActionOperation entityActionOperation)
            throws ServiceException {
        ClientResponse clientResponse = getActionClientResponse(entityActionOperation);
        entityActionOperation.processResponse(clientResponse);
        
        //PipelineHelpers.throwIfNotSuccess(clientResponse);
        
        if (clientResponse.getHeaders().containsKey("operation-id")) {
            List<String> operationIds = clientResponse.getHeaders().get("operation-id");
            if (operationIds.size() >= 0) {
                return operationIds.get(0);
            }
        }
        return null;
    }
432374
public static String buildAction(Class<?> clazz, String action) {
        return new StringBuilder().append(clazz.getCanonicalName()).append(".").append(action).toString();
    }
1016414
@SuppressWarnings("unchecked")
  public static <K1,V1,K2,V2>
  Class<Mapper<K1,V1,K2,V2>> getMapperClass(JobContext job) {
    return (Class<Mapper<K1,V1,K2,V2>>) 
         job.getConfiguration().getClass("mapred.map.multithreadedrunner.class",
                                         Mapper.class);
  }
489025
public Object getAction() throws ODataException {
        Option<String> actionNameOption = ODataUriUtil.getActionCallName(odataUri);
        if (actionNameOption.isDefined()) {
            LOG.debug("The operation is supposed to be an action");
            String actionName = actionNameOption.get();
            return parseAction(actionName);
        }

        Option<String> actionImportNameOption = ODataUriUtil.getActionImportCallName(odataUri);
        if (actionImportNameOption.isDefined()) {
            LOG.debug("The operation is supposed to be an action import");
            String actionImportName = actionImportNameOption.get();
            return parseActionImport(actionImportName);
        }

        throw new ODataUnmarshallingException("Not able to parse action / action import");
    }
1262305
public String getAction(final Method method) {
        final Annotation[] annotations = method.getAnnotations();
        return this.getAction(annotations, method);
    }
1072950
@SuppressWarnings("static-method")
	protected Job createJobForJavaProject(IProject project) {
		return new Job(Messages.EnableSarlMavenNatureAction_0) {

			@Override
			protected IStatus run(IProgressMonitor monitor) {
				final SubMonitor mon = SubMonitor.convert(monitor, 3);
				// Force the project configuration to SARL.
				SARLProjectConfigurator.configureSARLProject(
						// Project to configure
						project,
						// Add SARL natures
						true,
						// Force java configuration
						true,
						// Create folders
						true,
						// Monitor
						mon.newChild(3));
				return Status.OK_STATUS;
			}
		};
	}
198801
public static boolean execute(AbstractBuild build, BuildListener listener) {
        PrintStream logger = listener.getLogger();
        // Check all downstream Project of the project, not just those defined by BuildTrigger
        // TODO this may not yet be up to date if rebuildDependencyGraphAsync has been used; need a method to wait for the last call made before now to finish
        final DependencyGraph graph = Jenkins.getInstance().getDependencyGraph();
        List<Dependency> downstreamProjects = new ArrayList<>(
                graph.getDownstreamDependencies(build.getProject()));
        // Sort topologically
        downstreamProjects.sort(new Comparator<Dependency>() {
            public int compare(Dependency lhs, Dependency rhs) {
                // Swapping lhs/rhs to get reverse sort:
                return graph.compare(rhs.getDownstreamProject(), lhs.getDownstreamProject());
            }
        });

        for (Dependency dep : downstreamProjects) {
            List<Action> buildActions = new ArrayList<>();
            if (dep.shouldTriggerBuild(build, listener, buildActions)) {
                AbstractProject p = dep.getDownstreamProject();
                // Allow shouldTriggerBuild to return false first, in case it is skipping because of a lack of Item.READ/DISCOVER permission:
                if (p.isDisabled()) {
                    logger.println(Messages.BuildTrigger_Disabled(ModelHyperlinkNote.encodeTo(p)));
                    continue;
                }
                boolean scheduled = p.scheduleBuild(p.getQuietPeriod(), new UpstreamCause((Run)build), buildActions.toArray(new Action[0]));
                if (Jenkins.getInstance().getItemByFullName(p.getFullName()) == p) {
                    String name = ModelHyperlinkNote.encodeTo(p);
                    if (scheduled) {
                        logger.println(Messages.BuildTrigger_Triggering(name));
                    } else {
                        logger.println(Messages.BuildTrigger_InQueue(name));
                    }
                } // otherwise upstream users should not know that it happened
            }
        }

        return true;
    }
586332
protected function doJob(AbstractJob $job)
    {
        $this->validateJobParams($job);

        $resultData = SmsWorker::buildResultDataDefault(__NAMESPACE__);

        try {
            $transport = $this->getTransport();
            $transport->sendSMS($job->getSender(), $job->getRecipient(), $job->getText());

            $response = $transport->getResponse();
            $resultData[SmsWorker::P_RESULT_DATA_SUCCESS] = (count($response['errors']) == 0);
            $resultData[SmsWorker::P_RESULT_DATA_VENDOR_ID] = $response['id'];
            $resultData[SmsWorker::P_RESULT_DATA_ERRORS] = $response['errors'];

            $job->addDebug(['vendor_response' => $response]);

        } catch (\Exception $ex) {
            $job->addDebug(['exception' => $ex->getMessage()]);
            throw new ResultException(ResultException::ERROR_TRANSPORT);
        }


        if (false === $resultData[SmsWorker::P_RESULT_DATA_SUCCESS]) {

            if (!$job->isSync()) {
                // redirect result for new root gateway class
                $gatewayClass = static::getConfig(SmsWorker::GATEWAY_DISPATCH_CLASS);
                $job->addDebug(['set_gateway' => $gatewayClass]);
                $job->setWorkerClass($gatewayClass)->save();
                throw new ResultException(ResultException::RETRY_GATEWAY_DISPATCH_CLASS);
            }

            throw new ResultException(ResultException::R_FAILURE, $resultData);
        }

        throw new ResultException(ResultException::R_SUCCESS, $resultData);
    }
116659
@Override
    public Run<?, ?> resolve(Job<?, ?> job) {
        File f = getPermalinkFile(job);
        Run<?,?> b=null;

        try {
            String target = readSymlink(f);
            if (target!=null) {
                int n = Integer.parseInt(Util.getFileName(target));
                if (n==RESOLVES_TO_NONE)  return null;

                b = job.getBuildByNumber(n);
                if (b!=null && apply(b))
                    return b;   // found it (in the most efficient way possible)

                // the cache is stale. start the search
                if (b==null)
                     b=job.getNearestOldBuild(n);
            }
        } catch (InterruptedException e) {
            LOGGER.log(Level.WARNING, "Failed to read permalink cache:" + f, e);
            // if we fail to read the cache, fall back to the re-computation
        } catch (NumberFormatException e) { 
            LOGGER.log(Level.WARNING, "Failed to parse the build number in the permalink cache:" + f, e);
            // if we fail to read the cache, fall back to the re-computation
        } catch (IOException e) {
            // this happens when the symlink doesn't exist
            // (and it cannot be distinguished from the case when the actual I/O error happened
        }

        if (b==null) {
            // no cache
            b = job.getLastBuild();
        }

        // start from the build 'b' and locate the build that matches the criteria going back in time
        b = find(b);

        updateCache(job,b);
        return b;
    }
180352
public static PainGeneratorIf get(AbstractHBCIJob job, SepaVersion version) throws ClassNotFoundException,
        InstantiationException, IllegalAccessException {
        String jobname = ((AbstractSEPAGV) job).getPainJobName(); // referenzierter pain-Geschäftsvorfall
        return get(jobname, version);
    }
806022
protected Object execute(final Job job, final String curQueue, final Object instance) throws Exception {
        if (instance instanceof WorkerAware) {
            ((WorkerAware) instance).setWorker(this);
        }
        this.listenerDelegate.fireEvent(JOB_EXECUTE, this, curQueue, job, instance, null, null);
        final Object result;
        if (instance instanceof Callable) {
            result = ((Callable<?>) instance).call(); // The job is executing!
        } else if (instance instanceof Runnable) {
            ((Runnable) instance).run(); // The job is executing!
            result = null;
        } else { // Should never happen since we're testing the class earlier
            throw new ClassCastException(
                    "Instance must be a Runnable or a Callable: " + instance.getClass().getName() + " - " + instance);
        }
        return result;
    }
1284606
@Override
	public JobExecutionResult execute(String jobName) throws Exception {
		// transform the streaming program into a JobGraph
		StreamGraph streamGraph = getStreamGraph();
		streamGraph.setJobName(jobName);

		JobGraph jobGraph = streamGraph.getJobGraph();
		jobGraph.setAllowQueuedScheduling(true);

		Configuration configuration = new Configuration();
		configuration.addAll(jobGraph.getJobConfiguration());
		configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, "0");

		// add (and override) the settings with what the user defined
		configuration.addAll(this.configuration);

		if (!configuration.contains(RestOptions.BIND_PORT)) {
			configuration.setString(RestOptions.BIND_PORT, "0");
		}

		int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, jobGraph.getMaximumParallelism());

		MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder()
			.setConfiguration(configuration)
			.setNumSlotsPerTaskManager(numSlotsPerTaskManager)
			.build();

		if (LOG.isInfoEnabled()) {
			LOG.info("Running job on local embedded Flink mini cluster");
		}

		MiniCluster miniCluster = new MiniCluster(cfg);

		try {
			miniCluster.start();
			configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort());

			return miniCluster.executeJobBlocking(jobGraph);
		}
		finally {
			transformations.clear();
			miniCluster.close();
		}
	}