Package com.avoka.fc.core.service
Class SchedulerService
- java.lang.Object
-
- com.avoka.fc.core.service.BaseService
-
- com.avoka.fc.core.service.SchedulerService
-
public class SchedulerService extends BaseService
Provides a schedule service. This service provides schedule jobs handling with the quartz library.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFC_GROUP_NAMEThe group name for TM jobs
-
Constructor Summary
Constructors Constructor Description SchedulerService(org.quartz.Scheduler scheduler)Create a scheduler service given a scheduler.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjustTriggerTimezones()Go through the existing TM cron triggers and adjust their timezone.booleandeleteJob(String jobName)Delete the job for the given name, return true if the job was found.static SchedulerServicegetInstance()Return the singleton instance of the scheduler service.JobAndTriggergetJobAndTrigger(String jobName)Return the Job and Trigger for the given job nameJobAndTriggergetJobAndTrigger(String jobName, String groupName)Return the Job and Trigger for the given job nameList<JobAndTrigger>getJobAndTriggerList()Return the list of JobDetail and Trigger associations.org.quartz.JobDetailgetJobDetail(String jobName)Return the JobDetail for the given name.org.quartz.JobDetailgetJobDetail(String jobName, String groupName)Return the JobDetail for the given name.List<org.quartz.JobDetail>getJobDetailList()Return the list of scheduled JobDetails for the group name: "fc-group".org.quartz.SchedulergetScheduler()Return the scheduler instance.booleanhasJob(String jobName)Return true if the scheduler has the named job.booleanhasJob(String jobName, String groupName)Return true if the scheduler has the named job.booleaninterruptJob(String jobName)Interrupt the job for the given name, return true if the job was found.booleanisJobExecuting(String jobName)Return true if any job with the specified job name is currently executing.booleanisPaused()Return true if the scheduler is paused.voidpauseAll()Pause all the scheduled jobs, and interrupt any currently executing jobs.voidpauseJob(String jobName)Pause the job for the given name.voidresumeAll()Resume all paused jobs.voidresumeJob(String jobName)Resume the job for the given name.DatescheduleCronJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, String cronExpression)Perform a schedule cron jobDatescheduleSimpleJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, int repeatCount, long repeatInterval)Schedule a simple jobvoidsetScheduler(org.quartz.Scheduler scheduler)Sets the scheduler.voidtriggerJob(String jobName)Trigger the job for the given name.voidtriggerJob(String jobName, String groupName)Trigger the job for the given name.-
Methods inherited from class com.avoka.fc.core.service.BaseService
getLogger
-
-
-
-
Field Detail
-
FC_GROUP_NAME
public static final String FC_GROUP_NAME
The group name for TM jobs- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static SchedulerService getInstance()
Return the singleton instance of the scheduler service.- Returns:
- the singleton instance of the scheduler service
-
getScheduler
public org.quartz.Scheduler getScheduler()
Return the scheduler instance.- Returns:
- the scheduler instance
-
setScheduler
public void setScheduler(org.quartz.Scheduler scheduler)
Sets the scheduler.- Parameters:
scheduler- the new scheduler
-
scheduleSimpleJob
public Date scheduleSimpleJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, int repeatCount, long repeatInterval)
Schedule a simple job- Parameters:
jobDetail- job detailsstartDate- start date of the jobendDate- end date of the jobrepeatCount- the repeat countrepeatInterval- the repeat interval- Returns:
- the schedule date
-
scheduleCronJob
public Date scheduleCronJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, String cronExpression)
Perform a schedule cron job- Parameters:
jobDetail- job detailsstartDate- start date of the jobendDate- end date of the jobcronExpression- the cron expression for this cron job- Returns:
- the schedule date
-
isPaused
public boolean isPaused()
Return true if the scheduler is paused.- Returns:
- true if the scheduler is paused
-
isJobExecuting
public boolean isJobExecuting(String jobName)
Return true if any job with the specified job name is currently executing.- Parameters:
jobName- the name of the job- Returns:
- true if any job with the specified job name is currently executing
- Since:
- 4.1.0
-
pauseAll
public void pauseAll()
Pause all the scheduled jobs, and interrupt any currently executing jobs.
-
resumeAll
public void resumeAll()
Resume all paused jobs.
-
pauseJob
public void pauseJob(String jobName)
Pause the job for the given name.- Parameters:
jobName- the name of the job to pause
-
resumeJob
public void resumeJob(String jobName)
Resume the job for the given name.- Parameters:
jobName- the name of the job to resume
-
triggerJob
public void triggerJob(String jobName)
Trigger the job for the given name.- Parameters:
jobName- the name of the job to trigger
-
triggerJob
public void triggerJob(String jobName, String groupName)
Trigger the job for the given name.- Parameters:
jobName- the name of the job to triggergroupName- the name of the group the job belongs to- Since:
- 4.2.0
-
interruptJob
public boolean interruptJob(String jobName)
Interrupt the job for the given name, return true if the job was found.- Parameters:
jobName- the name of the job to interrupt- Returns:
- true if the job was found and interrupted.
-
deleteJob
public boolean deleteJob(String jobName)
Delete the job for the given name, return true if the job was found.- Parameters:
jobName- the name of the job to delete- Returns:
- true if the Job was found and deleted.
-
getJobDetailList
public List<org.quartz.JobDetail> getJobDetailList()
Return the list of scheduled JobDetails for the group name: "fc-group".- Returns:
- the list of scheduled JobDetails for the group name: "fc-group"
- See Also:
JobDetail
-
getJobDetail
public org.quartz.JobDetail getJobDetail(String jobName)
Return the JobDetail for the given name.- Parameters:
jobName- the job name- Returns:
- the JobDetail for the given name
-
getJobDetail
public org.quartz.JobDetail getJobDetail(String jobName, String groupName)
Return the JobDetail for the given name.- Parameters:
jobName- the job namegroupName- the group name- Returns:
- the JobDetail for the given name and group
- Since:
- 4.2.0
-
hasJob
public boolean hasJob(String jobName)
Return true if the scheduler has the named job.- Parameters:
jobName- the name of the job- Returns:
- true if the scheduler has the named job
-
hasJob
public boolean hasJob(String jobName, String groupName)
Return true if the scheduler has the named job.- Parameters:
jobName- the name of the jobgroupName- the name of the job group- Returns:
- true if the scheduler has the named job
-
getJobAndTriggerList
public List<JobAndTrigger> getJobAndTriggerList()
Return the list of JobDetail and Trigger associations.- Returns:
- the list of JobDetail and Trigger associations
-
getJobAndTrigger
public JobAndTrigger getJobAndTrigger(String jobName)
Return the Job and Trigger for the given job name- Parameters:
jobName- the name of the job- Returns:
- the Job and Trigger for the given job name
-
getJobAndTrigger
public JobAndTrigger getJobAndTrigger(String jobName, String groupName)
Return the Job and Trigger for the given job name- Parameters:
jobName- the name of the job (required)groupName- the group the job belongs to (required)- Returns:
- the Job and Trigger for the given job name
- Since:
- 4.2.0
-
adjustTriggerTimezones
public void adjustTriggerTimezones()
Go through the existing TM cron triggers and adjust their timezone. This is needed if the system timezone has changed to avoid existing jobs being scheduled at inappropriate times.- Since:
- 4.2.0
-
-