Class JobProcessor<T extends InputFromManager,S>
- Type Parameters:
T
- input-object typeS
- shared-state type
- All Implemented Interfaces:
ReplaceTask<T,
S>
- Direct Known Subclasses:
DebugDependentProcessor
,ParallelProcessor
,SequentialProcessor
public abstract class JobProcessor<T extends InputFromManager,S>
extends AnchorBean<JobProcessor<T,S>>
implements ReplaceTask<T,S>
Base class for a method to apply a task on inputs.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TaskStatistics
execute
(Outputter rootOutputter, List<T> inputs, ParametersExperiment parametersExperiment) Executes the task on allinputs
.executeLogStatistics
(Outputter rootOutputter, List<T> inputs, ParametersExperiment parametersExperiment) Executes the task on allinputs
and logs statistics about this to the file-systen.getTask()
The task to be applied to inputs.boolean
Is the execution-time of the task per-input expected to be very quick to execute?boolean
isInputCompatibleWith
(Class<? extends InputFromManager> inputClass) Is an input-type compatible with this particular task?boolean
When true, any exception thrown processing and input is caught and logged.void
replaceTask
(Task<T, S> taskToReplace) Replace the currently-assignedTask
with another.void
setSuppressExceptions
(boolean suppressExceptions) When true, any exception thrown processing and input is caught and logged.void
The task to be applied to inputs.Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
JobProcessor
public JobProcessor()
-
-
Method Details
-
executeLogStatistics
public TaskStatistics executeLogStatistics(Outputter rootOutputter, List<T> inputs, ParametersExperiment parametersExperiment) throws ExperimentExecutionException Executes the task on allinputs
and logs statistics about this to the file-systen.- Parameters:
rootOutputter
- an outputter, bound to the base (root) output directory into which outputed files are written.inputs
- the inputs to applytask
on.parametersExperiment
- parameters that exist pertaining to the experiment that is underway.- Returns:
- statistics about the success/failure/execution-time etc. of applying the task to inputs.
- Throws:
ExperimentExecutionException
- if anything goes wrong executing the experiment (but not necessarily if a processing a particular input fails whensuppressExceptions == true
.
-
replaceTask
Description copied from interface:ReplaceTask
Replace the currently-assignedTask
with another.- Specified by:
replaceTask
in interfaceReplaceTask<T extends InputFromManager,
S> - Parameters:
taskToReplace
- the task to replace.- Throws:
OperationFailedException
- if the task cannot be successfully replaced.
-
isInputCompatibleWith
Is an input-type compatible with this particular task?- Parameters:
inputClass
- a class describing the type of input, that is checked for compatibility.- Returns:
- true iff the input-type is compatible.
-
hasVeryQuickPerInputExecution
public boolean hasVeryQuickPerInputExecution()Is the execution-time of the task per-input expected to be very quick to execute?- Returns:
- true when the execution-time is expected to be very quick, or false otherwise.
-
execute
protected abstract TaskStatistics execute(Outputter rootOutputter, List<T> inputs, ParametersExperiment parametersExperiment) throws ExperimentExecutionException Executes the task on allinputs
.It is expected that elements are removed from
inputs
as they are consumed so as to allow garbage-collection of these items before all jobs are processed (as the list might be quite large).- Parameters:
rootOutputter
- an outputter, bound to the base (root) output directory into which outputted files are written.inputs
- the inputs to applytask
on.parametersExperiment
- parameters that exist pertaining to the experiment that is underway.- Returns:
- statistics about the success/failure/execution-time etc. of applying the task to inputs.
- Throws:
ExperimentExecutionException
- if anything goes wrong executing the experiment (but not necessarily if a processing a particular input fails whensuppressExceptions == true
.
-
getTask
The task to be applied to inputs. -
setTask
The task to be applied to inputs. -
isSuppressExceptions
public boolean isSuppressExceptions()When true, any exception thrown processing and input is caught and logged.This stops processing the affected input, but otherwise allows processing of other inputs to continue.
When false, an exception throw for a single input is immediately thrown, so all processing stops.
-
setSuppressExceptions
public void setSuppressExceptions(boolean suppressExceptions) When true, any exception thrown processing and input is caught and logged.This stops processing the affected input, but otherwise allows processing of other inputs to continue.
When false, an exception throw for a single input is immediately thrown, so all processing stops.
-