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.
  • Field Details

    • proxyTaskGroupWrapper

      protected com.microsoft.azure.management.resources.fluentcore.dag.TaskGroup.ProxyTaskGroupWrapper proxyTaskGroupWrapper
      The helper to operate on proxy TaskGroup of this TaskGroup for supporting dependents marked for post run.
  • Constructor Details

    • TaskGroup

      public TaskGroup(String rootTaskItemId, TaskItem rootTaskItem)
      Creates TaskGroup.
      Parameters:
      rootTaskItemId - the id of the root task in the group
      rootTaskItem - the root task
    • TaskGroup

      public TaskGroup(IndexableTaskItem rootTaskItem)
      Creates TaskGroup.
      Parameters:
      rootTaskItem - the root task
  • Method Details

    • key

      public String key()
      Specified by:
      key in interface Indexable
      Returns:
      the key of this task group, which is same as key of the root entry in the group
    • 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 com.microsoft.azure.management.resources.fluentcore.dag.TaskGroupEntry<TaskItem> root()
      Overrides:
      root in class DAGraph<TaskItem,com.microsoft.azure.management.resources.fluentcore.dag.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 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 rx.Observable<Indexable> invokeAsync(TaskGroup.InvocationContext context)
      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

      public TaskGroup.InvocationContext newInvocationContext()
      Returns:
      a new clean context instance.