Skip to content

Commit b7185d2

Browse files
authored
Add Topic-Name Profile Lookup for Endpoint Creation (#184)
* Tests for Topic-Name Profile Lookup Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Corrected tests for Profile Lookup Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Features for Topic-Name Profile Lookup Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Corrected Reader/Writer features for Topic Profile Lookup Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * XML override test Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * XML override feature Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Applied Suggestions for Topic Profile lookup on tests Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Applied Suggestions for Topic Profile lookup for feature Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Applied suggestions and refactored to avoid same topic name blocking Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Applied latest suggestions to test negative cases Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Tests to check that a endpoint profile is being overridden by discovered topic Qos Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Fix XML endpoint profile QoS being overridden by discovered topic QoS Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> * Applied suggestions for discovery vs user configured Qos separation Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com> --------- Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
1 parent 10553bb commit b7185d2

29 files changed

Lines changed: 1114 additions & 72 deletions

File tree

ddspipe_core/include/ddspipe_core/types/dds/TopicQoS.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ TopicQoS
144144
//! Downsampling factor: keep 1 out of every *downsampling* samples received (downsampling=1 <=> no downsampling)
145145
utils::Fuzzy<unsigned int> downsampling;
146146

147+
//! XML profile name to use for endpoint QoS lookup
148+
utils::Fuzzy<std::string> endpoint_profile_name;
149+
147150
/////////////////////////
148151
// GLOBAL VARIABLES
149152
/////////////////////////

ddspipe_core/include/ddspipe_core/types/topic/dds/DdsTopic.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ struct DdsTopic : public DistributedTopic
9090

9191
//! Type Identifiers: first one is complete and second one minimal
9292
fastdds::dds::xtypes::TypeIdentifierPair type_identifiers;
93+
94+
//! The Topic QoS explicitly configured by the user
95+
types::TopicQoS user_configured_qos{};
9396
};
9497

9598
} /* namespace types */

ddspipe_core/src/cpp/communication/dds/DdsBridge.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <cpp_utils/Log.hpp>
1717

1818
#include <ddspipe_core/communication/dds/DdsBridge.hpp>
19+
#include <ddspipe_core/types/topic/dds/DdsTopic.hpp>
1920

2021
#include <cpp_utils/utils.hpp>
2122

