private static SchedulerRuntimeException unchecked(String message, Throwable e) { return new SchedulerRuntimeException(message, e); } }
/** * The parameters are not available because the map could not be reconstructed. * * @return never returns normally * @throws SchedulerRuntimeException Unconditionally. The exception's {@code cause} will be * either a {@link JobRunnerNotRegisteredException} or the error that occurred during * deserialization. */ @Override @Nonnull public Map<String, Serializable> getParameters() { throw new SchedulerRuntimeException("The parameters cannot be accessed: " + cause, cause); }
private static byte[] toRawParameters(Long subscriptionId) { try { final ParameterMapSerializer serializer = new ParameterMapSerializer(); return serializer.serializeParameters(ImmutableMap.of(SUBSCRIPTION_IDENTIFIER, subscriptionId)); } catch (SchedulerServiceException sse) { throw new SchedulerRuntimeException("Unable to serialize parameter map", sse); } }
private void startAsyncServices() { try { dependencies.getSchedulerService().start(); } catch (SchedulerServiceException e) { throw new SchedulerRuntimeException("Unable to start the scheduler service", e); } }
private void startServicesInOtherThreads() { // Start the scheduler, if the node is inactive. ClusterManager clusterManager = ComponentAccessor.getComponent(ClusterManager.class); if (clusterManager.isActive()) { log.info("Restarting the JIRA Scheduler..."); try { getSchedulerService().start(); } catch (SchedulerServiceException e) { throw new SchedulerRuntimeException("Unable to restart the JIRA scheduler", e); } log.info("JIRA Scheduler started"); } }
private void pauseAndFlushScheduler(final LifecycleAwareSchedulerService schedulerService) { try { schedulerService.standby(); } catch (SchedulerServiceException e) { throw new SchedulerRuntimeException("Failed to place scheduler service into standby mode", e); } Integer waitUntil = jiraSystemProperties.getInteger("jira.quickimport.current.job.completion.timeout.sec", 30); try { boolean returnValue = schedulerService.waitUntilIdle(waitUntil, TimeUnit.SECONDS); if (!returnValue) { log.warn("timed out waiting for atlassian scheduler currently executing jobs to complete; background jobs touching the database during quick-import can lead to (flake)\njobs " + schedulerService.getLocallyRunningJobs()); } } catch (InterruptedException e) { log.error("interrupted while waiting for currently executing jobs to complete"); } }
@Nonnull @Override protected Schedule getSchedule(Trigger trigger) { if (trigger instanceof CronTrigger) { final CronTrigger cron = (CronTrigger) trigger; return Schedule.forCronExpression(cron.getCronExpression(), cron.getTimeZone()); } if (trigger instanceof SimpleTrigger) { final SimpleTrigger simple = (SimpleTrigger) trigger; return Schedule.forInterval(simple.getRepeatInterval(), simple.getStartTime()); } throw new SchedulerRuntimeException("The job with jobId '" + trigger.getName() + "' has an unsupported trigger class: " + trigger.getClass().getName()); }
@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)); }