Example usage for org.springframework.batch.core StepExecution setTerminateOnly

List of usage examples for org.springframework.batch.core StepExecution setTerminateOnly

Introduction

In this page you can find the example usage for org.springframework.batch.core StepExecution setTerminateOnly.

Prototype

public void setTerminateOnly() 

Source Link

Document

Set a flag that will signal to an execution environment that this execution (and its surrounding job) wishes to exit.

Usage

From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapStepExecutionDao.java

/**
 * Returns a copy of {@link StepExecution}, by adding new Objects for every field(no references are passed)
 * //from www.  j a v  a 2s.  co  m
 * @param original StepExecution to be copied
 * @return StepExecution copy
 */
private static StepExecution copy(StepExecution original) {
    StepExecution copy = new StepExecution(original.getStepName(), original.getJobExecution());
    copy.setCommitCount(original.getCommitCount());
    if (original.getEndTime() != null) {
        copy.setEndTime((Date) original.getEndTime().clone());
    }
    //Warning: no deep copy
    if (original.getExitStatus() != null) {
        copy.setExitStatus(new ExitStatus(original.getExitStatus().getExitCode(),
                original.getExitStatus().getExitDescription()));
    }
    copy.setFilterCount(original.getFilterCount());
    copy.setId(original.getId());
    if (original.getLastUpdated() != null) {
        copy.setLastUpdated((Date) original.getLastUpdated().clone());
    }
    copy.setProcessSkipCount(original.getProcessSkipCount());
    copy.setReadCount(original.getReadCount());
    copy.setReadSkipCount(original.getReadSkipCount());
    copy.setRollbackCount(original.getRollbackCount());
    if (original.getStartTime() != null) {
        copy.setStartTime((Date) original.getStartTime().clone());
    }
    if (original.getStatus() != null) {
        copy.setStatus(BatchStatus.valueOf(original.getStatus().name()));
    }
    if (original.isTerminateOnly()) {
        copy.setTerminateOnly();
    }
    copy.setVersion(original.getVersion());
    copy.setWriteCount(original.getWriteCount());
    copy.setWriteSkipCount(original.getWriteSkipCount());
    return copy;
}

From source file:org.springframework.batch.core.repository.support.SimpleJobRepository.java

/**
 * Check to determine whether or not the JobExecution that is the parent of
 * the provided StepExecution has been interrupted. If, after synchronizing
 * the status with the database, the status has been updated to STOPPING,
 * then the job has been interrupted.//w  ww  . j ava2s. c  o  m
 *
 * @param stepExecution
 */
private void checkForInterruption(StepExecution stepExecution) {
    JobExecution jobExecution = stepExecution.getJobExecution();
    jobExecutionDao.synchronizeStatus(jobExecution);
    if (jobExecution.isStopping()) {
        logger.info("Parent JobExecution is stopped, so passing message on to StepExecution");
        stepExecution.setTerminateOnly();
    }
}