List of usage examples for org.springframework.batch.core StepExecution getExitStatus
public ExitStatus getExitStatus()
From source file:de.langmi.spring.batch.examples.complex.file.renamefile.partition.extrastep.PropagateFileNamesListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { // get business key String businessKey = (String) stepExecution.getExecutionContext() .get(BatchConstants.CONTEXT_NAME_BUSINESS_KEY); this.fileNames.put(outputFile, businessKey); return stepExecution.getExitStatus(); }
From source file:org.duracloud.snapshot.service.impl.SpaceItemWriter.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { log.debug("Step complete with status: {}", stepExecution.getExitStatus()); try {/* w w w . ja v a 2s . c o m*/ md5Writer.close(); } catch (IOException ioe) { log.error("Error closing MD5 manifest BufferedWriter: ", ioe); } try { sha256Writer.close(); } catch (IOException ioe) { log.error("Error closing SHA-256 manifest BufferedWriter: ", ioe); } retrieveSnapshotProperties(); try { synchronized (propsWriter) { propsWriter.write("]\n"); } } catch (IOException ioe) { log.error("Error writing end of content property " + "manifest: ", ioe); } try { propsWriter.close(); } catch (IOException ioe) { log.error("Error closing content property " + "manifest BufferedWriter: ", ioe); } return stepExecution.getExitStatus(); }
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 w w . ja 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.duracloud.snapshot.service.impl.SyncWriter.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { try {/* w w w. j a v a 2 s . c o m*/ restoreManager.transitionRestoreStatus(restorationId, RestoreStatus.TRANSFER_TO_DURACLOUD_COMPLETE, ""); } catch (Exception e) { log.error("failed to transition restore status: " + e.getMessage(), e); return ExitStatus.FAILED; } return stepExecution.getExitStatus(); }
From source file:org.trpr.platform.batch.impl.spring.jmx.JobAdministrator.java
/** * Returns the JobStatistics array for all jobs deployed locally * @return JobStatistics array containing one instance per job deployed locally *///from www. j a v a2 s. c om private JobStatistics[] getStats() { JobStatistics[] jobStatistics = new JobStatistics[this.getJobOperator().getJobNames().size()]; int count = 0; for (String jobName : this.getJobOperator().getJobNames()) { jobStatistics[count] = new JobStatistics(); jobStatistics[count].setHostIP(this.getHostIP()); jobStatistics[count].setHostStartTimeStamp(this.getHostStartTimeStamp()); jobStatistics[count].setJobName(jobName); // get the last run JobInstance if any List<JobInstance> jobInstancesList = this.getJobExplorer().getJobInstances(jobName, 0, 1); // end is set as 1 to get a single element List if (jobInstancesList.size() > 0) { // there is at least one job instance // get the first i.e. the most recent job instance JobInstance jobInstance = jobInstancesList.get(0); // now get all successful JobExecution(s) for this JobInstance List<JobExecution> jobExecutionList = this.getJobExplorer().getJobExecutions(jobInstance); if (jobExecutionList.size() > 0) { // there is at least one job execution for the job instance // get the first i.e. the most recent job execution JobExecution jobExecution = jobExecutionList.get(0); jobStatistics[count].setJobStatus(jobExecution.getStatus().name()); if (jobExecution.getStatus() == BatchStatus.FAILED) { // try to get the exit description from the contained steps that errored out Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions(); for (StepExecution step : stepExecutions) { jobStatistics[count].getJobSteps().add(step.getStepName()); if (step.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) { jobStatistics[count].setJobStepInError(step.getStepName()); jobStatistics[count].setJobMessage(step.getExitStatus().getExitDescription()); } } } else { jobStatistics[count].setJobMessage(jobExecution.getExitStatus().getExitDescription()); } Calendar jobStartTimeStamp = Calendar.getInstance(); jobStartTimeStamp.setTime(jobExecution.getStartTime()); jobStatistics[count].setJobStartTimeStamp(jobStartTimeStamp); Calendar jobEndTimeStamp = Calendar.getInstance(); jobEndTimeStamp.setTime(jobExecution.getEndTime()); jobStatistics[count].setJobEndTimestamp(jobEndTimeStamp); } } count += 1; } return jobStatistics; }
From source file:org.seedstack.monitoring.batch.internal.rest.job.JobResource.java
/** * Retrieves the jobs tree.// w ww .j a va 2s . com * * @param jobName the job name * @return the response */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("/jobs-tree/{jobName}") @RequiresPermissions("seed:monitoring:batch:read") public Response jobsTree(@PathParam("jobName") String jobName) { int countJobInstances; try { countJobInstances = jobService.countJobExecutionsForJob(jobName); } catch (NoSuchJobException e1) { return Response.status(Response.Status.BAD_REQUEST).entity("There is no such jobs ") .type(MediaType.TEXT_PLAIN).build(); } if (countJobInstances == 0) { String error = "wrong job name " + jobName; return Response.status(Response.Status.BAD_REQUEST).entity(error).type(MediaType.TEXT_PLAIN).build(); } JobsTreeRepresentation jobsTreeRepresentation = new JobsTreeRepresentation(); int countJobs = jobService.countJobs(); Collection<String> listJobs = jobService.listJobs(0, countJobs); jobsTreeRepresentation.setJobNameList(listJobs); jobsTreeRepresentation.setName(jobName); jobsTreeRepresentation.setStatus(TREE_MAINNODE); jobsTreeRepresentation.setLink(TREE_URL_BATCH_JOBS_LIST); Collection<JobExecution> listJobExecutionsForJob; try { listJobExecutionsForJob = jobService.listJobExecutionsForJob(jobName, 0, countJobInstances); } catch (NoSuchJobException e) { return Response.status(Response.Status.BAD_REQUEST) .entity("There is no such job execution by jobname (" + jobName + ")") .type(MediaType.TEXT_PLAIN).build(); } /* list of job execution by job */ List<JobsTreeRepresentation> childrenJobExecution = new ArrayList<JobsTreeRepresentation>(); for (JobExecution jobExecution : listJobExecutionsForJob) { JobsTreeRepresentation jobExecTreeRepresentation = new JobsTreeRepresentation(); jobExecTreeRepresentation.setName("[id= " + jobExecution.getId() + "];" + jobExecution.getJobParameters().getParameters().toString()); jobExecTreeRepresentation.setLink(TREE_URL_BATCH_JOBS_LIST + "/" + jobName); jobExecTreeRepresentation.setSize(TREE_SIZE_JOBEXECUTION); jobExecTreeRepresentation.setStatus(jobExecution.getExitStatus().getExitCode()); Collection<StepExecution> stepExecutions; try { stepExecutions = jobService.getStepExecutions(jobExecution.getId()); } catch (NoSuchJobExecutionException e) { return Response.status(Response.Status.BAD_REQUEST) .entity("There is no such job execution (" + jobExecution.getId() + ")") .type(MediaType.TEXT_PLAIN).build(); } /* list of step by job execution */ List<JobsTreeRepresentation> childrenStep = new ArrayList<JobsTreeRepresentation>(); for (StepExecution stepExecution : stepExecutions) { JobsTreeRepresentation stepTreeRepresentation = new JobsTreeRepresentation(); stepTreeRepresentation.setName(stepExecution.getStepName()); stepTreeRepresentation .setLink(TREE_URL_BATCH_JOBS_LIST + "/" + jobName + "/" + jobExecution.getId()); stepTreeRepresentation.setSize(TREE_SIZE_STEP); stepTreeRepresentation.setStatus(stepExecution.getExitStatus().getExitCode()); childrenStep.add(stepTreeRepresentation); } jobExecTreeRepresentation.setChildren(childrenStep); childrenJobExecution.add(jobExecTreeRepresentation); } jobsTreeRepresentation.setChildren(childrenJobExecution); return Response.ok(jobsTreeRepresentation).build(); }
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 *///ww w. j a v a 2 s.co 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:de.langmi.spring.batch.examples.complex.file.renamefile.partition.RenameFileListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { // get business key String businessKey = (String) stepExecution.getExecutionContext() .get(BatchConstants.CONTEXT_NAME_BUSINESS_KEY); try {/* w ww . ja v a 2 s .c o m*/ String path = this.outputFileResource.getFile().getParent(); String newFilePathAndName = path + File.separator + businessKey + ".txt"; FileUtils.copyFile(outputFileResource.getFile(), new File(newFilePathAndName)); LOG.info("copied:" + this.outputFileResource.getFile().getPath() + " to:" + newFilePathAndName); // deletion here is not good, the itemstream will be closed after // this afterStep method is called // so get it deleted on jvm exit this.outputFileResource.getFile().deleteOnExit(); LOG.info("deleteOnExit for:" + this.outputFileResource.getFile().getPath()); } catch (Exception ex) { return new ExitStatus(ExitStatus.FAILED.getExitCode(), ex.getMessage()); } return stepExecution.getExitStatus(); }
From source file:org.emonocot.job.sitemap.SitemapFilesListener.java
public ExitStatus afterStep(StepExecution stepExecution) { logger.debug("After Step " + currentStep.getStepName()); try {/*w w w .ja va 2 s .com*/ Url u = new Url(); u.setLastmod(ISODateTimeFormat.dateTime().print((ReadableInstant) null)); u.setLoc(new URL(portalBaseUrl + "/" + sitemapDir + "/" + currentFile.getFilename())); sitemapNames.add(u); } catch (MalformedURLException e) { logger.error("Unable create Url for sitemap", e); } //reset counts to nulls to support beforeStep() currentStep = null; currentFile = null; chunkOfFile = 0; commitSize = 0; return stepExecution.getExitStatus(); }
From source file:org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.java
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues, parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes, parameterTypes.length)); return parameters; }