Interface TaskNode<T>

Type Parameters:
T - the type of results produced by the task.
All Superinterfaces:
Interruptibility, PositionalElement<Task<T>>, Runnable, Serializable, Task<T>
All Known Implementing Classes:
AbstractTaskNode

public interface TaskNode<T> extends Task<T>
Interface for tasks that are part of a dependency graph of tasks within a job.
Dependencies can be added using the dependsOn(Collection<TaskNode>) and dependsOn(TaskNode...) methods.

Dependency cycles are checked and detected every time one or more dependencies are added to this task via the aforementioned methods. When a dependency cycle is detected, a JPPFDependencyCycleException is raised, with a description of the cycle.

It is therefore guaranteed that tasks with dependencies form a directed acyclic graph (DAG). This ensures that the tasks can be executed in a topological order where no task will be executed before its dependencies.

Since:
6.2
Author:
Laurent Cohen
  • Method Details

    • dependsOn

      Add a set of dependencies to this task.
      Parameters:
      tasks - a collection of tasks that this task depends on.
      Returns:
      this task, for method call chaining.
      Throws:
      JPPFDependencyCycleException - if a cycle is detected in the graph of dependencies of this task.
    • dependsOn

      default TaskNode<T> dependsOn(TaskNode<?>... tasks) throws JPPFDependencyCycleException
      Add a set of dependencies to this task. This method is equivalent to calling dependsOn(Arrays.asList(tasks)).
      Parameters:
      tasks - an array of tasks that this task depends on.
      Returns:
      this task, for method call chaining.
      Throws:
      JPPFDependencyCycleException - if a cycle is detected in the graph of dependencies of this task.
    • getDependencies

      Collection<TaskNode<?>> getDependencies()
      Get the dependencies of this task, if any.
      Returns:
      the dependencies as a collection of TaskGraph instances, or null if there is no dependency.
    • getDependants

      Collection<TaskNode<?>> getDependants()
      Get the tasks that depend on this task, if any.
      Returns:
      the dependants as a collection of Task instances, or null if there is no dependant.
    • hasDependency

      default boolean hasDependency()
      Determine whether this tasks has at least one dependency.
      Returns:
      true if there is at least one dependency, false otherwise.
    • hasDependant

      default boolean hasDependant()
      Determine whether this tasks has at least one dependant, that is, another task that depends on it.
      Returns:
      true if there is at least one dependant, false otherwise.