@Override @Nonnull public JobId scheduleJobWithGeneratedId(JobConfig jobConfig) throws SchedulerServiceException { return delegate.scheduleJobWithGeneratedId(jobConfig); }
@Override public void triggerPoll(final long directoryID, final SynchronisationMode synchronisationMode) { JobConfig config = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RUN_ONCE_PER_CLUSTER) .withSchedule(Schedule.runOnce(null)) .withParameters(ImmutableMap.<String, Serializable>of("DIRECTORY_ID", directoryID)); try { schedulerService.scheduleJobWithGeneratedId(config); } catch (SchedulerServiceException e) { throw new RuntimeException(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 runNow(final long serviceId) throws Exception { JiraServiceContainer jiraServiceContainer = getServiceWithId(serviceId); if (jiraServiceContainer == null) { throw new ServiceException("Service with id '" + serviceId + "' was not found"); } JobConfig config = JobConfig.forJobRunnerKey(SERVICE_JOB_KEY) .withSchedule(Schedule.runOnce(null)) .withRunMode(RunMode.RUN_ONCE_PER_CLUSTER) .withParameters(ImmutableMap.<String, Serializable>of(SERVICE_ID_KEY, serviceId)); JobId jobId = schedulerService.scheduleJobWithGeneratedId(config); LOG.debug("JIRA Service '" + jiraServiceContainer.getName() + "' scheduled for immediate execution with job id '" + jobId + '\''); }