/** * Creates and returns an executable job based on the supplied pipeline. * Jet will asynchronously start executing the job. */ @Nonnull default Job newJob(@Nonnull Pipeline pipeline) { return newJob(pipeline.toDag()); }
/** * Creates and returns a Jet job based on the supplied pipeline and job * configuration. Jet will asynchronously start executing the job. * * <p>If the name in the JobConfig is non-null, Jet checks if there is an * active job with equal name, in which case it throws {@link * JobAlreadyExistsException}. Job is active if it is running, * suspended or waiting to be run; that is it has not completed or failed. * Thus there can be at most one active job with a given name at a time and * you can re-use the job name after the previous job completed. * * <p>See also {@link #newJobIfAbsent}. * * @throws JobAlreadyExistsException if there is an active job with * an equal name */ @Nonnull default Job newJob(@Nonnull Pipeline pipeline, @Nonnull JobConfig config) { return newJob(pipeline.toDag(), config); }
/** * Creates and returns a Jet job based on the supplied pipeline and job * configuration. Jet will asynchronously start executing the job. * * <p>If the name in the JobConfig is non-null, Jet checks if there is an * active job with equal name. If there is, it will join that job instead * of submitting a new one. Job is active if it is running, suspended or * waiting to be run; that is it has not completed or failed. In other * words, this method ensures that the job with this name is running and is * not running multiple times in parallel. * * <p>This method is useful for microservices deployment when each package * contains a jet member and the job and you want the job to run only once. * But if the job is a batch job and runs very quickly, it can happen that * it executes multiple times, because the job name can be reused after a * previous execution completed. * * <p>If the job name is null, a new job is always submitted. * * <p>See also {@link #newJob}. */ @Nonnull default Job newJobIfAbsent(@Nonnull Pipeline pipeline, @Nonnull JobConfig config) { return newJobIfAbsent(pipeline.toDag(), config); }