private static JobListenerType map(final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobListenerType jobListenerType) { final JobListenerType response; switch (jobListenerType) { case LOCAL_FOLDER_LISTENER: response = JobListenerType.LOCAL_FOLDER_LISTENER; break; default: throw new SpringBatchLightminApplicationException("Unknown JobListenerType: " + jobListenerType); } return response; }
private static JobListenerType map(final org.tuxdevelop.spring.batch.lightmin.domain.JobListenerType jobListenerType) { final JobListenerType response; switch (jobListenerType) { case LOCAL_FOLDER_LISTENER: response = JobListenerType.LOCAL_FOLDER_LISTENER; break; default: throw new SpringBatchLightminApplicationException("Unknown JobListenerType: " + jobListenerType); } return response; }
@Override public void stopJobExecution(final Long jobExecutionId) { try { this.jobOperator.stop(jobExecutionId); } catch (final Exception e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } }
private void checkHttpOk(final ResponseEntity<?> responseEntity) { if (!HttpStatus.OK.equals(responseEntity.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + responseEntity.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } }
private void checkHttpOk(final ResponseEntity<?> responseEntity) { if (!HttpStatus.OK.equals(responseEntity.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + responseEntity.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } }
@Override public void restartJobExecution(final Long jobExecutionId) { try { this.jobOperator.restart(jobExecutionId); } catch (final Exception e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } }
private void evaluateReponse(final ResponseEntity<?> responseEntity, final HttpStatus expectedStatus) { if (!expectedStatus.equals(responseEntity.getStatusCode())) { throw new SpringBatchLightminApplicationException("Could not execute remote call HttpStatusCode: " + responseEntity.getStatusCode()); } }
public static void checkHttpOk(final ResponseEntity<?> responseEntity) { if (!HttpStatus.OK.equals(responseEntity.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + responseEntity.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } else { log.debug("Response {} ok", responseEntity); } } }
public static TaskExecutorType getById(final Long id) { final TaskExecutorType type; if (SYNCHRONOUS.getId().equals(id)) { type = SYNCHRONOUS; } else if (ASYNCHRONOUS.getId().equals(id)) { type = ASYNCHRONOUS; } else { throw new SpringBatchLightminApplicationException("Unknown TaskExecutorType for id: " + id); } return type; } }
@Override public Collection<JobConfiguration> getJobConfigurationsByJobName(final String jobName) { try { return this.jobConfigurationRepository.getJobConfigurations(jobName, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } catch (final NoSuchJobException | NoSuchJobConfigurationException e) { final String message = "No Job with name: " + jobName + " is registered"; log.error(message); throw new SpringBatchLightminApplicationException(e, message); } }
@Override public void attachStepExecutions(JobExecution jobExecution) { jobExecution = this.jobExplorer.getJobExecution(jobExecution.getId()); if (jobExecution == null) { throw new SpringBatchLightminApplicationException("Could not attach StepExecutions for JobExecution"); } }
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; } }
public void stopJobExecution(final Long jobExecutionId, final String applicationInstanceId) { final LightminClientApplication lightminClientApplication = this.findLightminClientApplicatonById(applicationInstanceId); try { this.jobServerService.stopJobExecution(jobExecutionId, lightminClientApplication); } catch (final Exception e) { throw new SpringBatchLightminApplicationException("Could not stop Job"); } }
public void restartJobExecution(final Long jobExecutionId, final String applicationInstanceId) { final LightminClientApplication lightminClientApplication = this.findLightminClientApplicatonById(applicationInstanceId); try { this.jobServerService.restartJobExecution(jobExecutionId, lightminClientApplication); } catch (final Exception e) { throw new SpringBatchLightminApplicationException("Could not restart Job"); } }
@Override public void saveJobConfiguration(final JobConfiguration jobConfiguration, final LightminClientApplication lightminClientApplication) { final HttpEntity<JobConfiguration> entity = RequestUtil.createApplicationJsonEntity(jobConfiguration); final ResponseEntity<Void> response = this.restTemplate.postForEntity(this.getClientUri(lightminClientApplication), entity, Void.class); if (!HttpStatus.CREATED.equals(response.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + response.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } }
@Override public void launchJob(final JobLaunch jobLaunch, final LightminClientApplication lightminClientApplication) { final String uri = this.getClientUri(lightminClientApplication) + "/joblaunches"; final HttpEntity<JobLaunch> entity = RequestUtil.createApplicationJsonEntity(jobLaunch); final ResponseEntity<Void> response = this.restTemplate.postForEntity(uri, entity, Void.class); if (!HttpStatus.CREATED.equals(response.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + response.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } }
@Override public void saveJobConfiguration(final JobConfiguration jobConfiguration, final LightminClientApplication lightminClientApplication) { final HttpEntity<JobConfiguration> entity = RequestUtil.createApplicationJsonEntity(jobConfiguration); final ResponseEntity<Void> response = this.restTemplate.postForEntity(this.getClientUri(lightminClientApplication), entity, Void.class); if (!HttpStatus.CREATED.equals(response.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + response.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } }
@Override public void launchJob(final JobLaunch jobLaunch, final LightminClientApplication lightminClientApplication) { final String uri = this.getClientUri(lightminClientApplication) + "/joblaunches"; final HttpEntity<JobLaunch> entity = RequestUtil.createApplicationJsonEntity(jobLaunch); final ResponseEntity<Void> response = this.restTemplate.postForEntity(uri, entity, Void.class); if (!HttpStatus.CREATED.equals(response.getStatusCode())) { final String errorMessage = "ERROR - HTTP STATUS: " + response.getStatusCode(); throw new SpringBatchLightminApplicationException(errorMessage); } }
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; }
@Override public JobConfiguration getJobConfigurationById(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.attachSchedulerStatus(jobConfiguration); return jobConfiguration; } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } }