Source:
private void maybeScheduleMetricExpirationJob(List<JobDetails> backgroundJobs) { String jobIdConfigKey = "jobId"; String jobFrequencyKey = "jobFrequency"; String configId = "org.hawkular.metrics.jobs." + DeleteExpiredMetrics.JOB_NAME; Configuration config = configurationService.load(configId).toBlocking() .firstOrDefault(new Configuration(configId, new HashMap<>())); if (config.get(jobIdConfigKey) != null) { Integer configuredJobFrequency = null; try { configuredJobFrequency = Integer.parseInt(config.get(jobFrequencyKey)); } catch (Exception e) { } if (configuredJobFrequency == null || configuredJobFrequency != this.metricExpirationJobFrequencyInDays || this.metricExpirationJobFrequencyInDays <= 0 || configuredJobFrequency <= 0 || !this.metricExpirationJobEnabled) { scheduler.unscheduleJob(config.get(jobIdConfigKey)).await(); configurationService.delete(configId, jobIdConfigKey).toBlocking(); config.delete(jobIdConfigKey); configurationService.delete(configId, jobFrequencyKey).toBlocking(); config.delete(jobFrequencyKey); } } if (config.get(jobIdConfigKey) == null && this.metricExpirationJobFrequencyInDays > 0 && this.metricExpirationJobEnabled) { logger.info("Preparing to create and schedule " + DeleteExpiredMetrics.JOB_NAME + " job"); long nextStart = DateTimeService.current24HourTimeSlice().plusDays(1).getMillis(); JobDetails JobDetails = scheduler.scheduleJob(DeleteExpiredMetrics.JOB_NAME, DeleteExpiredMetrics.JOB_NAME, ImmutableMap.of(), new RepeatingTrigger.Builder().withTriggerTime(nextStart) .withInterval(this.metricExpirationJobFrequencyInDays, TimeUnit.DAYS).build()) .toBlocking().value(); backgroundJobs.add(JobDetails); configurationService.save(configId, jobIdConfigKey, JobDetails.getJobId().toString()).toBlocking(); configurationService.save(configId, jobFrequencyKey, this.metricExpirationJobFrequencyInDays + "") .toBlocking(); logger.info("Created and scheduled " + JobDetails); } }

Target:
private void maybeScheduleMetricExpirationJob(List<JobDetails> backgroundJobs) { String jobIdConfigKey = "jobId"; String jobFrequencyKey = "jobFrequency"; String configId = "org.hawkular.metrics.jobs." + DeleteExpiredMetrics.JOB_NAME; Configuration config = configurationService.load(configId).toBlocking() .firstOrDefault(new Configuration(configId, new HashMap<>())); if (config.get(jobIdConfigKey) != null) { Integer configuredJobFrequency = null; try { configuredJobFrequency = Integer.parseInt(config.get(jobFrequencyKey)); } catch (Exception e) { } if (configuredJobFrequency == null || configuredJobFrequency != this.metricExpirationJobFrequencyInDays || this.metricExpirationJobFrequencyInDays <= 0 || configuredJobFrequency <= 0 || !this.metricExpirationJobEnabled) { scheduler.unscheduleJob(config.get(jobIdConfigKey)).await(); configurationService.delete(configId, jobIdConfigKey).toBlocking(); config.delete(jobIdConfigKey); configurationService.delete(configId, jobFrequencyKey).toBlocking(); config.delete(jobFrequencyKey); } } if (config.get(jobIdConfigKey) == null && this.metricExpirationJobFrequencyInDays > 0 && this.metricExpirationJobEnabled) { logger.info("Preparing to create and schedule " + DeleteExpiredMetrics.JOB_NAME + " job"); long nextStart = DateTimeService.current24HourTimeSlice().plusDays(1).getMillis(); JobDetails jobDetails = scheduler.scheduleJob(DeleteExpiredMetrics.JOB_NAME, DeleteExpiredMetrics.JOB_NAME, ImmutableMap.of(), new RepeatingTrigger.Builder().withTriggerTime(nextStart) .withInterval(this.metricExpirationJobFrequencyInDays, TimeUnit.DAYS).build()) .toBlocking().value(); backgroundJobs.add(jobDetails); configurationService.save(configId, jobIdConfigKey, jobDetails.getJobId().toString()).toBlocking(); configurationService.save(configId, jobFrequencyKey, this.metricExpirationJobFrequencyInDays + "") .toBlocking(); logger.info("Created and scheduled " + jobDetails); } }