List of usage examples for org.springframework.batch.core StepExecution getFailureExceptions
public List<Throwable> getFailureExceptions()
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()); }// ww w . ja v a2s . co m } System.out.println("-----------------------------------"); } }
From source file:com.philips.cn.hr.pps.App.java
private void startCaclBtnActionPerformed(java.awt.event.ActionEvent evt) { String f1 = this.filePath1.getText(); String f2 = this.filePath2.getText(); String saveTo = this.saveToPath.getText(); StringBuffer message = new StringBuffer(); if (!isInputValidate(f1, f2, saveTo)) { message.append("file path null is not allowed"); JOptionPane.showMessageDialog(null, message); // System.exit(0); return;//from w ww .j a v a 2 s .c o m } System.out.println("going to execute application with parameters " + Arrays.asList(f1, f2, saveTo)); JobExecution jobExecution = null; try { jobExecution = Application.execute(f1, f2, saveTo, false); } catch (Exception e) { e.printStackTrace(); message.append(e.getMessage()); JOptionPane.showMessageDialog(null, message); return; } if (jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) { //job completed; message.append("Job execution completed ,Please verify generated files in "); message.append(saveTo); JOptionPane.showMessageDialog(null, message); } else { // for (Throwable exception : jobExecution.getAllFailureExceptions()) { // message.append("cause:" + exception.getCause()).append("message " + exception.getMessage()); // } // JOptionPane.showMessageDialog(null, message); for (StepExecution stepExecution : jobExecution.getStepExecutions()) { if (!stepExecution.getExitStatus().equals(ExitStatus.COMPLETED)) { message.append(stepExecution.getFailureExceptions()); message.append(" occurred when executing "); message.append(stepExecution.getStepName()); break; } } JOptionPane.showMessageDialog(null, message); } // System.exit(0);don't exit; return; }
From source file:org.seedstack.monitoring.batch.internal.rest.stepexecution.StepExecutionDetailsRepresentation.java
/** * Constructor that substitutes in null for the execution id. * * @param stepExecution the step execution *//*from w w w.j av a 2s .c o m*/ public StepExecutionDetailsRepresentation(StepExecution stepExecution) { Assert.notNull(stepExecution.getId(), "The entity Id must be provided to re-hydrate an existing StepExecution"); this.stepName = stepExecution.getStepName(); this.commitCount = stepExecution.getCommitCount(); this.endTime = stepExecution.getEndTime() == null ? "" : timeFormat.format(stepExecution.getEndTime()); this.executionContext = stepExecution.getExecutionContext(); this.statusExitCode = stepExecution.getExitStatus() != null ? stepExecution.getExitStatus().getExitCode() : ""; this.statusExitDescription = stepExecution.getExitStatus() != null ? stepExecution.getExitStatus().getExitDescription() : ""; this.failureExceptions = stepExecution.getFailureExceptions(); this.filterCount = stepExecution.getFilterCount(); this.lastUpdated = stepExecution.getLastUpdated() == null ? "" : dateFormat.format(stepExecution.getLastUpdated()); this.processSkipCount = stepExecution.getProcessSkipCount(); this.readCount = stepExecution.getReadCount(); this.readSkipCount = stepExecution.getReadSkipCount(); this.rollbackCount = stepExecution.getRollbackCount(); this.startTime = timeFormat.format(stepExecution.getStartTime()); this.status = stepExecution.getStatus(); this.stepName = stepExecution.getStepName(); this.terminateOnly = stepExecution.isTerminateOnly(); this.writeCount = stepExecution.getWriteCount(); this.writeSkipCount = stepExecution.getWriteSkipCount(); }
From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanRetryTests.java
@SuppressWarnings("unchecked") @Test/*from w w w .jav a 2s . co m*/ public void testNonSkippableException() throws Exception { // Very specific skippable exception factory.setSkippableExceptionClasses(getExceptionMap(UnsupportedOperationException.class)); // ...which is not retryable... factory.setRetryableExceptionClasses(getExceptionMap()); factory.setSkipLimit(1); ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("b")) { @Override public String read() { String item = super.read(); provided.add(item); count++; return item; } }; ItemWriter<String> itemWriter = new ItemWriter<String>() { @Override public void write(List<? extends String> item) throws Exception { processed.addAll(item); written.addAll(item); logger.debug("Write Called! Item: [" + item + "]"); throw new RuntimeException("Write error - planned but not skippable."); } }; factory.setItemReader(provider); factory.setItemWriter(itemWriter); Step step = factory.getObject(); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); repository.add(stepExecution); step.execute(stepExecution); String message = stepExecution.getFailureExceptions().get(0).getMessage(); assertTrue("Wrong message: " + message, message.contains("Write error - planned but not skippable.")); List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("")); assertEquals(expectedOutput, written); assertEquals(0, stepExecution.getSkipCount()); // [b] assertEquals("[b]", provided.toString()); // [b] assertEquals("[b]", processed.toString()); // [] assertEquals(0, recovered.size()); assertEquals(1, stepExecution.getReadCount()); }