当前位置: 首页>>代码示例>>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;未经允许,请勿转载。