Skip to content

Commit

Permalink
Add XML support for ThreadSettings (#3922)
Browse files Browse the repository at this point in the history
* Refs #19378: Add threadSettingsTypes to XSD schema

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add unit test for parsing thread_settings XML elements

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add getXMLThreadSettings to XMLElementParser

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add Log test cases to XMLProfileParserBasicTests.thread_settings_qos test

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add XML ThreadSettings config to Log

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add domainparticipant_factory XML tag tests

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add domainparticipant_factory XSD

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add XML ThreadSettings config to DomainParticipantFactory

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add getXMLEntityFactoryQos unit test

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add domainparticipant XML thread settings tests

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add XML ThreadSettings config to DomainParticipant

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Uncrustify

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add parseXMLReceptionThreads API & unit test

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add transport descriptor XML thread settings tests

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add parseXMLReceptionThreads implementation

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add transport descriptor XML thread settings config

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add datareader XML thread settings tests

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add datareader XML thread settings

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add builtin_transports_reception_threads to domainparticipant XML test

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Add builtin_transports_reception_threads to domainparticipant XML

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Fix Windows warning regarding sscanf

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Fix flow controllers unittests build when using Fast CDR as thirdparty

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Apply Miguel's suggestions

Signed-off-by: EduPonz <[email protected]>

* Refs #19378: Apply some other suggestions

Signed-off-by: EduPonz <[email protected]>

* Refs #19378. OSx has neither `SCHED_BATCH` nor `SCHED_IDLE`

Signed-off-by: Miguel Company <[email protected]>

* Refs #19378. Check result on pthread_setschedparam

Signed-off-by: Miguel Company <[email protected]>

* Refs #19378. Add include on `threading_osx.ipp`

Signed-off-by: Miguel Company <[email protected]>

* Refs #19378. Avoid using gettid on `threading_osx.ipp`

Signed-off-by: Miguel Company <[email protected]>

* Refs #19378: Fix mac warning

Signed-off-by: EduPonz <[email protected]>

---------

Signed-off-by: EduPonz <[email protected]>
Signed-off-by: Miguel Company <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
  • Loading branch information
EduPonz and MiguelCompany committed Nov 13, 2023
1 parent 77f2c8a commit b28f462
Show file tree
Hide file tree
Showing 38 changed files with 3,076 additions and 355 deletions.
36 changes: 36 additions & 0 deletions include/fastdds/dds/core/policy/QosPolicies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2951,6 +2951,7 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy
max_domains_ :
b.domain_ids().size());
domain_ids_ = b.domain_ids();
data_sharing_listener_thread_ = b.data_sharing_listener_thread();

return *this;
}
Expand All @@ -2961,6 +2962,7 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy
return kind_ == b.kind_ &&
shm_directory_ == b.shm_directory_ &&
domain_ids_ == b.domain_ids_ &&
data_sharing_listener_thread_ == b.data_sharing_listener_thread_ &&
Parameter_t::operator ==(b) &&
QosPolicy::operator ==(b);
}
Expand Down Expand Up @@ -3137,6 +3139,37 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy
}
}

/**
* Getter for DataSharing listener thread ThreadSettings
*
* @return rtps::ThreadSettings reference
*/
rtps::ThreadSettings& data_sharing_listener_thread()
{
return data_sharing_listener_thread_;
}

/**
* Getter for DataSharing listener thread ThreadSettings
*
* @return rtps::ThreadSettings reference
*/
const rtps::ThreadSettings& data_sharing_listener_thread() const
{
return data_sharing_listener_thread_;
}

/**
* Setter for the DataSharing listener thread ThreadSettings
*
* @param value New ThreadSettings to be set
*/
void data_sharing_listener_thread(
const rtps::ThreadSettings& value)
{
data_sharing_listener_thread_ = value;
}

private:

void setup(
Expand Down Expand Up @@ -3165,6 +3198,9 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy

//! Only endpoints with matching domain IDs are DataSharing compatible
std::vector<uint64_t> domain_ids_;

//! Thread settings for the DataSharing listener thread
rtps::ThreadSettings data_sharing_listener_thread_;
};


