當前位置: 首頁>>代碼示例>>Java>>正文


Java Scheduler.getTriggerState方法代碼示例

本文整理匯總了Java中org.quartz.Scheduler.getTriggerState方法的典型用法代碼示例。如果您正苦於以下問題:Java Scheduler.getTriggerState方法的具體用法?Java Scheduler.getTriggerState怎麽用?Java Scheduler.getTriggerState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.Scheduler的用法示例。


在下文中一共展示了Scheduler.getTriggerState方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRunningJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 所有正在運行的job
 * 
 * @return
 * @throws SchedulerException
 */
public List<ScheduleJob> getRunningJob() throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
    List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
    for (JobExecutionContext executingJob : executingJobs) {
        ScheduleJob job = new ScheduleJob();
        JobDetail jobDetail = executingJob.getJobDetail();
        JobKey jobKey = jobDetail.getKey();
        Trigger trigger = executingJob.getTrigger();
        job.setName(jobKey.getName());
        job.setGroup(jobKey.getGroup());
        job.setDescription("觸發器:" + trigger.getKey());
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
        job.setStatus(triggerState.name());
        if (trigger instanceof CronTrigger) {
            CronTrigger cronTrigger = (CronTrigger) trigger;
            String cronExpression = cronTrigger.getCronExpression();
            job.setCron(cronExpression);
        }
        jobList.add(job);
    }
    return jobList;
}
 
開發者ID:Zigin,項目名稱:MonitorPlatform,代碼行數:30,代碼來源:JobConfigService.java

示例2: getAllJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 獲取所有計劃中的任務列表
 * 
 * @return
 * @throws SchedulerException
 */
public List<ScheduleJob> getAllJob() throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();
    Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);
    List<ScheduleJob> jobList = new ArrayList<ScheduleJob>();
    for (JobKey jobKey : jobKeys) {
        List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
        for (Trigger trigger : triggers) {
            ScheduleJob job = new ScheduleJob();
            job.setName(jobKey.getName());
            job.setGroup(jobKey.getGroup());
            job.setDescription("觸發器:" + trigger.getKey());
            Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
            job.setStatus(triggerState.name());
            if (trigger instanceof CronTrigger) {
                CronTrigger cronTrigger = (CronTrigger) trigger;
                String cronExpression = cronTrigger.getCronExpression();
                job.setCron(cronExpression);
            }
            jobList.add(job);
        }
    }
    return jobList;
}
 
開發者ID:Zigin,項目名稱:MonitorPlatform,代碼行數:31,代碼來源:JobConfigService.java

示例3: wrapScheduleJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
private void wrapScheduleJob(ScheduleJob scheduleJob,Scheduler scheduler,JobKey jobKey,Trigger trigger){  
    try {  
        scheduleJob.setJobName(jobKey.getName());  
        scheduleJob.setJobGroup(jobKey.getGroup()); 
  
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);  
        ScheduleJob job = (ScheduleJob)jobDetail.getJobDataMap().get("scheduleJob");  
        scheduleJob.setDesc(job.getDesc());  
        scheduleJob.setJobId(job.getJobId());
  
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());  
        scheduleJob.setJobStatus(triggerState.name());  
        if(trigger instanceof CronTrigger){  
            CronTrigger cronTrigger = (CronTrigger)trigger;  
            String cronExpression = cronTrigger.getCronExpression();  
            scheduleJob.setCronExpression(cronExpression);  
        }  
    } catch (SchedulerException e) {  
        e.printStackTrace(); 
    }  
}
 
開發者ID:jiwenxing,項目名稱:springboot-quartz,代碼行數:22,代碼來源:ScheduleJobService.java

示例4: wrapScheduleJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 封裝ScheduleJob對象
 * 
 * @param scheduleJob
 * @param scheduler
 * @param jobKey
 * @param trigger
 */
