Skip to content

Commit 45f8534

Browse files
Limit RTPS History Depth (#288)
* Remove duplicated Forthcoming section Signed-off-by: Juan López Fernández <juanlopez@eprosima.com> * Limit RTPS History Depth Signed-off-by: Juan López Fernández <juanlopez@eprosima.com> * Uncrustify Signed-off-by: Juan López Fernández <juanlopez@eprosima.com> * Fix typo Signed-off-by: Juan López Fernández <juanlopez@eprosima.com> * Make RTPS Writers Synchronous Signed-off-by: Juan López Fernández <juanlopez@eprosima.com> Signed-off-by: Juan López Fernández <juanlopez@eprosima.com>
1 parent d7d1f83 commit 45f8534

23 files changed

Lines changed: 122 additions & 25 deletions

File tree

ddsrouter_core/include/ddsrouter_core/configuration/DDSRouterConfiguration.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ struct DDSRouterConfiguration : public DDSRouterReloadConfiguration
5353
std::set<std::shared_ptr<types::FilterTopic>> blocklist,
5454
std::set<std::shared_ptr<types::RealTopic>> builtin_topics,
5555
std::set<std::shared_ptr<ParticipantConfiguration>> participants_configurations,
56-
unsigned int number_of_threads);
56+
unsigned int number_of_threads,
57+
unsigned int max_history_depth);
5758

5859
/////////////////////////
5960
// METHODS
@@ -73,6 +74,8 @@ struct DDSRouterConfiguration : public DDSRouterReloadConfiguration
7374

7475
unsigned int number_of_threads = 12;
7576

77+
unsigned int max_history_depth = 5000;
78+
7679
protected:
7780

7881
static bool check_correct_configuration_object_(

ddsrouter_core/include/ddsrouter_core/configuration/participant/SimpleParticipantConfiguration.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ struct SimpleParticipantConfiguration : public ParticipantConfiguration
6767
/////////////////////////
6868

6969
types::DomainId domain = types::DomainId(0u);
70+
71+
unsigned int max_history_depth = 5000;
7072
};
7173

7274
} /* namespace configuration */

ddsrouter_core/src/cpp/configuration/DDSRouterConfiguration.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ DDSRouterConfiguration::DDSRouterConfiguration(
4040
std::set<std::shared_ptr<FilterTopic>> blocklist,
4141
std::set<std::shared_ptr<RealTopic>> builtin_topics,
4242
std::set<std::shared_ptr<ParticipantConfiguration>> participants_configurations,
43-
unsigned int number_of_threads /* = default_number_of_threads() */)
43+
unsigned int number_of_threads,
44+
unsigned int max_history_depth)
4445
: DDSRouterReloadConfiguration (allowlist, blocklist, builtin_topics)
4546
, participants_configurations(participants_configurations)
4647
, number_of_threads(number_of_threads)
48+
, max_history_depth(max_history_depth)
4749
{
4850
}
4951

ddsrouter_core/src/cpp/core/DDSRouterImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ void DDSRouterImpl::init_participants_()
288288
participant_factory_.create_participant(
289289
participant_config,
290290
payload_pool_,
291-
discovery_database_);
291+
discovery_database_,
292+
configuration_.max_history_depth);
292293

