Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/NodeManagers.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ same `ConfigurationNodeManager` through different interfaces.

As a diagnostics manager, it loads the standard diagnostics and server-support nodes generated for the stack, manages session and subscription diagnostics, diagnostics enable/disable state, aggregate functions, event notifier updates, and the well-known OPC UA Part 17 alias-name methods that dispatch through the server-wide alias-name registry. It registers namespace URIs for the OPC UA namespace and the diagnostics namespace.

As a configuration manager, the same instance exposes push certificate-management and server-configuration functionality from OPC UA Part 12. It owns the server-configuration methods and state that interact with trust lists, certificate groups, transaction coordination, pending regenerated keys, endpoint and listener registries, and post-`ApplyChanges` effects. The class is a partial split by concern (`ConfigurationNodeManager.PushMethods.cs`, `.PushValidation.cs`, `.CertificateSlots.cs`, `.ApplyChanges.cs`, `.TrustMaterial.cs`, `.CertificateAlarms.cs`, `.NamespaceMetadata.cs`) over one core file, and delegates namespace-metadata tracking and alarm scheduling to the internal `NamespaceMetadataRegistry` and `CertificateAlarmScheduler` collaborators.
As a configuration manager, the same instance hosts the OPC UA Part 12 ServerConfiguration nodes, but it does not implement push configuration itself. It composes one internal `ServerPushConfiguration` engine, which owns the push state (certificate groups and stores, transaction coordination, pending regenerated keys, the key generator) and binds the ServerConfiguration methods to its components: `ServerCertificatePush` (the certificate methods and slot bookkeeping), `PushConfigurationApplyChanges` (`ApplyChanges`, `CancelChanges`, `ResetToServerDefaults` and the deferred post-`ApplyChanges` effects), `PushConfigurationTrustMaterial` (the §7.10.9 TrustList effects and the trust-material enforcement pump) and `KeyCredentialPushBinder`. The components reach the shared state through the internal `IServerPushContext`. `ApplicationConfigurationPushBinding` composes its own engine, with `ManagedApplicationPush` for the managed application's effects, instead of a whole configuration node manager. The node manager keeps the certificate alarms (`ConfigurationNodeManager.CertificateAlarms.cs`) and namespace metadata (`.NamespaceMetadata.cs`), and delegates them to the internal `CertificateAlarmScheduler` and `NamespaceMetadataRegistry` collaborators.

