Skip to content

Commit 0032cdd

Browse files
Update DDS-Pipe filters (#174)
* [#24061] Updated filters to update 'DDS' spy readers instead of reseting them Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Removed unused functions from the previous filter implementation + 'is_fastddsspy' bool Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Updated code for DDS-Record-Replay filter Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Changed 'enable()' callback after all filter updates Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Added RTPS filter partition + changed participant default to DDS Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Refactor of new filter functions in IParticipant Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Removed unused functions in IParticipant Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Cleaned code + added FastDD-Spy filter yaml configuration Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Added support partitions in replayer using DDS Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Uncrustify Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Removed unnecessary mutex in DdsPipe Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] First approach for 'update_topic_partition()' in writers Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Finished IWriter 'update_topic_partitions()' implementation Signed-off-by: danipiza <dpizarrogallego@gmail.com> * Pass by reference and const instead of value Signed-off-by: Raül <raulojeda@eprosima.com> * Uncrustify Signed-off-by: Raül <raulojeda@eprosima.com> * More uncrustify Signed-off-by: Raül <raulojeda@eprosima.com> * [#24061] Applied revision Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Added filter functions to 'writers' Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Removed lock in DdsPipe + separated 'update_filters()' Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Recovered lock in DdsPipe + solved error in Windows Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Solved TSAN race conditions + removed 'bridges_mutex_' Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Removed non-standard DDS writer content_filteredtopic functions Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24061] Applied revision Signed-off-by: danipiza <dpizarrogallego@gmail.com> --------- Signed-off-by: danipiza <dpizarrogallego@gmail.com> Signed-off-by: Raül <raulojeda@eprosima.com> Co-authored-by: Raül <raulojeda@eprosima.com>
1 parent 834719c commit 0032cdd

64 files changed

Lines changed: 1183 additions & 958 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ddspipe_core/include/ddspipe_core/communication/dds/DdsBridge.hpp

Lines changed: 22 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -65,34 +65,6 @@ class DdsBridge : public Bridge
6565
const bool remove_unused_entities,
6666
const std::vector<core::types::ManualTopic>& manual_topics);
6767

68-
/**
69-
* Bridge constructor with partition filter.
70-
*
71-
* In Bridge construction, the inside \c Tracks are created.
72-
* In Bridge construction, a Writer and a Reader are created for each Participant.
73-
*
74-
* @param topic: Topic of which this Bridge manages communication
75-
* @param participant_database: Collection of Participants to manage communication
76-
* @param payload_pool: Payload Pool that handles the reservation/release of payloads throughout the DDS Router
77-
* @param thread_pool: Shared pool of threads in charge of data transmission.
78-
* @param routes_config: Configuration encapsulating the routes of a DdsPipe instance.
79-
* @param remove_unused_entities: Flag for removing unused entitites in the Bridge.
80-
* @param manual_topics: List of topics of the Bridge.
81-
* @param filter_partition: Set of partitions used in the filter of the Bridge.
82-
*
83-
* @throw InitializationException in case \c IWriters or \c IReaders creation fails.
84-
*/
85-
DDSPIPE_CORE_DllAPI
86-
DdsBridge(
87-
const utils::Heritable<types::DistributedTopic>& topic,
88-
const std::shared_ptr<ParticipantsDatabase>& participants_database,
89-
const std::shared_ptr<PayloadPool>& payload_pool,
90-
const std::shared_ptr<utils::SlotThreadPool>& thread_pool,
91-
const RoutesConfiguration& routes_config,
92-
const bool remove_unused_entities,
93-
const std::vector<core::types::ManualTopic>& manual_topics,
94-
const std::set<std::string> filter_partition);
95-
9668

9769
DDSPIPE_CORE_DllAPI
9870
~DdsBridge();
@@ -141,42 +113,46 @@ class DdsBridge : public Bridge
141113
void remove_writer(
142114
const types::ParticipantId& participant_id) noexcept;
143115

144-
DDSPIPE_CORE_DllAPI
145-
void update_readers_track(
146-
const std::set<std::string> filter_partition_set);
147-
148-
DDSPIPE_CORE_DllAPI
149-
void add_filter_partition(
150-
const std::set<std::string> filter_partition_);
151-
116+
/**
117+
* Adds a partition with its respective guid.
118+
*
119+
* @param guid: Guid of the endpoint.
120+
* @param partition: Partition that is going to be added.
121+
*/
152122
DDSPIPE_CORE_DllAPI
153123
void add_partition_to_topic(
154124
std::string guid,
155125
std::string partition);
156126

157-
protected:
158-
159127
/**
160-
* Create the readers, writers, and tracks that are required by the routes.
128+
* Function that updates the partition set of all bridges.
161129
*
162-
* Thread safe
130+
* @param partitions_set: Set of partitions
131+
*/
132+
DDSPIPE_CORE_DllAPI
133+
void update_partitions(
134+
const std::set<std::string>& partitions_set);
135+
136+
/**
137+
* Function that updates the content filtered topic of all bridges
163138
*
164-
* @throw InitializationException in case \c IWriters or \c IReaders creation fails.
139+
* @param expression: The expression of the filter.
165140
*/
166141
DDSPIPE_CORE_DllAPI
167-
void create_all_tracks_();
142+
void update_topic_filter(
143+
const std::string& expression);
144+
145+
protected:
168146

169147
/**
170-
* Create the readers, writers, and tracks that are required by the routes and
171-
* satisfy the filter.
148+
* Create the readers, writers, and tracks that are required by the routes.
172149
*
173150
* Thread safe
174151
*
175152
* @throw InitializationException in case \c IWriters or \c IReaders creation fails.
176153
*/
177154
DDSPIPE_CORE_DllAPI
178-
void create_all_tracks_with_filter(
179-
const std::set<std::string> filter_partition_set);
155+
void create_all_tracks_();
180156

181157
/**
182158
* Add each Participant's IWriters to its Track.
@@ -205,20 +181,6 @@ class DdsBridge : public Bridge
205181
void add_writers_to_tracks_nts_(
206182
std::map<types::ParticipantId, std::shared_ptr<IWriter>>& writers);
207183

208-
/**
209-
* Add each Participant's IWriters to its Track with filter.
210-
* If the Participant's IReader doesn't exist, create it.
211-
* If the Participant's Track doesn't exist, create it.
212-
*
213-
* @param writers: The map of ids to writers that are required for the tracks.
214-
*
215-
* @throw InitializationException in case \c IReaders creation fails.
216-
*/
217-
DDSPIPE_CORE_DllAPI
218-
void add_writers_to_tracks_with_filter_nts_(
219-
std::map<types::ParticipantId, std::shared_ptr<IWriter>>& writers,
220-
const std::set<std::string> filter_partition_set);
221-
222184
/**
223185
* @brief Impose the Topic QoS that have been pre-configured for a participant.
224186
*

ddspipe_core/include/ddspipe_core/communication/dds/Track.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,43 @@ class Track
137137
DDSPIPE_CORE_DllAPI
138138
void update_reader();
139139

140+
/**
141+
* Update the writer's topic partitions
142+
*
143+
* @param partition_name Dictionary of <participant_id, partition name>.
144+
*
145+
* Tread safe
146+
*/
147+
DDSPIPE_CORE_DllAPI
148+
void update_writers_topic_partitions(
149+
const std::map<std::string, std::string>& partition_name);
150+
151+
/**
152+
* Update the partitions configured in the track reader.
153+
*
154+
* The reader is disabled before applying the new partitions
155+
* and enabled again afterwards to ensure the reader receive data
156+
* with the correct partitions.
157+
*
158+
* @param partitions_set Set of partitions to configure in the reader.
159+
*/
160+
DDSPIPE_CORE_DllAPI
161+
void update_reader_partitions(
162+
const std::set<std::string>& partitions_set);
163+
164+
/**
165+
* Update the content filter expression configured in the track reader.
166+
*
167+
* The reader is disabled before applying the new expression
168+
* and enabled again afterwards to ensure the reader receive data
169+
* with the correct topic filter.
170+
*
171+
* @param expression SQL-like content filter expression to apply.
172+
*/
173+
DDSPIPE_CORE_DllAPI
174+
void update_reader_content_filter(
175+
const std::string& expression);
176+
140177
protected:
141178

142179
/*

ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,6 @@ class DdsPipe
9898
utils::ReturnCode reload_configuration(
9999
const DdsPipeConfiguration& new_configuration);
100100

101-
/**
102-
* @brief Reload the filter partitions set.
103-
*
104-
* @param [in] new_filter_partition_set : new filter partition set.
105-
*
106-
* @return \c RETCODE_OK if the new std::set has been updated correctly.
107-
* @return \c RETCODE_ERROR if any other error has occurred.
108-
*
109-
* @note This method calls \c update_readers_track() of all Topic bridges, to update the DataReaders.
110-
*/
111-
DDSPIPE_CORE_DllAPI
112-
void reload_filter_partition(
113-
const std::set<std::string> new_filter_partition_set);
114-
115101
/////////////////////////
116102
// ENABLING METHODS
117103
/////////////////////////
@@ -140,14 +126,38 @@ class DdsPipe
140126
DDSPIPE_CORE_DllAPI
141127
utils::ReturnCode disable() noexcept;
142128

129+
/**
130+
* @brief Update the stored partitions filter.
131+
*
132+
* This method replaces the current partitions filter used by the pipe.
133+
*
134+
* @param [in] filter_partition_set : new partitions filter.
135+
*/
143136
DDSPIPE_CORE_DllAPI
144-
void update_readers_track(
145-
const std::string topic_name,
137+
void update_filter(
146138
const std::set<std::string> filter_partition_set);
147139

140+
/**
141+
* @brief Update the partitions in every DDS topic bridge.
142+
*
143+
* @param [in] partitions_set : set of partitions to apply.
144+
*/
145+
DDSPIPE_CORE_DllAPI
146+
void update_partitions(
147+
const std::set<std::string>& partitions_set);
148+
149+
/**
150+
* @brief Update the content filter expression for one topic.
151+
*
152+
* The expression is applied to bridges whose topic name matches \c topic_name.
153+
*
154+
* @param [in] topic_name : topic where the filter must be updated.
155+
* @param [in] expression : new content filter expression.
156+
*/
148157
DDSPIPE_CORE_DllAPI
149-
void update_filter(
150-
const std::set<std::string> filter_partition_set);
158+
void update_content_filter(
159+
const std::string& topic_name,
160+
const std::string& expression);
151161

152162
protected:
153163

@@ -369,6 +379,14 @@ class DdsPipe
369379
*/
370380
void deactivate_all_topics_nts_() noexcept;
371381

382+
/**
383+
* @brief Update partitions for all bridges.
384+
*
385+
* This method must be called with \c mutex_ locked.
386+
*/
387+
void update_partitions_nts_(
388+
const std::set<std::string>& partitions_set);
389+
372390
//////////////////////////
373391
// CONFIGURATION VARIABLES
374392
//////////////////////////
@@ -409,9 +427,6 @@ class DdsPipe
409427
//! Thread Pool for tracks
410428
std::shared_ptr<utils::SlotThreadPool> thread_pool_;
411429

412-
//! Allowed partitions added in the filter
413-
std::set<std::string> allowed_partition_list_;
414-
415430
/////////////////////////
416431
// INTERNAL DATA STORAGE
417432
/////////////////////////
@@ -452,11 +467,6 @@ class DdsPipe
452467
* @brief Internal mutex for concurrent calls
453468
*/
454469
mutable std::mutex mutex_;
455-
456-
/**
457-
* @brief Internal mutex for bridges
458-
*/
459-
mutable std::mutex bridges_mutex_;
460470
};
461471

462472
} /* namespace core */

