org.springframework.batch.core.JobExecution

Here are the examples of the java api org.springframework.batch.core.JobExecution taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

97 Examples 7

19 View Source File : JobExecutionEvent.java
License : Apache License 2.0
Project Creator : yuanmabiji

/**
 * Spring {@link ApplicationEvent} encapsulating a {@link JobExecution}.
 *
 * @author Dave Syer
 */
@SuppressWarnings("serial")
public clreplaced JobExecutionEvent extends ApplicationEvent {

    private final JobExecution execution;

    /**
     * Create a new {@link JobExecutionEvent} instance.
     * @param execution the job execution
     */
    public JobExecutionEvent(JobExecution execution) {
        super(execution);
        this.execution = execution;
    }

    /**
     * Return the job execution.
     * @return the job execution
     */
    public JobExecution getJobExecution() {
        return this.execution;
    }
}

19 View Source File : TaskLauncherTaskletTests.java
License : Apache License 2.0
Project Creator : spring-cloud-task-app-starters

private ChunkContext chunkContext() {
    final long JOB_EXECUTION_ID = 123L;
    final String STEP_NAME = "myTestStep";
    JobExecution jobExecution = new JobExecution(JOB_EXECUTION_ID);
    StepExecution stepExecution = new StepExecution(STEP_NAME, jobExecution);
    StepContext stepContext = new StepContext(stepExecution);
    return new ChunkContext(stepContext);
}

private StepExecution getStepExecution() {
    final long JOB_EXECUTION_ID = 123L;
    final String STEP_NAME = "myTestStep";
    JobExecution jobExecution = new JobExecution(JOB_EXECUTION_ID);
    return new StepExecution(STEP_NAME, jobExecution);
}

19 View Source File : TestKafka.java
License : Apache License 2.0
Project Creator : redis-developer

@Test
public void testExport() throws Exception {
    StreamExportCommand command = (StreamExportCommand) command("export");
    log.info("Executing export command");
    JobExecution execution = command.executeAsync();
    Thread.sleep(100);
    String stream = "stream1";
    int producedCount = 100;
    log.info("Producing {} stream messages", producedCount);
    for (int index = 0; index < producedCount; index++) {
        sync.xadd(stream, map());
    }
    log.info("Polling Kafka messages");
    KafkaConsumer<String, Map<String, Object>> consumer = new KafkaConsumer<>(ImmutableMap.of(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers(), ConsumerConfig.GROUP_ID_CONFIG, UUID.randomUUID().toString(), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"), new StringDeserializer(), new JsonDeserializer<>());
    consumer.subscribe(Collections.singletonList(stream));
    List<ConsumerRecord<String, Map<String, Object>>> consumerRecords = new ArrayList<>();
    while (consumerRecords.size() < producedCount) {
        ConsumerRecords<String, Map<String, Object>> records = consumer.poll(Duration.ofSeconds(30));
        records.forEach(consumerRecords::add);
    }
    replacedertions.replacedertEquals(producedCount, consumerRecords.size());
    consumerRecords.forEach(r -> replacedertions.replacedertEquals(map(), r.value()));
    log.info("Waiting for execution to complete");
    awaitTermination(execution);
}

19 View Source File : BaseJobExecutionListener.java
License : Apache License 2.0
Project Creator : miyabayt

protected long took(JobExecution jobExecution) {
    return jobExecution.getEndTime().getTime() - jobExecution.getStartTime().getTime();
}

19 View Source File : JobExecutionEvent.java
License : Apache License 2.0
Project Creator : hello-shf

/**
 * Spring {@link ApplicationEvent} encapsulating a {@link JobExecution}.
 *
 * @author Dave Syer
 */
@SuppressWarnings("serial")
public clreplaced JobExecutionEvent extends ApplicationEvent {

    private final JobExecution execution;

    /**
     * Create a new {@link JobExecutionEvent} instance.
     *
     * @param execution the job execution
     */
    public JobExecutionEvent(JobExecution execution) {
        super(execution);
        this.execution = execution;
    }

    /**
     * Return the job execution.
     *
     * @return the job execution
     */
    public JobExecution getJobExecution() {
        return this.execution;
    }
}

19 View Source File : SpringBootBatchCommandLine.java
License : Apache License 2.0
Project Creator : devonfw

/**
 * @param jobExecution the {@link JobExecution}.
 * @return the corresponding {@link System#exit(int) exit code}.
 */
protected int getReturnCode(JobExecution jobExecution) {
    if (jobExecution.getStatus() != null && jobExecution.getStatus() == BatchStatus.COMPLETED)
        return 0;
    else
        return 1;
}

19 View Source File : SingleJobLauncher.java
License : Apache License 2.0
Project Creator : CogStack

private JobExecution getLastJobExecution() {
    JobExecution lastJobExecution = null;
    try {
        lastJobExecution = batchJobUtils.getLastSuccessfulJobExecution();
    } catch (NullPointerException e) {
        LOG.info("No previous successful jobs found");
    }
    if (lastJobExecution == null) {
        try {
            lastJobExecution = batchJobUtils.getLastJobExecution();
        } catch (NullPointerException e) {
            LOG.info("No previous jobs found");
        }
    }
    return lastJobExecution;
}

19 View Source File : CogstackJobPartitioner.java
License : Apache License 2.0
Project Creator : CogStack

public void setJobExecution(JobExecution jobExecution) {
    this.jobExecution = jobExecution;
}

18 View Source File : JobLauncherCommandLineRunner.java
License : Apache License 2.0
Project Creator : yuanmabiji

private boolean isStoppedOrFailed(JobExecution execution) {
    BatchStatus status = (execution != null) ? execution.getStatus() : null;
    return (status == BatchStatus.STOPPED || status == BatchStatus.FAILED);
}

18 View Source File : JobExecutionExitCodeGenerator.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Override
public int getExitCode() {
    for (JobExecution execution : this.executions) {
        if (execution.getStatus().ordinal() > 0) {
            return execution.getStatus().ordinal();
        }
    }
    return 0;
}

18 View Source File : JpaPagingBatchJobListener.java
License : Apache License 2.0
Project Creator : ypmc

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info("JpaPagingBatch job finished");
    } else {
        log.info("JpaPagingBatch job " + jobExecution.getStatus().name());
    }
}

18 View Source File : JdbcBatchItemWriterJobListener.java
License : Apache License 2.0
Project Creator : ypmc

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info("JdbcBatchItemWriter job finished");
    } else {
        log.info("JdbcBatchItemWriter job " + jobExecution.getStatus().name());
    }
}

18 View Source File : CommonJobListener.java
License : Apache License 2.0
Project Creator : ypmc

@Override
public void beforeJob(JobExecution jobExecution) {
    log.info("Job [" + jobExecution.getJobId() + "] start " + DateFormatUtils.format(jobExecution.getStartTime(), DATE_TIME_FORMAT));
}

18 View Source File : CommonJobListener.java
License : Apache License 2.0
Project Creator : ypmc

@Override
public void afterJob(JobExecution jobExecution) {
    log.info("Job [" + jobExecution.getJobId() + "] finish " + DateFormatUtils.format(jobExecution.getEndTime(), DATE_TIME_FORMAT));
    log.info("Job [" + jobExecution.getJobId() + "] status " + jobExecution.getStatus().name());
}

18 View Source File : SpringBatchFlowRunner.java
License : Apache License 2.0
Project Creator : spring-cloud

@SuppressWarnings("unchecked")
private List<Exception> exceptionsThrownBySteps(JobExecution execution) {
    return execution.getStepExecutions().stream().map(e -> e.getExecutionContext().get("errors") != null ? (List) e.getExecutionContext().get("errors") : new LinkedList()).reduce(new LinkedList<Exception>(), (o, o2) -> {
        o.addAll(o2);
        return o;
    });
}

18 View Source File : AbstractRiotTest.java
License : Apache License 2.0
Project Creator : redis-developer

protected void awaitTermination(JobExecution execution) throws InterruptedException {
    while (execution.isRunning()) {
        Thread.sleep(10);
    }
}

18 View Source File : TestKafka.java
License : Apache License 2.0
Project Creator : redis-developer

