Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage-manager): Replication supports Wildcard Updates
This commit adds support for Wildcard Updates (be it Delete or Put) when aligning replicated Storage. To make this feature possible the following structures and methods were added / changed: - A new enumeration `Action` was introduced. This enumeration builds on top of `SampleKind` and adds two variants: `WildcardPut` and `WildcardDelete`, each of these variants contains their full key expression. We track the full key expression to not have to deal with `Option` and the `strip_prefix`: there are cases where the `strip_prefix` cannot be removed from a Wildcard Update — yet the Wildcard Update should be recorded. For instance, if a storage subscribes to "test/replication/**" and has its strip prefix set to "test/replication", a delete on "test/**" should be recorded while the `strip_prefix` cannot be removed. - The `LogLatest`, `Interval` and `SubInterval` structures now have the the method `remove_events_overridden_by_wildcard_update`: this method removes all the Events that are impacted by a Wildcard Update and updates the Fingerprint of the impacted Interval / SubInterval. - The visibility of the fields of `Event` structure were set to `pub(crate)` to prevent modifying them without updating the Fingerprint. Setters and accessors were thus added. - The core `Replication` structure now keeps an `Arc` over the `StorageService` such that it can add Wildcard Updates to it when it receives some. - The visibility of the following field / structures were changed to `pub(crate)` such that the Replication can access them: - The `Update` structure that contains the payload and timestamp associated with a Wildcard Update. - The `configuration`, `wildcard_updates` fields of the `StorageService` structure. - The signature of the method `register_wildcard_update` was changed: it no longer extracts all the metadata from the `sample` argument as, when called from the Replication Aligner, these values are not "correct" (they are linked to a reply and not to the contained payload). * plugins/zenoh-plugin-storage-manager/src/replication/classification.rs: added the method `remove_events_overridden_by_wildcard_update` to the `Interval` and `SubInterval` structures. * plugins/zenoh-plugin-storage-manager/src/replication/configuration.rs: added the `prefix` accessor. * plugins/zenoh-plugin-storage-manager/src/replication/core.rs: - Changed the `Replication` structure to keep track of the `StorageService`. The latter is used to access and add/remove Wildcard Updates. - Added the method `remove_events_overridden_by_wildcard_updates` that takes a `HashMap` as this logic is shared for the latest cache and the Replication Log. * plugins/zenoh-plugin-storage-manager/src/replication/core/aligner_query.rs: updated the `reply_event_retrieval` method to handle Wildcard Updates. * plugins/zenoh-plugin-storage-manager/src/replication/core/aligner_reply.rs: - Added some traces to ease debugging. - Added the method `needs_further_processing` that, given an EventMetadata, checks if it needs to be processed, processes it if it can and otherwise returns true -- indicating that further processing is needed. - Added the method `apply_wildcard_update` that applies a Wildcard Update. - Added the method `is_overridden_by_wildcard_update` that checks if there is a Wildcard Update that overrides the provided key expression for the provided timestamp. - Added the method `store_event_overridden_by_wildcard_update` that overrides the provided EventMetadata with the Wildcard Update and stores the result. * plugins/zenoh-plugin-storage-manager/src/replication/log.rs: - Added the `Action` enumeration. - Changed the visibility of the fields of the `Event` structure to `pub(crate)` and added accessors / setters that properly update the Fingerprint. - Added the method `remove_events_overridden_by_wildcard_update` to the `LogLatest` structure. * plugins/zenoh-plugin-storage-manager/src/replication/mod.rs: make the `Action` visible from the `replication` module. * plugins/zenoh-plugin-storage-manager/src/replication/service.rs: changed the `spawn_start` function to take an `Arc<StorageService>` instead of a reference. * plugins/zenoh-plugin-storage-manager/src/storages_mgt/mod.rs: wrap the `StorageService` inside of an `Arc` such that the `Replication` can use it in its tasks. * plugins/zenoh-plugin-storage-manager/src/storages_mgt/service.rs: - Changed the visibility of the `Update` structure to `pub(crate)` and added accessors. - Changed the visibility of the `configuration` and `wildcard_updates` fields of the `StorageService` structure to `pub(crate)` as the `Replication` uses them when dealing with Wildcard Updates. - Changed the signature of the method `register_wildcard_update` to not extract the metadata from the `Sample` -- as the values are not correct when processing an Alignment reply. - Changed the visibility of the methods `register_wildcard_update` and `overriding_wild_update` to `pub(crate)` as they are used by the Replication to deal with Wildcard Updates. Signed-off-by: Julien Loudet <[email protected]>
- Loading branch information