Class ScheduleUtil

java.lang.Object
com.atlassian.confluence.schedule.ScheduleUtil

public class ScheduleUtil extends Object
A general utility class for scheduling.
Since:
5.10
  • Field Details

    • BACKUP_JOB_ID

      public static final com.atlassian.scheduler.config.JobId BACKUP_JOB_ID
    • SCHEDULER_FLUSH_TIMEOUT_SECONDS_PROPERTY_NAME

      public static final String SCHEDULER_FLUSH_TIMEOUT_SECONDS_PROPERTY_NAME
      The customer can set the value of this property to override the default timeout value - 2 minutes.
      See Also:
  • Constructor Details

    • ScheduleUtil

      public ScheduleUtil()
  • Method Details

    • isBackupEnabled

      public static boolean isBackupEnabled(ScheduledJobManager scheduledJobManager, Settings settings)
      Determines if the backup job is enabled.
    • calculateNextRunTime

      public static @Nullable Date calculateNextRunTime(com.atlassian.scheduler.SchedulerService schedulerService, com.atlassian.scheduler.config.JobConfig jobConfig, @Nullable Date thisRunTime) throws com.atlassian.scheduler.SchedulerServiceException
      As Javadoc of SchedulerService#calculateNextRunTime says, for interval job the result may not be correct, so we calculate by ourselves.
      Returns:
      null if repeat count reached
      Throws:
      com.atlassian.scheduler.SchedulerServiceException
    • generateUniqueJobId

      public static com.atlassian.scheduler.config.JobId generateUniqueJobId(com.atlassian.scheduler.SchedulerService schedulerService, String idPrefix) throws com.atlassian.scheduler.SchedulerServiceException
      Instead of using SchedulerService.scheduleJobWithGeneratedId(com.atlassian.scheduler.config.JobConfig), you can use SchedulerService.scheduleJob(com.atlassian.scheduler.config.JobId, com.atlassian.scheduler.config.JobConfig) with the result of this method.
      Throws:
      com.atlassian.scheduler.SchedulerServiceException
    • pauseAndFlushSchedulerService

      public static void pauseAndFlushSchedulerService(com.atlassian.scheduler.core.LifecycleAwareSchedulerService schedulerService) throws com.atlassian.scheduler.SchedulerServiceException
      If there's error, it will be wrapped in a SchedulerServiceException.
      Throws:
      com.atlassian.scheduler.SchedulerServiceException
    • shutdownAndFlushSchedulerService

      public static void shutdownAndFlushSchedulerService(com.atlassian.scheduler.core.LifecycleAwareSchedulerService schedulerService) throws com.atlassian.scheduler.SchedulerServiceException
      If there's error, it will be wrapped in a SchedulerServiceException.
      Throws:
      com.atlassian.scheduler.SchedulerServiceException
    • getSchedulerFlushTimeout

      public static long getSchedulerFlushTimeout()
    • withJitterSecs

      public static Map<String,Serializable> withJitterSecs(int jitterSecs)
      atlassian-scheduler doesn't support schedule jittering. We encode jitterSecs in JobConfig parameters.
    • withJitterSecs

      public static Map<String,Serializable> withJitterSecs(Map<String,Serializable> parameters, int jitterSecs)
      atlassian-scheduler doesn't support schedule jittering. We encode jitterSecs in JobConfig parameters.
    • getJitterSecs

      public static int getJitterSecs(Map<String,Serializable> parameters)
    • withoutJitterSecs

      public static Map<String,Serializable> withoutJitterSecs(Map<String,Serializable> parameters)
    • withUnscheduleJobAfterTimestampMillis

      public static Map<String,Serializable> withUnscheduleJobAfterTimestampMillis(long repeatInterval, int repeatCount, @Nullable Date firstRunTime)
      atlassian-scheduler interval jobs don't support repeat count. We encode repeat count as the timestamp to unschedule in JobConfig parameters: unschedule timestamp = firstRunTime (or now) + repeatInterval x repeatCount
    • withUnscheduleJobAfterTimestampMillis

      public static Map<String,Serializable> withUnscheduleJobAfterTimestampMillis(Map<String,Serializable> parameters, long repeatInterval, int repeatCount, @Nullable Date firstRunTime)
      atlassian-scheduler doesn't support repeat count. We encode repeat count as the timestamp to unschedule the job in JobConfig parameters: unschedule timestamp = firstRunTime (or now) + repeatInterval x repeatCount
    • getUnscheduleJobAfterTimestampMillis

      public static long getUnscheduleJobAfterTimestampMillis(Map<String,Serializable> parameters)
    • getRepeatCount

      public static int getRepeatCount(Map<String,Serializable> parameters)
    • withTimeZone

      public static com.atlassian.scheduler.config.JobConfig withTimeZone(com.atlassian.scheduler.config.JobConfig jobConfig, TimeZone timeZone)
      Returns a new JobConfig with the specified time zone if its schedule is of type CRON_EXPRESSION and the time zone has changed.
    • withCronSchedule

      public static com.atlassian.scheduler.config.JobConfig withCronSchedule(com.atlassian.scheduler.config.JobConfig jobConfig, @Nullable String cronExpression, TimeZone timeZone)
      Returns a new JobConfig with the new cronExpression and time zone if its schedule is of type CRON_EXPRESSION and the time zone has changed. If the new cronExpression is null, only the time zone is changed if it has changed.
    • getJobConfig

      public static com.atlassian.scheduler.config.JobConfig getJobConfig(ScheduledJobConfiguration configuration, ManagedScheduledJob job, TimeZone timeZone)
      Builds JobConfig from info in configuration, with fallback info from job.