Show / Hide Table of Contents

Class ExtractorTaskScheduler

Task scheduler that runs tasks and reports their status to the integrations API.

Inheritance
object
ExtractorTaskScheduler
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Cognite.Extractor.Utils.Unstable.Tasks
Assembly: ExtractorUtils.dll
Syntax
public class ExtractorTaskScheduler : IDisposable

Constructors

| Edit this page View Source

ExtractorTaskScheduler(IIntegrationSink, ILogger<ExtractorTaskScheduler>)

Constructor.

Declaration
public ExtractorTaskScheduler(IIntegrationSink sink, ILogger<ExtractorTaskScheduler> logger)
Parameters
Type Name Description
IIntegrationSink sink

Sink for task updates.

ILogger<ExtractorTaskScheduler> logger

Logger object.

Properties

| Edit this page View Source

CompletedTask

Task that terminates once the run method terminates.

Declaration
public Task CompletedTask { get; }
Property Value
Type Description
Task

Methods

| Edit this page View Source

AddScheduledTask(BaseSchedulableTask, bool)

Add a task to the scheduler.

Declaration
public void AddScheduledTask(BaseSchedulableTask operation, bool runImmediately)
Parameters
Type Name Description
BaseSchedulableTask operation

Type implementing the runnable task.

bool runImmediately

Whether to run the task immediately.

Exceptions
Type Condition
InvalidOperationException

If a task with the same name already exists.

| Edit this page View Source

CancelInnerAndWait(int, BaseErrorReporter)

Cancel the running task, if it exists.

Declaration
public Task CancelInnerAndWait(int timeoutms, BaseErrorReporter outerReporter)
Parameters
Type Name Description
int timeoutms
BaseErrorReporter outerReporter
Returns
Type Description
Task
| Edit this page View Source

CancelTask(string)

Cancel a task if it is currently running.

Declaration
public void CancelTask(string name)
Parameters
Type Name Description
string name

Name of the task to cancel

| Edit this page View Source

Dispose()

Declaration
public void Dispose()
| Edit this page View Source

Dispose(bool)

Dispose of the scheduler.

Can be overridden in base classes.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

Whether to dispose managed resources.

| Edit this page View Source

GetRegisteredTasks()

Get a list of registered tasks, used for reporting startup.

Declaration
public IEnumerable<IntegrationTask> GetRegisteredTasks()
Returns
Type Description
IEnumerable<IntegrationTask>
| Edit this page View Source

Notify()

Wake up the scheduler and tell it to check its tasks again.

Declaration
public void Notify()
| Edit this page View Source

Run(CancellationToken)

Run the scheduler.

This should only be called once on a given scheduler.

To re-run it after a crash, the scheduler must be re-initialized.

Declaration
public Task<ExtractorTaskResult> Run(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

Global cancellation token for stopping the entire scheduler.

Returns
Type Description
Task<ExtractorTaskResult>
| Edit this page View Source

ScheduleTaskNow(string, bool)

Schedule a task now. If it is already running it will

Declaration
public void ScheduleTaskNow(string name, bool reScheduleIfRunning = false)
Parameters
Type Name Description
string name

Name of the task to schedule

bool reScheduleIfRunning

If true, re-schedule the task to run again once it finishes. If false, and the task is already running, nothing will happen.

| Edit this page View Source

WaitForNextEndOfTask(string, TimeSpan, CancellationToken)

Wait for the next time the task given by task ends.

If the task is not currently running, this will wait until it starts running and then ends.

Note that if the task fails, this will re-throw the exception that caused the task failure, or a TaskCanceledException if it was canceled.

Declaration
public Task WaitForNextEndOfTask(string task, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
string task

Task to wait for, must be added to the scheduler.

TimeSpan timeout

Timeout, set to Timeout.InfiniteTimespan to wait forever.

CancellationToken token

Optional cancellation token.

Returns
Type Description
Task
Exceptions
Type Condition
ArgumentException

If the task does not exist.

TimeoutException

If waiting for the task to end timed out.

Implements

IDisposable

Extension Methods

DataModelUtils.GetOrCreateResourcesAsync<T, T2>(T2, IEnumerable<InstanceIdentifier>, Func<IEnumerable<InstanceIdentifier>, IEnumerable<SourcedNodeWrite<T>>>, Func<IEnumerable<SourcedNodeWrite<T>>, SanitationMode, (IEnumerable<SourcedNodeWrite<T>>, IEnumerable<CogniteError<SourcedNodeWrite<T>>>)>, int, int, RetryMode, SanitationMode, CancellationToken)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX