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