### Managers supplied by server features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public bool MatchesRuntime(
/// </summary>
public INodeManagerHandoffPause PauseCalls(ProvisionableDeviceNodeManager successor)
{
var trust = new List<ConfigurationNodeManager.TrustHandoff>(m_pushBindings.Count);
var trust = new List<PushConfigurationTrustHandoff>(m_pushBindings.Count);
INodeManagerHandoffPause calls = m_calls.Pause();
try
{
Expand All @@ -96,7 +96,7 @@ public INodeManagerHandoffPause PauseCalls(ProvisionableDeviceNodeManager succes
}
catch
{
foreach (ConfigurationNodeManager.TrustHandoff pause in trust)
foreach (PushConfigurationTrustHandoff pause in trust)
{
pause.Finish(m_calls.IsServing());
}
Expand All @@ -111,7 +111,7 @@ private sealed class DeviceHandoffPause(
ProvisionableDeviceNodeManager previous,
ProvisionableDeviceNodeManager successor,
INodeManagerHandoffPause calls,
List<ConfigurationNodeManager.TrustHandoff> trust) : INodeManagerHandoffPause
List<PushConfigurationTrustHandoff> trust) : INodeManagerHandoffPause
{
public async ValueTask DrainAsync(CancellationToken cancellationToken)
{
Expand All @@ -136,7 +136,7 @@ public void Finish(bool reopen)
}
calls.Finish(reopen);
bool serving = reopen || successor.m_calls.IsServing();
foreach (ConfigurationNodeManager.TrustHandoff pause in trust)
foreach (PushConfigurationTrustHandoff pause in trust)
{
pause.Finish(serving);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,45 @@ internal ApplicationConfigurationPushBinding(
TargetReservation reservation = registry.Reserve(
configuration, managementConfiguration, pendingKeys, configurationFileProvider,
servingServer.ConfigurationNodeManager as ConfigurationNodeManager);
PushPermissionOwner? grantOwner = null;
try
{
m_manager = new ConfigurationNodeManager(
// Only the push engine is composed: the managed application needs no
// diagnostics or configuration node manager of its own. Without a hosting
// node manager, a private owner scopes the SecurityAdmin call grants to
// this engine's lifetime.
m_engine = new ServerPushConfiguration(
server,
configuration,
server.Telemetry.CreateLogger<ConfigurationNodeManager>(),
context,
timeProvider: null,
coordinator: null,
pendingKeyStore: pendingKeys,
keyGenerator: keyGenerator,
serverConfigurationOptions: new ServerConfigurationOptions
trustListEffectHandler: null,
options: new ServerConfigurationOptions
{
PushAuthorization = authorization,
ConfigurationFileProvider = configurationFileProvider
});
m_shared = new SharedReservation(reservation);
m_attachment = m_manager.BindApplicationConfiguration(context, node, target, this);
},
applicationTarget: target);
if (permissionOwner == null)
{
#pragma warning disable CA2000 // Owned by the shared reservation and disposed with the engine.
grantOwner = new PushPermissionOwner(server, configuration);
#pragma warning restore CA2000
}
m_shared = new SharedReservation(reservation, grantOwner);
m_attachment = m_engine.BindApplicationConfiguration(
context, node, this, permissionOwner ?? grantOwner!);
}
catch (Exception error)
{
try
{
m_manager?.Dispose();
m_engine?.Dispose();
grantOwner?.Dispose();
}
catch (Exception cleanupError)
{
Expand Down Expand Up @@ -159,7 +175,7 @@ internal ApplicationConfigurationPushBinding(
m_isServing = isServing;
m_enter = enter;
m_exit = exit;
m_manager = previous.m_manager;
m_engine = previous.m_engine;
m_shared = previous.m_shared;
lock (previous.m_lifetime)
{
Expand All @@ -171,7 +187,8 @@ internal ApplicationConfigurationPushBinding(
}
try
{
m_attachment = m_manager.AttachApplicationPushNodes(context, node, this, previous.m_attachment);
m_attachment = m_engine.Applications!.Attach(
context, node, this, permissionOwner, previous.m_attachment);
}
catch
{
Expand All @@ -184,9 +201,9 @@ internal ApplicationConfigurationPushBinding(

internal bool IsServing => m_isServing?.Invoke() != false;

internal ConfigurationNodeManager.TrustHandoff PauseTrustEffects()
internal PushConfigurationTrustHandoff PauseTrustEffects()
{
return m_manager.PauseTrustEffects();
return m_engine.TrustMaterial.PauseTrustEffects();
}

internal void PrepareIdleSuccessor(ApplicationConfigurationPushBinding successor)
Expand Down Expand Up @@ -215,7 +232,7 @@ internal void ReopenAfterAbortedHandoff()
/// </summary>
public Task DrainPendingApplyChangesAsync(CancellationToken cancellationToken = default)
{
return m_manager.DrainPendingApplyChangesAsync(cancellationToken);
return m_engine.ApplyChanges.DrainPendingApplyChangesAsync(cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -391,7 +408,7 @@ private async Task DisposeCoreAsync()
{
if (IsServing || m_shared.IsLast)
{
await CompleteAsync(() => new ValueTask(m_manager.DrainPendingApplyChangesAsync()))
await CompleteAsync(() => new ValueTask(m_engine.ApplyChanges.DrainPendingApplyChangesAsync()))
.ConfigureAwait(false);
}
if (m_attachment.File is { } file)
Expand All @@ -409,18 +426,30 @@ private async Task DisposeCoreAsync()
last = m_shared.Release();
if (last)
{
await CompleteAsync(((INodeManagerShutdown)m_manager).PrepareForShutdownAsync)
await CompleteAsync(m_engine.PrepareForShutdownAsync)
.ConfigureAwait(false);
await CompleteAsync(() => new ValueTask(m_manager.StopAndDrainTrustMaterialChangesAsync()))
await CompleteAsync(() => new ValueTask(m_engine.TrustMaterial.StopAndDrainAsync()))
.ConfigureAwait(false);
try
{
await m_manager.DisposeAsync().ConfigureAwait(false);
m_engine.Dispose();
}
catch (Exception error)
{
errors.Add(error);
}
if (m_shared.GrantOwner is { } grantOwner)
{
// Retires the SecurityAdmin call grants registered for this engine.
try
{
await grantOwner.DisposeAsync().ConfigureAwait(false);
}
catch (Exception error)
{
errors.Add(error);
}
}
}
}
finally
Expand Down Expand Up @@ -608,19 +637,25 @@ public void Dispose()
/// <summary>The deployment admission shared by calls and deferred effects.</summary>
private readonly IApplicationConfigurationPushOperations? m_operations;

/// <summary>The engine retained by all attachments to this target.</summary>
private readonly ConfigurationNodeManager m_manager;
/// <summary>The push engine retained by all attachments to this target.</summary>
private readonly ServerPushConfiguration m_engine;

private readonly SharedReservation m_shared;
private readonly ConfigurationNodeManager.ApplicationPushAttachment m_attachment;
private readonly ApplicationPushAttachment m_attachment;
private readonly Func<bool>? m_isServing;
private readonly Action? m_enter;
private readonly Action? m_exit;

private sealed class SharedReservation(TargetReservation reservation)
private sealed class SharedReservation(TargetReservation reservation, PushPermissionOwner? grantOwner)
{
public TargetReservation Reservation { get; } = reservation;

/// <summary>
/// The private owner of the SecurityAdmin call grants when no hosting node manager
/// was supplied, released with the engine.
/// </summary>
public PushPermissionOwner? GrantOwner { get; } = grantOwner;

public bool IsLast => Volatile.Read(ref m_count) == 1;

public void Retain()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ namespace Opc.Ua.Server
/// and <c>TrustListOutOfDate</c> alarm subtrees in this manager's address space. Once an
/// alarm pair is registered its monitor is handed to <see cref="CertificateAlarmScheduler"/>,
/// which owns refresh and evaluation. Code in this file adds alarm instances to the group
/// nodes in <c>m_certificateGroups</c> but never changes the group list itself.
/// nodes in the push engine's certificate groups but never changes the group list itself.
/// </summary>
public partial class ConfigurationNodeManager
{
/// <summary>
/// Gets the scheduler that refreshes and evaluates the certificate-group
/// alarms. Exposed for testing.
/// </summary>
internal CertificateAlarmScheduler AlarmScheduler => m_alarmScheduler;
internal CertificateAlarmScheduler AlarmScheduler => m_push.AlarmScheduler;

/// <inheritdoc/>
public void StartAlarmMonitoring(TimeSpan interval)
{
m_alarmScheduler.Start(SystemContext, interval);
m_push.AlarmScheduler.Start(SystemContext, interval);
}

/// <inheritdoc/>
public void StopAlarmMonitoring()
{
m_alarmScheduler.Stop();
m_push.AlarmScheduler.Stop();
}

/// <summary>
Expand All @@ -55,7 +55,7 @@ private async ValueTask CreateCertificateAlarmsAsync(
IDictionary<NodeId, IList<IReference>> externalReferences,
CancellationToken cancellationToken)
{
foreach (ServerCertificateGroup certGroup in m_certificateGroups)
foreach (ServerCertificateGroup certGroup in m_push.CertificateGroups)
{
CertificateGroupState? node = certGroup.Node;
if (node == null)
Expand Down Expand Up @@ -83,7 +83,7 @@ private async ValueTask CreateCertificateAlarmsAsync(
var monitor = new CertificateGroupAlarmMonitor(
node,
certGroup.BrowseName,
m_timeProvider,
m_push.TimeProvider,
m_logger);
monitor.InitializeQuiet(context);

Expand Down Expand Up @@ -116,7 +116,7 @@ await AddRootNotifierAsync(node.TrustListOutOfDate, cancellationToken)
.ConfigureAwait(false);
}

m_alarmScheduler.Add(monitor, certGroup);
m_push.AlarmScheduler.Add(monitor, certGroup);
}
catch (Exception ex)
{
Expand Down

This file was deleted.

Loading
Loading