@Test
public void testImport() throws Exception {
    StreamImportCommand command = (StreamImportCommand) command("import");
    JobExecution execution = command.executeAsync();
    Thread.sleep(500);
    KafkaProducer<String, Map<String, String>> producer = new KafkaProducer<>(ImmutableMap.of(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers(), ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString()), new StringSerializer(), new JsonSerializer<>());
    int count = 100;
    for (int index = 0; index < count; index++) {
        ProducerRecord<String, Map<String, String>> record = new ProducerRecord<>("topic1", map());
        Future<RecordMetadata> future = producer.send(record);
        future.get();
    }
    Thread.sleep(100);
    List<StreamMessage<String, String>> messages = sync.xrange("topic1", Range.create("-", "+"));
    replacedertions.replacedertEquals(count, messages.size());
    messages.forEach(m -> replacedertions.replacedertEquals(map(), m.getBody()));
    execution.stop();
}

18 View Source File : TestReplicate.java
License : Apache License 2.0
Project Creator : redis-developer

@Test
public void replicateLive() throws Exception {
    sync.configSet("notify-keyspace-events", "AK");
    DataGenerator.builder().commands(async).build().run();
    ReplicateCommand command = (ReplicateCommand) command("replicate-live");
    JobExecution execution = command.executeAsync();
    Thread.sleep(100);
    log.info("Setting livestring keys");
    int count = 39;
    for (int index = 0; index < count; index++) {
        sync.set("livestring:" + index, "value" + index);
    }
    Thread.sleep(100);
    awaitTermination(execution);
    replacedertions.replacedertEquals(sync.dbsize(), targetSync.dbsize());
}

18 View Source File : BatchConfig.java
License : MIT License
Project Creator : PacktPublishing

@Scheduled(fixedRate = 5000)
public void startJob() throws Exception {
    JobExecution execution = jobLauncher.run(deptBatchJob(), new JobParametersBuilder().addLong("procId", System.nanoTime()).toJobParameters());
}

18 View Source File : JobExecutionTracer.java
License : Apache License 2.0
Project Creator : open-telemetry

public Context startSpan(JobExecution jobExecution) {
    String jobName = jobExecution.getJobInstance().getJobName();
    return startSpan("BatchJob " + jobName);
}

18 View Source File : BaseJobExecutionListener.java
License : Apache License 2.0
Project Creator : miyabayt

/**
 * 機能別の初期化処理を呼び出す
 *
 * @param jobExecution
 * @param context
 */
protected void before(JobExecution jobExecution, BatchContext context) {
}

18 View Source File : BaseJobExecutionListener.java
License : Apache License 2.0
Project Creator : miyabayt

/**
 * 機能別の終了処理を呼び出す
 *
 * @param jobExecution
 * @param context
 */
protected void after(JobExecution jobExecution, BatchContext context) {
}

18 View Source File : ImportStaffJobListener.java
License : Apache License 2.0
Project Creator : miyabayt

@Override
protected void after(JobExecution jobExecution, BatchContext context) {
// 終了する直前に呼び出される
}

18 View Source File : JobCompletionNotificationListener.java
License : GNU General Public License v3.0
Project Creator : gxing19

@Override
public void beforeJob(JobExecution jobExecution) {
    logger.info("Job Ready OK.......");
}

18 View Source File : JobCompletionNotificationListener.java
License : GNU General Public License v3.0
Project Creator : gxing19

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        logger.info("!!! JOB FINISHED! Time to verify the results");
        Integer count = jdbcTemplate.queryForObject("select count(*) from person", Integer.clreplaced);
        logger.info("!!! Found Person Number:{}", count);
    }
}

18 View Source File : CustomerReportJobConfig.java
License : MIT License
Project Creator : asaen

@Scheduled(fixedRate = 5000)
public void run() throws Exception {
    JobExecution execution = jobLauncher.run(customerReportJob(), new JobParametersBuilder().addLong("uniqueness", System.nanoTime()).toJobParameters());
    log.info("Exit status: {}", execution.getStatus());
}

17 View Source File : JobLauncherCommandLineRunner.java
License : Apache License 2.0
Project Creator : yuanmabiji

protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException, JobParametersNotFoundException {
    JobParameters parameters = getNextJobParameters(job, jobParameters);
    JobExecution execution = this.jobLauncher.run(job, parameters);
    if (this.publisher != null) {
        this.publisher.publishEvent(new JobExecutionEvent(execution));
    }
}

17 View Source File : MyJobExecutionListener.java
License : MIT License
Project Creator : wuyouzhuguli

@Override
public void beforeJob(JobExecution jobExecution) {
    System.out.println("before job execute: " + jobExecution.getJobInstance().getJobName());
}

