List of usage examples for org.springframework.batch.core JobExecution getStepExecutions
public Collection<StepExecution> getStepExecutions()
From source file:nu.yona.server.batch.service.BatchJobResultDto.java
static BatchJobResultDto createInstance(JobExecution jobExecution) { return new BatchJobResultDto(jobExecution.getStepExecutions().stream() .collect(Collectors.toMap(StepExecution::getStepName, StepExecution::getWriteCount))); }
From source file:org.seedstack.spring.batch.fixtures.FlatFileBatchDemo.java
protected static void printStatistics(JobExecution jobExecution) { for (StepExecution stepExecution : jobExecution.getStepExecutions()) { System.out.println("-----------------------------------"); System.out.println("STEP name: " + stepExecution.getStepName()); System.out.println("-----------------------------------"); System.out.println("CommitCount: " + stepExecution.getCommitCount()); System.out.println("FilterCount: " + stepExecution.getFilterCount()); System.out.println("ProcessSkipCount: " + stepExecution.getProcessSkipCount()); System.out.println("ReadCount: " + stepExecution.getReadCount()); System.out.println("ReadSkipCount: " + stepExecution.getReadSkipCount()); System.out.println("RollbackCount: " + stepExecution.getRollbackCount()); System.out.println("SkipCount: " + stepExecution.getSkipCount()); System.out.println("WriteCount: " + stepExecution.getWriteCount()); System.out.println("WriteSkipCount: " + stepExecution.getWriteSkipCount()); if (stepExecution.getFailureExceptions().size() > 0) { System.out.println("exceptions:"); System.out.println("-----------------------------------"); for (Throwable t : stepExecution.getFailureExceptions()) { System.out.println(t.getMessage()); }/*from w ww. java 2 s. c om*/ } System.out.println("-----------------------------------"); } }
From source file:be.ordina.springbatch.batch.listener.TrajectInformationJobExecutionListener.java
@Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) { int reads = jobExecution.getStepExecutions().stream().mapToInt(se -> se.getReadCount()).sum(); int writes = jobExecution.getStepExecutions().stream().mapToInt(se -> se.getWriteCount()).sum(); int skips = jobExecution.getStepExecutions().stream().mapToInt(se -> se.getSkipCount()).sum(); System.out.println("BATCH COMPLETED WITH GREAT SUCCESS reads = [ " + reads + " ] writes = [ " + writes + " ] skips = [" + skips + "]"); for (LicensePlateType licensePlateType : LicensePlateType.values()) { System.out.println(licensePlateType.name().toLowerCase() + " - " + jobExecution.getExecutionContext().getInt(licensePlateType.name(), 0)); }// ww w . j a v a 2 s.c o m System.out.println( "Total grave errors this batch : " + jobExecution.getExecutionContext().getInt("graveErrors")); System.out.println("Total money stolen from the honest speeder : " + jobExecution.getExecutionContext().getDouble("total") + ""); } else { System.err.println("BATCH COMPLETED WITH STATUS " + jobExecution.getExitStatus().getExitCode()); } }
From source file:com.javaetmoi.elasticsearch.musicbrainz.batch.TestMusicAlbumJob.java
private StepExecution getStepExecution(JobExecution jobExecution, String name) { for (StepExecution step : jobExecution.getStepExecutions()) { if (step.getStepName().equals(name)) { return step; }/*from w w w. j av a2s. c o m*/ } return null; }
From source file:org.jasig.ssp.util.importer.job.twodottwo.StageSuccessTest.java
@Test public void testStageSuccess() throws Exception { //Test file should have 1 step which should write successfully JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions(); for (StepExecution stepExecution : stepExecutions) { Assert.assertEquals(stepExecution.getWriteCount(), 1); }/*from ww w . j av a2s. c o m*/ BatchStatus exitStatus = jobExecution.getStatus(); Assert.assertEquals(BatchStatus.COMPLETED, exitStatus); }
From source file:org.jasig.ssp.util.importer.job.twodottwo.StageSuccessWithSkipTest.java
@Test public void testStageSuccessWithSkip() throws Exception { //Test file should have 1 step which should write successfully but skip 1 line JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions(); for (StepExecution stepExecution : stepExecutions) { Assert.assertEquals(1, stepExecution.getWriteCount()); Assert.assertEquals(1, stepExecution.getSkipCount()); }/*from www.j av a2 s. c o m*/ BatchStatus exitStatus = jobExecution.getStatus(); Assert.assertEquals(BatchStatus.COMPLETED, exitStatus); }
From source file:io.spring.batch.integration.ExecutionToTweetTransformer.java
private BatchStatus endingBatchStatus(JobExecution execution) { BatchStatus status = execution.getStatus(); Collection<StepExecution> stepExecutions = execution.getStepExecutions(); if (stepExecutions.size() > 0) { for (StepExecution stepExecution : stepExecutions) { if (stepExecution.getStatus().equals(BatchStatus.FAILED)) { status = BatchStatus.FAILED; break; } else { status = BatchStatus.COMPLETED; }//from w w w .j av a 2s. c om } } return status; }
From source file:nu.yona.server.batch.service.BatchTaskService.java
public BatchJobResultDto aggregateActivities() { logger.info("Triggering activity aggregation"); JobParameters jobParameters = new JobParametersBuilder().addDate("uniqueInstanceId", new Date()) .toJobParameters();/*from w ww .j a v a 2 s. c o m*/ // NOTICE: executes the job synchronously, on purpose, because the tests rely on this (they assert on job execution // results) and this is normally not scheduled manually JobExecution jobExecution = launchImmediatelySynchronously(activityAggregationJob, jobParameters); jobExecution.getStepExecutions().forEach(e -> logger.info("Step {} read {} entities and wrote {}", e.getStepName(), e.getReadCount(), e.getWriteCount())); return BatchJobResultDto.createInstance(jobExecution); }
From source file:de.langmi.spring.batch.examples.complex.skip.simple.SkipJobListener.java
@Override public void afterJob(JobExecution jobExecution) { LOG.debug("after job"); for (StepExecution stepExecution : jobExecution.getStepExecutions()) { LOG.debug(stepExecution.getSummary()); }/*w ww .j a v a 2 s . c o m*/ }
From source file:com.javaetmoi.core.batch.test.EndTasklet.java
private List<StepExecution> getUnpartitionedStepExecution(JobExecution jobExecution) { List<StepExecution> unpartitionedStepExecution = new ArrayList<StepExecution>(); Collection<StepExecution> allStepExecutions = jobExecution.getStepExecutions(); for (StepExecution stepExecution : allStepExecutions) { if (!stepExecution.getStepName().contains(":partition")) { unpartitionedStepExecution.add(stepExecution); }//ww w .ja v a 2 s.com } return unpartitionedStepExecution; }