@Override public void registerJobRunner(JobRunnerKey jobRunnerKey, JobRunner jobRunner) { delegate.registerJobRunner(jobRunnerKey, jobRunner); }
@Override public void scheduleJob(JobId jobId, JobConfig jobConfig) throws SchedulerServiceException { delegate.scheduleJob(jobId, jobConfig); }
@Override public void onStop() { scheduler.unregisterJobRunner(JOB_RUNNER_KEY); } }
@Override public void onStop() { schedulerService.unregisterJobRunner(DemoJobRunner.RUNNER_KEY); schedulerService.unscheduleJob(LOCAL_JOB_ID); schedulerService.unscheduleJob(CLUSTERED_JOB_ID); }
@Override public void removeAllPollers() { List<JobDetails> jobs = schedulerService.getJobsByJobRunnerKey(JOB_RUNNER_KEY); for (JobDetails job : jobs) { schedulerService.unscheduleJob(job.getJobId()); } } }
@Override public void onStart() { scheduler.registerJobRunner(JOB_RUNNER_KEY, this); try { scheduler.scheduleJob(JOB_ID, JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withSchedule(getSchedule())); } catch (final SchedulerServiceException e) { log.error("Unable to schedule analytics job", e); } }
final JobRunnerKey jobRunnerKey = JobRunnerKey.of(String.format("%s.%s", JIRA_CRON_SCHEDULER_JOB_RUNNER, jobKey)); unscheduleJob(jobKey); scheduler.unregisterJobRunner(jobRunnerKey); scheduler.registerJobRunner(jobRunnerKey, new JiraJobRunnerWrapper(jobDataMap, jobClass.getClassLoader())); final Schedule schedule = Schedule.forCronExpression(jobDataMap.get(CronScheduler.JOB_KEY_CRON_EXPRESSION).toString()); try scheduler.scheduleJob(JobId.of(jobKey), jobConfig); jobRunnerKeys.add(jobRunnerKey); scheduler.unregisterJobRunner(jobRunnerKey);
@Override public void updateSubscription(final ApplicationUser user, final Long subId, final String groupName, final String cronExpression, final Boolean emailOnEmpty) throws DataAccessException { Schedule schedule = Schedule.forCronExpression(cronExpression); try { schedulerService.unscheduleJob(toJobId(subId)); Update.into(ENTITY_NAME).set(USER_KEY, getKeyFor(user)).set(GROUP, groupName).set(EMAIL_ON_EMPTY, emailOnEmpty.toString()) .whereEqual(ID, subId).execute(entityEngine); JobConfig config = getJobConfig(subId, schedule); schedulerService.scheduleJob(toJobId(subId), config); } catch (final SchedulerServiceException e) { throw new DataAccessException(e); } }
@Test public void testSchedulerServiceJob() throws Exception { final CountDownLatch latch = new CountDownLatch(1); schedulerService.registerJobRunner(jobRunnerKey, new JobRunner() { @Nullable @Override public JobRunnerResponse runJob(JobRunnerRequest jobRunnerRequest) { latch.countDown(); return null; } }); final JobConfig jobConfig = JobConfig.forJobRunnerKey(jobRunnerKey) .withRunMode(RunMode.RUN_LOCALLY) .withSchedule(Schedule.runOnce(null)); try { schedulerService.scheduleJobWithGeneratedId(jobConfig); } catch (SchedulerServiceException sse) { throw new SchedulerRuntimeException(sse.getMessage(), sse); } assertThat(latch.await(30, TimeUnit.SECONDS), is(true)); }
@Override public void unscheduleJob(JobId jobId) { delegate.unscheduleJob(jobId); }
if (schedulerService.getRegisteredJobRunnerKeys().contains(jobRunnerKey)) final Collection<JobDetails> jobs = schedulerService.getJobsByJobRunnerKey(jobRunnerKey); for (JobDetails job : jobs) schedulerService.unscheduleJob(job.getJobId());
@Override public void deleteSubscription(final Long subId) throws GenericEntityException { final FilterSubscription subscription = getFilterSubscription(subId); if (subscription == null) { LOG.debug("Unable to find subscription for id : " + subId); } if (schedulerService.getJobDetails(toJobId(subId)) != null) { schedulerService.unscheduleJob(toJobId(subId)); } else { LOG.debug("Unable to find a scheduled job for the subscription: " + subId + "; removing the subscription anyway."); } Delete.from(Entity.FILTER_SUBSCRIPTION).whereIdEquals(subId).execute(entityEngine); }
@Override public JobDetails getLocalJobDetails(JobId jobId) { return local.getJobDetails(jobId); } }
@Override @Nullable public Date calculateNextRunTime(Schedule schedule) throws SchedulerServiceException { return delegate.calculateNextRunTime(schedule); }
@Override @Nonnull public JobId scheduleJobWithGeneratedId(JobConfig jobConfig) throws SchedulerServiceException { return delegate.scheduleJobWithGeneratedId(jobConfig); }
@Override public void afterPropertiesSet() throws Exception { schedulerService.registerJobRunner(CLEANUP_JOB_RUNNER_KEY, newCleanupTask()); // schedule the cleanup job once a day starting in a day schedulerService.scheduleJob(CLEANUP_JOB_ID, JobConfig.forJobRunnerKey(CLEANUP_JOB_RUNNER_KEY) .withSchedule(Schedule.forInterval(TimeUnit.DAYS.toMillis(1), DateTime.now().plusDays(1).toDate())) .withRunMode(RunMode.RUN_LOCALLY)); // cache dir is local to every application node }
@Override public void destroy() throws Exception { schedulerService.unscheduleJob(CLEANUP_JOB_ID); schedulerService.unregisterJobRunner(CLEANUP_JOB_RUNNER_KEY); }
private void unscheduleJob(final Long serviceId) { schedulerService.unscheduleJob(toJobId(serviceId)); }
@Override @CheckForNull public JobDetails getJobDetails(JobId jobId) { return delegate.getJobDetails(jobId); }
Date calculateNextRunTime(Schedule schedule) { try { return getSchedulerService().calculateNextRunTime(schedule); } catch (SchedulerServiceException sse) { final AssertionError err = new AssertionError("Unexpected exception finding first run time for " + schedule); err.initCause(sse); throw err; } }