本文整理汇总了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;
}
示例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));
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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());
}
}
示例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());
}
示例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());
}