21.188. Class TaskHandler
Namespace: ArmoniK.Core.Common.Pollster
Assembly: ArmoniK.Core.Common.dll
Handles the lifecycle and execution of a single task in the ArmoniK Pollster, including acquisition, preprocessing, execution, postprocessing, and error handling. Manages task and session metadata, agent communication, health checks, and resource cleanup for robust distributed task processing.
public sealed class TaskHandler : IAsyncDisposable
21.188.1. Inheritance
21.188.2. Implements
21.188.3. Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
21.188.4. Constructors
21.188.4.1. TaskHandler(ISessionTable, ITaskTable, IResultTable, IPushQueueStorage, IObjectStorage, ISubmitter, DataPrefetcher, IWorkerStreamHandler, IQueueMessageHandler, ITaskProcessingChecker, string, string, ActivitySource, IAgentHandler, ILogger, Pollster, Submitter, Action, ExceptionManager, FunctionExecutionMetrics<TaskHandler>, HealthCheckRecord)
Initializes a new instance of the
public TaskHandler(ISessionTable sessionTable, ITaskTable taskTable, IResultTable resultTable, IPushQueueStorage pushQueueStorage, IObjectStorage objectStorage, ISubmitter submitter, DataPrefetcher dataPrefetcher, IWorkerStreamHandler workerStreamHandler, IQueueMessageHandler messageHandler, ITaskProcessingChecker taskProcessingChecker, string ownerPodId, string ownerPodName, ActivitySource activitySource, IAgentHandler agentHandler, ILogger logger, Pollster pollsterOptions, Submitter submitterOptions, Action onDispose, ExceptionManager exceptionManager, FunctionExecutionMetrics<TaskHandler> functionExecutionMetrics, HealthCheckRecord healthCheckRecord)
21.188.4.1.1. Parameters
sessionTable ISessionTable
The session table for managing session metadata.
taskTable ITaskTable
The task table for managing task metadata.
resultTable IResultTable
The result table for managing result metadata.
pushQueueStorage IPushQueueStorage
The queue storage for pushing tasks to be processed.
objectStorage IObjectStorage
The object storage for managing payloads and results.
submitter ISubmitter
The submitter service for completing tasks and managing results.
dataPrefetcher DataPrefetcher
The data prefetcher for loading task input data.
workerStreamHandler IWorkerStreamHandler
The handler for worker stream communication.
messageHandler IQueueMessageHandler
The handler for queue messages associated with the task.
taskProcessingChecker ITaskProcessingChecker
The checker for verifying if a task is being processed by an agent.
ownerPodId string
The identifier of the current agent.
ownerPodName string
The name of the current agent.
activitySource ActivitySource
The activity source for distributed tracing.
agentHandler IAgentHandler
The handler for agent lifecycle management.
logger ILogger
The logger for diagnostic and trace logging.
pollsterOptions Pollster
The pollster options for configuration.
submitterOptions Submitter
The submitter options for configuration.
onDispose Action
The action to execute on disposal.
exceptionManager ExceptionManager
The exception manager for handling cancellation and errors.
functionExecutionMetrics FunctionExecutionMetrics<TaskHandler>
The metrics collector for function execution.
healthCheckRecord HealthCheckRecord
The health check record for agent health monitoring.
21.188.5. Properties
21.188.5.1. StartedAt
Start date for the task handled by the current Task Handler
public DateTime StartedAt { get; }
21.188.5.1.1. Property Value
21.188.6. Methods
21.188.6.1. AcquireTask()
Acquisition of the task in the message given to the constructor
public Task<AcquisitionStatus> AcquireTask()
21.188.6.1.1. Returns
Integer representing whether the task has been acquired Acquired when return is 0
21.188.6.1.2. Exceptions
status of the task is not recognized
21.188.6.2. DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
21.188.6.2.1. Returns
A task that represents the asynchronous dispose operation.
21.188.6.3. ExecuteTask()
Execution of the acquired task on the worker
public Task ExecuteTask()
21.188.6.3.1. Returns
Task representing the asynchronous execution of the method
21.188.6.3.2. Exceptions
wrong order of execution
ArmoniKException
worker pipe is not initialized
21.188.6.4. GetAcquiredTaskInfo()
Get the meta data of the acquired task
public TaskInfo GetAcquiredTaskInfo()
21.188.6.4.1. Returns
The metadata of the task
21.188.6.5. PostProcessing()
Post processing of the acquired task
public Task PostProcessing()
21.188.6.5.1. Returns
Task representing the asynchronous execution of the method
21.188.6.5.2. Exceptions
wrong order of execution
21.188.6.6. PreProcessing()
Preprocessing (including the data prefetching) of the acquired task
public Task PreProcessing()
21.188.6.6.1. Returns
Task representing the asynchronous execution of the method
21.188.6.6.2. Exceptions
wrong order of execution
ObjectDataNotFoundException
input data are not found
21.188.6.7. ReleaseAndPostponeTask(bool)
Release task from the current agent and set message to
public Task ReleaseAndPostponeTask(bool paused = false)
21.188.6.7.1. Parameters
paused bool
If task should be paused
21.188.6.7.2. Returns
Task representing the asynchronous execution of the method
21.188.6.7.3. Exceptions
wrong order of execution
21.188.6.8. StopCancelledTask()
Refresh task metadata and stop execution if current task should be cancelled
public Task<bool> StopCancelledTask()
21.188.6.8.1. Returns
Task representing the asynchronous execution of the method