Java Code Examples for org.springframework.batch.core.JobExecution#setStatus()
The following examples show how to use
org.springframework.batch.core.JobExecution#setStatus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTaskJobServiceTests.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
private void createSampleJob(JobRepository jobRepository, TaskBatchDao taskBatchDao, TaskExecutionDao taskExecutionDao, String jobName, int jobExecutionCount, BatchStatus status) { JobInstance instance = jobRepository.createJobInstance(jobName, new JobParameters()); TaskExecution taskExecution = taskExecutionDao.createTaskExecution(jobName, new Date(), new ArrayList<>(), null); JobExecution jobExecution; for (int i = 0; i < jobExecutionCount; i++) { jobExecution = jobRepository.createJobExecution(instance, this.jobParameters, null); StepExecution stepExecution = new StepExecution("foo", jobExecution, 1L); stepExecution.setId(null); jobRepository.add(stepExecution); taskBatchDao.saveRelationship(taskExecution, jobExecution); jobExecution.setStatus(status); jobExecution.setStartTime(new Date()); jobRepository.update(jobExecution); } }
Example 2
Source File: JobExecutionUtils.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
private static void createSampleJob(JobRepository jobRepository, TaskBatchDao taskBatchDao, TaskExecutionDao taskExecutionDao, String jobName, int jobExecutionCount, BatchStatus status) { JobInstance instance = jobRepository.createJobInstance(jobName, new JobParameters()); TaskExecution taskExecution = taskExecutionDao.createTaskExecution(jobName, new Date(), new ArrayList<>(), null); JobExecution jobExecution; for (int i = 0; i < jobExecutionCount; i++) { jobExecution = jobRepository.createJobExecution(instance, new JobParameters(), null); StepExecution stepExecution = new StepExecution("foo", jobExecution, 1L); stepExecution.setId(null); jobRepository.add(stepExecution); taskBatchDao.saveRelationship(taskExecution, jobExecution); jobExecution.setStatus(status); jobExecution.setStartTime(new Date()); if (BatchStatus.STOPPED.equals(status)) { jobExecution.setEndTime(new Date()); } jobRepository.update(jobExecution); } }
Example 3
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testIsJobExecutionAbandonableWithNullBatchStatus() { try { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(null); JobUtils.isJobExecutionAbandonable(jobExecution); fail("Expected an IllegalArgumentException to be thrown."); } catch (IllegalArgumentException e) { assertEquals("The BatchStatus of the provided jobExecution must not be null.", e.getMessage()); } }
Example 4
Source File: JobExecutionMapperTest.java From batchers with Apache License 2.0 | 5 votes |
@Test public void testToJobResultTo() throws Exception { //ARRANGE Date now = DateTime.now().toDate(); JobInstance jobInstance = new JobInstance(JOB_ID, JOB_NAME); JobParameters jobParams = new JobParameters(); JobExecution jobExecution = new JobExecution(jobInstance, jobParams); jobExecution.setStatus(BatchStatus.ABANDONED); jobExecution.setStartTime(new DateTime(now).minusSeconds(DURATION_IN_SECONDS).toDate()); jobExecution.setEndTime(now); jobExecution.setId(JOB_EXECUTION_ID); Map.Entry<JobInstance, List<JobExecution>> entry = new Map.Entry<JobInstance, List<JobExecution>>() { @Override public JobInstance getKey() { return jobInstance; } @Override public List<JobExecution> getValue() { return Arrays.asList(jobExecution); } @Override public List<JobExecution> setValue(List<JobExecution> value) { return null; } }; //ACT JobResult resultTo = mapper.toJobResultTo(entry); //ASSERT assertThat(resultTo.getJobExecutionResults()).hasSize(1); JobExecutionResult jobExecutionResult = resultTo.getJobExecutionResults().get(0); assertThat(jobExecutionResult.getStatus()).isEqualTo(BatchStatus.ABANDONED.toString()); assertThat(jobExecutionResult.getDuration()).isEqualTo(DURATION_IN_SECONDS * 1000); }
Example 5
Source File: ChangeStatusOnFailedStepsJobExecListener.java From batchers with Apache License 2.0 | 5 votes |
@Override public void afterJob(JobExecution jobExecution) { List<StepExecution> failedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) .collect(Collectors.toList()); if (failedStepExecutions.size() > 0) { jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setExitStatus(new ExitStatus("FAILED-BECAUSE-OF-SKIPS")); } }
Example 6
Source File: JobExecutionControllerTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private void createDirtyJob() { JobInstance instance = jobRepository.createJobInstance(JobExecutionUtils.BASE_JOB_NAME + "_NO_TASK", new JobParameters()); JobExecution jobExecution = jobRepository.createJobExecution( instance, new JobParameters(), null); jobExecution.setStatus(BatchStatus.STOPPED); jobExecution.setEndTime(new Date()); jobRepository.update(jobExecution); }
Example 7
Source File: JobExecutionsDocumentation.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private void createJobExecution(String name, BatchStatus status) { TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null); Map<String, JobParameter> jobParameterMap = new HashMap<>(); jobParameterMap.put("-spring.cloud.data.flow.platformname", new JobParameter("default")); JobParameters jobParameters = new JobParameters(jobParameterMap); JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), jobParameters, null); this.taskBatchDao.saveRelationship(taskExecution, jobExecution); jobExecution.setStatus(status); jobExecution.setStartTime(new Date()); this.jobRepository.update(jobExecution); }
Example 8
Source File: JobStepExecutionsDocumentation.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private void createJobExecution(String name, BatchStatus status) { TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null); JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), new JobParameters(), null); StepExecution stepExecution = new StepExecution(name + "_STEP", jobExecution, jobExecution.getId()); stepExecution.setId(null); jobRepository.add(stepExecution); this.taskBatchDao.saveRelationship(taskExecution, jobExecution); jobExecution.setStatus(status); jobExecution.setStartTime(new Date()); this.jobRepository.update(jobExecution); }
Example 9
Source File: JobInstancesDocumentation.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private void createJobExecution(String name, BatchStatus status) { TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null); JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), new JobParameters(), null); this.taskBatchDao.saveRelationship(taskExecution, jobExecution); jobExecution.setStatus(status); jobExecution.setStartTime(new Date()); this.jobRepository.update(jobExecution); }
Example 10
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testIsJobExecutionStoppableWithNullBatchStatus() { try { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(null); JobUtils.isJobExecutionStoppable(jobExecution); fail("Expected an IllegalArgumentException to be thrown."); } catch (IllegalArgumentException e) { assertEquals("The BatchStatus of the provided jobExecution must not be null.", e.getMessage()); } }
Example 11
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testIsJobExecutionRestartableWithNullBatchStatus() { try { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(null); JobUtils.isJobExecutionRestartable(jobExecution); fail("Expected an IllegalArgumentException to be thrown."); } catch (IllegalArgumentException e) { assertEquals("The BatchStatus of the provided jobExecution must not be null.", e.getMessage()); } }
Example 12
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test public void testIsJobExecutionAbandonableWithFailedBatchStatus() { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(BatchStatus.FAILED); assertTrue(JobUtils.isJobExecutionAbandonable(jobExecution)); }
Example 13
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test public void testIsJobExecutionRestartableWithFailedBatchStatus() { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(BatchStatus.FAILED); assertTrue(JobUtils.isJobExecutionRestartable(jobExecution)); }
Example 14
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test public void testIsJobExecutionStoppableWithFailedBatchStatus() { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(BatchStatus.FAILED); assertFalse(JobUtils.isJobExecutionStoppable(jobExecution)); }
Example 15
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test public void testIsJobExecutionAbandonableWithCompletedBatchStatus() { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(BatchStatus.COMPLETED); assertFalse(JobUtils.isJobExecutionAbandonable(jobExecution)); }
Example 16
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test public void testIsJobExecutionRestartableWithCompletedBatchStatus() { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(BatchStatus.COMPLETED); assertFalse(JobUtils.isJobExecutionRestartable(jobExecution)); }
Example 17
Source File: JobUtilsTests.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test public void testIsJobExecutionStoppableWithCompletedBatchStatus() { final JobExecution jobExecution = new JobExecution(1L); jobExecution.setStatus(BatchStatus.COMPLETED); assertFalse(JobUtils.isJobExecutionStoppable(jobExecution)); }