IllegalStateException - If the job is not processed asynchronously
or if this method has already been called.
isStopped
booleanisStopped()
If a job is stoppable, it should periodically check this method
and stop processing if the method return true.
If a job is stopped and the job executor detects this, its up
to the implementation to decide the result of such a state.
There might be use cases where the job returns JobExecutionResult.succeeded()
although it didn't process everything, or JobExecutionResult.failed()
to retry later on or JobExecutionResult.cancelled().
Returns:
Whether this job has been stopped from the outside.
initProgress
voidinitProgress(int steps,
long eta)
Indicate that the job executor is able to report the progress.
The progress can either be reported by a step count,
assuming that all steps take roughly the same amount of time.
Or the progress can be reported by an ETA containing the number
of seconds the job needs to finish.
This method should only be called once, consecutive calls
have no effect.
By using a step count of 100, the progress can be displayed
in percentage.
Parameters:
steps - Number of total steps or -1 if the number of
steps is unknown.
eta - Number of seconds the process should take or
-1 of it's not known now.
incrementProgressCount
voidincrementProgressCount(int steps)
Update the progress by additionally marking the provided
number of steps as finished. If the total number of finished
steps is equal or higher to the initial number of steps
reported in initProgress(int, long), then the
job progress is assumed to be 100%.
This method has only effect if initProgress(int, long)
has been called first with a positive number for steps
Parameters:
steps - The number of finished steps since the last call.
updateProgress
voidupdateProgress(long eta)
Update the progress to the new ETA.
This method has only effect if initProgress(int, long)
has been called first.
Log a message.
A job consumer can use this method during job processing to add additional information
about the current state of job processing.
As calling this method adds a significant overhead it should only
be used to log a few statements per job processing. If a consumer wants
to output detailed information about the processing it should persists it
by itself and not use this method for it.
The message and the arguments are passed to the MessageFormat
class.