From ae5d33e9316534b68e5672a9fd00fa00559b213e Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 4 Apr 2024 10:16:59 +0200 Subject: [PATCH 01/10] Refs #20739: Make monitor service interfaces private (except IProxyQueryable) Signed-off-by: Mario Dominguez --- .../rtps/monitor_service/connections_fwd.hpp | 38 +++++++++++++++++++ .../rtps/monitor-service}/Interfaces.hpp | 11 +++--- .../interfaces/IConnectionsObserver.hpp | 5 +-- .../interfaces/IConnectionsQueryable.hpp | 11 ++---- .../interfaces/IProxyObserver.hpp | 0 .../interfaces/IStatusObserver.hpp | 0 .../interfaces/IStatusQueryable.hpp | 13 ++----- 7 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp rename {include/fastdds/statistics/rtps/monitor_service => src/cpp/statistics/rtps/monitor-service}/Interfaces.hpp (68%) rename {include/fastdds/statistics/rtps/monitor_service => src/cpp/statistics/rtps/monitor-service}/interfaces/IConnectionsObserver.hpp (95%) rename {include/fastdds/statistics/rtps/monitor_service => src/cpp/statistics/rtps/monitor-service}/interfaces/IConnectionsQueryable.hpp (80%) rename {include/fastdds/statistics/rtps/monitor_service => src/cpp/statistics/rtps/monitor-service}/interfaces/IProxyObserver.hpp (100%) rename {include/fastdds/statistics/rtps/monitor_service => src/cpp/statistics/rtps/monitor-service}/interfaces/IStatusObserver.hpp (100%) rename {include/fastdds/statistics/rtps/monitor_service => src/cpp/statistics/rtps/monitor-service}/interfaces/IStatusQueryable.hpp (84%) diff --git a/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp new file mode 100644 index 00000000000..0f6ee4ef799 --- /dev/null +++ b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +/** + * @file connection_fwd.hpp + * + */ + +#ifndef _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_ +#define _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_ + +namespace eprosima { +namespace fastdds { +namespace statistics { + +class Connection; + +namespace rtps { + +using ConnectionList = std::vector; + +} // rtps +} // statistics +} // fastdds +} // eprosima + +#endif // _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_ diff --git a/include/fastdds/statistics/rtps/monitor_service/Interfaces.hpp b/src/cpp/statistics/rtps/monitor-service/Interfaces.hpp similarity index 68% rename from include/fastdds/statistics/rtps/monitor_service/Interfaces.hpp rename to src/cpp/statistics/rtps/monitor-service/Interfaces.hpp index df63506ff5a..c1d6c34e48a 100644 --- a/include/fastdds/statistics/rtps/monitor_service/Interfaces.hpp +++ b/src/cpp/statistics/rtps/monitor-service/Interfaces.hpp @@ -20,12 +20,13 @@ #ifndef _FASTDDS_STATISTICS_MONITOR_SERVICE_INTERFACES_HPP_ #define _FASTDDS_STATISTICS_MONITOR_SERVICE_INTERFACES_HPP_ -#include -#include -#include #include -#include -#include + +#include "interfaces/IConnectionsObserver.hpp" +#include "interfaces/IConnectionsQueryable.hpp" +#include "interfaces/IProxyObserver.hpp" +#include "interfaces/IStatusObserver.hpp" +#include "interfaces/IStatusQueryable.hpp" #endif // _FASTDDS_STATISTICS_MONITOR_SERVICE_INTERFACES_HPP_ diff --git a/include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsObserver.hpp b/src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsObserver.hpp similarity index 95% rename from include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsObserver.hpp rename to src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsObserver.hpp index 40b4b351764..bc64267fa5a 100644 --- a/include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsObserver.hpp +++ b/src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsObserver.hpp @@ -23,16 +23,13 @@ #include #include +#include namespace eprosima { namespace fastdds { namespace statistics { namespace rtps { -using namespace eprosima::fastdds::statistics; - -class Connection; - struct IConnectionsObserver { /** diff --git a/include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp b/src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsQueryable.hpp similarity index 80% rename from include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp rename to src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsQueryable.hpp index a168978551a..3e8974b5394 100644 --- a/include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp +++ b/src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsQueryable.hpp @@ -17,22 +17,20 @@ * */ -#ifndef _FASTDDS_STATISTICS_MONITOR_SERVICE_INTERFACES_ICONNECTIONSQUERYABLE_HPP_ -#define _FASTDDS_STATISTICS_MONITOR_SERVICE_INTERFACES_ICONNECTIONSQUERYABLE_HPP_ +#ifndef _STATISTICS_MONITOR_SERVICE_INTERFACES_ICONNECTIONSQUERYABLE_HPP_ +#define _STATISTICS_MONITOR_SERVICE_INTERFACES_ICONNECTIONSQUERYABLE_HPP_ #include #include +#include namespace eprosima { namespace fastdds { namespace statistics { -class Connection; namespace rtps { -using ConnectionList = std::vector; - struct IConnectionsQueryable { /** @@ -54,5 +52,4 @@ struct IConnectionsQueryable } // fastdds } // eprosima -#endif // _FASTDDS_STATISTICS_MONITOR_SERVICE_INTERFACES_ICONNECTIONSQUERYABLE_HPP_ - +#endif // _STATISTICS_MONITOR_SERVICE_INTERFACES_ICONNECTIONSQUERYABLE_HPP_ diff --git a/include/fastdds/statistics/rtps/monitor_service/interfaces/IProxyObserver.hpp b/src/cpp/statistics/rtps/monitor-service/interfaces/IProxyObserver.hpp similarity index 100% rename from include/fastdds/statistics/rtps/monitor_service/interfaces/IProxyObserver.hpp rename to src/cpp/statistics/rtps/monitor-service/interfaces/IProxyObserver.hpp diff --git a/include/fastdds/statistics/rtps/monitor_service/interfaces/IStatusObserver.hpp b/src/cpp/statistics/rtps/monitor-service/interfaces/IStatusObserver.hpp similarity index 100% rename from include/fastdds/statistics/rtps/monitor_service/interfaces/IStatusObserver.hpp rename to src/cpp/statistics/rtps/monitor-service/interfaces/IStatusObserver.hpp diff --git a/include/fastdds/statistics/rtps/monitor_service/interfaces/IStatusQueryable.hpp b/src/cpp/statistics/rtps/monitor-service/interfaces/IStatusQueryable.hpp similarity index 84% rename from include/fastdds/statistics/rtps/monitor_service/interfaces/IStatusQueryable.hpp rename to src/cpp/statistics/rtps/monitor-service/interfaces/IStatusQueryable.hpp index 7d63156f6da..9d11045cfc8 100644 --- a/include/fastdds/statistics/rtps/monitor_service/interfaces/IStatusQueryable.hpp +++ b/src/cpp/statistics/rtps/monitor-service/interfaces/IStatusQueryable.hpp @@ -26,19 +26,13 @@ #include #include +#include + namespace eprosima { namespace fastdds { namespace statistics { namespace rtps { -struct DDSEntityStatus : public eprosima::fastdds::dds::IncompatibleQosStatus, - public eprosima::fastdds::dds::BaseStatus, - public eprosima::fastdds::dds::LivelinessChangedStatus, - public eprosima::fastdds::dds::DeadlineMissedStatus -{ - -}; - struct IStatusQueryable { /** @@ -52,8 +46,7 @@ struct IStatusQueryable */ virtual bool get_monitoring_status( const fastrtps::rtps::GUID_t& guid, - const uint32_t& status_kind, - DDSEntityStatus*& status) = 0; + MonitorServiceData& status) = 0; }; From d493ab0e68fc13e3823e2a3b804a3b0bc672298b Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 4 Apr 2024 10:17:38 +0200 Subject: [PATCH 02/10] Refs #20739: Replace tabs with spaces in monitorservice_types.idl Signed-off-by: Mario Dominguez --- .../statistics/monitorservice_types.idl | 186 +++++++++--------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/include/fastdds/statistics/monitorservice_types.idl b/include/fastdds/statistics/monitorservice_types.idl index 0b7ec9e09cd..ff4bc1393ef 100644 --- a/include/fastdds/statistics/monitorservice_types.idl +++ b/include/fastdds/statistics/monitorservice_types.idl @@ -22,99 +22,99 @@ module eprosima { module fastdds { module statistics { - enum ConnectionMode - { - DATA_SHARING, - INTRAPROCESS, - TRANSPORT - }; - - struct Connection - { - ConnectionMode mode; - detail::GUID_s guid; - sequence announced_locators; - sequence used_locators; - }; - - struct QosPolicyCount_s - { - unsigned long policy_id; - unsigned long count; - }; - - struct BaseStatus_s - { - unsigned long total_count; - }; - - typedef sequence QosPolicyCountSeq_s; - - struct IncompatibleQoSStatus_s - { - unsigned long total_count; - unsigned long last_policy_id; - QosPolicyCountSeq_s policies; - }; - - struct LivelinessChangedStatus_s - { - unsigned long alive_count; - unsigned long not_alive_count; - octet last_publication_handle[16]; - }; - - struct DeadlineMissedStatus_s - { - unsigned long total_count; - octet last_instance_handle[16]; - }; - - typedef BaseStatus_s LivelinessLostStatus_s; - typedef BaseStatus_s InconsistentTopicStatus_s; - typedef BaseStatus_s SampleLostStatus_s; - - enum StatusKind - { - PROXY, - CONNECTION_LIST, - INCOMPATIBLE_QOS, - INCONSISTENT_TOPIC, - LIVELINESS_LOST, - LIVELINESS_CHANGED, - DEADLINE_MISSED, - SAMPLE_LOST, - STATUSES_SIZE - }; - - union MonitorServiceData switch(StatusKind) - { - case PROXY: - sequence entity_proxy; - case CONNECTION_LIST: - sequence connection_list; - case INCOMPATIBLE_QOS: - IncompatibleQoSStatus_s incompatible_qos_status; - case INCONSISTENT_TOPIC: - InconsistentTopicStatus_s inconsistent_topic_status; - case LIVELINESS_LOST: - LivelinessLostStatus_s liveliness_lost_status; - case LIVELINESS_CHANGED: - LivelinessChangedStatus_s liveliness_changed_status; - case DEADLINE_MISSED: - DeadlineMissedStatus_s deadline_missed_status; - case SAMPLE_LOST: - SampleLostStatus_s sample_lost_status; - case STATUSES_SIZE: - octet statuses_size; - }; - - struct MonitorServiceStatusData - { - @Key detail::GUID_s local_entity; - @Key StatusKind status_kind; - MonitorServiceData value; - }; + enum ConnectionMode + { + DATA_SHARING, + INTRAPROCESS, + TRANSPORT + }; + + struct Connection + { + ConnectionMode mode; + detail::GUID_s guid; + sequence announced_locators; + sequence used_locators; + }; + + struct QosPolicyCount_s + { + unsigned long policy_id; + unsigned long count; + }; + + struct BaseStatus_s + { + unsigned long total_count; + }; + + typedef sequence QosPolicyCountSeq_s; + + struct IncompatibleQoSStatus_s + { + unsigned long total_count; + unsigned long last_policy_id; + QosPolicyCountSeq_s policies; + }; + + struct LivelinessChangedStatus_s + { + unsigned long alive_count; + unsigned long not_alive_count; + octet last_publication_handle[16]; + }; + + struct DeadlineMissedStatus_s + { + unsigned long total_count; + octet last_instance_handle[16]; + }; + + typedef BaseStatus_s LivelinessLostStatus_s; + typedef BaseStatus_s InconsistentTopicStatus_s; + typedef BaseStatus_s SampleLostStatus_s; + + enum StatusKind + { + PROXY, + CONNECTION_LIST, + INCOMPATIBLE_QOS, + INCONSISTENT_TOPIC, + LIVELINESS_LOST, + LIVELINESS_CHANGED, + DEADLINE_MISSED, + SAMPLE_LOST, + STATUSES_SIZE + }; + + union MonitorServiceData switch(StatusKind) + { + case PROXY: + sequence entity_proxy; + case CONNECTION_LIST: + sequence connection_list; + case INCOMPATIBLE_QOS: + IncompatibleQoSStatus_s incompatible_qos_status; + case INCONSISTENT_TOPIC: + InconsistentTopicStatus_s inconsistent_topic_status; + case LIVELINESS_LOST: + LivelinessLostStatus_s liveliness_lost_status; + case LIVELINESS_CHANGED: + LivelinessChangedStatus_s liveliness_changed_status; + case DEADLINE_MISSED: + DeadlineMissedStatus_s deadline_missed_status; + case SAMPLE_LOST: + SampleLostStatus_s sample_lost_status; + case STATUSES_SIZE: + octet statuses_size; + }; + + struct MonitorServiceStatusData + { + @Key detail::GUID_s local_entity; + @Key StatusKind status_kind; + MonitorServiceData value; + }; }; // namespace statisitcs }; // namespace fastdds From 33ce4baabe9304c59e4a8f593dfa03a5e3c5b304 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 4 Apr 2024 10:19:03 +0200 Subject: [PATCH 03/10] Refs #20739: Refactor include and src files Signed-off-by: Mario Dominguez --- .../rtps/builtin/discovery/participant/PDP.h | 9 +- include/fastdds/rtps/reader/RTPSReader.h | 5 +- include/fastdds/rtps/writer/RTPSWriter.h | 5 +- src/cpp/fastdds/publisher/PublisherImpl.cpp | 31 +++++-- src/cpp/fastdds/publisher/PublisherImpl.hpp | 5 +- src/cpp/fastdds/subscriber/SubscriberImpl.cpp | 41 ++++++++-- src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 5 +- .../rtps/builtin/discovery/endpoint/EDP.cpp | 3 + .../builtin/discovery/endpoint/EDPSimple.cpp | 3 + .../discovery/participant/PDPListener.cpp | 2 +- .../rtps/participant/RTPSParticipantImpl.h | 3 +- .../fastdds/domain/DomainParticipantImpl.cpp | 7 +- .../fastdds/domain/DomainParticipantImpl.hpp | 5 +- .../rtps/monitor-service/MonitorService.cpp | 82 ++++--------------- .../rtps/monitor-service/MonitorService.hpp | 5 +- .../MonitorServiceListener.hpp | 3 +- 16 files changed, 104 insertions(+), 110 deletions(-) diff --git a/include/fastdds/rtps/builtin/discovery/participant/PDP.h b/include/fastdds/rtps/builtin/discovery/participant/PDP.h index d30d5cbc0d6..a94d40a4e37 100644 --- a/include/fastdds/rtps/builtin/discovery/participant/PDP.h +++ b/include/fastdds/rtps/builtin/discovery/participant/PDP.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,14 @@ namespace eprosima { namespace fastdds { +namespace statistics { +namespace rtps { + +struct IProxyObserver; + +} // namespace rtps +} // namespace statistics + namespace rtps { class PDPServerListener; diff --git a/include/fastdds/rtps/reader/RTPSReader.h b/include/fastdds/rtps/reader/RTPSReader.h index e4d9383cddf..6db4528e617 100644 --- a/include/fastdds/rtps/reader/RTPSReader.h +++ b/include/fastdds/rtps/reader/RTPSReader.h @@ -29,10 +29,7 @@ #include #include #include -#ifdef FASTDDS_STATISTICS -#include -#include -#endif // ifdef FASTDDS_STATISTICS +#include #include #include #include diff --git a/include/fastdds/rtps/writer/RTPSWriter.h b/include/fastdds/rtps/writer/RTPSWriter.h index 16f2f76a7d4..6faad6b225a 100644 --- a/include/fastdds/rtps/writer/RTPSWriter.h +++ b/include/fastdds/rtps/writer/RTPSWriter.h @@ -33,10 +33,7 @@ #include #include #include -#ifdef FASTDDS_STATISTICS -#include -#include -#endif // ifdef FASTDDS_STATISTICS +#include #include #include diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index 27bffd155ff..114f0160435 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -670,8 +670,7 @@ PublisherListener* PublisherImpl::get_listener_for( #ifdef FASTDDS_STATISTICS bool PublisherImpl::get_monitoring_status( - const uint32_t& status_id, - statistics::rtps::DDSEntityStatus*& status, + statistics::MonitorServiceData& status, const fastrtps::rtps::GUID_t& entity_guid) { bool ret = false; @@ -682,11 +681,21 @@ bool PublisherImpl::get_monitoring_status( { if (writer->guid() == entity_guid) { - switch (status_id) + switch (status._d()) { case statistics::INCOMPATIBLE_QOS: { - writer->get_offered_incompatible_qos_status(*static_cast(status)); + OfferedIncompatibleQosStatus incompatible_qos_status; + writer->get_offered_incompatible_qos_status(incompatible_qos_status); + status.incompatible_qos_status().total_count(incompatible_qos_status.total_count); + status.incompatible_qos_status().last_policy_id(incompatible_qos_status.last_policy_id); + for (auto& qos : incompatible_qos_status.policies) + { + statistics::QosPolicyCount_s count; + count.count(qos.count); + count.policy_id(qos.policy_id); + status.incompatible_qos_status().policies().push_back(count); + } ret = true; break; } @@ -699,19 +708,27 @@ bool PublisherImpl::get_monitoring_status( }*/ case statistics::LIVELINESS_LOST: { - writer->get_liveliness_lost_status(*static_cast(status)); + LivelinessLostStatus liveliness_lost_status; + writer->get_liveliness_lost_status(liveliness_lost_status); + status.liveliness_lost_status().total_count(liveliness_lost_status.total_count); ret = true; break; } case statistics::DEADLINE_MISSED: { - writer->get_offered_deadline_missed_status(*static_cast(status)); + DeadlineMissedStatus deadline_missed_status; + writer->get_offered_deadline_missed_status(deadline_missed_status); + status.deadline_missed_status().total_count(deadline_missed_status.total_count); + std::memcpy( + status.deadline_missed_status().last_instance_handle().data(), + deadline_missed_status.last_instance_handle.value, + 16); ret = true; break; } default: { - EPROSIMA_LOG_ERROR(PUBLISHER, "Queried status not available for this entity " << status_id); + EPROSIMA_LOG_ERROR(PUBLISHER, "Queried status not available for this entity " << status._d()); break; } } diff --git a/src/cpp/fastdds/publisher/PublisherImpl.hpp b/src/cpp/fastdds/publisher/PublisherImpl.hpp index deed3110d5b..39f19b2afed 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.hpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.hpp @@ -36,7 +36,7 @@ #include #ifdef FASTDDS_STATISTICS -#include +#include #endif // ifdef FASTDDS_STATISTICS using eprosima::fastrtps::types::ReturnCode_t; @@ -206,8 +206,7 @@ class PublisherImpl #ifdef FASTDDS_STATISTICS bool get_monitoring_status( - const uint32_t& status_id, - statistics::rtps::DDSEntityStatus*& status, + statistics::MonitorServiceData& status, const fastrtps::rtps::GUID_t& entity_guid); #endif //FASTDDS_STATISTICS diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index 862f297314b..53ea9a17b72 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -687,8 +687,7 @@ bool SubscriberImpl::can_be_deleted() const #ifdef FASTDDS_STATISTICS bool SubscriberImpl::get_monitoring_status( - const uint32_t& status_id, - statistics::rtps::DDSEntityStatus*& status, + statistics::MonitorServiceData& status, const fastrtps::rtps::GUID_t& entity_guid) { bool ret = false; @@ -699,12 +698,21 @@ bool SubscriberImpl::get_monitoring_status( { if (reader->guid() == entity_guid) { - switch (status_id) + switch (status._d()) { case statistics::INCOMPATIBLE_QOS: { - reader->get_requested_incompatible_qos_status(*static_cast( - status)); + RequestedIncompatibleQosStatus incompatible_qos_status; + reader->get_requested_incompatible_qos_status(incompatible_qos_status); + status.incompatible_qos_status().total_count(incompatible_qos_status.total_count); + status.incompatible_qos_status().last_policy_id(incompatible_qos_status.last_policy_id); + for (auto& qos : incompatible_qos_status.policies) + { + statistics::QosPolicyCount_s count; + count.count(qos.count); + count.policy_id(qos.policy_id); + status.incompatible_qos_status().policies().push_back(count); + } ret = true; break; } @@ -717,25 +725,40 @@ bool SubscriberImpl::get_monitoring_status( }*/ case statistics::LIVELINESS_CHANGED: { - reader->get_liveliness_changed_status(*static_cast(status)); + LivelinessChangedStatus liveliness_changed_status; + reader->get_liveliness_changed_status(liveliness_changed_status); + status.liveliness_changed_status().alive_count(liveliness_changed_status.alive_count); + status.liveliness_changed_status().not_alive_count(liveliness_changed_status.not_alive_count); + std::memcpy( + status.liveliness_changed_status().last_publication_handle().data(), + liveliness_changed_status.last_publication_handle.value, + 16); ret = true; break; } case statistics::DEADLINE_MISSED: { - reader->get_requested_deadline_missed_status(*static_cast(status)); + DeadlineMissedStatus deadline_missed_status; + reader->get_requested_deadline_missed_status(deadline_missed_status); + status.deadline_missed_status().total_count(deadline_missed_status.total_count); + std::memcpy( + status.deadline_missed_status().last_instance_handle().data(), + deadline_missed_status.last_instance_handle.value, + 16); ret = true; break; } case statistics::SAMPLE_LOST: { - reader->get_sample_lost_status(*static_cast(status)); + SampleLostStatus sample_lost_status; + reader->get_sample_lost_status(sample_lost_status); + status.sample_lost_status().total_count(sample_lost_status.total_count); ret = true; break; } default: { - EPROSIMA_LOG_ERROR(SUBSCRIBER, "Queried status not available for this entity " << status_id); + EPROSIMA_LOG_ERROR(SUBSCRIBER, "Queried status not available for this entity " << status._d()); break; } } diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index f5766ebefbc..6789ee252c6 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -231,8 +231,7 @@ class SubscriberImpl #ifdef FASTDDS_STATISTICS bool get_monitoring_status( - const uint32_t& status_id, - statistics::rtps::DDSEntityStatus*& status, + statistics::MonitorServiceData& status, const fastrtps::rtps::GUID_t& entity_guid); #endif //FASTDDS_STATISTICS diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 2bd7584f9f6..53ebb47275b 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -46,6 +46,9 @@ #include #include #include +#ifdef FASTDDS_STATISTICS +#include +#endif //FASTDDS_STATISTICS #include diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index 0466f149535..521400becce 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -37,6 +37,9 @@ #include #include +#ifdef FASTDDS_STATISTICS +#include +#endif //FASTDDS_STATISTICS #include diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index d116e0f74d4..a6d210faa94 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -39,7 +39,7 @@ #include #ifdef FASTDDS_STATISTICS -#include +#include #endif //FASTDDS_STATISTICS using ParameterList = eprosima::fastdds::dds::ParameterList; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index b091f6cbf77..c952def70f0 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -55,6 +54,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp index 7440faa2d6d..afd8aa662ec 100644 --- a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp @@ -624,8 +624,7 @@ bool DomainParticipantImpl::delete_topic_and_type( bool DomainParticipantImpl::get_monitoring_status( const fastrtps::rtps::GUID_t& entity_guid, - const uint32_t& status_id, - eprosima::fastdds::statistics::rtps::DDSEntityStatus*& status) + eprosima::fastdds::statistics::MonitorServiceData& status) { ReturnCode_t ret = ReturnCode_t::RETCODE_ERROR; @@ -634,7 +633,7 @@ bool DomainParticipantImpl::get_monitoring_status( std::lock_guard lock(mtx_subs_); for (auto& sub : subscribers_) { - if (sub.second->get_monitoring_status(status_id, status, entity_guid)) + if (sub.second->get_monitoring_status(status, entity_guid)) { ret = ReturnCode_t::RETCODE_OK; break; @@ -646,7 +645,7 @@ bool DomainParticipantImpl::get_monitoring_status( std::lock_guard lock(mtx_pubs_); for (auto& pub : publishers_) { - if (pub.second->get_monitoring_status(status_id, status, entity_guid)) + if (pub.second->get_monitoring_status(status, entity_guid)) { ret = ReturnCode_t::RETCODE_OK; break; diff --git a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp index 104f432c2bb..cec232c6ec0 100644 --- a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include "DomainParticipantStatisticsListener.hpp" +#include namespace efd = eprosima::fastdds::dds; @@ -290,8 +290,7 @@ class DomainParticipantImpl : public efd::DomainParticipantImpl, */ bool get_monitoring_status( const fastrtps::rtps::GUID_t& entity_guid, - const uint32_t& status_id, - eprosima::fastdds::statistics::rtps::DDSEntityStatus*&) override; + eprosima::fastdds::statistics::MonitorServiceData&) override; efd::Publisher* builtin_publisher_ = nullptr; PublisherImpl* builtin_publisher_impl_ = nullptr; diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 31dff974f47..b183c78c101 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -32,31 +32,6 @@ using namespace eprosima::fastrtps::rtps; namespace eprosima { namespace fastdds { namespace statistics { - -dds::IncompatibleQosStatus* to_fastdds_type( - IncompatibleQoSStatus_s& incompatible_qos) -{ - return reinterpret_cast(&incompatible_qos); -} - -dds::LivelinessChangedStatus* to_fastdds_type( - LivelinessChangedStatus_s& liv_changed) -{ - return reinterpret_cast(&liv_changed); -} - -dds::LivelinessLostStatus* to_fastdds_type( - LivelinessLostStatus_s& liv_lost) -{ - return reinterpret_cast(&liv_lost); -} - -dds::DeadlineMissedStatus* to_fastdds_type( - DeadlineMissedStatus_s& deadline_missed) -{ - return reinterpret_cast(&deadline_missed); -} - namespace rtps { MonitorService::MonitorService( @@ -325,24 +300,14 @@ bool MonitorService::write_status( } case INCOMPATIBLE_QOS: { - rtps::DDSEntityStatus* dds_entity_status = new rtps::DDSEntityStatus; - status_queryable_.get_monitoring_status(local_entity_guid, INCOMPATIBLE_QOS, dds_entity_status); - - assert(nullptr != dds_entity_status); - - IncompatibleQoSStatus_s incompatible_qos_status; - incompatible_qos_status.policies().resize(dds_entity_status->policies.size()); - dds::QosPolicyCountSeq* qos_policy_countseq = &dds_entity_status->policies; - incompatible_qos_status.policies() = - *reinterpret_cast(qos_policy_countseq); - incompatible_qos_status.last_policy_id() = dds_entity_status->last_policy_id; - incompatible_qos_status.total_count() = - static_cast(dds_entity_status)-> - total_count; - - data.incompatible_qos_status(std::move(incompatible_qos_status)); - delete dds_entity_status; - + data.incompatible_qos_status(IncompatibleQoSStatus_s{}); + if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) + { + EPROSIMA_LOG_ERROR(MONITOR_SERVICE, + "Could not retrieve the incompatible qos entity status "); + status_retrieved = false; + assert(false); + } break; } //Not triggered for the moment @@ -354,12 +319,8 @@ bool MonitorService::write_status( } case LIVELINESS_LOST: { - data.liveliness_lost_status(LivelinessLostStatus_s()); - DDSEntityStatus* liv_lost_status = - static_cast(to_fastdds_type( - data.liveliness_lost_status())); - if (!status_queryable_.get_monitoring_status(local_entity_guid, LIVELINESS_LOST, - liv_lost_status)) + data.liveliness_lost_status(LivelinessLostStatus_s{}); + if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the liveliness lost entity status "); @@ -371,12 +332,8 @@ bool MonitorService::write_status( } case LIVELINESS_CHANGED: { - data.liveliness_changed_status(LivelinessChangedStatus_s()); - DDSEntityStatus* liv_changed_status = - static_cast(to_fastdds_type( - data.liveliness_changed_status())); - if (!status_queryable_.get_monitoring_status(local_entity_guid, LIVELINESS_CHANGED, - liv_changed_status)) + data.liveliness_changed_status(LivelinessChangedStatus_s{}); + if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the liveliness changed entity status"); @@ -388,12 +345,8 @@ bool MonitorService::write_status( } case DEADLINE_MISSED: { - data.deadline_missed_status(DeadlineMissedStatus_s()); - DDSEntityStatus* deadline_missed_status = - static_cast(to_fastdds_type( - data.deadline_missed_status())); - if (!status_queryable_.get_monitoring_status(local_entity_guid, DEADLINE_MISSED, - deadline_missed_status)) + data.deadline_missed_status(DeadlineMissedStatus_s{}); + if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the deadline missed entity status"); status_retrieved = false; @@ -403,11 +356,8 @@ bool MonitorService::write_status( } case SAMPLE_LOST: { - data.sample_lost_status(SampleLostStatus_s()); - DDSEntityStatus* sample_lost_status = - static_cast(to_fastdds_type(data.sample_lost_status())); - if (!status_queryable_.get_monitoring_status(local_entity_guid, SAMPLE_LOST, - sample_lost_status)) + data.sample_lost_status(SampleLostStatus_s{}); + if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the sample lost entity status"); status_retrieved = false; diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp index 985d3ad1678..c9780829016 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp @@ -31,9 +31,9 @@ #include #include #include -#include #include +#include "Interfaces.hpp" #include #include #include @@ -59,8 +59,7 @@ class SimpleQueryable : public IStatusQueryable inline bool get_monitoring_status( const fastrtps::rtps::GUID_t&, - const uint32_t&, - rtps::DDSEntityStatus*&) override + MonitorServiceData&) override { return true; } diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorServiceListener.hpp b/src/cpp/statistics/rtps/monitor-service/MonitorServiceListener.hpp index 358c9f963d7..4b1a85b4b76 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorServiceListener.hpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorServiceListener.hpp @@ -21,7 +21,8 @@ #include -#include + +#include "Interfaces.hpp" namespace eprosima { namespace fastdds { From fd4005bf3639470d3727bb93a33addc54afeab76 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 4 Apr 2024 10:19:18 +0200 Subject: [PATCH 04/10] Refs #20739: Refactor tests Signed-off-by: Mario Dominguez --- .../rtps/builtin/discovery/participant/PDP.h | 15 +++-- .../rtps/participant/RTPSParticipant.h | 3 +- ...sDomainParticipantStatusQueryableTests.cpp | 65 +++++++++---------- .../statistics/rtps/MonitorServiceTests.cpp | 15 ++--- .../statistics/rtps/RTPSStatisticsTests.cpp | 2 +- .../rtps/monitor-service/MonitorService.hpp | 2 +- 6 files changed, 52 insertions(+), 50 deletions(-) diff --git a/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h b/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h index bfb56ea780f..c2d3f232f60 100644 --- a/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h +++ b/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h @@ -27,11 +27,18 @@ #include -#ifdef FASTDDS_STATISTICS -#include -#endif // ifdef FASTDDS_STATISTICS - namespace eprosima { + +namespace fastdds { +namespace statistics { +namespace rtps { + +struct IProxyObserver; + +} // namespace rtps +} // namespace statistics +} // namespace fastdds + namespace fastrtps { namespace rtps { diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h index 51817bddd94..26326c84327 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h @@ -23,13 +23,14 @@ #include #include #include -#include #include #include #include #include +#include + namespace eprosima { namespace fastdds { diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp index 09558402292..e9c3dec1e3f 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp @@ -131,10 +131,9 @@ class DomainParticipantImplTest : public DomainParticipantImpl bool monitoring_status( fastrtps::rtps::GUID_t guid, - uint32_t status_id, - fastdds::statistics::rtps::DDSEntityStatus*& status) + statistics::MonitorServiceData& status) { - return get_monitoring_status(guid, status_id, status); + return get_monitoring_status(guid, status); } }; @@ -188,17 +187,20 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_in statistics_pub_impl->insert_policy_violation(dw1->guid(), fastdds::dds::RELIABILITY_QOS_POLICY_ID); statistics_pub_impl->insert_policy_violation(dw2->guid(), fastdds::dds::RELIABILITY_QOS_POLICY_ID); - fastdds::statistics::rtps::DDSEntityStatus* incomp_qos_status_dw_1, * incomp_qos_status_dw_2; - incomp_qos_status_dw_1 = new fastdds::statistics::rtps::DDSEntityStatus; - incomp_qos_status_dw_2 = new fastdds::statistics::rtps::DDSEntityStatus; - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), 2, incomp_qos_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), 2, incomp_qos_status_dw_2)); + MonitorServiceData incomp_qos_status_dw_1; + incomp_qos_status_dw_1.incompatible_qos_status(IncompatibleQoSStatus_s{}); + MonitorServiceData incomp_qos_status_dw_2; + incomp_qos_status_dw_2.incompatible_qos_status(IncompatibleQoSStatus_s{}); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), incomp_qos_status_dw_1)); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), incomp_qos_status_dw_2)); //! Expect incompatibilities - ASSERT_EQ(1u, static_cast(incomp_qos_status_dw_1)->total_count); - ASSERT_EQ(1u, static_cast(incomp_qos_status_dw_2)->total_count); - ASSERT_EQ(1u, incomp_qos_status_dw_1->policies[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count); - ASSERT_EQ(1u, incomp_qos_status_dw_2->policies[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count); + ASSERT_EQ(1u, incomp_qos_status_dw_1.incompatible_qos_status().total_count()); + ASSERT_EQ(1u, incomp_qos_status_dw_2.incompatible_qos_status().total_count()); + ASSERT_EQ(1u, + incomp_qos_status_dw_1.incompatible_qos_status().policies()[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count()); + ASSERT_EQ(1u, + incomp_qos_status_dw_2.incompatible_qos_status().policies()[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -207,9 +209,6 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_in statistics_participant->delete_publisher(publisher); statistics_participant->delete_contained_entities(); - delete incomp_qos_status_dw_1; - delete incomp_qos_status_dw_2; - #endif // FASTDDS_STATISTICS } @@ -251,15 +250,16 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_li statistics_pub_impl->insert_policy_violation(dw1->guid(), fastdds::dds::LIVELINESS_QOS_POLICY_ID); statistics_pub_impl->insert_policy_violation(dw2->guid(), fastdds::dds::LIVELINESS_QOS_POLICY_ID); - rtps::DDSEntityStatus* liv_lost_status_dw_1, * liv_lost_status_dw_2; - liv_lost_status_dw_1 = new fastdds::statistics::rtps::DDSEntityStatus; - liv_lost_status_dw_2 = new fastdds::statistics::rtps::DDSEntityStatus; - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), 4, liv_lost_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), 4, liv_lost_status_dw_2)); + MonitorServiceData liv_lost_status_dw_1; + liv_lost_status_dw_1.liveliness_lost_status(LivelinessLostStatus_s{}); + MonitorServiceData liv_lost_status_dw_2; + liv_lost_status_dw_2.liveliness_lost_status(LivelinessLostStatus_s{}); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), liv_lost_status_dw_1)); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), liv_lost_status_dw_2)); //! Expect incompatibilities - ASSERT_EQ(1, static_cast(liv_lost_status_dw_1)->total_count); - ASSERT_EQ(1, static_cast(liv_lost_status_dw_2)->total_count); + ASSERT_EQ(1u, liv_lost_status_dw_1.liveliness_lost_status().total_count()); + ASSERT_EQ(1u, liv_lost_status_dw_2.liveliness_lost_status().total_count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -268,9 +268,6 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_li statistics_participant->delete_publisher(publisher); statistics_participant->delete_contained_entities(); - delete liv_lost_status_dw_1; - delete liv_lost_status_dw_2; - #endif // FASTDDS_STATISTICS } @@ -312,15 +309,16 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_de statistics_pub_impl->insert_policy_violation(dw1->guid(), fastdds::dds::DEADLINE_QOS_POLICY_ID); statistics_pub_impl->insert_policy_violation(dw2->guid(), fastdds::dds::DEADLINE_QOS_POLICY_ID); - rtps::DDSEntityStatus* deadline_missed_status_dw_1, * deadline_missed_status_dw_2; - deadline_missed_status_dw_1 = new rtps::DDSEntityStatus; - deadline_missed_status_dw_2 = new rtps::DDSEntityStatus; - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), 6, deadline_missed_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), 6, deadline_missed_status_dw_2)); + MonitorServiceData deadline_missed_status_dw_1; + deadline_missed_status_dw_1.deadline_missed_status(DeadlineMissedStatus_s{}); + MonitorServiceData deadline_missed_status_dw_2; + deadline_missed_status_dw_2.deadline_missed_status(DeadlineMissedStatus_s{}); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), deadline_missed_status_dw_1)); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), deadline_missed_status_dw_2)); //! Expect incompatibilities - ASSERT_EQ(1u, static_cast(deadline_missed_status_dw_1)->total_count); - ASSERT_EQ(1u, static_cast(deadline_missed_status_dw_2)->total_count); + ASSERT_EQ(1u, deadline_missed_status_dw_1.deadline_missed_status().total_count()); + ASSERT_EQ(1u, deadline_missed_status_dw_2.deadline_missed_status().total_count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -329,9 +327,6 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_de statistics_participant->delete_publisher(publisher); statistics_participant->delete_contained_entities(); - delete deadline_missed_status_dw_1; - delete deadline_missed_status_dw_2; - #endif // FASTDDS_STATISTICS } diff --git a/test/unittest/statistics/rtps/MonitorServiceTests.cpp b/test/unittest/statistics/rtps/MonitorServiceTests.cpp index 5416ffb4c3b..af7852a825f 100644 --- a/test/unittest/statistics/rtps/MonitorServiceTests.cpp +++ b/test/unittest/statistics/rtps/MonitorServiceTests.cpp @@ -18,8 +18,8 @@ #include #include -#include +#include #include #include @@ -30,10 +30,9 @@ namespace rtps { struct MockStatusQueryable : public IStatusQueryable { - MOCK_METHOD3(get_monitoring_status, bool ( + MOCK_METHOD2(get_monitoring_status, bool ( const fastrtps::rtps::GUID_t& guid, - const uint32_t& id, - DDSEntityStatus * &status)); + MonitorServiceData & status)); }; struct MockConnectionsQueryable : public IConnectionsQueryable @@ -208,11 +207,11 @@ TEST_F(MonitorServiceTests, multiple_dds_status_updates) ASSERT_TRUE(monitor_srv_.enable_monitor_service()); ASSERT_TRUE(monitor_srv_.is_enabled()); - ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). WillByDefault(testing::Return(true)); //! Expect the getters for each status that is going to be updated - EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). Times(n_local_entities * 5);//statuses * n_local_entities //! Trigger statuses updates for each entity @@ -247,7 +246,7 @@ TEST_F(MonitorServiceTests, entity_removal_correctly_performs) WillByDefault(testing::Return(true)); ON_CALL(mock_conns_q_, get_entity_connections(::testing::_, ::testing::_)). WillByDefault(testing::Return(true)); - ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). WillByDefault(testing::Return(true)); //! Expect the creation 5 ones @@ -257,7 +256,7 @@ TEST_F(MonitorServiceTests, entity_removal_correctly_performs) Times(5); //! Expect the getters for each status that is going to be updated - EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). Times(5 * 5); //! Trigger statuses updates for each of the non-existent entity diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 37da738aa49..a54d4c88183 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -52,6 +51,7 @@ #include #include +#include #include #include diff --git a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp index 622560f0901..0160eec3d28 100644 --- a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp +++ b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp @@ -31,10 +31,10 @@ #include #include #include -#include #include #include +#include #include #include #include From e21ae540b2e946f25cdd6a278f100da59f76b0ec Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 4 Apr 2024 11:22:20 +0200 Subject: [PATCH 05/10] Refs #20739: Apply suggestion regarding asserts Signed-off-by: Mario Dominguez --- .../rtps/monitor-service/MonitorService.cpp | 75 +++---------------- 1 file changed, 12 insertions(+), 63 deletions(-) diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index b183c78c101..8a57269c734 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -262,7 +262,6 @@ bool MonitorService::write_status( status_data.local_entity(to_statistics_type({local_participant_guid_.guidPrefix, entity_id})); GUID_t local_entity_guid = {local_participant_guid_.guidPrefix, entity_id}; - bool status_retrieved = true; switch (i) { case PROXY: @@ -270,44 +269,21 @@ bool MonitorService::write_status( CDRMessage_t msg; //! Depending on the entity type [Participant, Writer, Reader] //! the size will be accordingly calculated - - if (!proxy_queryable_->get_serialized_proxy(local_entity_guid, &msg)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the serialized entity"); - status_retrieved = false; - assert(false); - } - + assert(proxy_queryable_->get_serialized_proxy(local_entity_guid, &msg)); data.entity_proxy().assign(msg.buffer, msg.buffer + msg.length); - break; } case CONNECTION_LIST: { std::vector conns; - if (conns_queryable_->get_entity_connections(local_entity_guid, conns)) - { - data.connection_list(conns); - } - else - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, - "Could not get entity connections list for " << local_entity_guid); - assert(false); - } - + assert(conns_queryable_->get_entity_connections(local_entity_guid, conns)); + data.connection_list(conns); break; } case INCOMPATIBLE_QOS: { data.incompatible_qos_status(IncompatibleQoSStatus_s{}); - if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, - "Could not retrieve the incompatible qos entity status "); - status_retrieved = false; - assert(false); - } + assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); break; } //Not triggered for the moment @@ -320,66 +296,39 @@ bool MonitorService::write_status( case LIVELINESS_LOST: { data.liveliness_lost_status(LivelinessLostStatus_s{}); - if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, - "Could not retrieve the liveliness lost entity status "); - status_retrieved = false; - assert(false); - } - + assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); break; } case LIVELINESS_CHANGED: { data.liveliness_changed_status(LivelinessChangedStatus_s{}); - if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, - "Could not retrieve the liveliness changed entity status"); - status_retrieved = false; - assert(false); - } - + assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); break; } case DEADLINE_MISSED: { data.deadline_missed_status(DeadlineMissedStatus_s{}); - if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the deadline missed entity status"); - status_retrieved = false; - assert(false); - } + assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); break; } case SAMPLE_LOST: { data.sample_lost_status(SampleLostStatus_s{}); - if (!status_queryable_.get_monitoring_status(local_entity_guid, data)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the sample lost entity status"); - status_retrieved = false; - assert(false); - } + assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); break; } default: { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Referring to an unknown status"); - status_retrieved = false; assert(false); break; } } - if (status_retrieved) - { - status_data.status_kind((StatusKind)i); - status_data.value(data); - add_change(status_data, false); - } + status_data.status_kind((StatusKind)i); + status_data.value(data); + add_change(status_data, false); + } } } From a81affa5ed12e93ee56c7b1c3e9de7e9581d91b0 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 4 Apr 2024 15:10:48 +0200 Subject: [PATCH 06/10] Refs 20739: Rev 2 changes Signed-off-by: Mario Dominguez --- src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 4 +-- .../rtps/monitor-service/MonitorService.cpp | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index 6789ee252c6..3336a3a6de6 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -23,16 +23,16 @@ #include +#include #include #include #include -#include #include #include -#include #include +#include using eprosima::fastrtps::types::ReturnCode_t; diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 8a57269c734..b3a0475a6d6 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -262,6 +262,7 @@ bool MonitorService::write_status( status_data.local_entity(to_statistics_type({local_participant_guid_.guidPrefix, entity_id})); GUID_t local_entity_guid = {local_participant_guid_.guidPrefix, entity_id}; + bool status_retrieved = true; switch (i) { case PROXY: @@ -269,66 +270,69 @@ bool MonitorService::write_status( CDRMessage_t msg; //! Depending on the entity type [Participant, Writer, Reader] //! the size will be accordingly calculated - assert(proxy_queryable_->get_serialized_proxy(local_entity_guid, &msg)); + status_retrieved = proxy_queryable_->get_serialized_proxy(local_entity_guid,&msg); data.entity_proxy().assign(msg.buffer, msg.buffer + msg.length); break; } case CONNECTION_LIST: { std::vector conns; - assert(conns_queryable_->get_entity_connections(local_entity_guid, conns)); + status_retrieved = conns_queryable_->get_entity_connections(local_entity_guid,conns); data.connection_list(conns); break; } case INCOMPATIBLE_QOS: { data.incompatible_qos_status(IncompatibleQoSStatus_s{}); - assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } //Not triggered for the moment case INCONSISTENT_TOPIC: { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Inconsistent topic status not supported yet"); - assert(false); + (void)local_entity_guid; break; } case LIVELINESS_LOST: { data.liveliness_lost_status(LivelinessLostStatus_s{}); - assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } case LIVELINESS_CHANGED: { data.liveliness_changed_status(LivelinessChangedStatus_s{}); - assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } case DEADLINE_MISSED: { data.deadline_missed_status(DeadlineMissedStatus_s{}); - assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } case SAMPLE_LOST: { data.sample_lost_status(SampleLostStatus_s{}); - assert(status_queryable_.get_monitoring_status(local_entity_guid, data)); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } default: { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Referring to an unknown status"); - assert(false); + (void)local_entity_guid; break; } } - status_data.status_kind((StatusKind)i); - status_data.value(data); - add_change(status_data, false); - + assert(status_retrieved); + if (status_retrieved) + { + status_data.status_kind((StatusKind)i); + status_data.value(data); + add_change(status_data, false); + } } } } From 97abb943bb1a06a3a88e26c03520295e79ed889f Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Fri, 5 Apr 2024 08:01:35 +0200 Subject: [PATCH 07/10] Refs 20739: Linter Signed-off-by: Mario Dominguez --- src/cpp/statistics/rtps/monitor-service/MonitorService.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index b3a0475a6d6..63c51180cfc 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -270,14 +270,14 @@ bool MonitorService::write_status( CDRMessage_t msg; //! Depending on the entity type [Participant, Writer, Reader] //! the size will be accordingly calculated - status_retrieved = proxy_queryable_->get_serialized_proxy(local_entity_guid,&msg); + status_retrieved = proxy_queryable_->get_serialized_proxy(local_entity_guid, &msg); data.entity_proxy().assign(msg.buffer, msg.buffer + msg.length); break; } case CONNECTION_LIST: { std::vector conns; - status_retrieved = conns_queryable_->get_entity_connections(local_entity_guid,conns); + status_retrieved = conns_queryable_->get_entity_connections(local_entity_guid, conns); data.connection_list(conns); break; } From 82a8b067ed8365e7ed3e5ed6ffa841fc949820b9 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Fri, 5 Apr 2024 12:05:46 +0200 Subject: [PATCH 08/10] Refs 20739: Rev 3 changes Signed-off-by: Mario Dominguez --- src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 6 +++--- .../statistics/rtps/monitor-service/MonitorService.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index 3336a3a6de6..38057ec6bfe 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -21,18 +21,18 @@ #define _FASTDDS_SUBSCRIBERIMPL_HPP_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#include +#include +#include #include #include #include #include +#include #include #include -#include -#include using eprosima::fastrtps::types::ReturnCode_t; diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 63c51180cfc..cdfb068edd9 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -291,7 +291,7 @@ bool MonitorService::write_status( case INCONSISTENT_TOPIC: { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Inconsistent topic status not supported yet"); - (void)local_entity_guid; + static_cast(local_entity_guid); break; } case LIVELINESS_LOST: @@ -321,7 +321,7 @@ bool MonitorService::write_status( default: { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Referring to an unknown status"); - (void)local_entity_guid; + static_cast(local_entity_guid); break; } } @@ -333,6 +333,11 @@ bool MonitorService::write_status( status_data.value(data); add_change(status_data, false); } + else + { + EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the status data for " << i << " of " << + local_entity_guid); + } } } } From 2b3b3f7c4f01f639e2a54e76c8c6c4cfd7c15b24 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 9 Apr 2024 07:38:42 +0200 Subject: [PATCH 09/10] Refs #20739: Remove status assert Signed-off-by: Mario Dominguez --- src/cpp/statistics/rtps/monitor-service/MonitorService.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index cdfb068edd9..4cbb6e29ef2 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -326,7 +326,6 @@ bool MonitorService::write_status( } } - assert(status_retrieved); if (status_retrieved) { status_data.status_kind((StatusKind)i); From a5603431f4adf0dccfbdedb35bde57069d6a6daa Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 16 Apr 2024 11:12:05 +0200 Subject: [PATCH 10/10] Refs #20739: Comment typo Signed-off-by: Mario Dominguez --- .../fastdds/statistics/rtps/monitor_service/connections_fwd.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp index 0f6ee4ef799..abea1e4cf1e 100644 --- a/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp +++ b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file connection_fwd.hpp + * @file connections_fwd.hpp * */