Interface ExecutionHandler<R>

  • All Known Implementing Classes:
    AbstractExecutionHandler, AmplModelExecutionHandler, SecurityAnalysisExecutionHandler

    public interface ExecutionHandler<R>
    Base interface for processing to be executed through a ComputationManager.

    The before(Path) method will be called before the commands are actually executed: it is in charge of any preprocessing of providing the list of commands to be executed. Typically, it will copy input data to the specified working directory, and create the command to be executed with those inputs.

    The after(Path, ExecutionReport) method will be called after the commands have been executed: it is in charge of any postprocessing and of providing the actual computation result. Typically, it will check that the execution was correctly peformed, then read command results from the specified working directory and translate it to a business object.

    The generic parameter ExecutionHandler is the type of the result object provided by the command execution.

    Author:
    Geoffroy Jamgotchian
    • Method Detail

      • before

        List<CommandExecution> before​(Path workingDir)
                               throws IOException
        Method called by the ComputationManager with the working directory as parameter, before the commands are actually executed: it is in charge of any preprocessing of providing the list of commands to be executed. Typically, it will copy input data to the specified working directory, and create the command to be executed with those inputs.

        If the call throws an exception, no command will be executed.

        Parameters:
        workingDir - the working directory used for this computation. Input data may be written to it.
        Returns:
        the list of CommandExecutions to be executed.
        Throws:
        IOException - when an error occurs while wirting to working directory.
      • onExecutionStart

        void onExecutionStart​(CommandExecution execution,
                              int executionIndex)
      • onExecutionCompletion

        void onExecutionCompletion​(CommandExecution execution,
                                   int executionIndex)
      • after

        R after​(Path workingDir,
                ExecutionReport report)
         throws IOException
        Method called by the ComputationManager with the working directory and an execution report as parameters, after the commands defined by the before(java.nio.file.Path) method have been executed: it is in charge of any postprocessing and of providing the actual computation result. Typically, it will check that the execution was correctly performed, then read command results from the specified working directory and translate it to a business object.

        That method will not be called in case the call to before(java.nio.file.Path) throws an exception, or if the execution is cancelled.

        Parameters:
        workingDir - the working directory used for this computation. Results may be read from it.
        report - the execution report, in particular reporting command execution errors.
        Returns:
        the actual result of the processing.
        Throws:
        IOException - if and error occurs while reading results from the working directory.