View Javadoc

1   package com.atlassian.scheduler;
2   
3   import com.atlassian.annotations.PublicApi;
4   import com.atlassian.scheduler.config.JobConfig;
5   import com.atlassian.scheduler.config.JobId;
6   import com.atlassian.scheduler.status.RunDetails;
7   
8   import javax.annotation.Nonnull;
9   import java.util.Date;
10  
11  /**
12   * Represents a request to run a job, providing information such as the
13   * job's configuration and intended start time.
14   *
15   * @since v1.0
16   */
17  @PublicApi
18  public interface JobRunnerRequest {
19      /**
20       * Returns the time at which the job was started.  When this job completes, the {@link RunDetails} that stores the
21       * result will use this exact time for {@link com.atlassian.scheduler.status.RunDetails#getStartTime()}.
22       *
23       * @return the time at which the job was started.
24       */
25      @Nonnull
26      Date getStartTime();
27  
28      /**
29       * Returns the job ID that was used to schedule this job.
30       *
31       * @return the job ID that was used to schedule this job.
32       */
33      @Nonnull
34      JobId getJobId();
35  
36      /**
37       * Returns the job's configuration, such as its schedule and parameters.
38       *
39       * @return the job's configuration
40       */
41      @Nonnull
42      JobConfig getJobConfig();
43  
44      /**
45       * Returns {@code true} if the job runner should terminate its activities as gracefully as possible
46       * and exit; {@code false} to continue running normally.
47       * <p>
48       * Job cancellation is entirely cooperative.  If a job is likely to take longer than a few seconds
49       * to complete its work, then it should periodically check this value and react to it.  Normally,
50       * cancellation is requested because the application is trying to shut down, and continuing to run
51       * after this flag has been set increases the chance that the system administrator will grow
52       * impatient and forcibly kill the application.
53       * </p>
54       *
55       * @return {@code true} if cancellation is requested; {@code false} otherwise
56       */
57      boolean isCancellationRequested();
58  }