Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Extractor/BrowseCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,4 @@ public class BrowseReport
public string? TimeSeriesTable { get; set; }
public string? RelationshipsTable { get; set; }
}

internal class BrowseCallback : FunctionCallWrapper<BrowseReport>
{
private readonly bool callOnEmpty;
public BrowseCallback(CogniteDestination destination, BrowseCallbackConfig config, ILogger log)
: base(destination, config, log)
{
callOnEmpty = config.ReportOnEmpty;
}

public async Task Call(BrowseReport report, CancellationToken token)
{
if (report == null) return;
if (!callOnEmpty
&& report.AssetsCreated == 0
&& report.AssetsUpdated == 0
&& report.TimeSeriesCreated == 0
&& report.TimeSeriesUpdated == 0
&& report.RelationshipsCreated == 0
&& report.MinimalTimeSeriesCreated == 0) return;

await TryCall(report, token);
}
}
}
35 changes: 0 additions & 35 deletions Extractor/Config/CogniteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,11 @@ namespace Cognite.OpcUa.Config
{
public class CognitePusherConfig : CogniteConfig, IPusherConfig
{
/// <summary>
/// DEPRECATED. Data set to use for new objects. Existing objects will not be updated.
/// </summary>
public long? DataSetId { get; set; }
/// <summary>
/// DEPRECATED. Data set to use for new objects, overridden by data-set-id. Requires the capability datasets:read for the given data set.
/// </summary>
public string? DataSetExternalId { get; set; }
/// <summary>
/// Data set to use for new objects. Requires the capability datasets:read if external-id is used.
/// </summary>
public DataSetConfig? DataSet { get; set; }
/// <summary>
/// DEPRECATED. Debug mode, if true, Extractor will not push to target
/// </summary>
public bool Debug { get; set; }
/// <summary>
/// Whether to read start/end-points on startup, where possible. At least one pusher should be able to do this,
/// otherwise back/frontfill will run for the entire history every restart.
/// The CDF pusher is not able to read start/end points for events, so if reading historical events is enabled, one other pusher
Expand All @@ -55,23 +43,6 @@ public class CognitePusherConfig : CogniteConfig, IPusherConfig
[DefaultValue(true)]
public bool ReadExtractedRanges { get; set; } = true;
/// <summary>
/// Do not push any metadata at all. If this is true, plain timeseries without metadata will be created,
/// similarly to raw-metadata, and datapoints will be pushed. Nothing will be written to raw, and no assets will be created.
/// Events will be created, but without asset context.
/// </summary>
[Obsolete("Deprecated!")]
public bool SkipMetadata { get; set; }
/// <summary>
/// Store assets and/or timeseries data in raw. Assets will not be created at all,
/// timeseries will be created with just externalId, isStep and isString.
/// Both timeseries and assets will be persisted in their entirety to raw.
/// Datapoints are not affected, events will be created, but without asset context. The externalId
/// of the source node is added to metadata if applicable.
/// Use different table names for assets and timeseries.
/// </summary>
[Obsolete("Deprecated! Use MetadataTargetsConfig.RawMetadataTargetConfig instead.")]
public RawMetadataConfig? RawMetadata { get; set; }
/// <summary>
/// Map metadata to asset/timeseries attributes. Each of "assets" and "timeseries" is a map from property DisplayName to
/// CDF attribute. Legal attributes are "name, description, parentId" and "unit" for timeseries. "parentId" must somehow refer to
/// an existing asset. For timeseries it must be a mapped asset, for assets it can be any asset.
Expand Down Expand Up @@ -103,12 +74,6 @@ public double? NonFiniteReplacement
&& value.Value > CogniteUtils.NumericValueMin
&& value.Value < CogniteUtils.NumericValueMax ? value : null;
}
/// <summary>
/// Specification for a CDF function that is called after nodes are pushed to CDF,
/// reporting the number changed.
/// </summary>
public BrowseCallbackConfig? BrowseCallback { get; set; }

/// <summary>
/// There is no good way to mark relationships as deleted, so they are hard-deleted.
/// This has to be enabled to delete relationships deleted from OPC-UA. This requires extraction.deletes to be enabled.
Expand Down
4 changes: 0 additions & 4 deletions Extractor/Config/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ public class ProtoDataType
}
public interface IPusherConfig
{
/// <summary>
/// True to not write to destination, as a kind of dry-run for this destination.
/// </summary>
bool Debug { get; set; }
/// <summary>
/// If applicable, read the ranges of extracted variables from the destination.
/// </summary>
Expand Down
16 changes: 0 additions & 16 deletions Extractor/Config/ExtractionConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ public class ExtractionConfig
/// </summary>
public string? IdPrefix { get; set; }
/// <summary>
/// DEPRECATED. Specify a list of prefixes on DisplayName to ignore.
/// </summary>
public IEnumerable<string>? IgnoreNamePrefix { get; set; }
/// <summary>
/// DEPRECATED. Specify a list of DisplayNames to ignore.
/// </summary>
public IEnumerable<string>? IgnoreName { get; set; }
/// <summary>
/// Root node. Defaults to the Objects node.
/// </summary>
public ProtoNodeId? RootNode { get; set; }
Expand Down Expand Up @@ -109,14 +101,6 @@ public string? DataPushDelay
public DataTypeConfig DataTypes { get => dataTypes; set => dataTypes = value ?? dataTypes; }
private DataTypeConfig dataTypes = new DataTypeConfig();
/// <summary>
/// DEPRECATED. Regex filter on DisplayName to treat variables as properties.
/// </summary>
public string? PropertyNameFilter { get; set; }
/// <summary>
/// DEPRECATED. Regex filter on id to treat variables as properties.
/// </summary>
public string? PropertyIdFilter { get; set; }
/// <summary>
/// Configuration for translating OPC-UA references to relationships in CDF.
/// </summary>
public RelationshipConfig Relationships { get => relationships; set => relationships = value ?? relationships; }
Expand Down
4 changes: 0 additions & 4 deletions Extractor/Config/MqttConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ public class MqttPusherConfig : IPusherConfig
/// They will not be deleted or updated.
/// </summary>
public long InvalidateBefore { get; set; }
/// <summary>
/// DEPRECATED. If true, pusher will not push to target.
/// </summary>
public bool Debug { get; set; }
public bool ReadExtractedRanges { get; set; }
/// <summary>
/// Do not push any metadata at all. If this is true, plain timeseries without metadata will be created,
Expand Down
10 changes: 0 additions & 10 deletions Extractor/Config/SourceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ public class SourceConfig
[DefaultValue(500)]
public int PublishingInterval { get; set; } = 500;
/// <summary>
/// DEPRECATED, see subscriptions.sampling-interval
/// </summary>
[DefaultValue(100)]
public int? SamplingInterval { get; set; } = null;
/// <summary>
/// DEPRECATED, see subscriptions.queue-length
/// </summary>
[DefaultValue(100)]
public int? QueueLength { get; set; } = null;
/// <summary>
/// OPC-UA username, can be left out to use anonymous authentication.
/// </summary>
public string? Username { get; set; }
Expand Down
28 changes: 6 additions & 22 deletions Extractor/Pushers/CDFPusher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public sealed class CDFPusher : IPusher

private readonly CogniteDestinationWithIDM destination;

private readonly BrowseCallback? callback;
private RawMetadataTargetConfig? RawMetadataTargetConfig => fullConfig.Cognite?.MetadataTargets?.Raw;

private StreamRecordsWriter? recordsWriter;
Expand All @@ -81,10 +80,6 @@ public CDFPusher(
this.destination = destination;
this.fullConfig = fullConfig;
cdfWriter = provider.GetRequiredService<CDFWriter>();
if (config.BrowseCallback != null && (config.BrowseCallback.Id.HasValue || !string.IsNullOrEmpty(config.BrowseCallback.ExternalId)))
{
callback = new BrowseCallback(destination, config.BrowseCallback, log);
}

if (fullConfig.Cognite?.Records != null)
{
Expand Down Expand Up @@ -266,10 +261,6 @@ public async Task<PushResult> PushNodes(IEnumerable<BaseUANode> objects,

if (!variables.Any() && !objects.Any() && !references.Any())
{
if (callback != null && !fullConfig.DryRun)
{
await callback.Call(report, token);
}
log.LogDebug("Testing 0 nodes against CDF");
return result;
}
Expand Down Expand Up @@ -321,20 +312,13 @@ await cdfWriter.PushNodesAndReferences(
log.LogInformation("Finish pushing nodes to CDF");

if (
result.Objects
&& result.References
&& result.Variables
&& result.RawObjects
&& result.RawVariables
&& result.RawReferences
!result.Objects
|| !result.References
|| !result.Variables
|| !result.RawObjects
|| !result.RawVariables
|| !result.RawReferences
)
{
if (callback != null)
{
await callback.Call(report, token);
}
}
else
{
nodeEnsuringFailures.Inc();
}
Expand Down
51 changes: 1 addition & 50 deletions Extractor/UAExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ private async Task EnsureSubscriptions()
}

/// <summary>
/// Build transformations from configured list and deprecated filter properties.
/// Build transformations from configured list.
/// </summary>
private void BuildTransformations()
{
Expand All @@ -772,55 +772,6 @@ private void BuildTransformations()
}
}

if (!string.IsNullOrEmpty(Config.Extraction.PropertyIdFilter))
{
log.LogWarning("Property Id filter is deprecated, use transformations instead");
transformations.Add(new NodeTransformation(new RawNodeTransformation
{
Filter = new NodeFilter
{
Id = new RegexFieldFilter(Config.Extraction.PropertyIdFilter)
},
Type = TransformationType.Property
}, idx++));
}
if (!string.IsNullOrEmpty(Config.Extraction.PropertyNameFilter))
{
log.LogWarning("Property Name filter is deprecated, use transformations instead");
transformations.Add(new NodeTransformation(new RawNodeTransformation
{
Filter = new NodeFilter
{
Name = new RegexFieldFilter(Config.Extraction.PropertyNameFilter)
},
Type = TransformationType.Property
}, idx++));
}
if (Config.Extraction.IgnoreName != null && Config.Extraction.IgnoreName.Any())
{
log.LogWarning("Ignore name is deprecated, use transformations instead");
transformations.Add(new NodeTransformation(new RawNodeTransformation
{
Filter = new NodeFilter
{
Name = new ListFieldFilter(Config.Extraction.IgnoreName, null)
},
Type = TransformationType.Ignore
}, idx++));
}
if (Config.Extraction.IgnoreNamePrefix != null && Config.Extraction.IgnoreNamePrefix.Any())
{
log.LogWarning("Ignore name prefix is deprecated, use transformations instead: {Prefix}", string.Join(',', Config.Extraction.IgnoreNamePrefix));
var filterStr = string.Join('|', Config.Extraction.IgnoreNamePrefix.Select(str => $"^{str}"));
transformations.Add(new NodeTransformation(new RawNodeTransformation
{
Filter = new NodeFilter
{
Name = new RegexFieldFilter(filterStr)
},
Type = TransformationType.Ignore
}, idx++));
}
foreach (var trans in transformations)
{
log.LogDebug("{Transformation}", trans.ToString());
Expand Down
79 changes: 3 additions & 76 deletions ExtractorLauncher/ExtractorStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,7 @@ public static class ExtractorStarter
if (string.IsNullOrEmpty(config.Extraction.IdPrefix)) log.LogWarning("No id-prefix specified in config file");
if (config.Cognite == null && config.Mqtt == null) log.LogWarning("No destination system specified");
if (config.Extraction.IdPrefix == "events.") return "Do not use events. as id-prefix, as it is used internally";
if (config.Source.SamplingInterval != null)
{
log.LogWarning("source.sampling-interval is deprecated. Use subscriptions.sampling-interval instead.");
config.Subscriptions.SamplingInterval = config.Source.SamplingInterval.Value;
}
if (config.Source.QueueLength != null)
{
log.LogWarning("source.queue-length is deprecated. Use subscriptions.queue-length instead.");
config.Subscriptions.QueueLength = config.Source.QueueLength.Value;
}
if (config.Cognite?.Debug ?? false)
{
log.LogWarning("cognite.debug is deprecated. Use dry-run instead.");
config.DryRun = true;
}
if (config.Mqtt?.Debug ?? false)
{
log.LogWarning("mqtt.debug is deprecated. Use dry-run instead.");
config.DryRun = true;
}
if (config.Cognite?.DataSetId != null)
{
log.LogWarning("cognite.data-set-id is deprecated. Use cognite.data-set.id instead");
if (config.Cognite.DataSet == null) config.Cognite.DataSet = new Extensions.DataSetConfig();
config.Cognite.DataSet.Id = config.Cognite.DataSetId.Value;
}
if (config.Cognite?.DataSetExternalId != null)
{
log.LogWarning("cognite.data-set-external-id is deprecated. Use cognite.data-set.external-id instead");
if (config.Cognite.DataSet == null) config.Cognite.DataSet = new Extensions.DataSetConfig();
config.Cognite.DataSet.ExternalId = config.Cognite.DataSetExternalId;
}

if (config.Subscriptions.LifetimeCount <= 0 || config.Subscriptions.LifetimeCount < 3 * config.Subscriptions.KeepAliveCount)
{
return "subscriptions.lifetime-count must be greater than 0 and at least 3 * subscriptions.keep-alive-count";
Expand All @@ -112,52 +81,10 @@ public static class ExtractorStarter
{
return "subscriptions.keep-alive-count must be greater than 0";
}
#pragma warning disable 0618
if (config.Cognite?.RawMetadata != null)
{
log.LogWarning("cognite.raw-metadata is deprecated. Use cognite.metadata-targets instead");
if (config.Cognite.MetadataTargets != null)
{
return "cognite.raw-metadata and cognite.metadata-targets cannot be set at the same time.";
}
config.Cognite ??= new CognitePusherConfig();
var rawMetadata = config.Cognite.RawMetadata;
var useCleanAssets = (rawMetadata?.Database == null || rawMetadata?.AssetsTable == null) || config.Cognite.SkipMetadata;
var useCleanTimeseries = rawMetadata?.Database == null || rawMetadata?.TimeseriesTable == null;
var useCleanRelationships = rawMetadata?.Database == null || rawMetadata?.RelationshipsTable == null;
config.Cognite.MetadataTargets = new MetadataTargetsConfig
{
Clean = new CleanMetadataTargetConfig
{
Assets = useCleanAssets,
Timeseries = useCleanTimeseries,
Relationships = useCleanRelationships
},
Raw = new RawMetadataTargetConfig
{
Database = rawMetadata?.Database,
AssetsTable = rawMetadata?.AssetsTable,
TimeseriesTable = rawMetadata?.TimeseriesTable,
RelationshipsTable = rawMetadata?.RelationshipsTable
}
};
}
else if (config.Cognite?.MetadataTargets == null)
if (config.Cognite?.MetadataTargets == null)
{
if (config.Cognite?.SkipMetadata ?? false)
{
log.LogWarning("Use of skip-metadata has been deprecated. use cognite.metadata-targets instead");
}
else
{
log.LogWarning("Default writing to clean is deprecated, in the future not setting a metadata target will not write metadata to CDF at all");
config.Cognite ??= new CognitePusherConfig();
if (config.Cognite.MetadataTargets == null) config.Cognite.MetadataTargets = new MetadataTargetsConfig();
if (config.Cognite.MetadataTargets.Clean == null) config.Cognite.MetadataTargets.Clean = new CleanMetadataTargetConfig();
config.Cognite.MetadataTargets.Clean.Timeseries = true;
}
log.LogWarning("The extractor has not been configured with any metadata target. No metadata will be written to CDF.");
}
#pragma warning restore 0618

if (config.Cognite?.MetadataTargets?.Raw != null)
{
Expand Down
Loading
Loading