23.230. Class TaskLifeCycleHelper
Namespace: ArmoniK.Core.Common.Storage
Assembly: ArmoniK.Core.Common.dll
Provides helper methods for managing the lifecycle of tasks in the ArmoniK system. Includes utilities for validating, creating, finalizing, retrying, aborting, pausing, resuming, and completing tasks, as well as handling dependencies and task state transitions across storage and queue systems.
public static class TaskLifeCycleHelper
23.230.1. Inheritance
23.230.2. Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
23.230.3. Methods
23.230.3.1. AbortTaskAsync(ITaskTable, IResultTable, IObjectStorage, Submitter, TaskData, OutputStatus, string, ILogger, CancellationToken)
Retry the task if all retries have not been consumed, or abort otherwise
public static Task<TaskData> AbortTaskAsync(ITaskTable taskTable, IResultTable resultTable, IObjectStorage objectStorage, Submitter options, TaskData taskData, OutputStatus status, string errorMessage, ILogger logger, CancellationToken cancellationToken = default)
23.230.3.1.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
objectStorage IObjectStorage
Interface to manage object data
options Submitter
Submitter options
taskData TaskData
Data of the task
status OutputStatus
Output status of the task (cannot be success)
errorMessage string
Error message to record in the task output
logger ILogger
Logger
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.1.2. Returns
The status of the processed task
23.230.3.2. CompleteTaskAsync(ITaskTable, IResultTable, IObjectStorage, Submitter, TaskData, ILogger, CancellationToken)
Complete the task depending on the given output
public static Task<TaskData> CompleteTaskAsync(ITaskTable taskTable, IResultTable resultTable, IObjectStorage objectStorage, Submitter options, TaskData taskData, ILogger logger, CancellationToken cancellationToken = default)
23.230.3.2.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
objectStorage IObjectStorage
Interface to manage object data
options Submitter
Submitter options
taskData TaskData
Data of the task
logger ILogger
Logger
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.2.2. Returns
The status of the processed task
23.230.3.3. CreateTasks(ITaskTable, IResultTable, string, string, ICollection<TaskCreationRequest>, ILogger, CancellationToken)
Initiate task creation
public static Task CreateTasks(ITaskTable taskTable, IResultTable resultTable, string sessionId, string parentTaskId, ICollection<TaskCreationRequest> taskCreationRequests, ILogger logger, CancellationToken cancellationToken = default)
23.230.3.3.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
sessionId string
Session Id of the completed results
parentTaskId string
Id of the tasks that creates the tasks
taskCreationRequests ICollection<TaskCreationRequest>
Tasks to create
logger ILogger
Logger used to produce logs
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.3.2. Returns
Task representing the asynchronous execution of the method
23.230.3.4. DeleteTasksAsync(ITaskTable, IResultTable, ICollection<TaskCreationRequest>, CancellationToken)
DeleteTasks created by
public static Task DeleteTasksAsync(ITaskTable taskTable, IResultTable resultTable, ICollection<TaskCreationRequest> creationRequests, CancellationToken cancellationToken = default)
23.230.3.4.1. Parameters
taskTable ITaskTable
resultTable IResultTable
creationRequests ICollection<TaskCreationRequest>
cancellationToken CancellationToken
23.230.3.4.2. Returns
23.230.3.4.3. Remarks
Does not support tasks created during subtasking where parentTaskId != sessionId
23.230.3.5. FinalizeTaskCreation(ITaskTable, IResultTable, IPushQueueStorage, ICollection<TaskCreationRequest>, SessionData, string, ILogger, CancellationToken)
Finalize task creation
public static Task FinalizeTaskCreation(ITaskTable taskTable, IResultTable resultTable, IPushQueueStorage pushQueueStorage, ICollection<TaskCreationRequest> taskRequests, SessionData sessionData, string parentTaskId, ILogger logger, CancellationToken cancellationToken = default)
23.230.3.5.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
pushQueueStorage IPushQueueStorage
Interface to push tasks in the queue
taskRequests ICollection<TaskCreationRequest>
Tasks requests to finalize
sessionData SessionData
Session data of the completed results
parentTaskId string
Id of the tasks that creates the tasks
logger ILogger
Logger used to produce logs
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.5.2. Returns
Task representing the asynchronous execution of the method
23.230.3.6. HandleTaskCrashedWhileProcessing(ITaskTable, IResultTable, IObjectStorage, IPushQueueStorage, Submitter, TimeSpan, SessionData, TaskData, ILogger, CancellationToken)
Either finish completion of task if crashing pod was advanced enough, or retry task otherwise
public static Task<TaskStatus> HandleTaskCrashedWhileProcessing(ITaskTable taskTable, IResultTable resultTable, IObjectStorage objectStorage, IPushQueueStorage pushQueueStorage, Submitter options, TimeSpan processingCrashedDelay, SessionData sessionData, TaskData taskData, ILogger logger, CancellationToken cancellationToken)
23.230.3.6.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
objectStorage IObjectStorage
Interface to manage object data
pushQueueStorage IPushQueueStorage
Interface to push messages to the queue
options Submitter
Submitter options
processingCrashedDelay TimeSpan
The delay after the agent has verified the other agent crashed before retrying the task
sessionData SessionData
Data of the session
taskData TaskData
Data of the task
logger ILogger
Logger
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.6.2. Returns
The status of the processed task
23.230.3.7. PauseAsync(ITaskTable, ISessionTable, string, CancellationToken)
Pause session and its paused tasks
public static Task<SessionData> PauseAsync(ITaskTable taskTable, ISessionTable sessionTable, string sessionId, CancellationToken cancellationToken = default)
23.230.3.7.1. Parameters
taskTable ITaskTable
Interface to manage task states
sessionTable ISessionTable
Interface to manage session states
sessionId string
Id of the session to pause
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.7.2. Returns
The updated data of the session
23.230.3.8. ResolveDependencies(ITaskTable, IResultTable, IPushQueueStorage, SessionData, ICollection<string>, ILogger, CancellationToken)
Remove completed results from dependent tasks and submit tasks which dependencies are completed
public static Task ResolveDependencies(ITaskTable taskTable, IResultTable resultTable, IPushQueueStorage pushQueueStorage, SessionData sessionData, ICollection<string> results, ILogger logger, CancellationToken cancellationToken = default)
23.230.3.8.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
pushQueueStorage IPushQueueStorage
Interface to push tasks in the queue
sessionData SessionData
Session data of the completed results
results ICollection<string>
Collection of completed results
logger ILogger
Logger used to produce logs
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.8.2. Returns
Task representing the asynchronous execution of the method
23.230.3.9. ResumeAsync(ITaskTable, ISessionTable, IPushQueueStorage, string, CancellationToken)
Resume session and its paused tasks
public static Task<SessionData> ResumeAsync(ITaskTable taskTable, ISessionTable sessionTable, IPushQueueStorage pushQueueStorage, string sessionId, CancellationToken cancellationToken = default)
23.230.3.9.1. Parameters
taskTable ITaskTable
Interface to manage task states
sessionTable ISessionTable
Interface to manage session states
pushQueueStorage IPushQueueStorage
Interface to push tasks in the queue
sessionId string
Id of the session to resume
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.9.2. Returns
The updated data of the session
23.230.3.10. RetryTaskAsync(ITaskTable, IResultTable, IPushQueueStorage, TaskData, SessionData, ICollection<string>?, string, ILogger, CancellationToken)
Retry the task if all retries have not been consumed, or abort otherwise
public static Task<TaskData> RetryTaskAsync(ITaskTable taskTable, IResultTable resultTable, IPushQueueStorage pushQueueStorage, TaskData taskData, SessionData sessionData, ICollection<string>? subtasks, string errorMessage, ILogger logger, CancellationToken cancellationToken = default)
23.230.3.10.1. Parameters
taskTable ITaskTable
Interface to manage task states
resultTable IResultTable
Interface to manage result states
pushQueueStorage IPushQueueStorage
Interface to push messages to the queue
taskData TaskData
Data of the task
sessionData SessionData
Data of the session
subtasks ICollection<string>?
Ids of the tasks that have been created by the current task. If null, they will be fetched from the TaskTable
errorMessage string
Error message to record in the task output
logger ILogger
Logger
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.10.2. Returns
The status of the processed task
23.230.3.11. ValidateSession(SessionData, TaskOptions?, string, int, ILogger, CancellationToken)
Validate and merge task data from the session with the given options
public static TaskOptions ValidateSession(SessionData sessionData, TaskOptions? submissionOptions, string parentTaskId, int maxPriority, ILogger logger, CancellationToken cancellationToken)
23.230.3.11.1. Parameters
sessionData SessionData
Session Metadata
submissionOptions TaskOptions?
Incoming task options
parentTaskId string
Id of the tasks that creates the tasks
maxPriority int
Max priority managed by the queue
logger ILogger
Logger used to produce logs
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.230.3.11.2. Returns
TaskOptions
Merged task options
23.230.3.11.3. Exceptions
when partition in incoming tasks options is not allowed in the session