weka.knowledgeflow

## Class StepTask<T>

- java.lang.Object
- - weka.knowledgeflow.StepTask<T>

- Type Parameters:
    `T` - the type of the result stored in the returned ExecutionResult object
  All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.Callable<ExecutionResult<T>>

      public abstract class StepTask<T>
      extends java.lang.Object
      implements java.util.concurrent.Callable<ExecutionResult<T>>, java.io.Serializable

  A task that can be executed by the ExecutionEnvironment's submitTask() service. Step's wanting to use this to execute units of work in parallel must extends it and can work with it in one of two ways:
  1. By using the Future returned by submitTask(), or
  2. By registering an implementation of StepCallback when creating a subclass of StepTask.
  Subclasses of StepTask should store their results (and potentially errors) in the provided ExecutionResult member variable (obtainable by calling getExecutionResult()).
  Author:
    Mark Hall (mhall{[at]}pentaho{[dot]}com)
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StepTask(Step source)` Constructor.
    `StepTask(Step source, boolean resourceIntensive)` Constructor.
    `StepTask(Step source, StepTaskCallback<T> callback)` Constructor with supplied callback.
    `StepTask(Step source, StepTaskCallback<T> callback, boolean resourceIntensive)` Constructor with supplied callback.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ExecutionResult<T>` | `call()` Executor service calls this method to do the work
    `boolean` | `getMustRunSingleThreaded()` Get whether this `StepTask` must run single threaded - i.e.
    `boolean` | `isResourceIntensive()` Get whether this `StepTask` is resource intensive (cpu/memory) or not.
    `abstract void` | `process()` The actual work gets done here.
    `void` | `setMustRunSingleThreaded(boolean singleThreaded)` Set whether this `StepTask` must run single threaded - i.e.
    `void` | `setResourceIntensive(boolean resourceIntensive)` Set whether this `StepTask` is resource intensive (cpu/memory) or not.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StepTask

          public StepTask(Step source)

      Constructor. Use this constructor if you are going to access the Future returned by ExecutionEnvironment.submitTask().
      Parameters:
        `source` - the source step producing this task

    - #### StepTask

          public StepTask(Step source,
                          boolean resourceIntensive)

      Constructor. Use this constructor if you are going to access the Future returned by ExecutionEnvironment.submitTask()
      Parameters:
        `source` - the source step producing this task
        `resourceIntensive` - true if this task is cpu/memory intensive

    - #### StepTask

          public StepTask(Step source,
                          StepTaskCallback<T> callback)

      Constructor with supplied callback. Use this constructor to be notified via the supplied callback when a the task has completed processing
      Parameters:
        `source` - the source step producing this task
        `callback` - the callback to use

    - #### StepTask

          public StepTask(Step source,
                          StepTaskCallback<T> callback,
                          boolean resourceIntensive)

      Constructor with supplied callback. Use this constructor to be notified via the supplied callback when a task has completed processing
      Parameters:
        `source` - the source step producing this task
        `callback` - the callback to use
        `resourceIntensive` - true if this task is cpu/memory intensive

  - ### Method Detail

    - #### setResourceIntensive

          public void setResourceIntensive(boolean resourceIntensive)

      Set whether this `StepTask` is resource intensive (cpu/memory) or not. By default, a `StepTask` is resource intensive
      Parameters:
        `resourceIntensive` - false if this `StepTask` is not resource intensive

    - #### isResourceIntensive

          public boolean isResourceIntensive()

      Get whether this `StepTask` is resource intensive (cpu/memory) or not. By default, a `StepTask` is resource intensive
      Returns:
        false if this `StepTask` is not resource intensive

    - #### setMustRunSingleThreaded

          public void setMustRunSingleThreaded(boolean singleThreaded)

      Set whether this `StepTask` must run single threaded - i.e. only one of these tasks is executing at any one time in the JVM. The Knowledge Flow uses a special executor service with a single worker thread to execute these tasks. This property, if true, overrides isResourceIntensive().
      Parameters:
        `singleThreaded` - true if this task must run single threaded

    - #### getMustRunSingleThreaded

          public boolean getMustRunSingleThreaded()

      Get whether this `StepTask` must run single threaded - i.e. only one of these tasks is executing at any one time in the JVM. The Knowledge Flow uses a special executor service with a single worker thread to execute these tasks. This property, if true, overrides isResourceIntensive().
      Returns:
        true if this task must run single threaded

    - #### call

          public ExecutionResult<T> call()
                                  throws java.lang.Exception

      Executor service calls this method to do the work
      Specified by:
        `call` in interface `java.util.concurrent.Callable<ExecutionResult<T>>`
      Returns:
        the results of execution in an ExecutionResult
      Throws:
        `java.lang.Exception`

    - #### process

          public abstract void process()
                                throws java.lang.Exception

      The actual work gets done here. Subclasses to override. Subclasses can use getExecutionResult() to obtain an ExecutionResult object to store their results in
      Throws:
        `java.lang.Exception`