Class ScheduleUtil
java.lang.Object
com.atlassian.confluence.schedule.ScheduleUtil
A general utility class for scheduling.
- Since:
- 5.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.atlassian.scheduler.config.JobId
static final String
The customer can set the value of this property to override the default timeout value - 2 minutes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Date
calculateNextRunTime
(com.atlassian.scheduler.SchedulerService schedulerService, com.atlassian.scheduler.config.JobConfig jobConfig, @Nullable Date thisRunTime) As Javadoc of SchedulerService#calculateNextRunTime says, for interval job the result may not be correct, so we calculate by ourselves.static com.atlassian.scheduler.config.JobId
generateUniqueJobId
(com.atlassian.scheduler.SchedulerService schedulerService, String idPrefix) Instead of usingSchedulerService.scheduleJobWithGeneratedId(com.atlassian.scheduler.config.JobConfig)
, you can useSchedulerService.scheduleJob(com.atlassian.scheduler.config.JobId, com.atlassian.scheduler.config.JobConfig)
with the result of this method.static int
getJitterSecs
(Map<String, Serializable> parameters) static com.atlassian.scheduler.config.JobConfig
getJobConfig
(ScheduledJobConfiguration configuration, ManagedScheduledJob job, TimeZone timeZone) BuildsJobConfig
from info inconfiguration
, with fallback info fromjob
.static int
getRepeatCount
(Map<String, Serializable> parameters) static long
static long
getUnscheduleJobAfterTimestampMillis
(Map<String, Serializable> parameters) static boolean
isBackupEnabled
(ScheduledJobManager scheduledJobManager, Settings settings) Determines if the backup job is enabled.static void
pauseAndFlushSchedulerService
(com.atlassian.scheduler.core.LifecycleAwareSchedulerService schedulerService) If there's error, it will be wrapped in aSchedulerServiceException
.static void
shutdownAndFlushSchedulerService
(com.atlassian.scheduler.core.LifecycleAwareSchedulerService schedulerService) If there's error, it will be wrapped in aSchedulerServiceException
.static com.atlassian.scheduler.config.JobConfig
withCronSchedule
(com.atlassian.scheduler.config.JobConfig jobConfig, @Nullable String cronExpression, TimeZone timeZone) Returns a newJobConfig
with the newcronExpression
and time zone if its schedule is of typeCRON_EXPRESSION
and the time zone has changed.static Map<String,
Serializable> withJitterSecs
(int jitterSecs) atlassian-scheduler doesn't support schedule jittering.static Map<String,
Serializable> withJitterSecs
(Map<String, Serializable> parameters, int jitterSecs) atlassian-scheduler doesn't support schedule jittering.static Map<String,
Serializable> withoutJitterSecs
(Map<String, Serializable> parameters) static com.atlassian.scheduler.config.JobConfig
withTimeZone
(com.atlassian.scheduler.config.JobConfig jobConfig, TimeZone timeZone) Returns a newJobConfig
with the specified time zone if its schedule is of typeCRON_EXPRESSION
and the time zone has changed.static Map<String,
Serializable> withUnscheduleJobAfterTimestampMillis
(long repeatInterval, int repeatCount, @Nullable Date firstRunTime) atlassian-scheduler interval jobs don't support repeat count.static Map<String,
Serializable> withUnscheduleJobAfterTimestampMillis
(Map<String, Serializable> parameters, long repeatInterval, int repeatCount, @Nullable Date firstRunTime) atlassian-scheduler doesn't support repeat count.
-
Field Details
-
BACKUP_JOB_ID
public static final com.atlassian.scheduler.config.JobId BACKUP_JOB_ID -
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
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 usingSchedulerService.scheduleJobWithGeneratedId(com.atlassian.scheduler.config.JobConfig)
, you can useSchedulerService.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 aSchedulerServiceException
.- 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 aSchedulerServiceException
.- Throws:
com.atlassian.scheduler.SchedulerServiceException
-
getSchedulerFlushTimeout
public static long getSchedulerFlushTimeout() -
withJitterSecs
atlassian-scheduler doesn't support schedule jittering. We encode jitterSecs inJobConfig
parameters. -
withJitterSecs
public static Map<String,Serializable> withJitterSecs(Map<String, Serializable> parameters, int jitterSecs) atlassian-scheduler doesn't support schedule jittering. We encode jitterSecs inJobConfig
parameters. -
getJitterSecs
-
withoutJitterSecs
-
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
-
getRepeatCount
-
withTimeZone
public static com.atlassian.scheduler.config.JobConfig withTimeZone(com.atlassian.scheduler.config.JobConfig jobConfig, TimeZone timeZone) Returns a newJobConfig
with the specified time zone if its schedule is of typeCRON_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 newJobConfig
with the newcronExpression
and time zone if its schedule is of typeCRON_EXPRESSION
and the time zone has changed. If the newcronExpression
isnull
, 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) BuildsJobConfig
from info inconfiguration
, with fallback info fromjob
.
-