private void attachSchedulerStatus(final JobConfiguration jobConfiguration) { if (jobConfiguration.getJobSchedulerConfiguration() != null) { final String schedulerName = jobConfiguration.getJobSchedulerConfiguration().getBeanName(); final SchedulerStatus schedulerStatus = this.schedulerService.getSchedulerStatus(schedulerName); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(schedulerStatus); } } }
private void attachSchedulerStatus(final JobConfiguration jobConfiguration) { if (jobConfiguration.getJobSchedulerConfiguration() != null) { final String schedulerName = jobConfiguration.getJobSchedulerConfiguration().getBeanName(); final SchedulerStatus schedulerStatus = this.schedulerService.getSchedulerStatus(schedulerName); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(schedulerStatus); } } }
static Integer determineJobConfigurationType(final JobConfiguration jobConfiguration) { final Integer jobConfigurationType; if (jobConfiguration.getJobSchedulerConfiguration() != null) { jobConfigurationType = JobConfigurationType.SCHEDULER; } else if (jobConfiguration.getJobListenerConfiguration() != null) { jobConfigurationType = JobConfigurationType.LISTENER; } else { throw new SpringBatchLightminApplicationException("Could not determine JobConfigurationType"); } return jobConfigurationType; } }
@Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); }
@Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); }
@Test(expected = NoSuchJobException.class) public void getJobConfigurationsJobNameUnknownIT() throws NoSuchJobException, NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); final JobConfiguration secondAddedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(secondAddedJobConfiguration).isNotNull(); assertThat(secondAddedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(secondAddedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); this.getJobConfigurationRepository().getJobConfigurations("sampleJobUnknown", APPLICATION_NAME); }
@Test public void getJobConfigurationIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); final JobConfiguration fetchedJobConfiguration = this.getJobConfigurationRepository().getJobConfiguration (addedJobConfiguration.getJobConfigurationId(), APPLICATION_NAME); assertThat(fetchedJobConfiguration.getJobConfigurationId()).isEqualTo(addedJobConfiguration.getJobConfigurationId()); }
@Test(expected = NoSuchJobConfigurationException.class) public void deleteJobConfigurationIdNotExistingIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); addedJobConfiguration.setJobConfigurationId(-100L); this.getJobConfigurationRepository().delete(addedJobConfiguration, APPLICATION_NAME); }
private List<ValueRecord> getValueRecords(final JobConfiguration jobConfiguration) { final Integer jobConfigurationType = JobConfigurationType.determineJobConfigurationType(jobConfiguration); final List<ValueRecord> valueRecords; if (JobConfigurationType.SCHEDULER.equals(jobConfigurationType)) { valueRecords = JobSchedulerConfigurationMapper.map(jobConfiguration.getJobSchedulerConfiguration(), jobConfiguration.getJobConfigurationId()); } else if (JobConfigurationType.LISTENER.equals(jobConfigurationType)) { valueRecords = JobListenerConfigurationMapper.map(jobConfiguration.getJobListenerConfiguration(), jobConfiguration.getJobConfigurationId()); } else { throw new SpringBatchLightminApplicationException("Unknown JobConfigurationType : " + jobConfigurationType); } return valueRecords; }
@Test public void getJobConfigurationIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); final JobConfiguration fetchedJobConfiguration = this.getJobConfigurationRepository().getJobConfiguration (addedJobConfiguration.getJobConfigurationId(), APPLICATION_NAME); assertThat(fetchedJobConfiguration.getJobConfigurationId()).isEqualTo(addedJobConfiguration.getJobConfigurationId()); }
@Test(expected = NoSuchJobConfigurationException.class) public void deleteJobConfigurationIdNotExistingIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); addedJobConfiguration.setJobConfigurationId(-100L); this.getJobConfigurationRepository().delete(addedJobConfiguration, APPLICATION_NAME); }
@Test(expected = NoSuchJobConfigurationException.class) public void updateJobConfigurationIdNotExistingIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); addedJobConfiguration.setJobName("updated"); addedJobConfiguration.setJobConfigurationId(-1000L); this.getJobConfigurationRepository().update(addedJobConfiguration, APPLICATION_NAME); }
@Test(expected = NoSuchJobConfigurationException.class) public void deleteIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); this.getJobConfigurationRepository().delete(addedJobConfiguration, APPLICATION_NAME); this.getJobConfigurationRepository().getJobConfiguration(addedJobConfiguration.getJobConfigurationId(), APPLICATION_NAME); }
@Test(expected = NoSuchJobConfigurationException.class) public void deleteIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); this.getJobConfigurationRepository().delete(addedJobConfiguration, APPLICATION_NAME); this.getJobConfigurationRepository().getJobConfiguration(addedJobConfiguration.getJobConfigurationId(), APPLICATION_NAME); }
@Override public String registerSchedulerForJob(final JobConfiguration jobConfiguration) { final JobSchedulerType schedulerType = jobConfiguration.getJobSchedulerConfiguration().getJobSchedulerType(); final String beanName; switch (schedulerType) { case CRON: beanName = this.registerScheduler(jobConfiguration, CronScheduler.class); break; case PERIOD: beanName = this.registerScheduler(jobConfiguration, PeriodScheduler.class); break; default: throw new SpringBatchLightminConfigurationException("Unknown Scheduler Type: " + schedulerType); } return beanName; }
@Test(expected = NoSuchJobConfigurationException.class) public void updateJobConfigurationIdNotExistingIT() throws NoSuchJobConfigurationException { final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final JobConfiguration addedJobConfiguration = this.getJobConfigurationRepository().add(jobConfiguration, APPLICATION_NAME); assertThat(addedJobConfiguration).isNotNull(); assertThat(addedJobConfiguration.getJobConfigurationId()).isNotNull(); assertThat(addedJobConfiguration.getJobSchedulerConfiguration()).isNotNull(); addedJobConfiguration.setJobName("updated"); addedJobConfiguration.setJobConfigurationId(-1000L); this.getJobConfigurationRepository().update(addedJobConfiguration, APPLICATION_NAME); }
public PeriodScheduler(final SchedulerConstructorWrapper schedulerConstructorWrapper) { this.jobConfiguration = schedulerConstructorWrapper.getJobConfiguration(); this.threadPoolTaskScheduler = schedulerConstructorWrapper.getThreadPoolTaskScheduler(); this.jobSchedulerConfiguration = this.jobConfiguration.getJobSchedulerConfiguration(); this.job = schedulerConstructorWrapper.getJob(); this.jobRunner = new JobRunner(this.job, schedulerConstructorWrapper.getJobLauncher(), schedulerConstructorWrapper.getJobParameters(), schedulerConstructorWrapper.getJobIncrementer()); final SchedulerStatus schedulerStatus; if (this.jobSchedulerConfiguration.getSchedulerStatus() != null) { schedulerStatus = this.jobSchedulerConfiguration.getSchedulerStatus(); } else { schedulerStatus = SchedulerStatus.INITIALIZED; } this.setStatus(schedulerStatus); }
public PeriodScheduler(final SchedulerConstructorWrapper schedulerConstructorWrapper) { this.jobConfiguration = schedulerConstructorWrapper.getJobConfiguration(); this.threadPoolTaskScheduler = schedulerConstructorWrapper.getThreadPoolTaskScheduler(); this.jobSchedulerConfiguration = this.jobConfiguration.getJobSchedulerConfiguration(); this.job = schedulerConstructorWrapper.getJob(); this.jobRunner = new JobRunner(this.job, schedulerConstructorWrapper.getJobLauncher(), schedulerConstructorWrapper.getJobParameters(), schedulerConstructorWrapper.getJobIncrementer()); final SchedulerStatus schedulerStatus; if (this.jobSchedulerConfiguration.getSchedulerStatus() != null) { schedulerStatus = this.jobSchedulerConfiguration.getSchedulerStatus(); } else { schedulerStatus = SchedulerStatus.INITIALIZED; } this.setStatus(schedulerStatus); }
public static JobConfiguration map(final org.tuxdevelop.spring.batch.lightmin.domain.JobConfiguration jobConfiguration) { final JobConfiguration response = new JobConfiguration(); response.setJobConfigurationId(jobConfiguration.getJobConfigurationId()); response.setJobName(jobConfiguration.getJobName()); response.setJobIncrementer(map(jobConfiguration.getJobIncrementer())); response.setJobParameters(map(jobConfiguration.getJobParameters())); response.setJobSchedulerConfiguration(map(jobConfiguration.getJobSchedulerConfiguration())); response.setJobListenerConfiguration(map(jobConfiguration.getJobListenerConfiguration())); return response; }
public static JobConfiguration map(final org.tuxdevelop.spring.batch.lightmin.domain.JobConfiguration jobConfiguration) { final JobConfiguration response = new JobConfiguration(); response.setJobConfigurationId(jobConfiguration.getJobConfigurationId()); response.setJobName(jobConfiguration.getJobName()); response.setJobIncrementer(map(jobConfiguration.getJobIncrementer())); response.setJobParameters(map(jobConfiguration.getJobParameters())); response.setJobSchedulerConfiguration(map(jobConfiguration.getJobSchedulerConfiguration())); response.setJobListenerConfiguration(map(jobConfiguration.getJobListenerConfiguration())); return response; }