@@ -316,6 +317,10 @@ utils::Heritable<DistributedTopic> DdsBridge::create_topic_for_participant_nts_(
316317
// A Topic QoS set with fuzzy_level_hard (the highest FuzzyLevel) cannot be overwritten.
317318
// Thus, the order matters. In this case, manual_topics[0] > manual_topics[1] > participant.
318319

320+
// If this is a DDS Topic, also track the QoS that comes exclusively from user configuration,
321+
// as opposed to topic_qos which also absorbs QoS observed via RTPS discovery of remote endpoints.
322+
bool is_dds_topic = topic.can_cast<types::DdsTopic>();
323+
319324
// 1. Manually Configured Topic QoS.
320325
for (const auto& manual_topic : manual_topics_)
321326
{
@@ -324,12 +329,24 @@ utils::Heritable<DistributedTopic> DdsBridge::create_topic_for_participant_nts_(
324329
if (participant_ids.empty() || participant_ids.count(participant->id()))
325330
{
326331
topic->topic_qos.set_qos(manual_topic.first->topic_qos, utils::FuzzyLevelValues::fuzzy_level_hard);
332+
333+
if (is_dds_topic)
334+
{
335+
topic.dyn_cast<types::DdsTopic>().user_configured_qos.set_qos(
336+
manual_topic.first->topic_qos, utils::FuzzyLevelValues::fuzzy_level_hard);
337+
}
327338
}
328339
}
329340

330341
// 2. Participant Topic QoS.
331342
topic->topic_qos.set_qos(participant->topic_qos(), utils::FuzzyLevelValues::fuzzy_level_hard);
332343

344+
if (is_dds_topic)
345+
{
346+
topic.dyn_cast<types::DdsTopic>().user_configured_qos.set_qos(
347+
participant->topic_qos(), utils::FuzzyLevelValues::fuzzy_level_hard);
348+
}
349+
333350
// 3. Partitions Topic
334351
if (topic->partition_name.size() == 0)
335352
{

ddspipe_core/src/cpp/types/dds/TopicQoS.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ bool TopicQoS::operator ==(
6161
this->keyed == other.keyed &&
6262
this->max_tx_rate == other.max_tx_rate &&
6363
this->max_rx_rate == other.max_rx_rate &&
64-
this->downsampling == other.downsampling;
64+
this->downsampling == other.downsampling &&
65+
this->endpoint_profile_name == other.endpoint_profile_name;
6566
}
6667

6768
bool TopicQoS::is_reliable() const noexcept
@@ -132,6 +133,11 @@ void TopicQoS::set_qos(
132133
{
133134
downsampling.set_value(qos.downsampling.get_value(), fuzzy_level);
134135
}
136+
137+
if (endpoint_profile_name.get_level() < fuzzy_level && qos.endpoint_profile_name.is_set())
138+
{
139+
endpoint_profile_name.set_value(qos.endpoint_profile_name.get_value(), fuzzy_level);
140+
}
135141
}
136142

137143
void TopicQoS::set_default_qos() noexcept
@@ -259,6 +265,8 @@ std::ostream& operator <<(
259265
<< ";max_tx_rate(" << qos.max_tx_rate << ")"
260266
<< ";max_rx_rate(" << qos.max_rx_rate << ")"
261267
<< ";downsampling(" << qos.downsampling << ")"
268+
<< (qos.endpoint_profile_name.is_set() ? ";endpoint_profile_name(" + qos.endpoint_profile_name.get_value() +
269+
")" : "")
262270
<< "}";
263271

264272
return os;

ddspipe_core/src/cpp/types/topic/dds/DdsTopic.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ std::string DdsTopic::topic_unique_name() const noexcept
5656
std::string DdsTopic::serialize() const noexcept
5757
{
5858
std::stringstream ss;
59-
ss << "Topic{" << m_topic_name << ";" << type_name << ";" << topic_qos << "(" << m_internal_type_discriminator <<
60-
")}";
59+
ss << "Topic{" << m_topic_name << ";" << type_name << ";" << topic_qos << "(" << m_internal_type_discriminator
60+
<< ")}";
6161
return ss.str();
6262
}
6363

@@ -122,6 +122,7 @@ DdsTopic& DdsTopic::operator = (
122122

123123
this->type_name = other.type_name;
124124
this->type_identifiers = other.type_identifiers;
125+
this->user_configured_qos = other.user_configured_qos;
125126

126127
return *this;
127128
}

ddspipe_participants/include/ddspipe_participants/configuration/XmlParticipantConfiguration.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ namespace eprosima {
2323
namespace ddspipe {
2424
namespace participants {
2525

26+
enum class EndpointQoSMode
27+
{
28+
XML_STANDALONE, //! XML profile is selected
29+
XML_OVERRIDABLE, //! YAML QoS overrides XML
30+
};
31+
2632
/**
2733
* This data struct represents a configuration for a Participant loaded from an XML profile.
2834
*/
@@ -49,6 +55,8 @@ struct XmlParticipantConfiguration : public SimpleParticipantConfiguration
4955
/////////////////////////
5056

5157
utils::Fuzzy<std::string> participant_profile {};
58+
59+
EndpointQoSMode endpoint_qos_mode {EndpointQoSMode::XML_OVERRIDABLE};
5260
};
5361

5462
} /* namespace participants */

ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ class CommonParticipant : public core::IParticipant
250250
// INTERNAL VIRTUAL METHODS
251251
/////////////////////////
252252

253+
//! Whether the user's (YAML) QoS overrides the QoS from a matching XML endpoint profile
254+
DDSPIPE_PARTICIPANTS_DllAPI
255+
virtual bool endpoint_qos_mode_() const noexcept
256+
{
257+
return false;
258+
}
259+
260+
//! Whether XML endpoint profile lookup is enabled. Disabled by default for plain (non-XML) participants.
261+
DDSPIPE_PARTICIPANTS_DllAPI
262+
virtual bool xml_lookup_enabled_() const noexcept
263+
{
264+
return false;
265+
}
266+
253267
DDSPIPE_PARTICIPANTS_DllAPI
254268
virtual
255269
fastdds::dds::DomainParticipantQos

ddspipe_participants/include/ddspipe_participants/participant/dds/XmlParticipant.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ class XmlParticipant
6060
// INTERNAL METHODS
6161
/////////////////////////
6262

63+
//! Whether the user's (YAML) QoS overrides the QoS from a matching XML endpoint profile
64+
DDSPIPE_PARTICIPANTS_DllAPI
65+
virtual bool endpoint_qos_mode_() const noexcept override;
66+
67+
DDSPIPE_PARTICIPANTS_DllAPI
68+
virtual bool xml_lookup_enabled_() const noexcept override;
69+
6370
DDSPIPE_PARTICIPANTS_DllAPI
6471
virtual
6572
fastdds::dds::DomainParticipantQos

ddspipe_participants/include/ddspipe_participants/reader/dds/CommonReader.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ class CommonReader : public BaseReader, public fastdds::dds::DataReaderListener,
120120
const core::types::DdsTopic& topic,
121121
const std::shared_ptr<core::PayloadPool>& payload_pool,
122122
fastdds::dds::DomainParticipant* participant,
123-
fastdds::dds::Topic* topic_entity);
123+
fastdds::dds::Topic* topic_entity,
124+
const bool yaml_qos_override = true,
125+
const bool xml_lookup_enabled = false);
124126

125127
// Specific enable/disable do not need to be implemented
126128

@@ -177,6 +179,8 @@ class CommonReader : public BaseReader, public fastdds::dds::DataReaderListener,
177179

178180
fastdds::dds::DomainParticipant* dds_participant_;
179181
fastdds::dds::Topic* dds_topic_;
182+
bool yaml_qos_override_;
183+
bool xml_lookup_enabled_;
180184

181185
/////////////////////////
182186
// INTERNAL VARIABLES

ddspipe_participants/include/ddspipe_participants/reader/dds/SimpleReader.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class SimpleReader : public CommonReader
4848
const core::types::DdsTopic& topic,
4949
const std::shared_ptr<core::PayloadPool>& payload_pool,
5050
fastdds::dds::DomainParticipant* participant,
51-
fastdds::dds::Topic* topic_entity);
51+
fastdds::dds::Topic* topic_entity,
52+
const bool yaml_qos_override = true,
53+
const bool xml_lookup_enabled = false);
5254
};
5355

5456
} /* namespace dds */

0 commit comments

Comments
 (0)