ddspipe_core/include/ddspipe_core/interface/IParticipant.hpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,6 @@ class IParticipant
9696
virtual std::shared_ptr<IReader> create_reader(
9797
const ITopic& topic) = 0;
9898

99-
/**
100-
* @brief Return a new Reader
101-
*
102-
* Each reader is associated with a \c Bridge with the topic \c topic .
103-
* This reader will receive messages in this topic.
104-
*
105-
* @param [in] topic : Topic that this Reader will work with.
106-
* @param [in] partitions: List of allowed partitions
107-
*
108-
* @return Reader in this Participant referring this topic
109-
*
110-
* @throw \c InitializationException in case the reader creation fails.
111-
*/
112-
DDSPIPE_CORE_DllAPI
113-
virtual std::shared_ptr<IReader> create_reader_with_filter(
114-
const ITopic& topic,
115-
const std::set<std::string> partitions) = 0;
116-
11799
/**
118100
* Add a Partition in the Participant.
119101
*
@@ -164,6 +146,27 @@ class IParticipant
164146
*/
165147
DDSPIPE_CORE_DllAPI
166148
virtual void clear_topic_partitions() = 0;
149+
150+
/**
151+
* Update the partition filter data structure of the participant
152+
*
153+
* @param [in] partitions : Set of partitions for the new filter of partitions.
154+
*/
155+
DDSPIPE_CORE_DllAPI
156+
virtual void update_partitions(
157+
std::set<std::string> partitions) = 0;
158+
159+
/**
160+
* Update the content_topicfilter data structure of the participant
161+
*
162+
* @param [in] topic_name : Name of the topic.
163+
* @param [in] expression : Expression for the Content Filtered Topic
164+
*/
165+
DDSPIPE_CORE_DllAPI
166+
virtual void update_content_topicfilter(
167+
const std::string& topic_name,
168+
const std::string& expression) = 0;
169+
167170
};
168171

