perf(worker): alarm watch-list update diffs the subtag standby instead of rebuilding it (MXA-010, #258)
UpdateAlarmWatchList rebuilt the standby: a second MXAccess registration, an AddItem/Advise for every watched subtag, then an Unregister of the old source — work proportional to the whole list for a one-alarm change (reproduced by the previous commit's test). The subtag standby now takes the list as a diff: added alarms' subtags are advised on the existing source, removed alarms' subtags are unadvised, and unchanged alarms keep their advice and state. The update stays all-or-nothing: the list is validated and the additions advised before the swap, and an advise failure unadvises what it added and keeps the previous list. A changed target starts fresh and is initialised from the last delivered subtag values (acked/priority before active, MXA-007; bad quality still ignored, MXA-005). LmxSubtagAlarmSource tracks an item from AddItem so an Advise failure is retryable and removable.
This commit is contained in:
@@ -909,10 +909,11 @@ Galaxy's last deploy time (`GetLastDeployTimeAsync`), so an undeployed galaxy
|
||||
costs one deploy-time query per refresh rather than the alarm-attribute query
|
||||
and a rebuilt list; a failed discovery or an unknown deploy time is not cached.
|
||||
The gateway compares a SHA-256 of a canonical fingerprint of all six target
|
||||
fields and sends `UpdateAlarmWatchListCommand` only for a material change. The worker constructs,
|
||||
subscribes, and attaches the replacement standby on its STA before swapping it
|
||||
in; a setup failure leaves the previous standby and the current primary/subtag
|
||||
mode unchanged. The gateway advances its acknowledged fingerprint only after an
|
||||
fields and sends `UpdateAlarmWatchListCommand` only for a material change. The worker applies
|
||||
the new list to its existing subtag standby as a diff on its STA — advising only
|
||||
added alarms' subtags, unadvising only removed ones, and keeping the state of
|
||||
unchanged alarms; a failure leaves the previous list in force and the current
|
||||
primary/subtag mode unchanged. The gateway advances its acknowledged fingerprint only after an
|
||||
OK reply, so a rejected update remains degraded and is retried.
|
||||
|
||||
`SubscribeAlarmsCommand.fallback_enabled` distinguishes an initially empty but
|
||||
|
||||
+5
-3
@@ -45,9 +45,11 @@ The shared alarm command model includes `SubscribeAlarms` and
|
||||
initial watch list explicitly fallback-capable, allowing discovery recovery to
|
||||
populate a standby without restarting the primary alarm-manager subscription.
|
||||
`UpdateAlarmWatchListCommand.watch_list` is the complete replacement list. The
|
||||
worker prepares the replacement on its STA before swapping it into the existing
|
||||
failover consumer and returns a normal `MxCommandReply`; callers must treat only
|
||||
`protocol_status = OK` as acknowledgement of the new list.
|
||||
worker applies it to the existing failover consumer's standby as a diff on its
|
||||
STA (advising added alarms, unadvising removed ones, keeping unchanged alarms'
|
||||
state) and returns a normal `MxCommandReply`; a failed update leaves the previous
|
||||
list in force. Callers must treat only `protocol_status = OK` as acknowledgement
|
||||
of the new list.
|
||||
|
||||
`AcknowledgeAlarmRequest` carries the operator's identity: `operator_user`
|
||||
(required), `operator_password` (field 6) and `operator_domain` (field 7). The
|
||||
|
||||
@@ -459,14 +459,30 @@ its entry.
|
||||
## Live alarm watch-list replacement
|
||||
|
||||
An auto-mode `SubscribeAlarms` with `fallback_enabled = true` always builds a
|
||||
`FailoverAlarmConsumer`, even when initial discovery supplied no targets. The
|
||||
handler retains the subscription expression so `UpdateAlarmWatchList` can build
|
||||
and subscribe a new subtag consumer entirely on the session STA. The failover
|
||||
consumer attaches the replacement's transition callback before swapping the
|
||||
standby reference, then detaches and disposes the old standby. If construction,
|
||||
subscription, or attachment fails, it disposes the replacement and preserves
|
||||
the old standby. The active-provider selector is never reset, so primary mode
|
||||
stays primary and subtag mode immediately delegates to the new standby.
|
||||
`FailoverAlarmConsumer`, even when initial discovery supplied no targets.
|
||||
`UpdateAlarmWatchList` runs entirely on the session STA and applies the new list
|
||||
to the existing `SubtagAlarmConsumer` as a diff (MXA-010): the subtags of added
|
||||
alarms are advised on the standby's existing `LmxSubtagAlarmSource`, the subtags
|
||||
of removed alarms are unadvised (`UnAdvise` + `RemoveItem`), and an alarm whose
|
||||
target is unchanged in every field keeps its advice and its tracked state, so no
|
||||
transition is re-emitted for it. Rebuilding the standby instead cost a second
|
||||
MXAccess registration and an `AddItem`/`Advise` for every watched subtag on each
|
||||
change, however small. An alarm whose target changed is treated as removed and
|
||||
re-added and starts from fresh state; when its subtags are already advised, the
|
||||
consumer initialises it from the last value delivered for each subtag (acked and
|
||||
priority before active, so an already-acknowledged alarm syncs as `ACK_ALM`)
|
||||
rather than re-advising.
|
||||
|
||||
The update is all-or-nothing. The new list is validated and the added subtags
|
||||
are advised before anything is swapped; if advising fails, the subtags the call
|
||||
added are unadvised again, the standby keeps serving the previous list, and the
|
||||
command fails. Unadvising removed subtags happens after the swap and is best
|
||||
effort, because an unbound subtag's callbacks are already ignored. A standby that
|
||||
is not a `SubtagAlarmConsumer` (a test seam) is still rebuilt: the handler
|
||||
retains the subscription expression, builds and subscribes a replacement, and the
|
||||
failover consumer attaches its transition callback before swapping it in and
|
||||
disposing the old one. Either way the active-provider selector is never reset, so
|
||||
primary mode stays primary and subtag mode keeps delegating to the standby.
|
||||
|
||||
## COM Creation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user