Class TaskGroup
java.lang.Object
com.microsoft.azure.management.resources.fluentcore.dag.Graph<DataT,NodeT>
com.microsoft.azure.management.resources.fluentcore.dag.DAGraph<TaskItem,com.microsoft.azure.management.resources.fluentcore.dag.TaskGroupEntry<TaskItem>>
com.microsoft.azure.management.resources.fluentcore.dag.TaskGroup
- All Implemented Interfaces:
Indexable
public class TaskGroup
extends DAGraph<TaskItem,com.microsoft.azure.management.resources.fluentcore.dag.TaskGroupEntry<TaskItem>>
implements Indexable
Type representing a group of task entries with dependencies between them. Initially a task
group will have only one task entry known as root task entry, then more entries can be
added by taking dependency on other task groups or adding "post-run" task group dependents.
The method
invokeAsync(InvocationContext)
()} kick-off invocation of tasks
in the group, task are invoked in topological sorted order.
addDependencyTaskGroup(TaskGroup)
: A task group "A" can take dependency on
another task group "B" through this method e.g. `A.addDependencyTaskGroup(B)` indicates that
completion of tasks in the dependency task group "B" is required before the invocation of root
task in group "A". A.invokeAsync(cxt) will ensure this order.
addPostRunDependentTaskGroup(TaskGroup)
: there are scenarios where a subset
of dependent task groups say "H", "I" may required to run after the invocation of a task group
"K" when K.invokeAsync(cxt) is called. Such special dependents can be added via
K.addPostRunDependentTaskGroup(H) and K.addPostRunDependentTaskGroup(I).
The result produced by the tasks in the group are of type Indexable
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An interface representing a type composes a TaskGroup.static final class
A mutable type that can be used to pass data around task items during the invocation of the TaskGroup. -
Field Summary
Modifier and TypeFieldDescriptionprotected com.microsoft.azure.management.resources.fluentcore.dag.TaskGroup.ProxyTaskGroupWrapper
The helper to operate on proxy TaskGroup of this TaskGroup for supporting dependents marked for post run.Fields inherited from class com.microsoft.azure.management.resources.fluentcore.dag.DAGraph
parentDAGs, queue
-
Constructor Summary
ConstructorDescriptionTaskGroup
(IndexableTaskItem rootTaskItem) Creates TaskGroup.Creates TaskGroup. -
Method Summary
Modifier and TypeMethodDescriptionaddDependency
(FunctionalTaskItem dependencyTaskItem) Mark root of this task task group depends on the given TaskItem.void
addDependency
(TaskGroup.HasTaskGroup hasTaskGroup) Mark root of this task task group depends on the given item's taskGroup.void
addDependencyTaskGroup
(TaskGroup dependencyTaskGroup) Mark root of this task task group depends on the given task group's root.addPostRunDependent
(FunctionalTaskItem dependentTaskItem) Mark the given TaskItem depends on this taskGroup.void
addPostRunDependent
(TaskGroup.HasTaskGroup hasTaskGroup) Mark the given item with taskGroup depends on this taskGroup.void
addPostRunDependentTaskGroup
(TaskGroup dependentTaskGroup) Mark root of the given task group depends on this task group's root.boolean
Checks this TaskGroup depends on the given TaskGroup.rx.Observable<Indexable>
invokeAsync
(TaskGroup.InvocationContext context) Invokes tasks in the group.key()
protected com.microsoft.azure.management.resources.fluentcore.dag.TaskGroupEntry<TaskItem>
root()
taskResult
(String taskId) Retrieve the result produced by a task with the given id in the group.Methods inherited from class com.microsoft.azure.management.resources.fluentcore.dag.DAGraph
addDependencyGraph, addDependentGraph, getNext, getNode, hasParents, isPreparer, isRootNode, prepareForEnumeration, reportCompletion, reportError
-
Field Details
-
proxyTaskGroupWrapper
protected com.microsoft.azure.management.resources.fluentcore.dag.TaskGroup.ProxyTaskGroupWrapper proxyTaskGroupWrapperThe helper to operate on proxy TaskGroup of this TaskGroup for supporting dependents marked for post run.
-
-
Constructor Details
-
TaskGroup
Creates TaskGroup.- Parameters:
rootTaskItemId
- the id of the root task in the grouprootTaskItem
- the root task
-
TaskGroup
Creates TaskGroup.- Parameters:
rootTaskItem
- the root task
-
-
Method Details
-
key
-
taskResult
Retrieve the result produced by a task with the given id in the group. This method can be used to retrieve the result of invocation of both dependency and "post-run" dependent tasks. If task with the given id does not exists then IllegalArgumentException exception will be thrown.- Parameters:
taskId
- the task item id- Returns:
- the task result, null will be returned if task has not yet been invoked
-
dependsOn
Checks this TaskGroup depends on the given TaskGroup.- Parameters:
taskGroup
- the TaskGroup to check- Returns:
- true if TaskGroup is depends on the given TaskGroup
-
root
-
addDependency
Mark root of this task task group depends on the given TaskItem. This ensure this task group's root get picked for execution only after the completion of invocation of provided TaskItem.- Parameters:
dependencyTaskItem
- the task item that this task group depends on- Returns:
- the key of the dependency
-
addDependency
Mark root of this task task group depends on the given item's taskGroup. This ensure this task group's root get picked for execution only after the completion of invocation of provided TaskItem.- Parameters:
hasTaskGroup
- an item with taskGroup that this task group depends on
-
addDependencyTaskGroup
Mark root of this task task group depends on the given task group's root. This ensure this task group's root get picked for execution only after the completion of all tasks in the given group.- Parameters:
dependencyTaskGroup
- the task group that this task group depends on
-
addPostRunDependent
Mark the given TaskItem depends on this taskGroup.- Parameters:
dependentTaskItem
- the task item that depends on this task group- Returns:
- key to be used as parameter to taskResult(string) method to retrieve result of invocation of given task item.
-
addPostRunDependent
Mark the given item with taskGroup depends on this taskGroup.- Parameters:
hasTaskGroup
- an item with as task group that depends on this task group
-
addPostRunDependentTaskGroup
Mark root of the given task group depends on this task group's root. This ensure given task group's root get picked for invocation only after the completion of all tasks in this group. Calling invokeAsync(cxt) will run the tasks in the given dependent task group as well.- Parameters:
dependentTaskGroup
- the task group depends on this task group
-
invokeAsync
Invokes tasks in the group.- Parameters:
context
- group level shared context that need be passed to invokeAsync(cxt) method of each task item in the group when it is selected for invocation.- Returns:
- an observable that emits the result of tasks in the order they finishes.
-
newInvocationContext
- Returns:
- a new clean context instance.
-