Skip to content

Conversation

@romanett
Copy link
Contributor

@romanett romanett commented Mar 4, 2025

Proposed changes

This PR Enables the Server to persist existing durable subscriptions (incl message queue) on a server shutdown (incl. MonitoredItems & event / datatchange queues). And restore them after a server restart.

The persisting is done by extending Subscription & MonitoredItem with a method that converts the internal state of the object into a format that can be json serialized.

For this Subscription has a new Method public IStoredSubscription ToStorableSubscription().
The IMonitoredItem interface is extended with a new Method IStoredMonitoredItem ToStorableMonitoredItem().
Both Subscription & Monitoreditem have a new constructor accepting an IStoredSubscription/IStoredMonitoredItem.

The MasterNodeManager has a new Method

public virtual void RestoreMonitoredItems(
     IList<IStoredMonitoredItem> itemsToRestore,
     IList<IMonitoredItem> monitoredItems,
     IUserIdentity savedOwnerIdentity)

Also INodeManager is extended with a new Method

 void RestoreMonitoredItems(
     IList<IStoredMonitoredItem> itemsToRestore,
     IList<IMonitoredItem> monitoredItems,
     IUserIdentity savedOwnerIdentity)

Those methods are only called (& need to be implemented) if durable subscriptions will be supported by the server.

They will be called by the SubscriptionManager on Startup if subscriptions to restore a found.

The SubscriptionManager has access to an Interface ISubscriptionStore that is registered globally in the server.

The Interface has methods for Storing & Restoring Subscriptions & providing access to durable queues after a restart.
In the reference server the SubscriptionStore impementation communicates with the IMonitoredItemQueueManager to store & restore durable queues.

On Shutdown the SubscriptionManager will initate the storing process if an ISubscriptionStore is registered & durable subscriptions are enabled & present on the server.

In the reference server the serializable objects are written into a file in the current exectuting directory.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

Open Issues:

  • Restore of Event Filter fails with Opc.Ua.ServiceResultException: FilterOperand is not supported.

@codecov
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 79.62185% with 97 lines in your changes missing coverage. Please review.

Project coverage is 56.83%. Comparing base (ef9387b) to head (e764d0e).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...Server/Subscription/MonitoredItem/MonitoredItem.cs 73.63% 20 Missing and 9 partials ⚠️
...braries/Opc.Ua.Server/NodeManager/SamplingGroup.cs 0.00% 15 Missing ⚠️
...aries/Opc.Ua.Server/NodeManager/CoreNodeManager.cs 38.09% 9 Missing and 4 partials ⚠️
...ies/Opc.Ua.Server/NodeManager/MasterNodeManager.cs 71.79% 6 Missing and 5 partials ⚠️
.../Opc.Ua.Server/Subscription/SubscriptionManager.cs 81.03% 8 Missing and 3 partials ⚠️
...ies/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs 85.45% 3 Missing and 5 partials ⚠️
.../Opc.Ua.Server/NodeManager/SamplingGroupManager.cs 0.00% 7 Missing ⚠️
...braries/Opc.Ua.Server/Subscription/Subscription.cs 97.74% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3025      +/-   ##
==========================================
+ Coverage   56.70%   56.83%   +0.13%     
==========================================
  Files         356      357       +1     
  Lines       68110    68862     +752     
  Branches    13950    14133     +183     
==========================================
+ Hits        38619    39138     +519     
- Misses      25339    25528     +189     
- Partials     4152     4196      +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@romanett romanett self-assigned this Mar 11, 2025
Copy link
Contributor

@mrsuciu mrsuciu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. See the comments.

@mrsuciu mrsuciu self-requested a review March 18, 2025 18:15
@romanett romanett removed the request for review from Archie-Miller March 20, 2025 16:24
@mrsuciu mrsuciu merged commit 2f0770c into OPCFoundation:master Mar 24, 2025
77 checks passed
@romanett romanett deleted the restoreSubscriptions branch March 24, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants