Java Code Examples for com.xxl.job.admin.core.model.XxlJobInfo#setJobStatus()

The following examples show how to use com.xxl.job.admin.core.model.XxlJobInfo#setJobStatus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XxlJobDynamicScheduler.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
/**
    * fill job info
    *
    * @param jobInfo
    */
public static void fillJobInfo(XxlJobInfo jobInfo) {
	// TriggerKey : name + group
       String group = String.valueOf(jobInfo.getJobGroup());
       String name = String.valueOf(jobInfo.getId());
       TriggerKey triggerKey = TriggerKey.triggerKey(name, group);

       try {
		Trigger trigger = scheduler.getTrigger(triggerKey);

		TriggerState triggerState = scheduler.getTriggerState(triggerKey);
		
		// parse params
		if (trigger!=null && trigger instanceof CronTriggerImpl) {
			String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
			jobInfo.setJobCron(cronExpression);
		}

		//JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup()));
           //JobDetail jobDetail = scheduler.getJobDetail(jobKey);
           //String jobClass = jobDetail.getJobClass().getName();

		if (triggerState!=null) {
			jobInfo.setJobStatus(triggerState.name());
		}
		
	} catch (SchedulerException e) {
		logger.error(e.getMessage(), e);
	}
}
 
Example 2
Source File: XxlJobDynamicScheduler.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
    * fill job info
    *
    * @param jobInfo
    */
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);
       try {

           // trigger cron
		Trigger trigger = scheduler.getTrigger(triggerKey);
		if (trigger!=null && trigger instanceof CronTriggerImpl) {
			String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
			jobInfo.setJobCron(cronExpression);
		}

           // trigger state
           TriggerState triggerState = scheduler.getTriggerState(triggerKey);
		if (triggerState!=null) {
			jobInfo.setJobStatus(triggerState.name());
		}

           //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup()));
           //JobDetail jobDetail = scheduler.getJobDetail(jobKey);
           //String jobClass = jobDetail.getJobClass().getName();
		
	} catch (SchedulerException e) {
		logger.error(e.getMessage(), e);
	}
}
 
Example 3
Source File: XxlJobDynamicScheduler.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
/**
 * fill job info
 *
 * @param jobInfo
 */
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);
    try {

        // trigger cron
        Trigger trigger = scheduler.getTrigger(triggerKey);
        if (trigger != null && trigger instanceof CronTriggerImpl) {
            String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
            jobInfo.setJobCron(cronExpression);
        }

        // trigger state
        TriggerState triggerState = scheduler.getTriggerState(triggerKey);
        if (triggerState != null) {
            jobInfo.setJobStatus(triggerState.name());
        }

    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 4
Source File: XxlJobDynamicScheduler.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * fill job info
 *
 * @param jobInfo
 */
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);
    try {

        // trigger cron
        Trigger trigger = scheduler.getTrigger(triggerKey);
        if (trigger != null && trigger instanceof CronTriggerImpl) {
            String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
            jobInfo.setJobCron(cronExpression);
        }

        // trigger state
        TriggerState triggerState = scheduler.getTriggerState(triggerKey);
        if (triggerState != null) {
            jobInfo.setJobStatus(triggerState.name());
        }

    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
}