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


Java Scheduler.checkExists方法代碼示例

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


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

示例1: isJobWithNamePresent

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * Check job exist with given name
 */
@Override
public boolean isJobWithNamePresent(String jobName) {
	try {
		String groupKey = "SampleGroup";
		JobKey jobKey = new JobKey(jobName, groupKey);
		Scheduler scheduler = schedulerFactoryBean.getScheduler();
		if (scheduler.checkExists(jobKey)){
			return true;
		}
	} catch (SchedulerException e) {
		System.out.println("SchedulerException while checking job with name and group exist:"+e.getMessage());
		e.printStackTrace();
	}
	return false;
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:19,代碼來源:JobServiceImpl.java

示例2: hasSchedule

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 是否有這個任務
 * 
 * @param name
 * @return
 * @throws SchedulerException
 */
public boolean hasSchedule(String name) throws SchedulerException {
	Scheduler scheduler = SF.getScheduler();
	if (scheduler == null) {
		return false;
	}
	return scheduler.checkExists(new JobKey(name, Scheduler.DEFAULT_GROUP));
}
 
開發者ID:HankXV,項目名稱:Limitart,代碼行數:15,代碼來源:SchedulerUtil.java

示例3: executeScheduleJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 執行計劃任務
 * @param job
 * @param trigger
 * @return
 * @throws SchedulerException
 */
public static ScheduleJobResult executeScheduleJob(JobDetail job, Trigger trigger) throws SchedulerException {
    ScheduleJobResult scheduleJobResult = new ScheduleJobResult();
    //判斷是否滿足計劃任務的創建條件
    if(job.getKey() == null || trigger.getKey() == null || job.getJobDataMap() == null){
        scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.FAILED);
        //不滿足計劃任務的創建條件,返回scheduleJobResult值類
        return scheduleJobResult;
    }
    scheduleJobResult.setJobDetail(job);
    scheduleJobResult.setTrigger(trigger);
    //開始分配計劃任務
    Scheduler scheduler  = SchedulerFactory.getScheduler();
    //開始判斷是否存在相同的計劃任務
    if(scheduler.checkExists(job.getKey())){
        log.info("存在相同的計劃任務:{}",job.getKey());
        scheduler.deleteJob(job.getKey());
        scheduleJobResult.setJobKey(job.getKey());
        scheduleJobResult.setTriggerKey(trigger.getKey());
        scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.ISEXIST);
        scheduler.scheduleJob(job,trigger);
        scheduler.start();
    }else{
        scheduler.scheduleJob(job,trigger);
        scheduler.start();
        scheduleJobResult.setJobKey(job.getKey());
        scheduleJobResult.setTriggerKey(trigger.getKey());
        scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.SUCCESS);
    }
    //計劃任務分配成功
    return scheduleJobResult;
}
 
開發者ID:DevopsJK,項目名稱:SuitAgent,代碼行數:39,代碼來源:SchedulerUtil.java

示例4: scheduleJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
private void scheduleJob(final Scheduler scheduler, final JobDetail jobDetail, final String triggerIdentity, final String cron) {
    try {
        if (!scheduler.checkExists(jobDetail.getKey())) {
            scheduler.scheduleJob(jobDetail, createTrigger(triggerIdentity, cron));
        }
        scheduler.start();
        RUNNING_SCHEDULERS.putIfAbsent(scheduler.getSchedulerName(), scheduler);
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:12,代碼來源:DaemonTaskScheduler.java

示例5: executeJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
@Transactional
@Override
public boolean executeJob(JobKey jobKey) {
	try {
		Scheduler scheduler = schedulerFactoryBean.getScheduler();
		if(scheduler.checkExists(jobKey))
		{
			scheduler.triggerJob(jobKey);
		}
	} catch (SchedulerException e) {
		throw new ServiceException(e);
	}
	return Boolean.TRUE;
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:15,代碼來源:ScheduleJobServiceImpl.java

示例6: removeJobFromScheduler

import org.quartz.Scheduler; //導入方法依賴的package包/類
public void removeJobFromScheduler(String jobDefId,String companyId) throws SchedulerException {
	Scheduler scheduler=schedulerService.retrieveScheduler();
	JobKey jobKey=new JobKey(JOB_PREFIX+jobDefId,companyId);
	TriggerKey triggerKey=new TriggerKey(TRIGGER_PREFIX+jobDefId,companyId);
	if(scheduler.checkExists(jobKey)){
		scheduler.pauseTrigger(triggerKey);
		scheduler.unscheduleJob(triggerKey);
		scheduler.deleteJob(jobKey);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:11,代碼來源:JobServiceImpl.java

示例7: maybeScheduleArchiveJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * Schedule the archiving job based on the interval defined in the DB.
 *
 * If archiving is disabled, deletes the archiving job.
 */
@Override
public void maybeScheduleArchiveJob() {
    try {
        BaseDtoResponse<JobsArchiveDto> reponse = this.jobsArchiveService.dispatch(new Request() {
        });

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        boolean doesJobExists = scheduler.checkExists(new JobKey(ARCHIVE_JOB_NAME,
                ARCHIVE_GROUP_NAME));

        if (reponse.getDto().getAutoSchedule() && !doesJobExists) {
            JobDataMap jobDataMap = new JobDataMap();
            jobDataMap.put(GetJobsArchiveServiceApi.class.getName(), this.jobsArchiveService);
            jobDataMap.put(ArchiveServiceApi.class.getName(), this);

            JobDetail archiveJob = JobBuilder.newJob(ArchiveScheduledJob.class)
                    .usingJobData(jobDataMap)
                    .withIdentity(ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME).build();

            Trigger archiveTrigger = TriggerBuilder
                    .newTrigger()
                    .startAt(DateUtils.addMinutes(new Date(), ARCHIVE_STARTUP_DELAY_IN_MIN))
                    .withSchedule(
                            SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever()
                            .withMisfireHandlingInstructionFireNow()).build();

            scheduler.scheduleJob(archiveJob, archiveTrigger);

            log.info("Archiving job check is scheduled to run every 24 hours. Starting at: "
                    + archiveTrigger.getStartTime());

        } else if (!reponse.getDto().getAutoSchedule()) {
            // If archiving is disabled, delete the job if it exists
            if (scheduler.deleteJob(new JobKey(ArchiveScheduledJob.ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME))) {
                log.info("Archiving job Deleted");
            }
        }
    } catch (Exception e) {
        log.error("Scheduler fail to start/stop Archiving job", e);
        this.alertGenerator.processSystemFailureEvent(SystemFailureType.ARCHIVE_FAILURE,
                new LockObjectReference(1L, "Archive Settings", ObjectType.ARCHIVE),
                "Failure during archive schedule configuration " + e.getMessage());
    }
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:50,代碼來源:ArchiveService.java

示例8: checkJobExists

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 核查Job在scheduler是否存在
 * @param jobDetail
 * @param scheduler
 * @throws SchedulerException
 */
public static void checkJobExists(JobDetail jobDetail, Scheduler scheduler) throws SchedulerException {
    scheduler.checkExists(jobDetail.getKey());
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:10,代碼來源:QuartzUtils.java

示例9: checkTriggerExists

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 核查Trigger在scheduler是否存在
 *
 * @param trigger
 * @param scheduler
 * @return
 * @throws SchedulerException
 */
public static boolean checkTriggerExists(Trigger trigger, Scheduler scheduler) throws SchedulerException {
    return scheduler.checkExists(trigger.getKey());
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:12,代碼來源:QuartzUtils.java


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