/** * 关闭调度器. */ public synchronized void shutdown() { try { if (!scheduler.isShutdown()) { scheduler.shutdown(); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } } }
/** * 暂停作业. */ public synchronized void pauseJob() { try { if (!scheduler.isShutdown()) { scheduler.pauseAll(); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }
/** * 恢复作业. */ public synchronized void resumeJob() { try { if (!scheduler.isShutdown()) { scheduler.resumeAll(); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }
/** * 立刻启动作业. */ public synchronized void triggerJob() { try { if (!scheduler.isShutdown()) { scheduler.triggerJob(jobDetail.getKey()); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }
/** * 判断作业是否暂停. * * @return 作业是否暂停 */ public synchronized boolean isPaused() { try { return !scheduler.isShutdown() && Trigger.TriggerState.PAUSED == scheduler.getTriggerState(new TriggerKey(triggerIdentity)); } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }
/** * 重新调度作业. * * @param cron CRON表达式 */ public synchronized void rescheduleJob(final String cron) { try { CronTrigger trigger = (CronTrigger) scheduler.getTrigger(TriggerKey.triggerKey(triggerIdentity)); if (!scheduler.isShutdown() && null != trigger && !cron.equals(trigger.getCronExpression())) { scheduler.rescheduleJob(TriggerKey.triggerKey(triggerIdentity), createTrigger(cron)); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }
if (scheduler.isShutdown()) { return;
/** * <p> * Returns a handle to the Scheduler produced by this factory. * </p> * * <p> * If one of the <code>initialize</code> methods has not be previously * called, then the default (no-arg) <code>initialize()</code> method * will be called by this method. * </p> */ public Scheduler getScheduler() throws SchedulerException { if (cfg == null) { initialize(); } SchedulerRepository schedRep = SchedulerRepository.getInstance(); Scheduler sched = schedRep.lookup(getSchedulerName()); if (sched != null) { if (sched.isShutdown()) { schedRep.remove(getSchedulerName()); } else { return sched; } } sched = instantiate(); return sched; }
/** * <p> * Returns a handle to the Scheduler produced by this factory. * </p> * * <p> * If one of the <code>initialize</code> methods has not be previously * called, then the default (no-arg) <code>initialize()</code> method * will be called by this method. * </p> */ public Scheduler getScheduler() throws SchedulerException { if (cfg == null) { initialize(); } SchedulerRepository schedRep = SchedulerRepository.getInstance(); Scheduler sched = schedRep.lookup(getSchedulerName()); if (sched != null) { if (sched.isShutdown()) { schedRep.remove(getSchedulerName()); } else { return sched; } } sched = instantiate(); return sched; }
private void process(JobExecutionContext context, Ehcache underlyingCache, ScheduledRefreshConfiguration config, List<Serializable> batch) throws SchedulerException { JobDataMap map = new JobDataMap(context.getJobDetail().getJobDataMap()); map.put(ScheduledRefreshCacheExtension.PROP_KEYS_TO_PROCESS, batch); Scheduler scheduler = context.getScheduler(); JobDetail job = JobBuilder .newJob(RefreshBatchJob.class) .withIdentity("RefreshBatch-" + INSTANCE_ID_GENERATOR.incrementAndGet(), context.getTrigger().getJobKey().getGroup()).usingJobData(map).build(); try { waitForOutstandingJobCount(context, config, scheduler, config.getParallelJobCount()); if (!scheduler.isShutdown()) { Trigger trigger = TriggerBuilder.newTrigger().startNow().forJob(job).build(); scheduler.scheduleJob(job, trigger); } } catch (SchedulerException e) { if (!scheduler.isShutdown()) { throw e; } } }
private void waitForOutstandingJobCount(JobExecutionContext context, ScheduledRefreshConfiguration config, Scheduler scheduler, int minCount) throws SchedulerException { GroupMatcher<JobKey> matcher = GroupMatcher.jobGroupEquals(context.getJobDetail().getKey().getGroup()); for (Set<JobKey> queuedKeys = scheduler.getJobKeys(matcher); (!scheduler.isShutdown()) && (queuedKeys.size() > minCount); queuedKeys = scheduler.getJobKeys(matcher)) { try { Thread.sleep(config.getPollTimeMs()); } catch (InterruptedException e) { } } }
if (!context.getScheduler().isShutdown()) { LOG.warn("Unable to process Scheduled Refresh batch " + context.getJobDetail().getKey(), e);
@Override public void close() throws Exception { if (!scheduler.isShutdown()) { // Graceful shutdown. // We don't use InterruptableJob for simplicity, but just waiting for the job to be completed. scheduler.shutdown(true); } }
public void destroy(){ try{ if(scheduler!=null && !scheduler.isShutdown()){ scheduler.shutdown(false); } }catch(Exception ex){} }
@Override public void stop() { try{ if (!scheduler.isShutdown()){ scheduler.shutdown(); } } catch (SchedulerException e){ log.error("Failed to stop the scheduler", e); } }
public void shutdown() { try { if (!scheduler.isShutdown()) { scheduler.shutdown(); } } catch (Exception e) { logger.error("schedule service shutdown failed.", e); } }
public static boolean isShutdown() throws SchedulerException { Scheduler sched = StdSchedulerFactory.getDefaultScheduler(); return sched.isShutdown(); } }
/** * 恢复作业. */ public synchronized void resumeJob() { try { if (!scheduler.isShutdown()) { scheduler.resumeAll(); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }
public void pauseTrigger() throws Exception { Scheduler scheduler = getComponent().getScheduler(); boolean isClustered = scheduler.getMetaData().isJobStoreClustered(); if (jobPaused.get() || isClustered) { return; } jobPaused.set(true); if (!scheduler.isShutdown()) { LOG.info("Pausing trigger {}", triggerKey); scheduler.pauseTrigger(triggerKey); } }
public void deleteRouteJob(Action action, ScheduledRouteDetails scheduledRouteDetails) throws SchedulerException { JobKey jobKey = retrieveJobKey(action, scheduledRouteDetails); if (!getScheduler().isShutdown()) { getScheduler().deleteJob(jobKey); } LOG.debug("Scheduled job: {} is deleted", jobKey); }