Expand Down
38 changes: 1 addition & 37 deletions include/fastdds/dds/subscriber/qos/DataReaderQos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <fastdds/dds/subscriber/qos/ReaderQos.hpp>
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
#include <fastdds/rtps/attributes/ReaderAttributes.h>
#include <fastdds/rtps/attributes/ThreadSettings.hpp>
#include <fastrtps/attributes/TopicAttributes.h>
#include <fastrtps/fastrtps_dll.h>

Expand Down Expand Up @@ -208,8 +207,7 @@ class DataReaderQos
(properties_ == b.properties()) &&
(endpoint_ == b.endpoint()) &&
(reader_resource_limits_ == b.reader_resource_limits()) &&
(data_sharing_ == b.data_sharing()) &&
(data_sharing_listener_thread_ == b.data_sharing_listener_thread());
(data_sharing_ == b.data_sharing());
}

RTPS_DllAPI ReaderQos get_readerqos(
Expand Down Expand Up @@ -856,37 +854,6 @@ class DataReaderQos
data_sharing_ = data_sharing;
}

/**
* Getter for data sharing listener ThreadSettings
*
* @return rtps::ThreadSettings reference
*/
RTPS_DllAPI rtps::ThreadSettings& data_sharing_listener_thread()
{
return data_sharing_listener_thread_;
}

/**
* Getter for data sharing listener ThreadSettings
*
* @return rtps::ThreadSettings reference
*/
RTPS_DllAPI const rtps::ThreadSettings& data_sharing_listener_thread() const
{
return data_sharing_listener_thread_;
}

/**
* Setter for data sharing listener ThreadSettings
*
* @param data_sharing_listener_thread new value for the rtps::ThreadSettings
*/
RTPS_DllAPI void data_sharing_listener_thread(
const rtps::ThreadSettings& data_sharing_listener_thread)
{
data_sharing_listener_thread_ = data_sharing_listener_thread;
}

private:

//!Durability Qos, implemented in the library.
Expand Down Expand Up @@ -951,9 +918,6 @@ class DataReaderQos

//!DataSharing configuration (Extension)
DataSharingQosPolicy data_sharing_;

//! Thread settings for the data-sharing listener thread
rtps::ThreadSettings data_sharing_listener_thread_;
};

RTPS_DllAPI extern const DataReaderQos DATAREADER_QOS_DEFAULT;
Expand Down
12 changes: 11 additions & 1 deletion include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,14 @@ class RTPSParticipantAttributes
(this->properties == b.properties) &&
(this->prefix == b.prefix) &&
(this->flow_controllers == b.flow_controllers) &&
(this->builtin_controllers_sender_thread == b.builtin_controllers_sender_thread);
(this->builtin_controllers_sender_thread == b.builtin_controllers_sender_thread) &&
(this->timed_events_thread == b.timed_events_thread) &&
#if HAVE_SECURITY
(this->security_log_thread == b.security_log_thread) &&
#endif // if HAVE_SECURITY
(this->discovery_server_thread == b.discovery_server_thread) &&
(this->builtin_transports_reception_threads == b.builtin_transports_reception_threads);

}

/**
Expand Down Expand Up @@ -588,6 +595,9 @@ class RTPSParticipantAttributes
//! Thread settings for the discovery server thread
fastdds::rtps::ThreadSettings discovery_server_thread;

//! Thread settings for the builtin transports reception threads
fastdds::rtps::ThreadSettings builtin_transports_reception_threads;

#if HAVE_SECURITY
//! Thread settings for the security log thread
fastdds::rtps::ThreadSettings security_log_thread;
Expand Down
79 changes: 70 additions & 9 deletions include/fastrtps/xmlparser/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@
#ifndef XML_PARSER_H_
#define XML_PARSER_H_

#include <stdio.h>
#include <fastrtps/transport/TransportDescriptorInterface.h>
#include <cstdint>
#include <cstdio>
#include <map>
#include <memory>
#include <string>

#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/rtps/attributes/ThreadSettings.hpp>
#include <fastdds/rtps/transport/PortBasedTransportDescriptor.hpp>
#include <fastdds/rtps/transport/SocketTransportDescriptor.h>
#include <fastrtps/attributes/LibrarySettingsAttributes.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/attributes/RequesterAttributes.hpp>
#include <fastrtps/attributes/ReplierAttributes.hpp>
#include <fastrtps/xmlparser/XMLParserCommon.h>
#include <fastrtps/attributes/RequesterAttributes.hpp>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/transport/TransportDescriptorInterface.h>
#include <fastrtps/types/DynamicTypeBuilderPtr.h>
#include <fastrtps/attributes/LibrarySettingsAttributes.h>

#include <map>
#include <string>
#include <fastrtps/xmlparser/XMLParserCommon.h>

namespace tinyxml2 {
class XMLElement;
Expand All @@ -52,6 +59,11 @@ typedef std::map<std::string, sp_transport_t> sp_transport_map_t;
typedef types::DynamicTypeBuilder* p_dynamictypebuilder_t;
typedef std::map<std::string, p_dynamictypebuilder_t> p_dynamictype_map_t;

typedef std::unique_ptr<fastdds::dds::DomainParticipantFactoryQos> up_participantfactory_t;
typedef DataNode<fastdds::dds::DomainParticipantFactoryQos> node_participantfactory_t;
typedef node_participantfactory_t* p_node_participantfactory_t;
typedef std::unique_ptr<node_participantfactory_t> up_node_participantfactory_t;

typedef std::unique_ptr<ParticipantAttributes> up_participant_t;
typedef DataNode<ParticipantAttributes> node_participant_t;
typedef node_participant_t* p_node_participant_t;
Expand Down Expand Up @@ -177,6 +189,10 @@ class XMLParser
RTPS_DllAPI static XMLP_ret parseXMLTransportsProf(
tinyxml2::XMLElement* p_root);

RTPS_DllAPI static XMLP_ret parseXMLDomainParticipantFactoryProf(
tinyxml2::XMLElement* p_root,
BaseNode& rootNode);

RTPS_DllAPI static XMLP_ret parseXMLParticipantProf(
tinyxml2::XMLElement* p_root,
BaseNode& rootNode);
Expand Down Expand Up @@ -204,10 +220,21 @@ class XMLParser
RTPS_DllAPI static XMLP_ret parseXMLTransportData(
tinyxml2::XMLElement* p_root);

RTPS_DllAPI static XMLP_ret validateXMLTransportElements(
tinyxml2::XMLElement& p_root);

RTPS_DllAPI static XMLP_ret parseXMLCommonTransportData(
tinyxml2::XMLElement* p_root,
sp_transport_t p_transport);

RTPS_DllAPI static XMLP_ret parseXMLPortBasedTransportData(
tinyxml2::XMLElement* p_root,
std::shared_ptr<fastdds::rtps::PortBasedTransportDescriptor> p_transport);

RTPS_DllAPI static XMLP_ret parseXMLSocketTransportData(
tinyxml2::XMLElement* p_root,
std::shared_ptr<fastdds::rtps::SocketTransportDescriptor> p_transport);

RTPS_DllAPI static XMLP_ret parseXMLCommonTCPTransportData(
tinyxml2::XMLElement* p_root,
sp_transport_t p_transport);
Expand All @@ -220,6 +247,10 @@ class XMLParser
tinyxml2::XMLElement* p_root,
sp_transport_t tcp_transport);

RTPS_DllAPI static XMLP_ret parseXMLReceptionThreads(
tinyxml2::XMLElement& p_root,
fastdds::rtps::PortBasedTransportDescriptor::ReceptionThreadsConfigMap& reception_threads);

/**
* Load a XML consumer node and parses it. Adds the parsed consumer to Log directly.
* @param consumer Node to be loaded.
Expand Down Expand Up @@ -280,6 +311,10 @@ class XMLParser
types::MemberId mId,
const std::string& values);

RTPS_DllAPI static XMLP_ret fillDataNode(
tinyxml2::XMLElement* p_profile,
DataNode<fastdds::dds::DomainParticipantFactoryQos>& factory_node);

RTPS_DllAPI static XMLP_ret fillDataNode(
tinyxml2::XMLElement* p_profile,
DataNode<ParticipantAttributes>& participant_node);
Expand Down Expand Up @@ -549,6 +584,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 @@ -599,6 +639,10 @@ class XMLParser
rtps::GuidPrefix_t& prefix,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLDomainParticipantFactoryQos(
tinyxml2::XMLElement& elem,
fastdds::dds::DomainParticipantFactoryQos& qos);

RTPS_DllAPI static XMLP_ret getXMLPublisherAttributes(
tinyxml2::XMLElement* elem,
PublisherAttributes& publisher,
Expand All @@ -608,6 +652,23 @@ class XMLParser
tinyxml2::XMLElement* elem,
SubscriberAttributes& subscriber,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLThreadSettings(
tinyxml2::XMLElement& elem,
fastdds::rtps::ThreadSettings& thread_setting);

/*
Return XMLP_ret::XML_OK when OK, XMLP_ret::XML_NOK when port attribute is not present, and
XMLP_ret::XML_ERROR if error
*/
RTPS_DllAPI static XMLP_ret getXMLThreadSettingsWithPort(
tinyxml2::XMLElement& elem,
fastdds::rtps::ThreadSettings& thread_setting,
uint32_t& port);

RTPS_DllAPI static XMLP_ret getXMLEntityFactoryQos(
tinyxml2::XMLElement& elem,
fastdds::dds::EntityFactoryQosPolicy& entity_factory);
};

} // namespace xmlparser
Expand Down
22 changes: 22 additions & 0 deletions include/fastrtps/xmlparser/XMLParserCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern const char* LIBRARY_SETTINGS;
extern const char* TRANSPORT_DESCRIPTORS;
extern const char* PROFILE_NAME;
extern const char* DEFAULT_PROF;
extern const char* DOMAINPARTICIPANT_FACTORY;
extern const char* PARTICIPANT;
extern const char* PUBLISHER;
extern const char* SUBSCRIBER;
Expand Down Expand Up @@ -80,8 +81,17 @@ extern const char* HEALTHY_CHECK_TIMEOUT_MS;
extern const char* DISCARD;
extern const char* FAIL;
extern const char* RTPS_DUMP_FILE;
extern const char* DEFAULT_RECEPTION_THREADS;
extern const char* RECEPTION_THREADS;
extern const char* RECEPTION_THREAD;
extern const char* DUMP_THREAD;
extern const char* ON;
extern const char* AUTO;
extern const char* THREAD_SETTINGS;
extern const char* SCHEDULING_POLICY;
extern const char* PRIORITY;
extern const char* AFFINITY;
extern const char* STACK_SIZE;

// IntraprocessDeliveryType
extern const char* OFF;
Expand All @@ -98,6 +108,12 @@ extern const char* DATA_READER;
/// LibrarySettings attributes
extern const char* INTRAPROCESS_DELIVERY;

/// DomainParticipantFactory Qos
extern const char* ENTITY_FACTORY;
extern const char* AUTOENABLE_CREATED_ENTITIES;
extern const char* SHM_WATCHDOG_THREAD;
extern const char* FILE_WATCH_THREADS;

/// RTPS Participant attributes
extern const char* ALLOCATION;
extern const char* PREFIX;
Expand Down Expand Up @@ -132,6 +148,11 @@ extern const char* DYNAMIC_LC;
extern const char* MAX_PROPERTIES;
extern const char* MAX_USER_DATA;
extern const char* MAX_PARTITIONS;
extern const char* TIMED_EVENTS_THREAD;
extern const char* DISCOVERY_SERVER_THREAD;
extern const char* SECURITY_LOG_THREAD;
extern const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS;
extern const char* BUILTIN_CONTROLLERS_SENDER_THREAD;

/// Publisher-subscriber attributes
extern const char* TOPIC;
Expand All @@ -149,6 +170,7 @@ extern const char* USER_DEF_ID;
extern const char* ENTITY_ID;
extern const char* MATCHED_SUBSCRIBERS_ALLOCATION;
extern const char* MATCHED_PUBLISHERS_ALLOCATION;
extern const char* DATA_SHARING_LISTENER_THREAD;

///
extern const char* IGN_NON_MATCHING_LOCS;
Expand Down
Loading

0 comments on commit b28f462

Please sign in to comment.