Add configurable non-transparent OPC UA server redundancy
Separates ApplicationUri from namespace identity so each instance in a redundant pair has a unique server URI while sharing the same Galaxy namespace. Exposes RedundancySupport, ServerUriArray, and dynamic ServiceLevel through the standard OPC UA server object. ServiceLevel is computed from role (Primary/Secondary) and runtime health (MXAccess and DB connectivity). Adds CLI redundancy command, second deployed service instance, and 31 new tests including paired-server integration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
41
src/ZB.MOM.WW.LmxOpcUa.Host/OpcUa/RedundancyModeResolver.cs
Normal file
41
src/ZB.MOM.WW.LmxOpcUa.Host/OpcUa/RedundancyModeResolver.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using Opc.Ua;
|
||||
using Serilog;
|
||||
|
||||
namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps a configured redundancy mode string to the OPC UA <see cref="RedundancySupport"/> enum.
|
||||
/// </summary>
|
||||
public static class RedundancyModeResolver
|
||||
{
|
||||
private static readonly ILogger Log = Serilog.Log.ForContext(typeof(RedundancyModeResolver));
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the configured mode string to a <see cref="RedundancySupport"/> value.
|
||||
/// Returns <see cref="RedundancySupport.None"/> when redundancy is disabled or the mode is unrecognized.
|
||||
/// </summary>
|
||||
/// <param name="mode">The mode string from configuration (e.g., "Warm", "Hot").</param>
|
||||
/// <param name="enabled">Whether redundancy is enabled.</param>
|
||||
/// <returns>The resolved redundancy support mode.</returns>
|
||||
public static RedundancySupport Resolve(string mode, bool enabled)
|
||||
{
|
||||
if (!enabled)
|
||||
return RedundancySupport.None;
|
||||
|
||||
var resolved = (mode ?? "").Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"warm" => RedundancySupport.Warm,
|
||||
"hot" => RedundancySupport.Hot,
|
||||
_ => RedundancySupport.None
|
||||
};
|
||||
|
||||
if (resolved == RedundancySupport.None)
|
||||
{
|
||||
Log.Warning("Unknown redundancy mode '{Mode}' — falling back to None. Supported modes: Warm, Hot", mode);
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user