Class IndexableTaskItem

    • Constructor Detail

      • IndexableTaskItem

        public IndexableTaskItem​(String key)
        Creates a TaskItem which is index-able using provided key.
        Parameters:
        key - the unique key to index this TaskItem
      • IndexableTaskItem

        public IndexableTaskItem()
        Creates a TaskItem which is index-able using a random UUID.
      • IndexableTaskItem

        public IndexableTaskItem​(ResourceManagerUtils.InternalRuntimeContext internalContext)
        Creates a TaskItem which is index-able using a random UUID.
        Parameters:
        internalContext - the internal runtime context
    • Method Detail

      • create

        public static IndexableTaskItem create​(FunctionalTaskItem taskItem)
        Creates an IndexableTaskItem from provided FunctionalTaskItem.
        Parameters:
        taskItem - functional TaskItem
        Returns:
        IndexableTaskItem
      • clear

        public void clear()
        Clear the result produced by the task.
      • key

        public String key()
        Specified by:
        key in interface Indexable
        Returns:
        the index key.
      • addDependency

        protected String addDependency​(FunctionalTaskItem dependency)
        Add a dependency task item for this task item.
        Parameters:
        dependency - the dependency task item.
        Returns:
        key to be used as parameter to taskResult(string) method to retrieve result the task item
      • addDependency

        protected String addDependency​(TaskGroup.HasTaskGroup dependency)
        Add a dependency for this task item.
        Parameters:
        dependency - the dependency.
        Returns:
        key to be used as parameter to taskResult(string) method to retrieve result of root task in the given dependency task group
      • addDependency

        protected String addDependency​(Creatable<? extends Indexable> creatable)
        Add a creatable dependency for this task item.
        Parameters:
        creatable - the creatable dependency.
        Returns:
        the key to be used as parameter to taskResult(string) method to retrieve created dependency
      • addDependency

        protected String addDependency​(Appliable<? extends Indexable> appliable)
        Add an appliable dependency for this task item.
        Parameters:
        appliable - the appliable dependency.
        Returns:
        the key to be used as parameter to taskResult(string) method to retrieve updated dependency
      • addDependency

        protected String addDependency​(Executable<? extends Indexable> executable)
        Add an executable dependency for this task item.
        Parameters:
        executable - the executable dependency
        Returns:
        the key to be used as parameter to taskResult(string) method to retrieve result of executing the executable dependency
      • addPostRunDependent

        public String addPostRunDependent​(FunctionalTaskItem dependent)
        Add a "post-run" dependent task item for this task item.
        Parameters:
        dependent - the "post-run" dependent task item.
        Returns:
        key to be used as parameter to taskResult(string) method to retrieve result of root task in the given dependent task group
      • addPostRunDependent

        public String addPostRunDependent​(TaskGroup.HasTaskGroup dependent)
        Add a "post-run" dependent for this task item.
        Parameters:
        dependent - the "post-run" dependent.
        Returns:
        key to be used as parameter to taskResult(string) method to retrieve result of root task in the given dependent task group
      • addPostRunDependent

        protected String addPostRunDependent​(Creatable<? extends Indexable> creatable)
        Add a creatable "post-run" dependent for this task item.
        Parameters:
        creatable - the creatable "post-run" dependent.
        Returns:
        the key to be used as parameter to taskResult(string) method to retrieve created "post-run" dependent
      • addPostRunDependent

        protected String addPostRunDependent​(Appliable<? extends Indexable> appliable)
        Add an appliable "post-run" dependent for this task item.
        Parameters:
        appliable - the appliable "post-run" dependent.
        Returns:
        the key to be used as parameter to taskResult(string) method to retrieve updated "post-run" dependent
      • addPostRunDependent

        protected String addPostRunDependent​(Executable<? extends Indexable> executable)
        Add an executable "post-run" dependent for this task item.
        Parameters:
        executable - the executable "post-run" dependent
        Returns:
        the key to be used as parameter to taskResult(string) method to retrieve result of executing the executable "post-run" dependent
      • taskResult

        protected <T extends Indexable> T taskResult​(String key)
        Get result of one of the task that belongs to this task's task group.
        Type Parameters:
        T - the actual type of the task result
        Parameters:
        key - the task key
        Returns:
        the task result, null will be returned if task has not produced a result yet
      • result

        public Indexable result()
        Specified by:
        result in interface TaskItem
        Returns:
        the result of the task invocation
      • beforeGroupInvoke

        public void beforeGroupInvoke()
        Description copied from interface: TaskItem
        The method that gets called before invoking all the tasks in the TaskGroup this task belongs to.
        Specified by:
        beforeGroupInvoke in interface TaskItem
      • isHot

        public boolean isHot()
        Specified by:
        isHot in interface TaskItem
        Returns:
        true if the publisher returned by invokeAsync(cxt) is a hot observable, false if its a cold publisher.
      • invokeAsync

        public Mono<Indexable> invokeAsync​(TaskGroup.InvocationContext context)
        Description copied from interface: TaskItem
        The method that gets called to perform the unit of work asynchronously.
        Specified by:
        invokeAsync in interface TaskItem
        Parameters:
        context - the context shared across the the all task items in the group this task item belongs to.
        Returns:
        a Mono upon subscription does the unit of work and produces result of type Indexable
      • invokeAfterPostRunAsync

        public Mono<Void> invokeAfterPostRunAsync​(boolean isGroupFaulted)
        Description copied from interface: TaskItem
        The method that gets called after invocation of "post run" task items depends on this TaskItem.

        This method will be invoked only if this TaskItem had "post run" dependents.

        Specified by:
        invokeAfterPostRunAsync in interface TaskItem
        Parameters:
        isGroupFaulted - true if one or more tasks in the group this TaskItem belongs to are in faulted state.
        Returns:
        a Flux representing any asynchronous work initiated
      • invokeTaskAsync

        protected abstract Mono<Indexable> invokeTaskAsync​(TaskGroup.InvocationContext context)
        Invokes a task asynchronously.
        Parameters:
        context - Context of the invocation.
        Returns:
        an Observable upon subscription emits Indexable.
      • voidIndexable

        protected Indexable voidIndexable()
        Returns:
        an instance of VoidIndexable with key same as the key of this TaskItem.
      • voidPublisher

        protected Mono<Indexable> voidPublisher()
        Returns:
        an Observable upon subscription emits VoidIndexable with key same as the key of this TaskItem