293294
// create_participant should throw an exception in fail, never return nullptr
294295
if (!new_participant || !new_participant->id().is_valid() ||

ddsrouter_core/src/cpp/core/ParticipantFactory.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ using namespace eprosima::ddsrouter::core::configuration;
4343
std::shared_ptr<IParticipant> ParticipantFactory::create_participant(
4444
std::shared_ptr<configuration::ParticipantConfiguration> participant_configuration,
4545
std::shared_ptr<PayloadPool> payload_pool,
46-
std::shared_ptr<DiscoveryDatabase> discovery_database)
46+
std::shared_ptr<DiscoveryDatabase> discovery_database,
47+
unsigned int max_history_depth)
4748
{
4849
// Create a new Participant depending on the ParticipantKind specified by the configuration
4950
switch (participant_configuration->kind)
@@ -80,6 +81,8 @@ std::shared_ptr<IParticipant> ParticipantFactory::create_participant(
8081
std::shared_ptr<configuration::SimpleParticipantConfiguration> conf_ =
8182
std::dynamic_pointer_cast<configuration::SimpleParticipantConfiguration>(
8283
participant_configuration);
84+
// TMP: Until Transparency QoS module is available
85+
conf_->max_history_depth = max_history_depth;
8386
if (!conf_)
8487
{
8588
throw utils::ConfigurationException(
@@ -100,6 +103,8 @@ std::shared_ptr<IParticipant> ParticipantFactory::create_participant(
100103
std::shared_ptr<configuration::DiscoveryServerParticipantConfiguration> conf_ =
101104
std::dynamic_pointer_cast<configuration::DiscoveryServerParticipantConfiguration>(
102105
participant_configuration);
106+
// TMP: Until Transparency QoS module is available
107+
conf_->max_history_depth = max_history_depth;
103108
if (!conf_)
104109
{
105110
throw utils::ConfigurationException(
@@ -119,6 +124,8 @@ std::shared_ptr<IParticipant> ParticipantFactory::create_participant(
119124
std::shared_ptr<configuration::InitialPeersParticipantConfiguration> conf_ =
120125
std::dynamic_pointer_cast<configuration::InitialPeersParticipantConfiguration>(
121126
participant_configuration);
127+
// TMP: Until Transparency QoS module is available
128+
conf_->max_history_depth = max_history_depth;
122129
if (!conf_)
123130
{
124131
throw utils::ConfigurationException(

ddsrouter_core/src/cpp/core/ParticipantFactory.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ class ParticipantFactory
4040
* participant that will be created, and its Configuration.
4141
* @param [in] payload : Common Payload pool to create the Participant
4242
* @param [in] discovery_database : Common Discovery Database to create the Participant
43+
* @param [in] max_history_depth : Maximum size of RTPS History instances (only applies to RTPS participants);
4344
* @return new Participant
4445
*/
4546
std::shared_ptr<IParticipant> create_participant(
4647
std::shared_ptr<configuration::ParticipantConfiguration> participant_configuration,
4748
std::shared_ptr<PayloadPool> payload,
48-
std::shared_ptr<DiscoveryDatabase> discovery_database);
49+
std::shared_ptr<DiscoveryDatabase> discovery_database,
50+
unsigned int max_history_depth);
4951

5052
/**
5153
* @brief Delete correctly a Participant

ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ CommonParticipant::CommonParticipant(
4141
std::shared_ptr<PayloadPool> payload_pool,
4242
std::shared_ptr<DiscoveryDatabase> discovery_database,
4343
const types::DomainId& domain_id,
44-
const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes)
44+
const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes,
45+
unsigned int max_history_depth)
4546
: BaseParticipant(participant_configuration, payload_pool, discovery_database)
47+
, max_history_depth_(max_history_depth)
4648
{
4749
create_participant_(
4850
domain_id,
@@ -242,6 +244,7 @@ std::shared_ptr<IWriter> CommonParticipant::create_writer_(
242244
topic,
243245
this->payload_pool_,
244246
rtps_participant_,
247+
max_history_depth_,
245248
this->configuration_->is_repeater);
246249
}
247250

ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class CommonParticipant
5353
std::shared_ptr<PayloadPool> payload_pool,
5454
std::shared_ptr<DiscoveryDatabase> discovery_database,
5555
const types::DomainId& domain_id,
56-
const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes);
56+
const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes,
57+
unsigned int max_history_depth);
5758

5859
virtual ~CommonParticipant();
5960

@@ -97,6 +98,9 @@ class CommonParticipant
9798

9899
//! Mutex that guards every access to the RTPS Participant
99100
mutable std::recursive_mutex rtps_mutex_;
101+
102+
//! Maximum depth of RTPS History instances
103+
unsigned int max_history_depth_;
100104
};
101105

102106
} /* namespace rtps */

ddsrouter_core/src/cpp/participant/implementations/rtps/DiscoveryServerParticipant.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ DiscoveryServerParticipant::DiscoveryServerParticipant(
4242
payload_pool,
4343
discovery_database,
4444
participant_configuration->domain,
45-
participant_attributes_(participant_configuration.get()))
45+
participant_attributes_(participant_configuration.get()),
46+
participant_configuration->max_history_depth)
4647
{
4748
}
4849

ddsrouter_core/src/cpp/participant/implementations/rtps/InitialPeersParticipant.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ InitialPeersParticipant::InitialPeersParticipant(
3939
payload_pool,
4040
discovery_database,
4141
participant_configuration->domain,
42-
participant_attributes_(participant_configuration.get()))
42+
participant_attributes_(participant_configuration.get()),
43+
participant_configuration->max_history_depth)
4344
{
4445
}
4546

0 commit comments

Comments
 (0)