Package org.jppf.node.protocol.graph
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
Interface for tasks that are part of a dependency graph of tasks within a job.
Dependencies can be added using the
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 Summary
Modifier and TypeMethodDescriptiondependsOn(Collection<TaskNode<?>> tasks) Add a set of dependencies to this task.Add a set of dependencies to this task.Collection<TaskNode<?>>Get the tasks that depend on this task, if any.Collection<TaskNode<?>>Get the dependencies of this task, if any.default booleanDetermine whether this tasks has at least one dependant, that is, another task that depends on it.default booleanDetermine whether this tasks has at least one dependency.Methods inherited from interface org.jppf.node.protocol.Interruptibility
isInterruptibleMethods inherited from interface org.jppf.node.protocol.PositionalElement
getPosition, setPositionMethods inherited from interface org.jppf.node.protocol.Task
compute, fireNotification, getDataProvider, getId, getJob, getMaxResubmits, getNode, getResult, getTaskClassLoader, getTaskObject, getThrowable, getTimeoutSchedule, isInNode, isResubmit, onCancel, onTimeout, setDataProvider, setId, setInNode, setJob, setMaxResubmits, setNode, setResubmit, setResult, setThrowable, setTimeoutSchedule
-
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
Add a set of dependencies to this task. This method is equivalent to callingdependsOn(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
TaskGraphinstances, ornullif 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
Taskinstances, ornullif there is no dependant.
-
hasDependency
default boolean hasDependency()Determine whether this tasks has at least one dependency.- Returns:
trueif there is at least one dependency,falseotherwise.
-
hasDependant
default boolean hasDependant()Determine whether this tasks has at least one dependant, that is, another task that depends on it.- Returns:
trueif there is at least one dependant,falseotherwise.
-