@SuppressWarnings("NullableProblems") // Guava should not have stuck @Nullable on this... @Override public JobRunnerKey apply(String jobName) { return JobRunnerKey.of(jobName); } });
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final JobConfig other = (JobConfig) o; return jobRunnerKey.equals(other.jobRunnerKey) && runMode == other.runMode && schedule.equals(other.schedule) && parameters.equals(other.parameters); }
@Nonnull @Override public Collection<ClusteredJob> findByJobRunnerKey(final JobRunnerKey jobRunnerKey) { final List<OfBizClusteredJob> list = Select.from(CLUSTERED_JOB) .whereEqual(JOB_RUNNER_KEY, jobRunnerKey.toString()) .runWith(entityEngine) .asList(); return ImmutableList.copyOf(list); }
/** * Wraps the provided string as a {@code JobRunnerKey}. * <p> * Although it is not necessary for correctness, it will usually make sense to create a single instance of * the {@code JobRunnerKey} and reuse it as a constant, as in: * </p> * <pre><code> * private static final JobRunnerKey <strong>POP3_SERVICE</strong> = JobRunnerKey.of("com.example.plugin.Pop3Service"); * * // ... * * private void registerJobRunner() * { * schedulerService.registerJobRunner(<strong>POP3_SERVICE</strong>, new Pop3JobRunner()); * } * * private String scheduleJobWithGeneratedId(String cronExpression) * { * JobConfig jobConfig = JobConfig.forJobRunnerKey(<strong>POP3_SERVICE</strong>) * .withSchedule(Schedule.forCronExpression(cronExpression)); * return schedulerService.scheduleJobWithGeneratedId(jobConfig); * } * </code></pre> * * @param key the job runner key, as a string * @return the wrapped job runner key */ public static JobRunnerKey of(String key) { return new JobRunnerKey(key); }
@Override public int hashCode() { int result = jobRunnerKey.hashCode(); result = 31 * result + runMode.hashCode(); result = 31 * result + schedule.hashCode(); result = 31 * result + parameters.hashCode(); return result; }
@Override public int compareTo(final JobRunnerWrapper o) { return getKey().compareTo(o.getKey()); } }
@Nonnull @Override protected JobRunnerKey getJobRunnerKey(Trigger trigger) { return JobRunnerKey.of(trigger.getJobName()); }
@Nullable JobDetail getQuartzJob(final JobRunnerKey jobRunnerKey) { try { return getScheduler().getJobDetail(jobRunnerKey.toString(), QUARTZ_JOB_GROUP); } catch (SchedulerException se) { logWarn("Error getting quartz job details for '{}'", jobRunnerKey, se); return null; } }
@Nonnull @Override public List<JobDetails> getJobsByJobRunnerKey(@Nonnull JobRunnerKey jobRunnerKey) { List<JobDetails> result = new ArrayList<JobDetails>(); for (Map.Entry<JobId, JobConfig> entry : scheduledJobs.entrySet()) { if (jobRunnerKey.equals(entry.getValue().getJobRunnerKey())) { result.add(new SimpleJobDetails(entry.getKey(), entry.getValue())); } } return result; }
@Nonnull @Override public Set<JobRunnerKey> findAllJobRunnerKeys() { final ImmutableSet.Builder<JobRunnerKey> keys = ImmutableSet.builder(); Select.distinctString(JOB_RUNNER_KEY) .from(Name.CLUSTERED_JOB) .runWith(entityEngine) .visitWith(jobRunnerKey -> keys.add(JobRunnerKey.of(jobRunnerKey))); return keys.build(); }
boolean deleteJob(final JobRunnerKey jobRunnerKey) { try { return getScheduler().deleteJob(jobRunnerKey.toString(), QUARTZ_JOB_GROUP); } catch (SchedulerException se) { logWarn("Error removing Quartz job for '{}'", jobRunnerKey, se); return false; } }
public DefaultSubscriptionManager(final MailQueue mailQueue, final TemplateManager templateManager, final SubscriptionMailQueueItemFactory subscriptionMailQueueItemFactory, final ProjectRoleManager projectRoleManager, final GroupManager groupManager, SchedulerService schedulerService, final EntityEngine entityEngine) { super(templateManager, projectRoleManager); this.mailQueue = mailQueue; this.subscriptionMailQueueItemFactory = subscriptionMailQueueItemFactory; this.groupManager = groupManager; this.schedulerService = schedulerService; this.entityEngine = entityEngine; schedulerService.registerJobRunner(JobRunnerKey.of(JOB_RUNNER_KEY), new SendFilterJob()); }
Trigger[] getTriggersOfJob(final JobRunnerKey jobRunnerKey) { try { return getScheduler().getTriggersOfJob(jobRunnerKey.toString(), QUARTZ_JOB_GROUP); } catch (SchedulerException se) { throw unchecked("Could not get the triggers from Quartz", se); } }
private static JobConfig getJobConfig(final Long subscriptionId, final Schedule schedule) { return JobConfig.forJobRunnerKey(JobRunnerKey.of(JOB_RUNNER_KEY)) .withSchedule(schedule) .withParameters(ImmutableMap.<String, Serializable>of(SUBSCRIPTION_IDENTIFIER, subscriptionId)); }
void scheduleJob(final JobRunnerKey jobRunnerKey, final Trigger trigger) throws SchedulerServiceException { if (getQuartzJob(jobRunnerKey) != null) { trigger.setJobGroup(QUARTZ_JOB_GROUP); trigger.setJobName(jobRunnerKey.toString()); scheduleJob(trigger); return; } try { final JobDetail quartzJob = new JobDetail(); quartzJob.setGroup(QUARTZ_JOB_GROUP); quartzJob.setName(jobRunnerKey.toString()); quartzJob.setJobClass(Quartz1Job.class); quartzJob.setDurability(false); getScheduler().scheduleJob(quartzJob, trigger); } catch (SchedulerException se) { throw checked("Unable to create the Quartz job and trigger", se); } }
@Override public void destroy() { executor.shutdown(); schedulerService.unregisterJobRunner(JobRunnerKey.of(TASK_ID_HERCULES)); // Clear the scan results cache if the add-on is uninstalled clearScanResultCache(); }
@Override public Map<String, Object> fieldMapFrom(final OfBizClusteredJob value) { final FieldMap fields = new FieldMap() .add(ID, value.getId()) .add(JOB_ID, value.getJobId().toString()) .add(JOB_RUNNER_KEY, value.getJobRunnerKey().toString()) .add(NEXT_RUN, toLong(value.getNextRunTime())) .add(VERSION, value.getVersion()) .add(PARAMETERS, value.getRawParameters()); addScheduleInfo(fields, value.getSchedule()); return fields; }
boolean unscheduleJob(final JobId jobId) { final Trigger trigger = getTrigger(jobId); if (trigger == null) { return false; } final JobRunnerKey jobRunnerKey = JobRunnerKey.of(trigger.getJobName()); if (deleteTrigger(jobId) && !hasAnyTriggers(jobRunnerKey)) { deleteJob(jobRunnerKey); } return true; }
final JobRunnerKey jobRunnerKey = JobRunnerKey.of(String.format("%s.%s", JIRA_CRON_SCHEDULER_JOB_RUNNER, jobKey)); unscheduleJob(jobKey); scheduler.unregisterJobRunner(jobRunnerKey);
private static final String REINDEX_ALLOWED_PROPERTY="upgrade.reindex.allowed"; public static final JobRunnerKey JOB_RUNNER_KEY = JobRunnerKey.of(DelayedUpgradeJobRunner.class.getName()); public static final JobId JOB_ID = JobId.of(DelayedUpgradeJobRunner.class.getName());