169172
} /* namespace core */

ddspipe_core/include/ddspipe_core/interface/IReader.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ class IReader
130130
DDSPIPE_CORE_DllAPI
131131
virtual types::DdsTopic topic() const = 0;
132132

133+
//! Update method to change the partitions in the content_topicfilter
134+
DDSPIPE_CORE_DllAPI
135+
virtual void update_partitions(
136+
const std::set<std::string>& partitions_set) = 0;
137+
138+
//! Update method to change the expression in the content_topicfilter
139+
DDSPIPE_CORE_DllAPI
140+
virtual void update_content_topic_filter(
141+
const std::string& expression) = 0;
142+
133143
DDSPIPE_CORE_DllAPI
134144
virtual types::ParticipantId participant_id() const = 0;
135145
/////////////////////////

ddspipe_core/include/ddspipe_core/interface/IWriter.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#pragma once
1616

17+
#include <set>
18+
1719
#include <cpp_utils/ReturnCode.hpp>
1820

1921
#include <ddspipe_core/interface/IRoutingData.hpp>
@@ -82,6 +84,16 @@ class IWriter
8284
DDSPIPE_CORE_DllAPI
8385
virtual utils::ReturnCode write(
8486
IRoutingData& data) noexcept = 0;
87+
88+
//! Update method to change the partitions in the content_topicfilter
89+
DDSPIPE_CORE_DllAPI
90+
virtual void update_partitions(
91+
const std::set<std::string>& partitions_set) = 0;
92+
93+
//! Update method to change the topic_partitions
94+
DDSPIPE_CORE_DllAPI
95+
virtual void update_topic_partitions(
96+
const std::map<std::string, std::string>& partition_name) = 0;
8597
};
8698

8799
} /* namespace core */

ddspipe_core/include/ddspipe_core/types/topic/filter/WildcardDdsFilterTopic.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ struct WildcardDdsFilterTopic : public IFilterTopic
8080
//! The subset of manually configured Topic QoS.
8181
utils::Fuzzy<types::TopicQoS> topic_qos;
8282

83+
//! Topic filter. If not set all messages are sent/received.
84+
utils::Fuzzy<std::string> content_topic_filter;
85+
8386
protected:
8487

8588
/////////////////////////

0 commit comments

Comments
 (0)