Table of Contents

Class ConnectorBase<T>

Namespace
Cognite.Simulator.Utils
Assembly
Cognite.Simulator.Utils.dll

Base class for simulator connectors. Implements heartbeat reporting. The connector information is stored in the simulator integration resource in CDF.

public abstract class ConnectorBase<T> where T : BaseConfig

Type Parameters

T
Inheritance
ConnectorBase<T>
Derived
Inherited Members

Constructors

ConnectorBase(CogniteDestination, ConnectorConfig, IList<SimulatorConfig>, ILogger<ConnectorBase<T>>, RemoteConfigManager<T>, ScopedRemoteApiSink)

Initialize the connector with the given parameters

public ConnectorBase(CogniteDestination cdf, ConnectorConfig config, IList<SimulatorConfig> simulators, ILogger<ConnectorBase<T>> logger, RemoteConfigManager<T> remoteConfigManager, ScopedRemoteApiSink remoteSink)

Parameters

cdf CogniteDestination

CDF client wrapper

config ConnectorConfig

Connector configuration

simulators IList<SimulatorConfig>

List of simulator configurations

logger ILogger<ConnectorBase<T>>

Logger

remoteConfigManager RemoteConfigManager<T>
remoteSink ScopedRemoteApiSink

Remote API sink for the logger

Properties

Cdf

CDF client wrapper

protected CogniteDestination Cdf { get; }

Property Value

CogniteDestination

Simulators

List of simulator configurations handled by this connector

protected IList<SimulatorConfig> Simulators { get; }

Property Value

IList<SimulatorConfig>

Methods

GetConnectorName()

Returns the connector name.This is reported periodically to CDF

public string GetConnectorName()

Returns

string

Connector name

GetConnectorVersion()

Returns the connector version. This is reported periodically to CDF

public abstract string GetConnectorVersion()

Returns

string

Connector version

GetHeartbeatInterval()

How often to report the connector information back to CDF (Heartbeat)

public TimeSpan GetHeartbeatInterval()

Returns

TimeSpan

Time interval

GetLicenseCheckInterval()

How often to report the simulator license status information back to CDF (Heartbeat)

public TimeSpan GetLicenseCheckInterval()

Returns

TimeSpan

Time interval

GetLicenseStatus()

This method should be overridden in each specific Connector class.

public LicenseStatus GetLicenseStatus()

Returns

LicenseStatus

True if the simulator has a valid license, false otherwise.

GetSimulatorIntegration(string)

Returns the ID of the simulator integration resource in CDF, if any

public SimulatorIntegration GetSimulatorIntegration(string simulator)

Parameters

simulator string

Simulator name

Returns

SimulatorIntegration

Simulator integration ID, or null if not found

GetSimulatorIntegrations()

Returns the first simulator integration.

public IEnumerable<SimulatorIntegration> GetSimulatorIntegrations()

Returns

IEnumerable<SimulatorIntegration>

A list of simulator integrations.

GetSimulatorVersion(string)

Returns the version of the given simulator. The connector reads the version and report it back to CDF

public abstract string GetSimulatorVersion(string simulator)

Parameters

simulator string

Name of the simulator

Returns

string

Version

HeartbeatLoop(CancellationToken)

Task that runs in a loop, reporting the connector information to CDF periodically (with the interval defined in GetHeartbeatInterval())

public Task HeartbeatLoop(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

Init(CancellationToken)

Initialize the connector. Should include any initialization tasks to be performed before the connector loop. This should include a call to InitRemoteSimulatorIntegrations(CancellationToken)

public abstract Task Init(CancellationToken token)

Parameters

token CancellationToken

Cancellation token

Returns

Task

InitRemoteSimulatorIntegrations(CancellationToken)

For each simulator specified in the configuration, create a simulator integration in CDF containing the simulator name, connector name, data set id, connector version, etc. These parameters will be updated periodically by the connector, and indicate the status of the currently running connector to applications consuming this simulation integration data.

protected Task InitRemoteSimulatorIntegrations(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

LicenseCheckLoop(CancellationToken)

Task that runs in a loop, reporting the connector license status to CDF periodically (with the interval defined in GetLicenseCheckInterval())

public Task LicenseCheckLoop(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

RestartOnNewRemoteConfigLoop(CancellationToken)

Task that runs in a loop, checking for new config in extraction pipelines

public Task RestartOnNewRemoteConfigLoop(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

Run(CancellationToken)

Implements the connector loop. Should call the HeartbeatLoop(CancellationToken) method and any other thats that are done periodically by the connector

public abstract Task Run(CancellationToken token)

Parameters

token CancellationToken

Cancellation token

Returns

Task

ShouldLicenseCheck()

If the connector should check and report the license status back to CDF

public bool ShouldLicenseCheck()

Returns

bool

UpdateRemoteSimulatorIntegrations(bool, CancellationToken)

Update the heartbeat, data set id and connector version in CDF. Data set id and connector version are not expected to change while the connector is running, and are only set during initialization.

protected Task UpdateRemoteSimulatorIntegrations(bool init, CancellationToken token)

Parameters

init bool
token CancellationToken

Returns

Task