Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21136] Add XML configuration for FlowControllerDescriptor to 2.x (backport #4893) #4906

Merged
merged 7 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace rtps {
struct FlowControllerDescriptor
{
//! Name of the flow controller.
const char* name = nullptr;
const char* name = FASTDDS_FLOW_CONTROLLER_DEFAULT;

//! Scheduler policy used by the flow controller.
//!
Expand Down
27 changes: 27 additions & 0 deletions include/fastrtps/xmlparser/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <fastrtps/attributes/LibrarySettingsAttributes.h>

#include <map>
#include <mutex>
#include <set>
#include <string>

namespace tinyxml2 {
Expand Down Expand Up @@ -91,6 +93,8 @@ class XMLParser

public:

using FlowControllerDescriptorList = std::vector<std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>>;

/**
* Load the default XML file.
* @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case.
Expand Down Expand Up @@ -160,6 +164,14 @@ class XMLParser
RTPS_DllAPI static XMLP_ret loadXMLDynamicTypes(
tinyxml2::XMLElement& types);


/**
* Clears the private static collections.
*
* @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case.
*/
RTPS_DllAPI static XMLP_ret clear();

protected:

RTPS_DllAPI static XMLP_ret parseXML(
Expand Down Expand Up @@ -501,6 +513,11 @@ class XMLParser
rtps::ThroughputControllerDescriptor& throughputController,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLFlowControllerDescriptorList(
tinyxml2::XMLElement* elem,
FlowControllerDescriptorList& flow_controller_descriptor_list,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLPortParameters(
tinyxml2::XMLElement* elem,
rtps::PortParameters& port,
Expand Down Expand Up @@ -556,6 +573,11 @@ class XMLParser
uint16_t* ui16,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLUint(
tinyxml2::XMLElement* elem,
uint64_t* ui64,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLBool(
tinyxml2::XMLElement* elem,
bool* b,
Expand Down Expand Up @@ -620,6 +642,11 @@ class XMLParser
tinyxml2::XMLElement* elem,
eprosima::fastdds::rtps::BuiltinTransports* bt,
uint8_t ident);

private:

static std::mutex collections_mtx_;
static std::set<std::string> flow_controller_descriptor_names_;
};

} // namespace xmlparser
Expand Down
11 changes: 11 additions & 0 deletions include/fastrtps/xmlparser/XMLParserCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ extern const char* PART_ID;
extern const char* IP4_TO_SEND;
extern const char* IP6_TO_SEND;
extern const char* THROUGHPUT_CONT;
extern const char* FLOW_CONTROLLER_DESCRIPTOR_LIST;
extern const char* USER_TRANS;
extern const char* USE_BUILTIN_TRANS;
extern const char* BUILTIN_TRANS;
Expand Down Expand Up @@ -261,6 +262,16 @@ extern const char* ALLOCATED_SAMPLES;
extern const char* EXTRA_SAMPLES;
extern const char* BYTES_PER_SECOND;
extern const char* PERIOD_MILLISECS;
extern const char* FLOW_CONTROLLER_DESCRIPTOR;
extern const char* SCHEDULER;
extern const char* MAX_BYTES_PER_PERIOD;
extern const char* PERIOD_MS;
extern const char* FLOW_CONTROLLER_NAME;
extern const char* FIFO;
extern const char* HIGH_PRIORITY;
extern const char* ROUND_ROBIN;
extern const char* PRIORITY_WITH_RESERVATION;
extern const char* FLOW_CONTROLLER_NAME;
extern const char* PORT_BASE;
extern const char* DOMAIN_ID_GAIN;
extern const char* PARTICIPANT_ID_GAIN;
Expand Down
43 changes: 41 additions & 2 deletions resources/xsd/fastRTPS_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
├ propertiesPolicy [0~1],
├ allocation [0~1],
├ userData [0~1],
└ prefix [0~1]-->
├ prefix [0~1],
└ flow_controller_descriptor_list [flowControllerDescriptorListType]-->
<!-- TODO: How to ensure that the userTransports identifiers exist in transport descriptors in the XML file? -->
<xs:complexType name="participantProfileType">
<xs:all>
Expand Down Expand Up @@ -160,6 +161,7 @@
<xs:element name="allocation" type="rtpsParticipantAllocationAttributesType" minOccurs="0" maxOccurs="1"/>
<xs:element name="userData" type="octectVectorQosPolicyType" minOccurs="0" maxOccurs="1"/>
<xs:element name="prefix" type="prefixType" minOccurs="0" maxOccurs="1"/>
<xs:element name="flow_controller_descriptor_list" type="flowControllerDescriptorListType" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -1554,7 +1556,8 @@
</xs:complexType>

<!--QoS Publish Mode:
└ kind [string] ("ASYNCHRONOUS", "SYNCHRONOUS") -->
├ kind [string] ("ASYNCHRONOUS", "SYNCHRONOUS")
└ flow_controller_name [string] -->
<xs:complexType name="publishModeQosPolicyType">
<xs:all>
<xs:element name="kind" minOccurs="0" maxOccurs="1">
Expand All @@ -1565,6 +1568,7 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="flow_controller_name" type="string" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>

Expand Down Expand Up @@ -1695,7 +1699,38 @@
</xs:all>
</xs:complexType>

<!--Flow Controller Descriptor List Type:
└ flow_controller_descriptor [1~*]-->
<xs:complexType name="flowControllerDescriptorListType">
<xs:sequence minOccurs="1" maxOccurs="unbounded"> <!-- multiple instances of the elements -->
<xs:element name="flow_controller_descriptor" type="flowControllerDescriptorType"/>
</xs:sequence>
</xs:complexType>

<!--Flow Controller Descriptor Type:
├ name [string] req,
├ scheduler [flowControllerSchedulerPolicy],
├ max_bytes_per_period [int32],
└ period_ms [uint64]-->
<xs:complexType name="flowControllerDescriptorType">
<xs:all>
<xs:element name="name" type="string" minOccurs="1" maxOccurs="1"/>
<xs:element name="scheduler" type="flowControllerSchedulerPolicy" minOccurs="0" maxOccurs="1"/>
<xs:element name="max_bytes_per_period" type="int32" minOccurs="0" maxOccurs="1"/>
<xs:element name="period_ms" type="uint64" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>

<!--Flow Controller Scheduler Policy Type [string]:
("FIFO", "ROUND_ROBIN", "HIGH_PRIORITY", "PRIORITY_WITH_RESERVATION")-->
<xs:simpleType name="flowControllerSchedulerPolicy">
<xs:restriction base="xs:string">
<xs:enumeration value="FIFO" />
<xs:enumeration value="ROUND_ROBIN" />
<xs:enumeration value="HIGH_PRIORITY" />
<xs:enumeration value="PRIORITY_WITH_RESERVATION" />
</xs:restriction>
</xs:simpleType>


<!--| PRIMITIVE TYPES DEFINITION |-->
Expand Down Expand Up @@ -1821,6 +1856,10 @@
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>

<xs:simpleType name="uint64">
<xs:restriction base="xs:unsignedLong"/>
</xs:simpleType>

<!--Octect vector-->
<xs:simpleType name="octectVector">
<xs:restriction base="xs:string">
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ bool RTPSParticipantImpl::create_writer(

GUID_t guid(m_guid.guidPrefix, entId);
fastdds::rtps::FlowController* flow_controller = nullptr;
const char* flow_controller_name = param.flow_controller_name;
std::string flow_controller_name = param.flow_controller_name;

// Support of old flow controller style.
if (param.throughputController.bytesPerPeriod != UINT32_MAX && param.throughputController.periodMillisecs != 0)
Expand Down
Loading
Loading