@Override public void scheduleJob(JobId jobId, JobConfig jobConfig) throws SchedulerServiceException { delegate.scheduleJob(jobId, jobConfig); }
private void scheduleLogScanJob(Schedule schedule) { try { schedulerService.scheduleJob(JOB_ID, JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RunMode.RUN_ONCE_PER_CLUSTER) .withSchedule(schedule)); } catch (SchedulerServiceException e) { log.error("Failed to schedule log scan job", e); } } }
@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 }
private void queueDelayedEvent(final JiraHomeChangeEvent event) { delayedFileReplicationQueue.add(event); JobConfig jobConfig = JobConfig.forJobRunnerKey(DELAYED_REPLICATION_KEY) .withRunMode(RunMode.RUN_LOCALLY) .withSchedule(Schedule.runOnce(DateTime.now().plusSeconds(IDLE_SECONDS).toDate())); try { schedulerService.scheduleJob(DELAYED_REPLICATION_ID, jobConfig); } catch (SchedulerServiceException e) { log.error("Failed to schedule delayed replication", e); } }
@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 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); } }
@Override public void onStart() { schedulerService.registerJobRunner(JOB_RUNNER_KEY, this); JobConfig config = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RUN_ONCE_PER_CLUSTER) .withSchedule(Schedule.forInterval(REMOVE_INTERVAL, new Date(System.currentTimeMillis() + REMOVE_INTERVAL))); try { schedulerService.scheduleJob(JobId.of(JOB_ID), config); } catch (SchedulerServiceException e) { log.error("Unable to schedule expired session remover job", e); } }
@Override public void onStart() { long intervalInMillis = configuration.getAlertTruncationInterval().toMillis(); long firstRunTime = System.currentTimeMillis() + intervalInMillis; schedulerService.registerJobRunner(JOB_RUNNER_KEY, new TruncateAlertsJobRunner()); try { schedulerService.scheduleJob(JOB_ID, JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withSchedule(Schedule.forInterval(intervalInMillis, new Date(firstRunTime))) .withRunMode(RunMode.RUN_ONCE_PER_CLUSTER)); } catch (SchedulerServiceException e) { log.warn("Failed to schedule periodic alert truncation", e); } }
@Override public void start() throws Exception { final SchedulerService scheduler = ComponentAccessor.getComponent(SchedulerService.class); scheduler.registerJobRunner(JOB_RUNNER_KEY, this); // we need to scatter a bit sending events to analytics system, // lets not start this service on every instance in the same moment final Date firstRun = Date.from(Instant.now().plusMillis(random.nextLong() % FOUR_HOURS)); final JobConfig jobConfig = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RunMode.RUN_LOCALLY) .withSchedule(Schedule.forInterval(RUN_INTERVAL, firstRun)); scheduler.scheduleJob(JOB_ID, jobConfig); }
@Override @Nonnull public Status scheduleDelayedUpgrades(final int delayMins, final boolean isAllowReindex) { final Schedule schedule = Schedule.runOnce(DateTime.now().plusMinutes(delayMins).toDate()); JobConfig jobConfig = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withSchedule(schedule) .withParameters(ImmutableMap.<String, Serializable>of(REINDEX_ALLOWED_PROPERTY, isAllowReindex)); try { schedulerService.scheduleJob(JOB_ID, jobConfig); } catch (SchedulerServiceException e) { log.error( "Unable to schedule upgrade tasks for future execution :" + e, e); final Collection<String> errors = ImmutableList.of( "Unable to schedule upgrade tasks for future execution: " + e.getMessage() + '\n' + ExceptionUtils.getStackTrace(e)); return new Status(errors); } return Status.OK; }
/** * Request a full replication of files in the home directories that are configured for replication. */ public void replicateJiraHome() throws SchedulerServiceException { JobConfig jobConfig = JobConfig.forJobRunnerKey(FULL_REPLICATION_KEY) .withRunMode(RunMode.RUN_ONCE_PER_CLUSTER) .withSchedule(Schedule.runOnce(null)); schedulerService.scheduleJob(FULL_REPLICATION_ID, jobConfig); }
@EventListener public void onFrameworkStarted(PluginFrameworkStartedEvent event) { schedulerService.registerJobRunner(JOB_RUNNER_KEY, new AlertAnalyticsJobRunner()); try { schedulerService.scheduleJob(JOB_ID, JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withSchedule(Schedule.forCronExpression("0 19 * * * ?")) // collect stats daily at 00:19 .withRunMode(RunMode.RUN_ONCE_PER_CLUSTER)); } catch (SchedulerServiceException e) { log.warn("Failed to schedule daily alert analytics publishing job", e); } }
@Override public void start() throws Exception { SchedulerService scheduler = ComponentAccessor.getComponent(SchedulerService.class); scheduler.registerJobRunner(JOB_RUNNER_KEY, this); final JobConfig jobConfig = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RunMode.RUN_LOCALLY) .withSchedule(Schedule.forInterval(FIVE_MINUTES, null)); scheduler.scheduleJob(JOB_ID, jobConfig); }
@Override public void addPoller(final DirectoryPoller poller) throws DirectoryMonitorRegistrationException { final Date oneMinuteFromNow = new DateTime().plusMinutes(1).toDate(); final JobConfig config = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RUN_ONCE_PER_CLUSTER) .withSchedule(Schedule.forInterval(poller.getPollingInterval() * 1000, oneMinuteFromNow)) .withParameters(ImmutableMap.<String, Serializable>of(DIRECTORY_ID, poller.getDirectoryID())); try { schedulerService.scheduleJob(getJobId(poller), config); } catch (SchedulerServiceException e) { throw new DirectoryMonitorRegistrationException(e); } }
@Override public void start() throws Exception { final SchedulerService scheduler = ComponentAccessor.getComponent(SchedulerService.class); scheduler.registerJobRunner(JOB_RUNNER_KEY, this); final JobConfig jobConfig = JobConfig.forJobRunnerKey(JOB_RUNNER_KEY) .withRunMode(RunMode.RUN_LOCALLY) .withSchedule(Schedule.forInterval(DAILY, null)); scheduler.scheduleJob(JOB_ID, jobConfig); } }
private void scheduleSimpleJob(final JiraServiceContainer jiraServiceContainer) throws SchedulerServiceException { // Work out the fire time delay. Date nextFireTime = null; long lastRunMillis = jiraServiceContainer.getLastRun(); final long nextRunMillis = lastRunMillis > 0 ? lastRunMillis + jiraServiceContainer.getDelay() : System.currentTimeMillis(); final boolean localService = jiraServiceContainer.isLocalService(); if (nextRunMillis > System.currentTimeMillis()) { nextFireTime = new Date(nextRunMillis); } JobConfig config = JobConfig.forJobRunnerKey(SERVICE_JOB_KEY) .withSchedule(Schedule.forInterval(jiraServiceContainer.getDelay(), nextFireTime)) .withRunMode(localService ? RunMode.RUN_LOCALLY : RunMode.RUN_ONCE_PER_CLUSTER) .withParameters(ImmutableMap.<String, Serializable>of(SERVICE_ID_KEY, jiraServiceContainer.getId())); schedulerService.scheduleJob(toJobId(jiraServiceContainer.getId()), config); }
@Override protected void startHeartbeat() throws SchedulerServiceException { super.startHeartbeat(); //Initially run explicitly to get the first run out immediately SharedHomeFileWriterJobRunner runner = new SharedHomeFileWriterJobRunner(); runner.writeFile(); schedulerService.registerJobRunner(SHARED_HOME_FILE_WRITER_JOB_RUNNER_KEY, runner); JobConfig jobConfig = JobConfig.forJobRunnerKey(SHARED_HOME_FILE_WRITER_JOB_RUNNER_KEY) .withRunMode(RunMode.RUN_LOCALLY) .withSchedule(Schedule.forInterval(TimeUnit.MINUTES.toMillis(1), null)); schedulerService.scheduleJob(JobId.of(SHARED_HOME_FILE_WRITER_JOB_RUNNER_KEY_NAME), jobConfig); }
private void scheduleCronJob(final JiraServiceContainer jiraServiceContainer) throws SchedulerServiceException { final boolean localService = jiraServiceContainer.isLocalService(); JobConfig config = JobConfig.forJobRunnerKey(SERVICE_JOB_KEY) .withSchedule(Schedule.forCronExpression(jiraServiceContainer.getCronExpression())) .withRunMode(localService ? RunMode.RUN_LOCALLY : RunMode.RUN_ONCE_PER_CLUSTER) .withParameters(ImmutableMap.<String, Serializable>of(SERVICE_ID_KEY, jiraServiceContainer.getId())); schedulerService.scheduleJob(toJobId(jiraServiceContainer.getId()), config); }
private FilterSubscription createSubscription(final ApplicationUser user, final Long filterId, String groupName, final Boolean emailOnEmpty, final Schedule schedule) { final FilterSubscription newSubscription = new DefaultFilterSubscription(null, filterId, user.getKey(), groupName, null, emailOnEmpty); try { final FilterSubscription subscription = entityEngine.createValue(Entity.FILTER_SUBSCRIPTION, newSubscription); JobConfig config = getJobConfig(subscription.getId(), schedule); schedulerService.scheduleJob(toJobId(subscription.getId()), config); return subscription; } catch (final SchedulerServiceException e) { throw new DataAccessException(e); } }
@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); } }