Package org.springframework.batch.core
Class StepExecution
java.lang.Object
org.springframework.batch.core.Entity
org.springframework.batch.core.StepExecution
- All Implemented Interfaces:
Serializable
Batch domain object representation the execution of a step. Unlike
JobExecution, there are additional properties related the processing
of items such as commit count, etc.- Author:
- Lucas Ward, Dave Syer, Mahmoud Ben Hassine, Taeik Lim
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStepExecution(String stepName, JobExecution jobExecution) Constructor that substitutes in null for the execution idStepExecution(String stepName, JobExecution jobExecution, Long id) Constructor with mandatory properties. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFailureException(Throwable throwable) Add aThrowableto failure exceptions.voidapply(StepContribution contribution) On successful execution just before a chunk commit, this method should be called.Factory method forStepContribution.booleanAttempt to establish identity based on id if both exist.longReturns the current number of commits for this executionReturns the time that this execution ended ornullif the step is running.Returns theExecutionContextfor this executionlongReturns the current number of items filtered out of this executionAccessor for the execution context information of the enclosing job.Accessor for the job execution id.Convenience method to get the current job parameters.longlongReturns the current number of items read for this executionlonglongReturns the current number of rollbacks for this executionlongGets the time this execution startedReturns the current status of this steplongReturns the current number of items written for this executionlonginthashCode()Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode().voidIncrement the number of commitsvoidOn unsuccessful execution after a chunk has rolled back.booleanvoidsetCommitCount(long commitCount) Sets the current number of commits for this executionvoidsetEndTime(Date endTime) Sets the time that this execution endedvoidsetExecutionContext(ExecutionContext executionContext) Sets theExecutionContextfor this executionvoidsetExitStatus(ExitStatus exitStatus) voidsetFilterCount(long filterCount) Public setter for the number of items filtered out of this execution.voidsetLastUpdated(Date lastUpdated) Set the time when the StepExecution was last updated before persistingvoidsetProcessSkipCount(long processSkipCount) Set the number of records skipped during processing.voidsetReadCount(long readCount) Sets the current number of read items for this executionvoidsetReadSkipCount(long readSkipCount) Set the number of records skipped on readvoidsetRollbackCount(long rollbackCount) Setter for number of rollbacks for this executionvoidsetStartTime(Date startTime) Sets the time this execution startedvoidsetStatus(BatchStatus status) Sets the current status of this stepvoidSet a flag that will signal to an execution environment that this execution (and its surrounding job) wishes to exit.voidsetWriteCount(long writeCount) Sets the current number of written items for this executionvoidsetWriteSkipCount(long writeSkipCount) Set the number of records skipped on writetoString()voidupgradeStatus(BatchStatus status) Upgrade the status field if the provided value is greater than the existing one.Methods inherited from class org.springframework.batch.core.Entity
getId, getVersion, incrementVersion, setId, setVersion
-
Constructor Details
-
StepExecution
Constructor with mandatory properties.- Parameters:
stepName- the step to which this execution belongsjobExecution- the current job executionid- the id of this execution
-
StepExecution
Constructor that substitutes in null for the execution id- Parameters:
stepName- the step to which this execution belongsjobExecution- the current job execution
-
-
Method Details
-
getExecutionContext
Returns theExecutionContextfor this execution- Returns:
- the attributes
-
setExecutionContext
Sets theExecutionContextfor this execution- Parameters:
executionContext- the attributes
-
getCommitCount
public long getCommitCount()Returns the current number of commits for this execution- Returns:
- the current number of commits
-
setCommitCount
public void setCommitCount(long commitCount) Sets the current number of commits for this execution- Parameters:
commitCount- the current number of commits
-
getEndTime
Returns the time that this execution ended ornullif the step is running.- Returns:
- the time that this execution ended or
nullif the step is running
-
setEndTime
Sets the time that this execution ended- Parameters:
endTime- the time that this execution ended
-
getReadCount
public long getReadCount()Returns the current number of items read for this execution- Returns:
- the current number of items read for this execution
-
setReadCount
public void setReadCount(long readCount) Sets the current number of read items for this execution- Parameters:
readCount- the current number of read items for this execution
-
getWriteCount
public long getWriteCount()Returns the current number of items written for this execution- Returns:
- the current number of items written for this execution
-
setWriteCount
public void setWriteCount(long writeCount) Sets the current number of written items for this execution- Parameters:
writeCount- the current number of written items for this execution
-
getRollbackCount
public long getRollbackCount()Returns the current number of rollbacks for this execution- Returns:
- the current number of rollbacks for this execution
-
getFilterCount
public long getFilterCount()Returns the current number of items filtered out of this execution- Returns:
- the current number of items filtered out of this execution
-
setFilterCount
public void setFilterCount(long filterCount) Public setter for the number of items filtered out of this execution.- Parameters:
filterCount- the number of items filtered out of this execution to set
-
setRollbackCount
public void setRollbackCount(long rollbackCount) Setter for number of rollbacks for this execution- Parameters:
rollbackCount- long the number of rollbacks.
-
getStartTime
Gets the time this execution started- Returns:
- the time this execution started
-
setStartTime
Sets the time this execution started- Parameters:
startTime- the time this execution started
-
getStatus
Returns the current status of this step- Returns:
- the current status of this step
-
setStatus
Sets the current status of this step- Parameters:
status- the current status of this step
-
upgradeStatus
Upgrade the status field if the provided value is greater than the existing one. Clients using this method to set the status can be sure that they don't overwrite a failed status with an successful one.- Parameters:
status- the new status value
-
getStepName
- Returns:
- the name of the step
-
getJobExecutionId
Accessor for the job execution id.- Returns:
- the jobExecutionId
-
setExitStatus
- Parameters:
exitStatus-ExitStatusinstance used to establish the exit status.
-
getExitStatus
- Returns:
- the exitCode
-
getJobExecution
Accessor for the execution context information of the enclosing job.- Returns:
- the
JobExecutionthat was used to start this step execution.
-
createStepContribution
Factory method forStepContribution.- Returns:
- a new
StepContribution
-
apply
On successful execution just before a chunk commit, this method should be called. Synchronizes access to theStepExecutionso that changes are atomic.- Parameters:
contribution-StepContributioninstance used to update the StepExecution state.
-
incrementRollbackCount
public void incrementRollbackCount()On unsuccessful execution after a chunk has rolled back. -
isTerminateOnly
public boolean isTerminateOnly()- Returns:
- flag to indicate that an execution should halt
-
setTerminateOnly
public void setTerminateOnly()Set a flag that will signal to an execution environment that this execution (and its surrounding job) wishes to exit. -
getSkipCount
public long getSkipCount()- Returns:
- the total number of items skipped.
-
incrementCommitCount
public void incrementCommitCount()Increment the number of commits -
getJobParameters
Convenience method to get the current job parameters.- Returns:
- the
JobParametersfrom the enclosing job, or empty if that is null
-
getReadSkipCount
public long getReadSkipCount()- Returns:
- the number of records skipped on read
-
getWriteSkipCount
public long getWriteSkipCount()- Returns:
- the number of records skipped on write
-
setReadSkipCount
public void setReadSkipCount(long readSkipCount) Set the number of records skipped on read- Parameters:
readSkipCount- long containing read skip count to be used for the step execution.
-
setWriteSkipCount
public void setWriteSkipCount(long writeSkipCount) Set the number of records skipped on write- Parameters:
writeSkipCount- long containing write skip count to be used for the step execution.
-
getProcessSkipCount
public long getProcessSkipCount()- Returns:
- the number of records skipped during processing
-
setProcessSkipCount
public void setProcessSkipCount(long processSkipCount) Set the number of records skipped during processing.- Parameters:
processSkipCount- long containing process skip count to be used for the step execution.
-
getLastUpdated
- Returns:
- the Date representing the last time this execution was persisted.
-
setLastUpdated
Set the time when the StepExecution was last updated before persisting- Parameters:
lastUpdated-Dateinstance used to establish the last updated date for the Step Execution.
-
getFailureExceptions
-
addFailureException
Add aThrowableto failure exceptions.- Parameters:
throwable- TheThrowableto add to failure exceptions.
-
equals
Description copied from class:EntityAttempt to establish identity based on id if both exist. If either id does not exist use Object.equals(). -
hashCode
public int hashCode()Description copied from class:EntityUse ID if it exists to establish hash code, otherwise fall back to Object.hashCode(). Based on the same information as equals, so if that changes, this will. N.B. this follows the contract of Object.hashCode(), but will cause problems for anyone adding an unsavedEntityto a Set because Set.contains() will almost certainly return false for theEntityafter it is saved. Spring Batch does not store any of its entities in Sets as a matter of course, so internally this is consistent. Clients should not be exposed to unsaved entities. -
toString
-
getSummary
- Returns:
- The
Stringcontaining a summary of the step execution.
-