Files
lmxopcua/src/Server/ZB.MOM.WW.OtOpcUa.Host/Configuration/OpcUaRedundancyStartupGuard.cs
T
Joseph Doherty 7829b937d1 feat(717): Warm non-transparent redundancy, default-off (T1-T10)
OpcUa:Redundancy:Mode (Unset default = today's server exactly; None; Warm; Hot and unknown values fail start).
- T1 options + validator + effective-URI check + boot banner; Warm needs the driver role.
- T2 metadata in OnNodeManagerStartedAsync: Warm -> NonTransparentRedundancyType, read-only
  ServerUriArray [self, peers], RedundancySupport=Warm, boot ServiceLevel 1; None -> RedundancySupport=None
  and the SDK's orphan i=11314 deleted; Unset untouched.
- T3 RedundancyStateChanged.Revision (up-number, incarnation tick, sequence); subscribers drop older
  revisions under Warm (OpcUaPublishActor, DriverHostActor); unrevisioned never makes a node Active.
- T4 WarmRoleAuthority + ComputeWarm bands (Standby 90/50, Active 250/200/100), PromoteWhilePrimaryUnreachable.
- T5 IStandbyProjection + DeferredStandbyProjection; OpcUaPublishActor runs promotion/demotion in the spec
  4.7 order (Active level last and retried; Standby level first, data degraded regardless).
- T6 EquipmentVariableState read projection (BadOutOfService/null); Warm Standby refuses writes BadInvalidState.
- T7 D4 mechanism adopted after T0: ordinary-tag marker on MonitoredItemNotification.Message validated by
  (ClientHandle, DataValue); first-delivery decision keyed by (SubscriptionId, SequenceNumber); the SDK's
  cached copy is never mutated.
- T8 queue current/BadOutOfService to live ordinary-tag items ignoring filters.
- T9 alarm stamp/deliver split (suppressed on Standby), Part 9 methods refused on Standby, promotion
  refresh via ISubscription.ConditionRefresh2Async on every live event item.
- T10 deploy-time RedundancyMode cross-check + six instruments.

Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
2026-11-13 03:39:50 -05:00

28 lines
1.4 KiB
C#

using ZB.MOM.WW.OtOpcUa.Commons.OpcUa;
using ZB.MOM.WW.OtOpcUa.OpcUaServer;
namespace ZB.MOM.WW.OtOpcUa.Host.Configuration;
/// <summary>
/// The one Gitea #717 startup rule the options validator cannot see: <c>OpcUa:Redundancy:Mode=Warm</c> needs the
/// <c>driver</c> role (the validator is registered only on driver nodes, so on any other node it would never run).
/// </summary>
public static class OpcUaRedundancyStartupGuard
{
/// <summary>Fails host start when a node without the driver role is configured Warm.</summary>
/// <param name="configuredMode">The raw <c>OpcUa:Redundancy:Mode</c> value.</param>
/// <param name="hasDriver">Whether this node carries the driver role.</param>
/// <exception cref="InvalidOperationException">Warm without the driver role.</exception>
public static void RequireDriverRoleForWarm(string? configuredMode, bool hasDriver)
{
if (hasDriver) return;
var options = new OpcUaRedundancyOptions { Mode = configuredMode ?? string.Empty };
if (options.TryParseMode(out var mode) && mode == OpcUaRedundancyMode.Warm)
{
throw new InvalidOperationException(
"OpcUa:Redundancy:Mode is Warm on a node without the driver role; Warm redundancy needs the driver role "
+ "(the OPC UA endpoint is served by driver nodes only). Remove the setting or add the driver role.");
}
}
}