Java Code Examples for org.springframework.batch.core.JobExecution#getStatus()
The following examples show how to use
org.springframework.batch.core.JobExecution#getStatus() .
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: AlarmJobTest.java From pinpoint with Apache License 2.0 | 8 votes |
public static void main(String[] args) throws Exception{ GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext("/applicationContext-test.xml"); JobLauncherTestUtils testLauncher = applicationContext.getBean(JobLauncherTestUtils.class); JobExecution jobExecution = testLauncher.launchJob(getParameters()); BatchStatus status = jobExecution.getStatus(); assertEquals(BatchStatus.COMPLETED, status); applicationContext.close(); }
Example 2
Source File: JobCompletionPayRollListener.java From Software-Architecture-with-Spring-5.0 with MIT License | 7 votes |
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { log.info(">>>>> PAY ROLL JOB FINISHED! "); jdbcTemplate.query("SELECT PERSON_IDENTIFICATION, CURRENCY, TX_AMMOUNT, ACCOUNT_TYPE, ACCOUNT_ID, TX_DESCRIPTION, FIRST_LAST_NAME FROM PAYROLL", (rs, row) -> new PayrollTo( rs.getInt(1), rs.getString(2), rs.getDouble(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7)) ).forEach(payroll -> log.info("Found <" + payroll + "> in the database.")); } }
Example 3
Source File: JobCompleteNotificationListener.java From CogStack-Pipeline with Apache License 2.0 | 7 votes |
@Override public synchronized void afterJob(JobExecution jobExecution) { if(jobExecution.getStatus() == BatchStatus.COMPLETED) { if(columnRangePartitioner.isFirstRun()){ columnRangePartitioner.setFirstRun(false); } log.info("!!! JOB FINISHED! promoting last good record date to JobExecutionContext"); jobExecution.getExecutionContext().put("last_successful_timestamp_from_this_job", timeOfNextJob); jobRepository.updateExecutionContext(jobExecution); // Workaround to close ElasticSearch REST properly (the job was stuck before this change) if (esRestService != null) { try { esRestService.destroy(); } catch (IOException e) { log.warn("IOException when destroying ElasticSearch REST service"); } log.debug("Shutting down ElasticSearch REST service"); esServiceAlreadyClosed = true; } } }
Example 4
Source File: JdbcBatchItemWriterJobListener.java From spring-cloud with Apache License 2.0 | 6 votes |
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { log.info("JdbcBatchItemWriter job finished"); } else { log.info("JdbcBatchItemWriter job " + jobExecution.getStatus().name()); } }
Example 5
Source File: JobExecutionEvent.java From spring-cloud-task with Apache License 2.0 | 6 votes |
/** * Constructor for the StepExecution to initialize the DTO. * @param original the StepExecution to build this DTO around. */ public JobExecutionEvent(JobExecution original) { this.jobParameters = new JobParametersEvent( original.getJobParameters().getParameters()); this.jobInstance = new JobInstanceEvent(original.getJobInstance().getId(), original.getJobInstance().getJobName()); for (StepExecution stepExecution : original.getStepExecutions()) { this.stepExecutions.add(new StepExecutionEvent(stepExecution)); } this.status = original.getStatus(); this.startTime = original.getStartTime(); this.createTime = original.getCreateTime(); this.endTime = original.getEndTime(); this.lastUpdated = original.getLastUpdated(); this.exitStatus = new ExitStatus(original.getExitStatus()); this.executionContext = original.getExecutionContext(); this.failureExceptions = original.getFailureExceptions(); this.jobConfigurationName = original.getJobConfigurationName(); this.setId(original.getId()); this.setVersion(original.getVersion()); }
Example 6
Source File: JobCompletionNotificationListener.java From spring-boot-samples with Apache License 2.0 | 6 votes |
@Override public void afterJob(JobExecution jobExecution) { if(jobExecution.getStatus() == BatchStatus.COMPLETED) { log.info("!!! JOB FINISHED! Time to verify the results"); List<Person> results = jdbcTemplate.query("SELECT first_name, last_name FROM people", new RowMapper<Person>() { @Override public Person mapRow(ResultSet rs, int row) throws SQLException { return new Person(rs.getString(1), rs.getString(2)); } }); for (Person person : results) { log.info("Found <" + person + "> in the database."); } } }
Example 7
Source File: SettleJobListeners.java From seed with Apache License 2.0 | 6 votes |
@Override public void afterJob(JobExecution jobExecution) { if(jobExecution.getStatus() == BatchStatus.COMPLETED){ LogUtil.getLogger().info("批量任务Job-->[{}-{}]-->处理完成,TotalDuration[{}]ms", jobExecution.getJobId(), jobExecution.getJobInstance().getJobName(), SystemClockUtil.INSTANCE.now()-jobExecution.getStartTime().getTime()); LogUtil.getLogger().info("======================================================================="); } }
Example 8
Source File: NotificationListener.java From batch-processing-large-datasets-spring with MIT License | 6 votes |
@Override public void afterJob(final JobExecution jobExecution) { if(jobExecution.getStatus() == BatchStatus.COMPLETED) { LOGGER.info("!!! JOB FINISHED! Time to verify the results"); jdbcTemplate.query("SELECT volt, time FROM voltage", (rs, row) -> new Voltage( rs.getBigDecimal(1), rs.getDouble(2)) ).forEach(voltage -> LOGGER.info("Found <" + voltage + "> in the database.")); } }
Example 9
Source File: JobUtils.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Determine whether the provided {@link JobExecution} is restartable. * * @param jobExecution Must not be null and its {@link BatchStatus} must not be null * either. * @return Never returns null */ public static boolean isJobExecutionRestartable(JobExecution jobExecution) { Assert.notNull(jobExecution, "The provided jobExecution must not be null."); final BatchStatus batchStatus = jobExecution.getStatus(); Assert.notNull(batchStatus, "The BatchStatus of the provided jobExecution must not be null."); return batchStatus.isGreaterThan(BatchStatus.STOPPING) && batchStatus.isLessThan(BatchStatus.ABANDONED); }
Example 10
Source File: JobUtils.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Determine whether the provided {@link JobExecution} is abandonable. * * @param jobExecution Must not be null and its {@link BatchStatus} must not be null * either. * @return Never returns null */ public static boolean isJobExecutionAbandonable(JobExecution jobExecution) { Assert.notNull(jobExecution, "The provided jobExecution must not be null."); final BatchStatus batchStatus = jobExecution.getStatus(); Assert.notNull(batchStatus, "The BatchStatus of the provided jobExecution must not be null."); return batchStatus.isGreaterThan(BatchStatus.STARTED) && batchStatus != BatchStatus.ABANDONED; }
Example 11
Source File: JobUtils.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Determine whether the provided {@link JobExecution} is stoppable. * * @param jobExecution Must not be null and its {@link BatchStatus} must not be null * either. * @return Never returns null */ public static boolean isJobExecutionStoppable(JobExecution jobExecution) { Assert.notNull(jobExecution, "The provided jobExecution must not be null."); final BatchStatus batchStatus = jobExecution.getStatus(); Assert.notNull(batchStatus, "The BatchStatus of the provided jobExecution must not be null."); return batchStatus.isLessThan(BatchStatus.STOPPING) && batchStatus != BatchStatus.COMPLETED; }
Example 12
Source File: JpaPagingBatchJobListener.java From spring-cloud with Apache License 2.0 | 5 votes |
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { log.info("JpaPagingBatch job finished"); } else { log.info("JpaPagingBatch job " + jobExecution.getStatus().name()); } }
Example 13
Source File: RepositoryItemWriterJobListener.java From spring-cloud with Apache License 2.0 | 5 votes |
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { log.info("RepositoryItemWriter job finished, Time to verify the results"); List<People> results = jdbcTemplate.query("SELECT person_id, first_name, last_name FROM people", (rs, row) -> new People(rs.getString(1) , rs.getString(2) , rs.getString(3) )); for (People people : results) { log.info("Found <" + people + "> in the database."); } } }
Example 14
Source File: ChangeStatusOnFailedStepsJobExecListenerTest.java From batchers with Apache License 2.0 | 5 votes |
@Test public void testAfterJobJobExecutionHasBatchStatusUnchangedWhenAllStepsCompleted() throws Exception { JobExecution jobExecution = new JobExecution(1L); StepExecution completedStepExecution = createStepExecution(jobExecution, COMPLETED); StepExecution anotherStepExecution = createStepExecution(jobExecution, COMPLETED); jobExecution.addStepExecutions(asList(completedStepExecution, anotherStepExecution)); BatchStatus jobExecutionStatus = jobExecution.getStatus(); changeStatusOnFailedStepsJobExecListener.afterJob(jobExecution); assertThat(jobExecution.getStatus()).isEqualTo(jobExecutionStatus); }
Example 15
Source File: BaseJobExecutionListener.java From spring-boot-doma2-sample with Apache License 2.0 | 4 votes |
@Override public void afterJob(JobExecution jobExecution) { // コンテキストを取り出す val context = BatchContextHolder.getContext(); // 機能別の終了処理を呼び出す try { after(jobExecution, context); } catch (Throwable t) { log.error("exception occurred. ", t); throw new IllegalStateException(t); } finally { // 共通の終了処理 try { val batchId = context.getBatchId(); val batchName = context.getBatchName(); val jobStatus = jobExecution.getStatus(); val endTime = jobExecution.getEndTime(); if (log.isDebugEnabled()) { val jobId = jobExecution.getJobId(); val jobInstance = jobExecution.getJobInstance(); val jobInstanceId = jobInstance.getInstanceId(); log.debug("job executed. [job={}(JobInstanceId:{} status:{})] in {}ms", jobId, jobInstanceId, jobStatus, took(jobExecution)); jobExecution.getStepExecutions() .forEach(s -> log.debug("step executed. [step={}] in {}ms", s.getStepName(), took(s))); } if (!jobStatus.isRunning()) { log.info("*********************************************"); log.info("* バッチID : {}", batchId); log.info("* バッチ名 : {}", batchName); log.info("* ステータス : {}", jobStatus.getBatchStatus().toString()); log.info("* 対象件数 : {}", context.getTotalCount()); log.info("* 処理件数 : {}", context.getProcessCount()); log.info("* エラー件数 : {}", context.getErrorCount()); log.info("* 終了時刻 : {}", DateUtils.format(endTime, YYYY_MM_DD_HHmmss)); log.info("*********************************************"); } } finally { MDC.remove(MDC_BATCH_ID); // 監査情報をクリアする AuditInfoHolder.clear(); // ジョブコンテキストをクリアする context.clear(); } } }
Example 16
Source File: JobCompletionNotificationListener.java From spring-batch-rest with Apache License 2.0 | 4 votes |
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { semaphore.release(); } }
Example 17
Source File: ReportsExecutionJob.java From POC with Apache License 2.0 | 4 votes |
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { log.info("BATCH JOB COMPLETED SUCCESSFULLY"); } }
Example 18
Source File: TaskJobLauncherCommandLineRunner.java From spring-cloud-task with Apache License 2.0 | 4 votes |
private boolean isStoppedOrFailed(JobExecution execution) { BatchStatus status = execution.getStatus(); return (status == BatchStatus.STOPPED || status == BatchStatus.FAILED); }