From 15ffc4bc69a580e179f322771a9f7b54c129ab09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Dom=C3=ADnguez=20L=C3=B3pez?= <116071334+Mario-DL@users.noreply.github.com> Date: Fri, 31 May 2024 12:42:13 +0200 Subject: [PATCH] Add XML configuration for FlowControllerDescriptor and remove ThroughputController (#4837) * Refs #21054: Remove ThroughputController* references from project src/cpp files (except xmlparser) Signed-off-by: Mario Dominguez * Refs #21054: Refactor flow_controller names to be std::string Signed-off-by: Mario Dominguez * Refs #21054: Add flow_controller_descriptor_list to XSD Signed-off-by: Mario Dominguez * Refs #21054: Update XML related source files to the new flow_controller_descriptor_list Signed-off-by: Mario Dominguez * Refs #21054: Update unittests Signed-off-by: Mario Dominguez * Refs #21054: Update BlackBox tests Signed-off-by: Mario Dominguez * Refs #21054: Update FlowControllerExample Signed-off-by: Mario Dominguez * Refs #21054: Linter Signed-off-by: Mario Dominguez * Refs #21054: Apply partial rev suggestions Signed-off-by: Mario Dominguez * Refs #21054: Remove ThroughputControllerDescriptor.cpp from test source Signed-off-by: Mario Dominguez * Refs #21054: Set flow_controller_name as optional in .xsd Signed-off-by: Mario Dominguez * Refs #21054: fix windows unittests Signed-off-by: Mario Dominguez * Refs #21054: Minor corrections Signed-off-by: Mario Dominguez * Refs #21054: Update versions.md Signed-off-by: Mario Dominguez * Refs #21054: Apply rev suggestions Signed-off-by: Mario Dominguez * Refs #21054: Add scheduling policy and thread setting tags to existing XML flow controller snippets Signed-off-by: Mario Dominguez * Refs #21054: Add missing getXMLFlowControllerDescriptorList() unittesting Signed-off-by: Mario Dominguez * Refs #21054: Linter Signed-off-by: Mario Dominguez * Refs #21054: Add checks for repeated tags and test Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Dominguez --- .../FlowControlExamplePublisher.cxx | 13 +- .../cpp/dds/FlowControlExample/README.txt | 24 +-- .../fastdds/dds/core/policy/QosPolicies.hpp | 12 +- .../dds/publisher/qos/DataWriterQos.hpp | 38 ----- .../attributes/RTPSParticipantAttributes.h | 9 - .../rtps/attributes/WriterAttributes.h | 10 +- .../flowcontrol/FlowControllerDescriptor.hpp | 4 +- .../ThroughputControllerDescriptor.h | 56 ------- resources/xsd/fastdds_profiles.xsd | 41 ++++- src/cpp/CMakeLists.txt | 1 - .../fastdds/domain/DomainParticipantImpl.cpp | 1 - src/cpp/fastdds/publisher/DataWriterImpl.cpp | 3 - src/cpp/fastdds/utils/QosConverters.cpp | 3 - .../discovery/participant/PDPClient.cpp | 4 +- .../discovery/participant/PDPSimple.cpp | 4 +- .../flowcontrol/FlowControllerFactory.cpp | 7 - .../flowcontrol/FlowControllerFactory.hpp | 7 + .../ThroughputControllerDescriptor.cpp | 31 ---- .../rtps/participant/RTPSParticipantImpl.cpp | 69 +------- src/cpp/xmlparser/XMLElementParser.cpp | 154 ++++++++++++++---- src/cpp/xmlparser/XMLParser.cpp | 9 +- src/cpp/xmlparser/XMLParser.h | 6 +- src/cpp/xmlparser/XMLParserCommon.cpp | 15 +- src/cpp/xmlparser/XMLParserCommon.h | 14 +- .../attributes/PublisherAttributes.hpp | 4 - test/blackbox/api/dds-pim/PubSubWriter.hpp | 7 +- .../api/dds-pim/PubSubWriterReader.hpp | 7 +- .../BlackboxTestsPubSubFlowControllers.cpp | 10 +- .../common/BlackboxTestsPubSubFragments.cpp | 22 +-- .../blackbox/common/BlackboxTestsSecurity.cpp | 16 +- .../blackbox/common/BlackboxTestsVolatile.cpp | 2 +- .../common/DDSBlackboxTestsListeners.cpp | 34 ++-- test/blackbox/common/RTPSAsSocketWriter.hpp | 22 ++- .../common/RTPSBlackboxTestsBasic.cpp | 2 +- .../common/RTPSWithRegistrationWriter.hpp | 15 +- .../attributes/RTPSParticipantAttributes.h | 9 - .../dds/participant/ParticipantTests.cpp | 8 - .../profiles/test_xml_for_string_profile.xml | 12 ++ .../dds/profiles/test_xml_profile.xml | 25 +++ test/unittest/dds/publisher/CMakeLists.txt | 1 - .../unittest/dds/publisher/PublisherTests.cpp | 2 +- test/unittest/dds/status/CMakeLists.txt | 1 - test/unittest/rtps/discovery/CMakeLists.txt | 2 - test/unittest/rtps/flowcontrol/CMakeLists.txt | 1 - test/unittest/rtps/network/CMakeLists.txt | 1 - test/unittest/rtps/security/CMakeLists.txt | 1 - test/unittest/rtps/writer/CMakeLists.txt | 1 - .../security/accesscontrol/CMakeLists.txt | 1 - .../security/authentication/CMakeLists.txt | 1 - test/unittest/statistics/dds/CMakeLists.txt | 2 - test/unittest/statistics/rtps/CMakeLists.txt | 1 - test/unittest/transport/CMakeLists.txt | 5 - test/unittest/xmlparser/CMakeLists.txt | 3 - .../xmlparser/XMLElementParserTests.cpp | 139 ++++++++++++++-- test/unittest/xmlparser/XMLParserTests.cpp | 18 +- .../xmlparser/XMLProfileParserTests.cpp | 37 +++-- .../xmlparser/test_xml_deprecated.xml | 23 ++- test/unittest/xmlparser/test_xml_profile.xml | 13 ++ .../xmlparser/test_xml_profile_env_var.xml | 15 ++ .../xmlparser/test_xml_rooted_deprecated.xml | 22 ++- .../xmlparser/wrapper/XMLParserTest.hpp | 6 +- versions.md | 1 + 62 files changed, 561 insertions(+), 466 deletions(-) delete mode 100644 include/fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h delete mode 100644 src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp diff --git a/examples/cpp/dds/FlowControlExample/FlowControlExamplePublisher.cxx b/examples/cpp/dds/FlowControlExample/FlowControlExamplePublisher.cxx index 3506549fceb..e7d63b02d4d 100644 --- a/examples/cpp/dds/FlowControlExample/FlowControlExamplePublisher.cxx +++ b/examples/cpp/dds/FlowControlExample/FlowControlExamplePublisher.cxx @@ -27,6 +27,7 @@ #include using namespace eprosima::fastdds::dds; +using namespace eprosima::fastdds::rtps; using namespace eprosima::fastrtps::rtps; FlowControlExamplePublisher::FlowControlExamplePublisher() @@ -72,6 +73,13 @@ bool FlowControlExamplePublisher::init() pqos.wire_protocol().builtin.discovery_config.leaseDuration = eprosima::fastrtps::c_TimeInfinite; pqos.name("Participant_publisher"); //You can put here the name you want + // This controller allows 300kb per second. + auto slow_flow_controller_descriptor = std::make_shared(); + slow_flow_controller_descriptor->name = "slow_flow_controller_descriptor"; + slow_flow_controller_descriptor->max_bytes_per_period = 300000; + slow_flow_controller_descriptor->period_ms = static_cast(1000); + pqos.flow_controllers().push_back(slow_flow_controller_descriptor); + participant_ = DomainParticipantFactory::get_instance()->create_participant(0, pqos); if (participant_ == nullptr) @@ -121,10 +129,7 @@ bool FlowControlExamplePublisher::init() // Create slow DataWriter DataWriterQos wsqos; wsqos.publish_mode().kind = ASYNCHRONOUS_PUBLISH_MODE; - - // This controller allows 300kb per second. - ThroughputControllerDescriptor slowPublisherThroughputController{300000, 1000}; - wsqos.throughput_controller() = slowPublisherThroughputController; + wsqos.publish_mode().flow_controller_name = slow_flow_controller_descriptor->name; slow_writer_ = slow_publisher_->create_datawriter(topic_, wsqos, &m_listener); diff --git a/examples/cpp/dds/FlowControlExample/README.txt b/examples/cpp/dds/FlowControlExample/README.txt index 105d373359f..10c47ecc7c0 100644 --- a/examples/cpp/dds/FlowControlExample/README.txt +++ b/examples/cpp/dds/FlowControlExample/README.txt @@ -1,32 +1,32 @@ To launch this example open two consoles: - 1) "$ ./DDSFlowControlExample subscriber" (or "DDSFlowControlExample.exe subscriber" in Windows). + 1) "$ ./DDSFlowControlExample subscriber" (or "DDSFlowControlExample.exe subscriber" in Windows). 2..*) "$ ./DDSFlowControlExample publisher" (or "DDSFlowControlExample.exe publisher" in Windows). -This example illustrates the flow control feature. +This example illustrates the flow control feature. ================ = Flow Control = ================ -In Fast DDS, Flow Control is implemented through objects called Flow Controllers. In -particular, we will be looking at the simplest kind, the Throughput Controller. +In Fast DDS, Flow Control is implemented through objects called Flow Controllers. In +particular, we will be looking at the simplest kind, the Flow Controller. -A throughput controller is univocally defined by a Throughput Controller Descriptor, +A flow controller is univocally defined by a Flow Controller Descriptor, which is a simple struct that includes two values: -> A size in bytes. -> A period in milliseconds. -Once instantiated from this descriptor, a throughput controller will make sure there is a -limit on the data it processes, so that no more than the specified size gets +Once instantiated from this descriptor, a flow controller will make sure there is a +limit on the data it processes, so that no more than the specified size gets through it in the specified time. In other words, it limits data throughput. -Throughput filters can be placed at different points in the system. In this example, you -can see a controller being placed on a particular Writer. Controllers allocated in this -way display a hierarchical behaviour, so in order for data to be sent, it must clear +Flow filters can be placed at different points in the system. In this example, you +can see a controller being placed on a particular Writer. Controllers allocated in this +way display a hierarchical behaviour, so in order for data to be sent, it must clear both the Participant filter and the Writer filter, if available. -Looking at FlowControlExamplePublisher::init(), you can see the steps involved in -adding a size filter to the publisher parameters. +Looking at FlowControlExamplePublisher::init(), you can see the steps involved in +adding a size filter to the publisher parameters. diff --git a/include/fastdds/dds/core/policy/QosPolicies.hpp b/include/fastdds/dds/core/policy/QosPolicies.hpp index b28c77f6137..db8ef1cb8e7 100644 --- a/include/fastdds/dds/core/policy/QosPolicies.hpp +++ b/include/fastdds/dds/core/policy/QosPolicies.hpp @@ -2047,7 +2047,7 @@ class PublishModeQosPolicy : public QosPolicy * * @since 2.4.0 */ - const char* flow_controller_name = fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT; + std::string flow_controller_name = fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT; inline void clear() override { @@ -2059,7 +2059,7 @@ class PublishModeQosPolicy : public QosPolicy const PublishModeQosPolicy& b) const { return (this->kind == b.kind) && - 0 == strcmp(flow_controller_name, b.flow_controller_name) && + flow_controller_name == b.flow_controller_name.c_str() && QosPolicy::operator ==(b); } @@ -2679,7 +2679,6 @@ class WireProtocolConfigQos : public QosPolicy (this->participant_id == b.participant_id) && (this->builtin == b.builtin) && (this->port == b.port) && - (this->throughput_controller == b.throughput_controller) && (this->default_unicast_locator_list == b.default_unicast_locator_list) && (this->default_multicast_locator_list == b.default_multicast_locator_list) && (this->default_external_unicast_locators == b.default_external_unicast_locators) && @@ -2705,13 +2704,6 @@ class WireProtocolConfigQos : public QosPolicy //! Port Parameters fastrtps::rtps::PortParameters port; - /** - * @brief Throughput controller parameters. Leave default for uncontrolled flow. - * - * @deprecated Use flow_controllers() on DomainParticipantQoS - */ - fastrtps::rtps::ThroughputControllerDescriptor throughput_controller; - /** * Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case * that it was defined with NO UnicastLocators. At least ONE locator should be included in this list. diff --git a/include/fastdds/dds/publisher/qos/DataWriterQos.hpp b/include/fastdds/dds/publisher/qos/DataWriterQos.hpp index 291982d6829..7630ca52044 100644 --- a/include/fastdds/dds/publisher/qos/DataWriterQos.hpp +++ b/include/fastdds/dds/publisher/qos/DataWriterQos.hpp @@ -114,7 +114,6 @@ class DataWriterQos (this->reliable_writer_qos_ == b.reliable_writer_qos()) && (this->endpoint_ == b.endpoint()) && (this->writer_resource_limits_ == b.writer_resource_limits()) && - (this->throughput_controller_ == b.throughput_controller()) && (this->data_sharing_ == b.data_sharing()); } @@ -772,40 +771,6 @@ class DataWriterQos writer_resource_limits_ = writer_resource_limits; } - /** - * Getter for ThroughputControllerDescriptor - * - * @return ThroughputControllerDescriptor reference - * @deprecated Use flow_controllers() on DomainParticipantQoS - */ - FASTDDS_EXPORTED_API fastrtps::rtps::ThroughputControllerDescriptor& throughput_controller() - { - return throughput_controller_; - } - - /** - * Getter for ThroughputControllerDescriptor - * - * @return ThroughputControllerDescriptor reference - * @deprecated Use flow_controllers() on DomainParticipantQoS - */ - FASTDDS_EXPORTED_API const fastrtps::rtps::ThroughputControllerDescriptor& throughput_controller() const - { - return throughput_controller_; - } - - /** - * Setter for ThroughputControllerDescriptor - * - * @param throughput_controller new value for the ThroughputControllerDescriptor - * @deprecated Use flow_controllers() on DomainParticipantQoS - */ - FASTDDS_EXPORTED_API void throughput_controller( - const fastrtps::rtps::ThroughputControllerDescriptor& throughput_controller) - { - throughput_controller_ = throughput_controller; - } - /** * Getter for DataSharingQosPolicy * @@ -902,9 +867,6 @@ class DataWriterQos //!Writer Resource Limits Qos WriterResourceLimitsQos writer_resource_limits_; - //!Throughput controller - fastrtps::rtps::ThroughputControllerDescriptor throughput_controller_; - //!DataSharing configuration DataSharingQosPolicy data_sharing_; }; diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index 307f8f6d4d0..79b2e726c1b 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -432,7 +431,6 @@ class RTPSParticipantAttributes (this->port == b.port) && (this->userData == b.userData) && (this->participantID == b.participantID) && - (this->throughputController == b.throughputController) && (this->useBuiltinTransports == b.useBuiltinTransports) && (this->properties == b.properties) && (this->prefix == b.prefix) && @@ -516,13 +514,6 @@ class RTPSParticipantAttributes //! Participant ID int32_t participantID = -1; - /** - * @brief Throughput controller parameters. Leave default for uncontrolled flow. - * - * @deprecated Use flow_controllers on RTPSParticipantAttributes - */ - ThroughputControllerDescriptor throughputController; - //! User defined transports to use alongside or in place of builtins. std::vector> userTransports; diff --git a/include/fastdds/rtps/attributes/WriterAttributes.h b/include/fastdds/rtps/attributes/WriterAttributes.h index adf951ee14e..625186312b6 100644 --- a/include/fastdds/rtps/attributes/WriterAttributes.h +++ b/include/fastdds/rtps/attributes/WriterAttributes.h @@ -26,7 +26,6 @@ #include #include #include -#include #include namespace eprosima { @@ -123,13 +122,6 @@ class WriterAttributes //!Indicates if the Writer is synchronous or asynchronous RTPSWriterPublishMode mode; - /** - * @brief Throughput controller, always the last one to apply - * - * @deprecated Use flow_controllers on RTPSParticipantAttributes - */ - ThroughputControllerDescriptor throughputController; - //! Disable the sending of heartbeat piggybacks. bool disable_heartbeat_piggyback; @@ -143,7 +135,7 @@ class WriterAttributes Duration_t keep_duration; //! Flow controller name. Default: fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT. - const char* flow_controller_name = fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT; + std::string flow_controller_name = fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT; }; } /* namespace rtps */ diff --git a/include/fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp b/include/fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp index 35873f7f994..55d05780bf8 100644 --- a/include/fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp +++ b/include/fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp @@ -15,6 +15,8 @@ #ifndef FASTDDS_RTPS_FLOWCONTROL_FLOWCONTROLLERDESCRIPTOR_HPP #define FASTDDS_RTPS_FLOWCONTROL_FLOWCONTROLLERDESCRIPTOR_HPP +#include + #include #include "FlowControllerConsts.hpp" @@ -33,7 +35,7 @@ namespace rtps { struct FlowControllerDescriptor { //! Name of the flow controller. - const char* name = nullptr; + std::string name = FASTDDS_FLOW_CONTROLLER_DEFAULT; //! Scheduler policy used by the flow controller. //! diff --git a/include/fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h b/include/fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h deleted file mode 100644 index cc6ddbaa13e..00000000000 --- a/include/fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _FASTDDS_RTPS_THROUGHPUT_CONTROLLER_DESCRIPTOR_H -#define _FASTDDS_RTPS_THROUGHPUT_CONTROLLER_DESCRIPTOR_H - -#include -#include - -namespace eprosima { -namespace fastrtps { -namespace rtps { - -/** - * Descriptor for a Throughput Controller, containing all constructor information - * for it. - * @ingroup NETWORK_MODULE - * @deprecated Use FlowControllerDescriptor - */ -struct ThroughputControllerDescriptor -{ - //! Packet size in bytes that this controller will allow in a given period. - uint32_t bytesPerPeriod; - //! Window of time in which no more than 'bytesPerPeriod' bytes are allowed. - uint32_t periodMillisecs; - - FASTDDS_EXPORTED_API ThroughputControllerDescriptor(); - FASTDDS_EXPORTED_API ThroughputControllerDescriptor( - uint32_t size, - uint32_t time); - - bool operator ==( - const ThroughputControllerDescriptor& b) const - { - return (this->bytesPerPeriod == b.bytesPerPeriod) && - (this->periodMillisecs == b.periodMillisecs); - } - -}; - -} // namespace rtps -} // namespace fastrtps -} // namespace eprosima - -#endif // THROUGHPUT_CONTROLLER_DESCRIPTOR_H diff --git a/resources/xsd/fastdds_profiles.xsd b/resources/xsd/fastdds_profiles.xsd index aa1845d84d4..88473439623 100644 --- a/resources/xsd/fastdds_profiles.xsd +++ b/resources/xsd/fastdds_profiles.xsd @@ -139,6 +139,7 @@ ├ allocation [0~1], ├ userData [0~1], ├ prefix [0~1], + ├ flow_controller_descriptor_list [flowControllerDescriptorListType], ├ builtin_controllers_sender_thread [threadSettingsType], ├ timed_events_thread [threadSettingsType], ├ discovery_server_thread [threadSettingsType], @@ -184,6 +185,7 @@ + @@ -1747,7 +1749,8 @@ + ├ kind [string] ("ASYNCHRONOUS", "SYNCHRONOUS") + └ flow_controller_name [string] --> @@ -1758,6 +1761,7 @@ + @@ -1888,6 +1892,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +