Class JobProcessor<T extends InputFromManager,S>

Object
AnchorBean<JobProcessor<T,S>>
JobProcessor<T,S>
Type Parameters:
T - input-object type
S - 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 Details

    • JobProcessor

      public JobProcessor()
  • Method Details

    • executeLogStatistics

      public TaskStatistics executeLogStatistics(Outputter rootOutputter, List<T> inputs, ParametersExperiment parametersExperiment) throws ExperimentExecutionException
      Executes the task on all inputs 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 apply task 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 when suppressExceptions == true.
    • replaceTask

      public void replaceTask(Task<T,S> taskToReplace) throws OperationFailedException
      Description copied from interface: ReplaceTask
      Replace the currently-assigned Task with another.
      Specified by:
      replaceTask in interface ReplaceTask<T extends InputFromManager,S>
      Parameters:
      taskToReplace - the task to replace.
      Throws:
      OperationFailedException - if the task cannot be successfully replaced.
    • isInputCompatibleWith

      public boolean isInputCompatibleWith(Class<? extends InputFromManager> inputClass)
      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 all inputs.

      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 apply task 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 when suppressExceptions == true.
    • getTask

      public Task<T,S> getTask()
      The task to be applied to inputs.
    • setTask

      public void setTask(Task<T,S> task)
      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.