List of usage examples for org.springframework.batch.core JobExecution getJobInstance
public JobInstance getJobInstance()
From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapJobInstanceDao.java
public JobInstance getJobInstance(JobExecution jobExecution) { return jobExecution.getJobInstance(); }
From source file:com.manning.siia.batch.JobRestart.java
@ServiceActivator public void restartIfPossible(JobExecution execution) throws JobInstanceAlreadyCompleteException, JobParametersInvalidException, JobRestartException, JobExecutionAlreadyRunningException { jobLauncher.run(job, execution.getJobInstance().getJobParameters()); }
From source file:io.spring.batch.integration.ExecutionToTweetTransformer.java
@Transformer(inputChannel = "jobRequests", outputChannel = "statusTweets") public TweetData transform(JobExecution execution) { DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SS"); StringBuilder builder = new StringBuilder(); builder.append(execution.getJobInstance().getJobName()); BatchStatus evaluatedStatus = endingBatchStatus(execution); if (evaluatedStatus == BatchStatus.COMPLETED || evaluatedStatus.compareTo(BatchStatus.STARTED) > 0) { builder.append(" has completed with a status of " + execution.getStatus().name() + " at " + formatter.format(new Date())); } else {//from w w w .ja va 2 s . c om builder.append(" has started at " + formatter.format(new Date())); } return new TweetData(builder.toString()); }
From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapJobExecutionDao.java
@Override public Set<JobExecution> findRunningJobExecutions(String jobName) { Set<JobExecution> result = new HashSet<JobExecution>(); for (JobExecution exec : executionsById.values()) { if (!exec.getJobInstance().getJobName().equals(jobName) || !exec.isRunning()) { continue; }/*w ww . j a va 2 s . co m*/ result.add(copy(exec)); } return result; }
From source file:de.codecentric.batch.listener.ProtocolListener.java
public void beforeJob(JobExecution jobExecution) { StringBuilder protocol = new StringBuilder(); protocol.append(createFilledLine('-')); protocol.append("Job " + jobExecution.getJobInstance().getJobName() + " started with Job-Execution-Id " + jobExecution.getId() + " \n"); protocol.append("Job-Parameter: \n"); JobParameters jp = jobExecution.getJobParameters(); for (Iterator<Entry<String, JobParameter>> iter = jp.getParameters().entrySet().iterator(); iter .hasNext();) {//from w w w . j av a 2s .com Entry<String, JobParameter> entry = iter.next(); protocol.append(" " + entry.getKey() + "=" + entry.getValue() + "\n"); } protocol.append(createFilledLine('-')); LOGGER.info(protocol.toString()); }
From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapJobExecutionDao.java
@Override public JobExecution getLastJobExecution(JobInstance jobInstance) { JobExecution lastExec = null;/*from w ww . j ava 2s . c o m*/ for (JobExecution exec : executionsById.values()) { if (!exec.getJobInstance().equals(jobInstance)) { continue; } if (lastExec == null) { lastExec = exec; } if (lastExec.getCreateTime().before(exec.getCreateTime())) { lastExec = exec; } } return copy(lastExec); }
From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapJobExecutionDao.java
@Override public List<JobExecution> findJobExecutions(JobInstance jobInstance) { List<JobExecution> executions = new ArrayList<JobExecution>(); for (JobExecution exec : executionsById.values()) { if (exec.getJobInstance().equals(jobInstance)) { executions.add(copy(exec));//from w ww .j ava 2 s .c o m } } Collections.sort(executions, new Comparator<JobExecution>() { @Override public int compare(JobExecution e1, JobExecution e2) { long result = (e1.getId() - e2.getId()); if (result > 0) { return -1; } else if (result < 0) { return 1; } else { return 0; } } }); return executions; }
From source file:de.codecentric.batch.metrics.MetricsListener.java
@Override public void afterJob(JobExecution jobExecution) { long jobDuration = jobExecution.getEndTime().getTime() - jobExecution.getStartTime().getTime(); gaugeService.submit(TIMER_PREFIX + jobExecution.getJobInstance().getJobName() + ".duration", jobDuration); // What the f*** is that Thread.sleep doing here? ;-) // Metrics are written asynchronously to Spring Boot's repository. In our tests we experienced // that sometimes batch execution was so fast that this listener couldn't export the metrics // because they hadn't been written. It all happened in the same millisecond. So we added // a Thread.sleep of 100 milliseconds which gives us enough safety and doesn't hurt anyone. try {//from www . j ava 2 s . c o m Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } // Export Metrics to Console or Remote Systems LOGGER.info(metricsOutputFormatter.format(exportBatchRichGauges(), exportBatchMetrics())); // Codahale if (exporters != null) { for (Exporter exporter : exporters) { if (exporter != null) { LOGGER.info("Exporting Metrics with " + exporter.getClass().getName()); exporter.export(); } } } }
From source file:bamons.process.monitoring.service.listener.EmailMonitoringNotifier.java
private String createMessageContent(JobExecution jobExecution) { List<Throwable> exceptions = jobExecution.getFailureExceptions(); StringBuilder content = new StringBuilder(); content.append("Job execution ID #"); content.append(jobExecution.getId()); content.append(" of job instance ID #"); content.append(jobExecution.getJobInstance().getId()); content.append(" failed with following exceptions : "); for (Throwable exception : exceptions) { content.append(""); content.append(formatExceptionMessage(exception)); }// w w w. j av a 2s. c o m return content.toString(); }
From source file:org.duracloud.snapshot.service.impl.SnapshotJobExecutionListener.java
@Transactional public void beforeJob(JobExecution jobExecution) { log.debug("entering beforeJob()"); JobParameters jobParams = jobExecution.getJobParameters(); String snapshotId = this.parameterMarshaller.unmarshal(jobParams); String jobName = jobExecution.getJobInstance().getJobName(); if (jobName.equals(SnapshotServiceConstants.SNAPSHOT_JOB_NAME)) { SnapshotStatus status = SnapshotStatus.TRANSFERRING_FROM_DURACLOUD; log.debug("updating snapshot status to " + status + " for snapshot.name = " + snapshotId + "; jobParameters = " + jobParams); Snapshot snapshot = snapshotRepo.findByName(snapshotId); changeSnapshotStatus(snapshot, status, ""); }// w w w. j a va 2 s . com }