private void wrapScheduleJob(ScheduleJobEntity scheduleJob,
		Scheduler scheduler, JobKey jobKey, Trigger trigger) {
	try {
		scheduleJob.setJobName(jobKey.getName());
		scheduleJob.setJobGroup(jobKey.getGroup());

		JobDetail jobDetail = scheduler.getJobDetail(jobKey);
		scheduleJob.setJobClass(jobDetail.getJobClass());
		scheduleJob.setJobDesc(jobDetail.getDescription());
		
		Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
		scheduleJob.setTriggerStatus(triggerState.name());
		
		if (trigger instanceof CronTrigger) {
			CronTrigger cronTrigger = (CronTrigger) trigger;
			TriggerKey triggerKey = cronTrigger.getKey();
			scheduleJob.setTriggerName(triggerKey.getName());
			scheduleJob.setTriggerGroup(triggerKey.getGroup());
			scheduleJob.setNextFireTime(cronTrigger.getNextFireTime());
			scheduleJob.setCronExpression(cronTrigger.getCronExpression());
			scheduleJob.setStartDate(cronTrigger.getStartTime());
			scheduleJob.setEndDate(cronTrigger.getEndTime());
		}
	} catch (SchedulerException e) {
		logger.error("獲取觸發器狀態失敗", e);
		throw new ServiceException(e);
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:37,代碼來源:ScheduleJobServiceImpl.java

示例5: getJobState

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * Get the current state of job
 */
public String getJobState(String jobName) {
	System.out.println("JobServiceImpl.getJobState()");

	try {
		String groupKey = "SampleGroup";
		JobKey jobKey = new JobKey(jobName, groupKey);

		Scheduler scheduler = schedulerFactoryBean.getScheduler();
		JobDetail jobDetail = scheduler.getJobDetail(jobKey);

		List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobDetail.getKey());
		if(triggers != null && triggers.size() > 0){
			for (Trigger trigger : triggers) {
				TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());

				if (TriggerState.PAUSED.equals(triggerState)) {
					return "PAUSED";
				}else if (TriggerState.BLOCKED.equals(triggerState)) {
					return "BLOCKED";
				}else if (TriggerState.COMPLETE.equals(triggerState)) {
					return "COMPLETE";
				}else if (TriggerState.ERROR.equals(triggerState)) {
					return "ERROR";
				}else if (TriggerState.NONE.equals(triggerState)) {
					return "NONE";
				}else if (TriggerState.NORMAL.equals(triggerState)) {
					return "SCHEDULED";
				}
			}
		}
	} catch (SchedulerException e) {
		System.out.println("SchedulerException while checking job with name and group exist:"+e.getMessage());
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:40,代碼來源:JobServiceImpl.java

示例6: jobs

import org.quartz.Scheduler; //導入方法依賴的package包/類
@Override
public Collection<JobDetailInfo> jobs() throws SchedulerException {
	List<JobDetailInfo> jobDetailInfoes = new ArrayList<>();
	Scheduler scheduler = schedulerFactoryBean.getScheduler();
	GroupMatcher<JobKey> jobMatcher = GroupMatcher.anyJobGroup();
	Set<JobKey> jobKeys = scheduler.getJobKeys(jobMatcher);

	for (JobKey jobKey : jobKeys) {
		JobDetail jobDetail = scheduler.getJobDetail(jobKey);
		List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);

		for (Trigger trigger : triggers) {
			JobDetailInfo jobDetailInfo = new JobDetailInfo();

			jobDetailInfo.setJobName(jobKey.getName());
			jobDetailInfo.setJobGroupName(jobKey.getGroup());
			jobDetailInfo.setJobDescription(jobDetail.getDescription());
			jobDetailInfo.setJobClassName(jobDetail.getJobClass().getName());
			jobDetailInfo.setTriggerName(trigger.getKey().getName());
			jobDetailInfo.setTriggerGroupName(trigger.getKey().getGroup());
			jobDetailInfo.setTriggerDescription(trigger.getDescription());

			CronTrigger cronTrigger = (CronTrigger) trigger;

			jobDetailInfo.setTriggerCronExpression(cronTrigger.getCronExpression());
			jobDetailInfo.setStartTime(new DateTime(trigger.getStartTime()).toString("yyyy-MM-dd HH:mm:ss"));
			jobDetailInfo.setEndTime(new DateTime(trigger.getEndTime()).toString("yyyy-MM-dd HH:mm:ss"));
			jobDetailInfo
					.setFinalFireTime(new DateTime(trigger.getFinalFireTime()).toString("yyyy-MM-dd HH:mm:ss"));
			jobDetailInfo.setPreviousFireTime(
					new DateTime(trigger.getPreviousFireTime()).toString("yyyy-MM-dd HH:mm:ss"));
			jobDetailInfo.setNextFireTime(new DateTime(trigger.getNextFireTime()).toString("yyyy-MM-dd HH:mm:ss"));
			jobDetailInfo.setMisfireInstruction(trigger.getMisfireInstruction());

			TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());

			jobDetailInfo.setJobState(triggerState.name());

			jobDetailInfoes.add(jobDetailInfo);
		}
	}

	return jobDetailInfoes;

}
 
開發者ID:easynet-cn,項目名稱:easynetcn-cloud,代碼行數:46,代碼來源:JobServiceImpl.java

示例7: getTriggerState

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 獲取
 * @param trigger
 * @param scheduler
 * @return
 * @throws SchedulerException
 */
public static TriggerState getTriggerState(Trigger trigger, Scheduler scheduler) throws SchedulerException {
    TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
    return triggerState;
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:12,代碼來源:QuartzUtils.java

示例8: triggerStateEquals

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 對比兩個Trigger是否相等
 * @param trigger
 * @param triggerState
 * @param scheduler
 * @return
 * @throws SchedulerException
 */
public static boolean triggerStateEquals(Trigger trigger, TriggerState triggerState, Scheduler scheduler)
        throws SchedulerException {
    TriggerState sourceTriggerState = scheduler.getTriggerState(trigger.getKey());
    return sourceTriggerState.ordinal() == triggerState.ordinal();
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:14,代碼來源:QuartzUtils.java


注:本文中的org.quartz.Scheduler.getTriggerState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。