|
|
|
@ -164,11 +164,10 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
*/ |
|
|
|
|
public static void fillJobInfo(XxlJobInfo jobInfo) { |
|
|
|
|
|
|
|
|
|
String group = String.valueOf(jobInfo.getJobGroup()); |
|
|
|
|
String name = String.valueOf(jobInfo.getId()); |
|
|
|
|
|
|
|
|
|
// trigger key
|
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(name, group); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(name); |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
// trigger cron
|
|
|
|
@ -198,15 +197,14 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
* add trigger + job |
|
|
|
|
* |
|
|
|
|
* @param jobName |
|
|
|
|
* @param jobGroup |
|
|
|
|
* @param cronExpression |
|
|
|
|
* @return |
|
|
|
|
* @throws SchedulerException |
|
|
|
|
*/ |
|
|
|
|
public static boolean addJob(String jobName, String jobGroup, String cronExpression) throws SchedulerException { |
|
|
|
|
public static boolean addJob(String jobName, String cronExpression) throws SchedulerException { |
|
|
|
|
// 1、job key
|
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup); |
|
|
|
|
JobKey jobKey = new JobKey(jobName, jobGroup); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName); |
|
|
|
|
JobKey jobKey = new JobKey(jobName); |
|
|
|
|
|
|
|
|
|
// 2、valid
|
|
|
|
|
if (scheduler.checkExists(triggerKey)) { |
|
|
|
@ -239,16 +237,15 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
* remove trigger + job |
|
|
|
|
* |
|
|
|
|
* @param jobName |
|
|
|
|
* @param jobGroup |
|
|
|
|
* @return |
|
|
|
|
* @throws SchedulerException |
|
|
|
|
*/ |
|
|
|
|
public static boolean removeJob(String jobName, String jobGroup) throws SchedulerException { |
|
|
|
|
public static boolean removeJob(String jobName) throws SchedulerException { |
|
|
|
|
|
|
|
|
|
JobKey jobKey = new JobKey(jobName, jobGroup); |
|
|
|
|
JobKey jobKey = new JobKey(jobName); |
|
|
|
|
scheduler.deleteJob(jobKey); |
|
|
|
|
|
|
|
|
|
/*TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup); |
|
|
|
|
/*TriggerKey triggerKey = TriggerKey.triggerKey(jobName); |
|
|
|
|
if (scheduler.checkExists(triggerKey)) { |
|
|
|
|
scheduler.unscheduleJob(triggerKey); // trigger + job
|
|
|
|
|
}*/ |
|
|
|
@ -261,16 +258,15 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
/** |
|
|
|
|
* updateJobCron |
|
|
|
|
* |
|
|
|
|
* @param jobGroup |
|
|
|
|
* @param jobName |
|
|
|
|
* @param cronExpression |
|
|
|
|
* @return |
|
|
|
|
* @throws SchedulerException |
|
|
|
|
*/ |
|
|
|
|
public static boolean updateJobCron(String jobGroup, String jobName, String cronExpression) throws SchedulerException { |
|
|
|
|
public static boolean updateJobCron(String jobName, String cronExpression) throws SchedulerException { |
|
|
|
|
|
|
|
|
|
// 1、job key
|
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName); |
|
|
|
|
|
|
|
|
|
// 2、valid
|
|
|
|
|
if (!scheduler.checkExists(triggerKey)) { |
|
|
|
@ -293,7 +289,7 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
scheduler.rescheduleJob(triggerKey, oldTrigger); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
JobKey jobKey = new JobKey(jobName, jobGroup); |
|
|
|
|
JobKey jobKey = new JobKey(jobName); |
|
|
|
|
|
|
|
|
|
// old job detail
|
|
|
|
|
JobDetail jobDetail = scheduler.getJobDetail(jobKey); |
|
|
|
@ -304,7 +300,7 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
// cover trigger of job detail
|
|
|
|
|
scheduler.scheduleJob(jobDetail, triggerSet, true);*/ |
|
|
|
|
|
|
|
|
|
logger.info(">>>>>>>>>>> resumeJob success, JobGroup:{}, JobName:{}", jobGroup, jobName); |
|
|
|
|
logger.info(">>>>>>>>>>> resumeJob success, JobName:{}", jobName); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -313,13 +309,12 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
* pause |
|
|
|
|
* |
|
|
|
|
* @param jobName |
|
|
|
|
* @param jobGroup |
|
|
|
|
* @return |
|
|
|
|
* @throws SchedulerException |
|
|
|
|
*/ |
|
|
|
|
/*public static boolean pauseJob(String jobName, String jobGroup) throws SchedulerException { |
|
|
|
|
/*public static boolean pauseJob(String jobName) throws SchedulerException { |
|
|
|
|
|
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName); |
|
|
|
|
|
|
|
|
|
boolean result = false; |
|
|
|
|
if (scheduler.checkExists(triggerKey)) { |
|
|
|
@ -336,13 +331,12 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
* resume |
|
|
|
|
* |
|
|
|
|
* @param jobName |
|
|
|
|
* @param jobGroup |
|
|
|
|
* @return |
|
|
|
|
* @throws SchedulerException |
|
|
|
|
*/ |
|
|
|
|
/*public static boolean resumeJob(String jobName, String jobGroup) throws SchedulerException { |
|
|
|
|
/*public static boolean resumeJob(String jobName) throws SchedulerException { |
|
|
|
|
|
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName); |
|
|
|
|
|
|
|
|
|
boolean result = false; |
|
|
|
|
if (scheduler.checkExists(triggerKey)) { |
|
|
|
@ -359,14 +353,13 @@ public final class XxlJobDynamicScheduler { |
|
|
|
|
* run |
|
|
|
|
* |
|
|
|
|
* @param jobName |
|
|
|
|
* @param jobGroup |
|
|
|
|
* @return |
|
|
|
|
* @throws SchedulerException |
|
|
|
|
*/ |
|
|
|
|
/*public static boolean triggerJob(String jobName, String jobGroup) throws SchedulerException { |
|
|
|
|
/*public static boolean triggerJob(String jobName) throws SchedulerException { |
|
|
|
|
// TriggerKey : name + group
|
|
|
|
|
JobKey jobKey = new JobKey(jobName, jobGroup); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup); |
|
|
|
|
JobKey jobKey = new JobKey(jobName); |
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName); |
|
|
|
|
|
|
|
|
|
boolean result = false; |
|
|
|
|
if (scheduler.checkExists(triggerKey)) { |
|
|
|
|