mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-15 04:02:53 +00:00
added java doc and some comments to scheduling module
This commit is contained in:
@@ -2,11 +2,14 @@ package dev.sheldan.abstracto.scheduling.model.database;
|
||||
|
||||
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The scheduler job instance according to the properties stored in the database. This is needed in order to have a
|
||||
* reference of the jobs which *can* be scheduled.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@@ -20,16 +23,34 @@ public class SchedulerJob {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The name of the job
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The group of the job
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* The absolute path of a class extending {@link org.springframework.scheduling.quartz.QuartzJobBean} which should be executed by this job
|
||||
*/
|
||||
private String clazz;
|
||||
|
||||
/**
|
||||
* If the job should be executed based on a cron expression, this contains this expression. If it is a one-time job this needs to be null.
|
||||
*/
|
||||
private String cronExpression;
|
||||
|
||||
/**
|
||||
* Whether or not the job is active and available to be scheduled.
|
||||
*/
|
||||
private boolean active;
|
||||
|
||||
/**
|
||||
* Whether or not the job should be re-tried in an recovery of fail over situation.
|
||||
*/
|
||||
private boolean recovery;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,16 +6,76 @@ import org.quartz.JobDataMap;
|
||||
import java.util.Date;
|
||||
|
||||
public interface SchedulerService {
|
||||
/**
|
||||
* Starts all the currently active and available jobs from the database with their respective configuration
|
||||
*/
|
||||
void startScheduledJobs();
|
||||
|
||||
/**
|
||||
* Schedules the given {@link SchedulerJob} instance directly
|
||||
* @param job The job to schedule
|
||||
*/
|
||||
void scheduleJob(SchedulerJob job);
|
||||
|
||||
/**
|
||||
* Updates an already scheduled job, with the same name and group, with the new {@link SchedulerJob} configuration
|
||||
* @param job The new configuration of the job to use. The name and the group of the job to update are taken from this object as well.
|
||||
* @param startDate The date at which this scheduled job should start executing
|
||||
*/
|
||||
void updateJob(SchedulerJob job, Date startDate);
|
||||
boolean unScheduleJob(String jobName);
|
||||
|
||||
/**
|
||||
* Removes a job from the scheduler.
|
||||
* @param triggerKey The key of the trigger to unschedule
|
||||
* @return if the job was found and unscheduled
|
||||
*/
|
||||
boolean unScheduleJob(String triggerKey);
|
||||
|
||||
/**
|
||||
* Deletes the job from the scheduler.
|
||||
* @param job The {@link SchedulerJob} instance containing the configuration of the job to remove
|
||||
* @return fi the job was found and deleted
|
||||
*/
|
||||
boolean deleteJob(SchedulerJob job);
|
||||
|
||||
/**
|
||||
* Pauses the given job in the scheduler
|
||||
* @param job The {@link SchedulerJob} instance containing the configuration of the job to pause
|
||||
* @return fi the job was found and paused
|
||||
*/
|
||||
boolean pauseJob(SchedulerJob job);
|
||||
|
||||
/**
|
||||
* Continues the job in the scheduler.
|
||||
* @param job The {@link SchedulerJob} instance containing the configuration of the job to continue
|
||||
* @return fi the job was found and continued
|
||||
*/
|
||||
boolean continueJob(SchedulerJob job);
|
||||
/**
|
||||
* Executes the job directly in the scheduler.
|
||||
* @param job The {@link SchedulerJob} instance containing the configuration of the job to execute directly
|
||||
* @return fi the job was found and executed directly
|
||||
*/
|
||||
boolean executeJob(SchedulerJob job);
|
||||
|
||||
/**
|
||||
* Executes the job identified by name and group with the given {@link JobDataMap} as parameters on the given {@link Date}
|
||||
* @param name The name of the job to execute
|
||||
* @param group The group of the job to execute
|
||||
* @param dataMap The {@link JobDataMap} made available to the group
|
||||
* @param date The {@link Date} at which the job should be execute at.
|
||||
* @return The trigger key which triggers the job at the given date
|
||||
*/
|
||||
String executeJobWithParametersOnce(String name, String group, JobDataMap dataMap, Date date);
|
||||
String startCronJobWithParameters(String name, String group, JobDataMap dataMap, String cronExpression);
|
||||
|
||||
/**
|
||||
* Stops the trigger identified by the trigger key.
|
||||
* @param triggerKey The key of the trigger to stop
|
||||
*/
|
||||
void stopTrigger(String triggerKey);
|
||||
|
||||
/**
|
||||
* Actually starts the scheduler.
|
||||
*/
|
||||
void startScheduler();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user