Class TaskGroup
- java.lang.Object
-
- com.azure.resourcemanager.resources.fluentcore.dag.Graph<DataT,NodeT>
-
- com.azure.resourcemanager.resources.fluentcore.dag.DAGraph<TaskItem,TaskGroupEntry<TaskItem>>
-
- com.azure.resourcemanager.resources.fluentcore.dag.TaskGroup
-
- All Implemented Interfaces:
Indexable
public class TaskGroup extends DAGraph<TaskItem,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
Nested Classes Modifier and Type Class Description static interfaceTaskGroup.HasTaskGroupAn interface representing a type composes a TaskGroup.static classTaskGroup.InvocationContextA mutable type that can be used to pass data around task items during the invocation of the TaskGroup.protected static classTaskGroup.ProxyTaskGroupWrapperWrapper type to simplify operations on proxy TaskGroup.-
Nested classes/interfaces inherited from class com.azure.resourcemanager.resources.fluentcore.dag.Graph
Graph.EdgeType, Graph.Visitor<U>
-
-
Field Summary
Fields Modifier and Type Field Description protected TaskGroup.ProxyTaskGroupWrapperproxyTaskGroupWrapperThe helper to operate on proxy TaskGroup of this TaskGroup for supporting dependents marked for post run.-
Fields inherited from class com.azure.resourcemanager.resources.fluentcore.dag.DAGraph
parentDAGs, queue
-
-
Constructor Summary
Constructors Constructor Description TaskGroup(IndexableTaskItem rootTaskItem)Creates TaskGroup.TaskGroup(String rootTaskItemId, TaskItem rootTaskItem)Creates TaskGroup.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddDependency(FunctionalTaskItem dependencyTaskItem)Mark root of this task task group depends on the given TaskItem.voidaddDependency(TaskGroup.HasTaskGroup hasTaskGroup)Mark root of this task task group depends on the given item's taskGroup.voidaddDependencyTaskGroup(TaskGroup dependencyTaskGroup)Mark root of this task task group depends on the given task group's root.StringaddPostRunDependent(FunctionalTaskItem dependentTaskItem)Mark the given TaskItem depends on this taskGroup.StringaddPostRunDependent(FunctionalTaskItem dependentTaskItem, ResourceManagerUtils.InternalRuntimeContext internalContext)Mark the given TaskItem depends on this taskGroup.voidaddPostRunDependent(TaskGroup.HasTaskGroup hasTaskGroup)Mark the given item with taskGroup depends on this taskGroup.voidaddPostRunDependentTaskGroup(TaskGroup dependentTaskGroup)Mark root of the given task group depends on this task group's root.booleandependsOn(TaskGroup taskGroup)Checks this TaskGroup depends on the given TaskGroup.Mono<Indexable>invokeAsync()Invokes tasks in the group.Flux<Indexable>invokeAsync(TaskGroup.InvocationContext context)Invokes tasks in the group.Flux<Indexable>invokeDependencyAsync(TaskGroup.InvocationContext context)Invokes dependency tasks in the group, but not.Stringkey()TaskGroup.InvocationContextnewInvocationContext()protected TaskGroupEntry<TaskItem>root()IndexabletaskResult(String taskId)Retrieve the result produced by a task with the given id in the group.-
Methods inherited from class com.azure.resourcemanager.resources.fluentcore.dag.DAGraph
addDependencyGraph, addDependentGraph, getNext, getNode, hasParents, isPreparer, isRootNode, prepareForEnumeration, reportCompletion, reportError
-
-
-
-
Field Detail
-
proxyTaskGroupWrapper
protected TaskGroup.ProxyTaskGroupWrapper proxyTaskGroupWrapper
The helper to operate on proxy TaskGroup of this TaskGroup for supporting dependents marked for post run.
-
-
Constructor Detail
-
TaskGroup
public TaskGroup(String rootTaskItemId, TaskItem rootTaskItem)
Creates TaskGroup.- Parameters:
rootTaskItemId- the id of the root task in the grouprootTaskItem- the root task
-
TaskGroup
public TaskGroup(IndexableTaskItem rootTaskItem)
Creates TaskGroup.- Parameters:
rootTaskItem- the root task
-
-
Method Detail
-
key
public String key()
-
taskResult
public Indexable taskResult(String taskId)
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
public boolean dependsOn(TaskGroup taskGroup)
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
protected TaskGroupEntry<TaskItem> root()
- Overrides:
rootin classDAGraph<TaskItem,TaskGroupEntry<TaskItem>>- Returns:
- the root task entry in the group.
-
addDependency
public String addDependency(FunctionalTaskItem dependencyTaskItem)
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
public void addDependency(TaskGroup.HasTaskGroup hasTaskGroup)
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
public void addDependencyTaskGroup(TaskGroup dependencyTaskGroup)
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
public String addPostRunDependent(FunctionalTaskItem dependentTaskItem)
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
public String addPostRunDependent(FunctionalTaskItem dependentTaskItem, ResourceManagerUtils.InternalRuntimeContext internalContext)
Mark the given TaskItem depends on this taskGroup.- Parameters:
dependentTaskItem- the task item that depends on this task groupinternalContext- the internal runtime context- Returns:
- key to be used as parameter to taskResult(string) method to retrieve result of invocation of given task item.
-
addPostRunDependent
public void addPostRunDependent(TaskGroup.HasTaskGroup hasTaskGroup)
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
public void addPostRunDependentTaskGroup(TaskGroup dependentTaskGroup)
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
public Flux<Indexable> invokeAsync(TaskGroup.InvocationContext context)
Invokes tasks in the group. It is not guaranteed to return indexable in topological order.- 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.
-
invokeAsync
public Mono<Indexable> invokeAsync()
Invokes tasks in the group.- Returns:
- the root result of task group.
-
invokeDependencyAsync
public Flux<Indexable> invokeDependencyAsync(TaskGroup.InvocationContext context)
Invokes dependency tasks in the group, but not.- 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
public TaskGroup.InvocationContext newInvocationContext()
- Returns:
- a new clean context instance.
-
-