Package de.uni_kiel.rz.fdr.repl
Class REPLJob
java.lang.Object
de.uni_kiel.rz.fdr.repl.REPLJob
- All Implemented Interfaces:
Serializable
This class represents a single job to be executed in the background. It also provides static methods to manage all
jobs that are currently on file.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
A record containing a job's results for one single input item.static final record
Represents an event that occured during job processing, to be consumed by an event handler.static enum
The different event types that aJobEvent
handler might receive.static final record
A record that summarizes a job's state at one instant in time.static enum
The possible states that a job can be in. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Consumer<REPLJob.JobEvent>
A predefined job event handler that you can use; it logs regular process messages to your SSH session.static final Consumer<REPLJob.JobEvent>
A predefined job event handler you can use, it pauses the job whenever an error happens.static final String
Threads of cau-repls job workers have names that start with this prefix. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Archives a loaded job.static boolean
Archives a loaded job.boolean
cancel()
Cancels a running job.boolean
cancelForce
(int timeoutSeconds) Forcefully cancels a running job.Logs a message with log levelDEBUG
to the global REPL log, as well as the job's private persistent log.Logs a message with log levelERROR
to the global REPL log, as well as the job's private persistent log.static REPLJob
Get a loaded job by key.int
Get the job's concurrency level.Gets the time at which this instance was created.Returns a future that you can wait on.Gets the list of the job's inputs.For internal purposes only.Get the job's private log, which contains messages logged withinfo(Object...)
and similar methods.getKey()
Get the job's key.Returns the latest entry from the job's private log.getName()
Get the job's name.Gets the job's current progress.Gets the job's current progress callback.Gets the list of the job's results.Gets the key of the job which was resumed with this instance.Get the state file of this job.Logs a message with log levelINFO
to the global REPL log, as well as the job's private persistent log.list()
Get the list of all jobs that are not archived - that is: loaded in memory.Get the list of all archived jobs' keys.static REPLJob
Loads an archived job without preparing it for resuming.static REPLJob
Loads an archived job without preparing it for resuming.void
log
(REPLLogEntry entry) Logs a given message to the global REPL log, as well as the job's private persistent log.void
log
(REPLLogEntry entry, Set<REPLLog.LOG_TARGETS> targets, PrintStream... streams) Logs a given message to the global REPL log, as well as the job's private persistent log.Logs a message with log levelINFO
to the global REPL log, as well as the job's private persistent log.boolean
pause()
Pauses a running job.Removes the state files of all archived jobs that were completedsuccessfully
.static REPLJob
repljob
(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs) Creates a new job with inputs and no concurrency that is ready to be started.static REPLJob
repljob
(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, int concurrency) Creates a new job with inputs that is ready to be started.static REPLJob
repljob
(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, int concurrency, String name) Creates a new job with inputs that is ready to be started.static REPLJob
repljob
(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, int concurrency, String name, boolean becomeDelegate) Creates a new job with inputs that is ready to be started.static REPLJob
repljob
(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, String name) Creates a new job with inputs and no concurrency that is ready to be started.static REPLJob
repljob
(BiFunction<Serializable, REPLJob, Serializable> function, List<Serializable> inputs) Creates a new job with inputs or concurrency that is ready to be started.static REPLJob
repljob
(BiFunction<Serializable, REPLJob, Serializable> function, List<Serializable> inputs, int concurrency) Creates a new job with inputs that is ready to be started.static REPLJob
repljob
(BiFunction<Serializable, REPLJob, Serializable> function, List<Serializable> inputs, int concurrency, String name) Creates a new job with inputs that is ready to be started.static REPLJob
repljob
(BiFunction<Serializable, REPLJob, Serializable> function, List<Serializable> inputs, String name) Creates a new job with inputs and no concurrency that is ready to be started.static REPLJob
repljob
(Supplier<Serializable> supplier) Creates a new job without inputs or concurrency that is ready to be started.static REPLJob
repljob
(Supplier<Serializable> supplier, int concurrency) Creates a new job without inputs that is ready to be started.static REPLJob
repljob
(Supplier<Serializable> supplier, String name) Creates a new job without inputs or concurrency that is ready to be started.static REPLJob
resume
(File path, groovy.lang.Closure<Serializable> closure) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.static REPLJob
resume
(File path, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(File path, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors, boolean becomeDelegate) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(File path, BiFunction<Serializable, REPLJob, Serializable> function) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.static REPLJob
resume
(File path, BiFunction<Serializable, REPLJob, Serializable> function, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(File path, Supplier<Serializable> supplier) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.static REPLJob
resume
(File path, Supplier<Serializable> supplier, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(String key, groovy.lang.Closure<Serializable> closure) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.static REPLJob
resume
(String key, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(String key, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors, boolean becomeDelegate) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(String key, BiFunction<Serializable, REPLJob, Serializable> function) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.static REPLJob
resume
(String key, BiFunction<Serializable, REPLJob, Serializable> function, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.static REPLJob
resume
(String key, Supplier<Serializable> supplier) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.static REPLJob
resume
(String key, Supplier<Serializable> supplier, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.void
retryIndex
(int index) Flag the input item with the specified index for resuming.void
setConcurrency
(int concurrency) Set the job's concurrency level.void
setInternalCallback
(Consumer<REPLJob.JobEvent> internalCallback) For internal purposes only.void
setProgressCallback
(Consumer<REPLJob.JobEvent> progressCallback) Sets the job's progress callback.start()
Starts processing.start
(ThreadFactory threadFactory) Starts processing.start
(ThreadFactory threadFactory, Consumer<REPLJob.JobEvent> progressCallback) Starts processing.start
(Consumer<REPLJob.JobEvent> progressCallback) Starts processing.Stream all archived jobs without adding them to the list of active jobs.toString()
Logs a message with log levelTRACE
to the global REPL log, as well as the job's private persistent log.unpause()
Restarts processing after a job has been paused.Logs a message with log levelWARN
to the global REPL log, as well as the job's private persistent log.
-
Field Details
-
THREAD_PREFIX
Threads of cau-repls job workers have names that start with this prefix. Threads belonging to a single job will also be placed in a common thread group.- See Also:
-
CALLBACK_LOG_TO_SHELL
A predefined job event handler that you can use; it logs regular process messages to your SSH session. This will make it hard to use the session interactively while the job is running. -
CALLBACK_PAUSE_ON_ERROR
A predefined job event handler you can use, it pauses the job whenever an error happens. if you enabled concurrency, multiple errors might accumulate in pause event.
-
-
Method Details
-
list
Get the list of all jobs that are not archived - that is: loaded in memory.- Returns:
- the list of all jobs that are not archived
-
listArchived
Get the list of all archived jobs' keys.- Returns:
- The list of all archived jobs' keys.
-
streamArchived
Stream all archived jobs without adding them to the list of active jobs. This can be a time-consuming operation, because all inputs and results will be loaded as well. Note that the job instances that this method streams are not resumable by design. If this is important, use one of the variousresume()
methods instead.- Returns:
- A stream of all archived jobs.
-
pruneArchived
Removes the state files of all archived jobs that were completedsuccessfully
.- Returns:
- The keys of all pruned jobs.
-
get
Get a loaded job by key. To retrieve an archived job, use one of theload()
orresume()
methods instead.- Parameters:
key
- The key to look up.- Returns:
- The Job with the key, or
null
if none was found.
-
archive
Archives a loaded job. Jobs that are stillactive
can't be archived. Archiving an active job will throw an exception.- Parameters:
job
- The job to archive.- Returns:
- Flag indicating whether this job was archived or not.
- Throws:
JobException
- The action failed, e.g. because the job's state prevented it.
-
archive
Archives a loaded job. Jobs that are stillactive
can't be archived. Archiving an active job will throw an exception.- Parameters:
key
- The key of the job to archive.- Returns:
- Flag indicating whether this job was archived or not.
- Throws:
JobException
- The action failed, e.g. because the job's state prevented it.
-
repljob
Creates a new job without inputs or concurrency that is ready to be started.- Parameters:
supplier
- The job action.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
Creates a new job without inputs that is ready to be started.- Parameters:
supplier
- The job action.concurrency
- The concurrency level to use.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
Creates a new job without inputs or concurrency that is ready to be started.- Parameters:
supplier
- The job action.name
- A name for the job that will be displayed in the job list.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(BiFunction<Serializable, REPLJob, throws IOExceptionSerializable> function, List<Serializable> inputs) Creates a new job with inputs or concurrency that is ready to be started.- Parameters:
function
- The job action.inputs
- The inputs that the job action will operate on.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs) throws IOException Creates a new job with inputs and no concurrency that is ready to be started.- Parameters:
closure
- The job action.inputs
- The inputs that the job action will operate on.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(BiFunction<Serializable, REPLJob, throws IOExceptionSerializable> function, List<Serializable> inputs, int concurrency) Creates a new job with inputs that is ready to be started.- Parameters:
function
- The job action.inputs
- The inputs that the job action will operate on.concurrency
- The concurrency level to use.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, int concurrency) throws IOException Creates a new job with inputs that is ready to be started.- Parameters:
closure
- The job action.inputs
- The inputs that the job action will operate on.concurrency
- The concurrency level to use.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(BiFunction<Serializable, REPLJob, throws IOExceptionSerializable> function, List<Serializable> inputs, String name) Creates a new job with inputs and no concurrency that is ready to be started.- Parameters:
function
- The job action.inputs
- The inputs that the job action will operate on.name
- A name for the job that will be displayed in the job list.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, String name) throws IOException Creates a new job with inputs and no concurrency that is ready to be started.- Parameters:
closure
- The job action.inputs
- The inputs that the job action will operate on.name
- A name for the job that will be displayed in the job list.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(BiFunction<Serializable, REPLJob, throws IOExceptionSerializable> function, List<Serializable> inputs, int concurrency, String name) Creates a new job with inputs that is ready to be started.- Parameters:
function
- The job action.inputs
- The inputs that the job action will operate on.concurrency
- The concurrency level to use.name
- A name for the job that will be displayed in the job list.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, int concurrency, String name) throws IOException Creates a new job with inputs that is ready to be started.- Parameters:
closure
- The job action.inputs
- The inputs that the job action will operate on.concurrency
- The concurrency level to use.name
- A name for the job that will be displayed in the job list.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
repljob
public static REPLJob repljob(groovy.lang.Closure<Serializable> closure, List<Serializable> inputs, int concurrency, String name, boolean becomeDelegate) throws IOException Creates a new job with inputs that is ready to be started.- Parameters:
closure
- The job action.inputs
- The inputs that the job action will operate on.concurrency
- The concurrency level to use.name
- A name for the job that will be displayed in the job list.becomeDelegate
- Controls whether the job instance should be set as the Closure's delegate.- Returns:
- The new job.
- Throws:
IOException
- The job's state file could not be created.
-
resume
public static REPLJob resume(String key, groovy.lang.Closure<Serializable> closure) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.- Parameters:
key
- The key of the archived job to resume.closure
- The job action.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(String key, BiFunction<Serializable, REPLJob, throws IOException, ObjectStoreInvalidException, JobExceptionSerializable> function) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.- Parameters:
key
- The key of the archived job to resume.function
- The job action.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(String key, Supplier<Serializable> supplier) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.- Parameters:
key
- The key of the archived job to resume.supplier
- The job action.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(String key, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares it for resuming.- Parameters:
key
- The key of the archived job to resume.closure
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(String key, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors, boolean becomeDelegate) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares it for resuming.- Parameters:
key
- The key of the archived job to resume.closure
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.becomeDelegate
- Controls whether the job instance should be set as the Closure's delegate.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(String key, BiFunction<Serializable, REPLJob, throws IOException, ObjectStoreInvalidException, JobExceptionSerializable> function, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.- Parameters:
key
- The key of the archived job to resume.function
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(String key, Supplier<Serializable> supplier, boolean retrySuccess, boolean retryErrors) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares it for resuming.- Parameters:
key
- The key of the archived job to resume.supplier
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, groovy.lang.Closure<Serializable> closure) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.- Parameters:
path
- The location of the archived job's state file.closure
- The job action.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, BiFunction<Serializable, REPLJob, throws IOException, ObjectStoreInvalidException, JobExceptionSerializable> function) Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.- Parameters:
path
- The location of the archived job's state file.function
- The job action.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, Supplier<Serializable> supplier) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares unfinished and unsuccessful inputs for resuming.- Parameters:
path
- The location of the archived job's state file.supplier
- The job action.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares it for resuming.- Parameters:
path
- The location of the archived job's state file.closure
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, groovy.lang.Closure<Serializable> closure, boolean retrySuccess, boolean retryErrors, boolean becomeDelegate) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares it for resuming.- Parameters:
path
- The location of the archived job's state file.closure
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.becomeDelegate
- Controls whether the job instance should be set as the Closure's delegate.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, BiFunction<Serializable, REPLJob, throws IOException, ObjectStoreInvalidException, JobExceptionSerializable> function, boolean retrySuccess, boolean retryErrors) Loads an archived job instance and prepares it for resuming.- Parameters:
path
- The location of the archived job's state file.function
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
resume
public static REPLJob resume(File path, Supplier<Serializable> supplier, boolean retrySuccess, boolean retryErrors) throws IOException, ObjectStoreInvalidException, JobException Loads an archived job instance and prepares it for resuming.- Parameters:
path
- The location of the archived job's state file.supplier
- The job action.retrySuccess
- Controls whether previously successful inputs should be resubmitted.retryErrors
- Controls whether previously unsuccessful inputs should be resubmitted.- Returns:
- A new instance of the archived job that can be resumed.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's state file is corrupted.JobException
- The job could not be resumed.
-
load
Loads an archived job without preparing it for resuming. Such instances can't be started, but allow you to inspect their state unaltered.- Parameters:
key
- The key of the job to load.- Returns:
- The job.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's object store is corrupted.
-
load
Loads an archived job without preparing it for resuming. Such instances can't be started, but allow you to inspect their state unaltered.- Parameters:
path
- The location of the archived job's state file.- Returns:
- The job.
- Throws:
IOException
- A file could not be accessed.ObjectStoreInvalidException
- The old job's object store is corrupted.
-
start
Starts processing. Each job instance can only be started once.- Returns:
- A Future that will complete once the job is no longer active.
- Throws:
JobException
- The job could not be started, e.g. because it is in the wrong state.
-
start
Starts processing. Each job instance can only be started once.- Parameters:
threadFactory
- A custom Thread Factory that will be used for the worker threads.- Returns:
- A Future that will complete once the job is no longer active.
- Throws:
JobException
- The job could not be started, e.g. because it is in the wrong state.
-
start
public Future<REPLJob.JobProgress> start(Consumer<REPLJob.JobEvent> progressCallback) throws JobException Starts processing. Each job instance can only be started once.- Parameters:
progressCallback
- A callback that can monitor and control the job's execution. Multiple callbacks can be chained withConsumer.andThen(Consumer)
. Note that your callback will be run from the job's main control thread, so you should offload long-running activities triggered by it to a different thread or risk lowering the job's throughput.- Returns:
- A Future that will complete once the job is no longer active.
- Throws:
JobException
- The job could not be started, e.g. because it is in the wrong state.
-
start
public Future<REPLJob.JobProgress> start(ThreadFactory threadFactory, Consumer<REPLJob.JobEvent> progressCallback) throws JobException Starts processing. Each job instance can only be started once.- Parameters:
threadFactory
- A custom Thread Factory that will be used for the worker threads.progressCallback
- A callback that can monitor and control the job's execution. Multiple callbacks can be chained withConsumer.andThen(Consumer)
. Note that your callback will be run from the job's main control thread, so you should offload long-running activities triggered by it to a different thread or risk lowering the job's throughput.- Returns:
- A Future that will complete once the job is no longer active.
- Throws:
JobException
- The job could not be started, e.g. because it is in the wrong state.
-
getProgress
Gets the job's current progress.- Returns:
- The job's current progress.
-
retryIndex
Flag the input item with the specified index for resuming. This makes sure that it will be reprocessed regardless of its previous success. You must call this method before starting the job.- Parameters:
index
- The index of the input item to resume.- Throws:
JobException
- The job's state does not permit changing this value.
-
cancel
Cancels a running job. The instance will immediately transition toCANCELLING
status and wait for all currently active workers to finish their current inputs. When they all have terminated, the job will transition toCANCELLED
status. If some workers hang around for too long, it is safe to subsequently callcancelForce()
again on the job. Jobs without inputs must usecancelForce()
.- Returns:
- A flag indicating whether a concel was actually requested, or unneccesary because the job had already finished in the meantime.
- Throws:
JobException
- The job's state does not permit this action.
-
cancelForce
Forcefully cancels a running job. The instance will immediately transition toCANCELLING
status and wait the specified number of seconds for all currently active workers to finish their current inputs. If a worker is still active after the timeout, an attempt is made to forecefully terminate its thread. After this, the job will transition toCANCELLED
status.- Parameters:
timeoutSeconds
- The number of seconds to wait before forcefully terminating a worker's thread.- Returns:
- A flag indicating whether a concel was actually requested, or unneccesary because the job had already finished in the meantime.
- Throws:
JobException
- The job's state does not permit this action.
-
pause
Pauses a running job. The job will immediately transition toPAUSING
state and workers will no longer be supplied with new inputs. After all workers have finisihed their current inputs, the job will transition toPAUSED
. Note that jobs without inputs can't be paused. The invocation will raise an exception in this case.- Returns:
- A flag indicating whether the job was newly paused, or whether no actual change was made (e.g. because it had already been paused).
- Throws:
JobException
- The job's state does not permit this action.
-
unpause
Restarts processing after a job has been paused. Note that jobs without inputs can't be paused. The invocation will raise an exception in this case.- Returns:
- The length of this pause period in milliseconds, or
null
if the job was not actually unpaused (e.g. because it was not actually paused before). - Throws:
JobException
- The job's state does not permit this action.
-
getKey
Get the job's key.- Returns:
- The job's key.
-
getConcurrency
public int getConcurrency()Get the job's concurrency level.- Returns:
- The job's concurrency level.
-
setConcurrency
public void setConcurrency(int concurrency) Set the job's concurrency level. This method is safe to use while the job is running, unless you are usingthe Auto Tune feature
. If you reduce a job's concurrency, your change will take effect gradually as old workers finish their prior input.- Parameters:
concurrency
- The new concurrency level.
-
getName
Get the job's name.- Returns:
- The job's name.
-
getProgressCallback
Gets the job's current progress callback.- Returns:
- The job's current progress callback.
-
setProgressCallback
Sets the job's progress callback. This method is safe to use while the job is active.- Parameters:
progressCallback
- The new progress callback.
-
setInternalCallback
For internal purposes only. Do not use.- Parameters:
internalCallback
- For internal purposes only.
-
getInternalCallback
For internal purposes only. Do not use.- Returns:
- The internal callback.
-
getInputs
Gets the list of the job's inputs.- Returns:
- The job's input as an unmodifiable list.
-
getResults
Gets the list of the job's results.- Returns:
- The job's results as an unmodifiable list.
-
getStateFile
Get the state file of this job.- Returns:
- The state file of this job.
-
getJobLog
Get the job's private log, which contains messages logged withinfo(Object...)
and similar methods.- Returns:
- The job's private log.
-
getFuture
Returns a future that you can wait on. It will be completed as soon as the job has finished.- Returns:
- The future, or
null
if the job has not yet been started.
-
getResumedKey
Gets the key of the job which was resumed with this instance.- Returns:
- The previous key, or
null
if this job did not resume another one.
-
getCreatedTimestamp
Gets the time at which this instance was created. This is not the start time, which you can instead determine fromgetProgress()
.- Returns:
- The time of the job's instantiation.
-
toString
-
getLastLogEntry
Returns the latest entry from the job's private log.- Returns:
- The latest log entry.
-
trace
Logs a message with log levelTRACE
to the global REPL log, as well as the job's private persistent log.- Parameters:
args
- The log message.- Returns:
- The log entry which has been persisted to the logs.
-
debug
Logs a message with log levelDEBUG
to the global REPL log, as well as the job's private persistent log.- Parameters:
args
- The log message.- Returns:
- The log entry which has been persisted to the logs.
-
info
Logs a message with log levelINFO
to the global REPL log, as well as the job's private persistent log.- Parameters:
args
- The log message.- Returns:
- The log entry which has been persisted to the logs.
-
warn
Logs a message with log levelWARN
to the global REPL log, as well as the job's private persistent log.- Parameters:
args
- The log message.- Returns:
- The log entry which has been persisted to the logs.
-
error
Logs a message with log levelERROR
to the global REPL log, as well as the job's private persistent log.- Parameters:
args
- The log message.- Returns:
- The log entry which has been persisted to the logs.
-
log
Logs a message with log levelINFO
to the global REPL log, as well as the job's private persistent log.- Parameters:
args
- The log message.- Returns:
- The log entry which has been persisted to the logs.
-
log
Logs a given message to the global REPL log, as well as the job's private persistent log.- Parameters:
entry
- The log message.
-
log
Logs a given message to the global REPL log, as well as the job's private persistent log.- Parameters:
entry
- The log message.targets
- The log targets. The job's internal log is always implicitly a target.streams
- Additional PrintStreams that will receive this message.
-