17 View Source File : MyJobExecutionListener.java
License : MIT License
Project Creator : wuyouzhuguli

@Override
public void afterJob(JobExecution jobExecution) {
    System.out.println("after job execute: " + jobExecution.getJobInstance().getJobName());
}

17 View Source File : CsvJobListener.java
License : Apache License 2.0
Project Creator : turoDog

@Override
public void beforeJob(JobExecution jobExecution) {
    startTime = System.currentTimeMillis();
    logger.info("任务处理开始");
}

17 View Source File : CsvJobListener.java
License : Apache License 2.0
Project Creator : turoDog

@Override
public void afterJob(JobExecution jobExecution) {
    endTime = System.currentTimeMillis();
    logger.info("任务处理结束");
    logger.info("任务耗时:" + (endTime - startTime) + "ms");
}

17 View Source File : NotificationListener.java
License : MIT License
Project Creator : swathisprasad

@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."));
    }
}

17 View Source File : SpringBatchFlowRunner.java
License : Apache License 2.0
Project Creator : spring-cloud

private ExecutionResult runJob(Job job) {
    try {
        JobExecution execution = this.jobLauncher.run(job, new JobParameters());
        if (!ExitStatus.COMPLETED.equals(execution.getExitStatus())) {
            return ExecutionResult.failure(new IllegalStateException("Job failed to get executed successfully. Failed with exit code [" + execution.getExitStatus().getExitCode() + "] and description [" + execution.getExitStatus().getExitDescription() + "]"));
        }
        List<Exception> thrownExceptions = exceptionsThrownBySteps(execution);
        return new ExecutionResult(thrownExceptions);
    } catch (JobExecutionException | UnexpectedJobExecutionException ex) {
        return ExecutionResult.failure(ex);
    }
}

17 View Source File : JobCompletionPayRollListener.java
License : MIT License
Project Creator : PacktPublishing

@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."));
    }
}

17 View Source File : DemoJobListener.java
License : GNU General Public License v3.0
Project Creator : mintster

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        logger.info("!!! JOB FINISHED! LAST POSTID IMPORTED: " + jobExecution.getExecutionContext().get("postId"));
    }
}

17 View Source File : JobCompletionNotificationListener.java
License : GNU General Public License v3.0
Project Creator : memphisx

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info("!!! JOB FINISHED!");
    }
}

17 View Source File : JobListener.java
License : MIT License
Project Creator : jonathanlermitage

@Override
public void afterJob(JobExecution jobExecution) {
    super.afterJob(jobExecution);
    log.info("job {} ended in state {}", jobExecution.getJobInstance().getJobName(), jobExecution.getStatus());
}

17 View Source File : JobLauncherCommandLineRunner.java
License : Apache License 2.0
Project Creator : hello-shf

protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException, JobParametersNotFoundException {
    JobParameters nextParameters = new JobParametersBuilder(jobParameters, this.jobExplorer).getNextJobParameters(job).toJobParameters();
    JobExecution execution = this.jobLauncher.run(job, nextParameters);
    if (this.publisher != null) {
        this.publisher.publishEvent(new JobExecutionEvent(execution));
    }
}

17 View Source File : AbstractSubCommand.java
License : Apache License 2.0
Project Creator : devonfw

/**
 * Find all executions for the job identified by jobIdentifier which match the given status.
 *
 * @param jobIdentifier The name of the job
 * @param batchStatus The status to look for
 * @return Returns a list of all executions for the given job with the given status.
 * @throws NoSuchJobException If the job does not exists.
 */
protected List<JobExecution> findJobExecutionsWithStatus(String jobIdentifier, BatchStatus batchStatus) throws NoSuchJobException {
    List<JobExecution> result = new ArrayList<>();
    for (JobExecution jobExecution : findAllExecutions(jobIdentifier)) {
        if (jobExecution.getStatus() != batchStatus) {
            result.add(jobExecution);
        }
    }
    return result.isEmpty() ? null : result;
}

17 View Source File : SingleJobLauncher.java
License : Apache License 2.0
Project Creator : CogStack

