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 for the execution of a step. Unlike
JobExecution
, additional properties are related to the processing of items,
such as commit count and others.- Author:
- Lucas Ward, Dave Syer, Mahmoud Ben Hassine, Taeik Lim
- See Also:
-
Constructor Summary
ConstructorDescriptionStepExecution
(String stepName, JobExecution jobExecution) Constructor that substitutes null for the execution ID.StepExecution
(String stepName, JobExecution jobExecution, Long id) Constructor with mandatory properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailureException
(Throwable throwable) Add aThrowable
to failure exceptions.void
apply
(StepContribution contribution) This method should be called on successful execution just before a chunk commit.Factory method forStepContribution
.boolean
Attempt to establish identity based onid
if both exist.long
Returns the current number of commits for this execution.Gets the time this execution was createdReturns the time when this execution ended ornull
if the step is running.Returns theExecutionContext
for this execution.long
Returns the current number of items filtered out of this execution.Accessor for the execution context information of the enclosing job.Accessor for the job execution ID.Convenience method to get the current job parameters.long
long
Returns the current number of items read for this execution.long
long
Returns the current number of rollbacks for this execution.long
Gets the time when this execution started.Returns the current status of this step.long
Returns the current number of items written for this execution.long
int
hashCode()
Useid
, if it exists, to establish a hash code.void
Increment the number of commits.void
Increments the rollback count.boolean
void
setCommitCount
(long commitCount) Sets the current number of commits for this execution.void
setCreateTime
(LocalDateTime createTime) Sets the time this execution was createdvoid
setEndTime
(LocalDateTime endTime) Sets the time when this execution ended.void
setExecutionContext
(ExecutionContext executionContext) Sets theExecutionContext
for this execution.void
setExitStatus
(ExitStatus exitStatus) void
setFilterCount
(long filterCount) Sets the number of items filtered out of this execution.void
setLastUpdated
(LocalDateTime lastUpdated) Sets the time when theStepExecution
was last updated before persisting.void
setProcessSkipCount
(long processSkipCount) Sets the number of records skipped during processing.void
setReadCount
(long readCount) Sets the current number of read items for this execution.void
setReadSkipCount
(long readSkipCount) Set the number of records skipped on read.void
setRollbackCount
(long rollbackCount) Sets the number of rollbacks for this execution.void
setStartTime
(LocalDateTime startTime) Sets the time when this execution started.void
setStatus
(BatchStatus status) Sets the current status of this step.void
Sets a flag that signals to an execution environment that this execution (and its surrounding job) wishes to exit.void
setWriteCount
(long writeCount) Sets the current number of written items for this execution.void
setWriteSkipCount
(long writeSkipCount) Set the number of records skipped on write.toString()
Creates a string representation of theEntity
, including theid
,version
, and class name.void
upgradeStatus
(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 belongs.jobExecution
- The current job execution.id
- The ID of this execution.
-
StepExecution
Constructor that substitutes null for the execution ID.- Parameters:
stepName
- The step to which this execution belongs.jobExecution
- The current job execution.
-
-
Method Details
-
getExecutionContext
Returns theExecutionContext
for this execution.- Returns:
- the attributes.
-
setExecutionContext
Sets theExecutionContext
for 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 when this execution ended ornull
if the step is running.- Returns:
- the time when this execution ended or
null
if the step is running.
-
setEndTime
Sets the time when this execution ended.- Parameters:
endTime
- The time when 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) Sets 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) Sets the number of rollbacks for this execution.- Parameters:
rollbackCount
-long
the number of rollbacks.
-
getCreateTime
Gets the time this execution was created- Returns:
- the time when this execution was created.
-
setCreateTime
Sets the time this execution was created- Parameters:
createTime
- creation time of this execution.
-
getStartTime
Gets the time when this execution started.- Returns:
- the time when this execution started.
-
setStartTime
Sets the time when this execution started.- Parameters:
startTime
- The time when 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 do not overwrite a failed status with a 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
- TheExitStatus
instance used to establish the exit status.
-
getExitStatus
- Returns:
- the
ExitStatus
.
-
getJobExecution
Accessor for the execution context information of the enclosing job.- Returns:
- the
JobExecution
that was used to start this step execution.
-
createStepContribution
Factory method forStepContribution
.- Returns:
- a new
StepContribution
-
apply
This method should be called on successful execution just before a chunk commit. Synchronizes access to theStepExecution
so that changes are atomic.- Parameters:
contribution
- TheStepContribution
instance used to update theStepExecution
state.
-
incrementRollbackCount
public void incrementRollbackCount()Increments the rollback count. Should be used 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()Sets a flag that signals 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
JobParameters
from the enclosing job or empty if that isnull
.
-
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
- Along
containing the 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
- Along
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) Sets the number of records skipped during processing.- Parameters:
processSkipCount
- Along
containing the process skip count to be used for the step execution.
-
getLastUpdated
- Returns:
- the Date representing the last time this execution was persisted.
-
setLastUpdated
Sets the time when theStepExecution
was last updated before persisting.- Parameters:
lastUpdated
- theLocalDateTime
instance used to establish the last updated date for theStepExecution
.
-
getFailureExceptions
-
addFailureException
Add aThrowable
to failure exceptions.- Parameters:
throwable
- TheThrowable
to add to failure exceptions.
-
equals
Description copied from class:Entity
Attempt to establish identity based onid
if both exist. If eitherid
does not exist, useObject.equals()
. -
hashCode
public int hashCode()Description copied from class:Entity
Useid
, if it exists, to establish a hash code. Otherwise fall back toObject.hashCode()
. It is based on the same information asequals
, so, if that changes, this will. Note that this follows the contract ofObject.hashCode()
but will cause problems for anyone adding an unsavedEntity
to aSet
becauseSet.contains()
almost certainly returns false for theEntity
after it is saved. Spring Batch does not store any of its entities in sets as a matter of course, so this is internally consistent. Clients should not be exposed to unsaved entities. -
toString
Description copied from class:Entity
Creates a string representation of theEntity
, including theid
,version
, and class name. -
getSummary
- Returns:
- The
String
containing a summary of the step execution.
-