@Override public void pauseScheduler() { final SchedulerDetail schedulerDetail = this.schedularWritePlatformService.retriveSchedulerDetail(); if (!schedulerDetail.isSuspended()) { schedulerDetail.updateSuspendedState(true); this.schedularWritePlatformService.updateSchedulerDetail(schedulerDetail); } }
@Override public void startScheduler() { final SchedulerDetail schedulerDetail = this.schedularWritePlatformService.retriveSchedulerDetail(); if (schedulerDetail.isSuspended()) { schedulerDetail.updateSuspendedState(false); this.schedularWritePlatformService.updateSchedulerDetail(schedulerDetail); if (schedulerDetail.isExecuteInstructionForMisfiredJobs()) { final List<ScheduledJobDetail> scheduledJobDetails = this.schedularWritePlatformService.retrieveAllJobs(); for (final ScheduledJobDetail jobDetail : scheduledJobDetails) { if (jobDetail.isTriggerMisfired()) { if (jobDetail.isActiveSchedular()) { executeJob(jobDetail, SchedulerServiceConstants.TRIGGER_TYPE_CRON); } final String schedulerName = getSchedulerName(jobDetail); final Scheduler scheduler = this.schedulers.get(schedulerName); if (scheduler != null) { final String key = jobDetail.getJobKey(); final JobKey jobKey = constructJobKey(key); try { final List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey); for (final Trigger trigger : triggers) { if (trigger.getNextFireTime() != null && trigger.getNextFireTime().after(jobDetail.getNextRunTime())) { jobDetail.updateNextRunTime(trigger.getNextFireTime()); } } } catch (final SchedulerException e) { logger.error(e.getMessage(), e); } } jobDetail.updateTriggerMisfired(false); this.schedularWritePlatformService.saveOrUpdate(jobDetail); } } } } }