public void launchJob() {
    JobExecution lastJobExecution = getLastJobExecution();
    try {
        if (lastJobExecution != null) {
            BatchStatus lastJobStatus = lastJobExecution.getStatus();
            switch(lastJobStatus) {
                case COMPLETED:
                    LOG.info("Last job execution was successful");
                    startNextInstance();
                    break;
                case STARTED:
                case STARTING:
                case STOPPING:
                    LOG.info("Job is already running. Repository in unknown state." + " Attempting to repair and restart from last successful job");
                    abandonAllJobsStartedAfterLastSuccessfulJob();
                    startNextInstance();
                    break;
                case FAILED:
                    LOG.info("Last job failed. Attempting restart");
                    startNextInstance();
                    break;
                case ABANDONED:
                    LOG.info("Last job was abandoned. Attempting start from last successful job");
                    abandonAllJobsStartedAfterLastSuccessfulJob();
                    startNextInstance();
                    break;
                case STOPPED:
                    LOG.info("Last job was stopped. Attempting restart");
                    startNextInstance();
                    break;
                case UNKNOWN:
                    LOG.info("Last job has unknown status. Marking as abandoned and attempting restart from last successful job");
                    abandonAllJobsStartedAfterLastSuccessfulJob();
                    startNextInstance();
                    break;
                default:
                    LOG.error("Should be unreachable");
                    break;
            }
        } else {
            LOG.info("No previous completed jobs found");
            startNextInstance();
        }
    } catch (JobInstanceAlreadyCompleteException | JobExecutionAlreadyRunningException | JobParametersInvalidException e) {
        LOG.error("Cannot start job", e);
    } catch (JobRestartException e) {
        LOG.error("Cannot restart job. Attempting start from last successful job", e);
        try {
            jobOperator.abandon(lastJobExecution.getId());
            startNextInstance();
        } catch (NoSuchJobExecutionException | JobExecutionAlreadyRunningException | NoSuchJobException | JobInstanceAlreadyCompleteException | JobRestartException | JobParametersNotFoundException | JobParametersInvalidException e1) {
            throw new RuntimeException("Cannot start next instance", e1);
        }
    } catch (Exception e) {
        LOG.error("Cannot start job", e);
    }
}

17 View Source File : JobCompletionNotificationListener.java
License : Apache License 2.0
Project Creator : chrisgleissner

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        semapreplaced.release();
    }
}

17 View Source File : JobPropertyResolvers.java
License : Apache License 2.0
Project Creator : chrisgleissner

@Override
public void accept(JobExecution je) {
    if (!je.isRunning()) {
        JobPropertyResolver resolver = resolvers.remove(je.getJobInstance().getJobName());
        if (resolver != null)
            log.info("Disabled {}", je.getJobInstance().getJobName());
    }
}

17 View Source File : Fixtures.java
License : Apache License 2.0
Project Creator : chrisgleissner

public clreplaced Fixtures {

    private static final List<String> JOB_NAMES = newArrayList("j1", "j2");

    public static final String JOB_NAME_1 = "j1";

    public static final JobInstance ji11 = new JobInstance(11L, JOB_NAME_1);

    public static final JobExecution je11 = jobExecution(11, ji11, COMPLETED);

    public static final JobInstance ji12 = new JobInstance(12L, JOB_NAME_1);

    public static final JobExecution je12 = jobExecution(12, ji12, FAILED);

    public static final String JOB_NAME_2 = "j2";

    public static final JobInstance ji21 = new JobInstance(21L, JOB_NAME_2);

    public static final JobExecution je21 = jobExecution(21, ji21, COMPLETED);

    public static final JobInstance ji22 = new JobInstance(22L, JOB_NAME_2);

    public static final JobExecution je22 = jobExecution(22, ji22, COMPLETED);

    public static final JobInstance ji23 = new JobInstance(23L, JOB_NAME_2);

    public static final JobExecution je23 = jobExecution(23, ji23, FAILED);

    // Re-run of job instance 23
    public static final JobExecution je24 = jobExecution(24, ji23, FAILED);

    public static void configureMock(JobExplorer jobExplorer) {
        reset(jobExplorer);
        when(jobExplorer.getJobNames()).thenReturn(JOB_NAMES);
    }

    public static void configureMock(JobRegistry jobRegistry) {
        reset(jobRegistry);
        when(jobRegistry.getJobNames()).thenReturn(JOB_NAMES);
    }

    public static void configureMock(AdHocStarter adHocStarter) {
        reset(adHocStarter);
        when(adHocStarter.start(isA(JobConfig.clreplaced))).thenReturn(jobExecution(1, ji11, ExitStatus.EXECUTING));
    }

    public static void configureForJobExecutionsService(JobExplorer jobExplorer) {
        when(jobExplorer.getJobInstances(eq(JOB_NAME_1), anyInt(), anyInt())).thenReturn(newArrayList(ji11, ji12));
        when(jobExplorer.getJobInstances(eq(JOB_NAME_2), anyInt(), anyInt())).thenReturn(newArrayList(ji21, ji22, ji23));
        when(jobExplorer.getJobExecutions(ji11)).thenReturn(newArrayList(je11));
        when(jobExplorer.getJobExecutions(ji12)).thenReturn(newArrayList(je12));
        when(jobExplorer.getJobExecutions(ji21)).thenReturn(newArrayList(je21));
        when(jobExplorer.getJobExecutions(ji22)).thenReturn(newArrayList(je22));
        when(jobExplorer.getJobExecutions(ji23)).thenReturn(newArrayList(je23, je24));
    }

    public static void configureForJobExecutionsService(CachedJobExecutionProvider provider) {
        provider.accept(je11);
        provider.accept(je12);
        provider.accept(je21);
        provider.accept(je22);
        provider.accept(je23);
        provider.accept(je24);
    }

    public static JobExecution jobExecution(int id, JobInstance ji, ExitStatus exitStatus) {
        JobExecution jobExecution = new JobExecution(ji, (long) id, null, "config" + id);
        jobExecution.setCreateTime(new Date(id * 100L));
        jobExecution.setStartTime(new Date(id * 200L));
        if (!exitStatus.getExitCode().equals(ExitStatus.EXECUTING.getExitCode())) {
            jobExecution.setEndTime(new Date(id * 300L));
            if (exitStatus.getExitCode().equals(ExitStatus.FAILED.getExitCode()))
                jobExecution.setStatus(BatchStatus.FAILED);
            else
                jobExecution.setStatus(BatchStatus.COMPLETED);
        } else
            jobExecution.setStatus(BatchStatus.STARTED);
        jobExecution.setExitStatus(exitStatus);
        return jobExecution;
    }
}

17 View Source File : CsvJobListener.java
License : Apache License 2.0
Project Creator : ab-book

@Override
public void beforeJob(JobExecution jobExecution) {
    startTime = System.currentTimeMillis();
    System.out.println("任务处理开始");
}

17 View Source File : CsvJobListener.java
License : Apache License 2.0
Project Creator : ab-book

@Override
public void afterJob(JobExecution jobExecution) {
    endTime = System.currentTimeMillis();
    System.out.println("任务处理结束");
    System.out.println("耗时:" + (endTime - startTime) + "ms");
}

16 View Source File : JobExecutionExitCodeGeneratorTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testExitCodeForFailed() {
    JobExecution execution = new JobExecution(0L);
    execution.setStatus(BatchStatus.FAILED);
    this.generator.onApplicationEvent(new JobExecutionEvent(execution));
    replacedertThat(this.generator.getExitCode()).isEqualTo(5);
}

16 View Source File : JobExecutionExitCodeGeneratorTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testExitCodeForCompleted() {
    JobExecution execution = new JobExecution(0L);
    execution.setStatus(BatchStatus.COMPLETED);
    this.generator.onApplicationEvent(new JobExecutionEvent(execution));
    replacedertThat(this.generator.getExitCode()).isEqualTo(0);
}

16 View Source File : JobLauncherCommandLineRunner.java
License : Apache License 2.0
Project Creator : yuanmabiji

private JobParameters getNextJobParametersForExisting(Job job, JobParameters jobParameters) {
    JobExecution lastExecution = this.jobRepository.getLastJobExecution(job.getName(), jobParameters);
    if (isStoppedOrFailed(lastExecution) && job.isRestartable()) {
        JobParameters previousIdentifyingParameters = getGetIdentifying(lastExecution.getJobParameters());
        return merge(previousIdentifyingParameters, jobParameters);
    }
    return jobParameters;
}

16 View Source File : RepositoryItemWriterJobListener.java
License : Apache License 2.0
Project Creator : ypmc

@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.");
        }
    }
}

See More Examples