From 4ca144ec45c242c815a4eb82abbe173a1320bece Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 07:35:01 +0200 Subject: [PATCH] Refactor IStatusQueryable and make monitor service interfaces private (#4651) (#4687) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor IStatusQueryable and make monitor service interfaces private (#4651) * Refs #20739: Make monitor service interfaces private (except IProxyQueryable) Signed-off-by: Mario Dominguez * Refs #20739: Replace tabs with spaces in monitorservice_types.idl Signed-off-by: Mario Dominguez * Refs #20739: Refactor include and src files Signed-off-by: Mario Dominguez * Refs #20739: Refactor tests Signed-off-by: Mario Dominguez * Refs #20739: Apply suggestion regarding asserts Signed-off-by: Mario Dominguez * Refs 20739: Rev 2 changes Signed-off-by: Mario Dominguez * Refs 20739: Linter Signed-off-by: Mario Dominguez * Refs 20739: Rev 3 changes Signed-off-by: Mario Dominguez * Refs #20739: Remove status assert Signed-off-by: Mario Dominguez * Refs #20739: Comment typo Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Dominguez (cherry picked from commit fb841b9a1a2c9ea967b3d71adb30cfc59914822a) # Conflicts: # include/fastdds/rtps/reader/RTPSReader.h # include/fastdds/rtps/writer/RTPSWriter.h * Fix conflicts based on original PR Signed-off-by: JesusPoderoso --------- Signed-off-by: JesusPoderoso Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com> Co-authored-by: JesusPoderoso --- .../rtps/builtin/discovery/participant/PDP.h | 9 +- include/fastdds/rtps/reader/RTPSReader.h | 9 +- include/fastdds/rtps/writer/RTPSWriter.h | 11 +- .../statistics/monitorservice_types.idl | 186 +++++++++--------- .../rtps/monitor_service/connections_fwd.hpp | 38 ++++ 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 | 13 +- .../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}/Interfaces.hpp | 11 +- .../rtps/monitor-service/MonitorService.cpp | 133 ++----------- .../rtps/monitor-service/MonitorService.hpp | 5 +- .../MonitorServiceListener.hpp | 3 +- .../interfaces/IConnectionsObserver.hpp | 5 +- .../interfaces/IConnectionsQueryable.hpp | 11 +- .../interfaces/IProxyObserver.hpp | 0 .../interfaces/IStatusObserver.hpp | 0 .../interfaces/IStatusQueryable.hpp | 13 +- .../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 +- 30 files changed, 313 insertions(+), 336 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/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 f571011604d..8b9ce3b3845 100644 --- a/include/fastdds/rtps/reader/RTPSReader.h +++ b/include/fastdds/rtps/reader/RTPSReader.h @@ -28,16 +28,11 @@ #include #include #include +#include +#include #include #include -#include - -#ifdef FASTDDS_STATISTICS -#include -#include -#endif // ifdef FASTDDS_STATISTICS - namespace eprosima { namespace fastrtps { namespace rtps { diff --git a/include/fastdds/rtps/writer/RTPSWriter.h b/include/fastdds/rtps/writer/RTPSWriter.h index 6dc10a914a9..f12e2653019 100644 --- a/include/fastdds/rtps/writer/RTPSWriter.h +++ b/include/fastdds/rtps/writer/RTPSWriter.h @@ -32,16 +32,13 @@ #include #include #include -#include "DeliveryRetCode.hpp" -#include "LocatorSelectorSender.hpp" +#include +#include #include -#include -#ifdef FASTDDS_STATISTICS -#include -#include -#endif // ifdef FASTDDS_STATISTICS +#include "DeliveryRetCode.hpp" +#include "LocatorSelectorSender.hpp" namespace eprosima { 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 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..abea1e4cf1e --- /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 connections_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/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index e4cfb15900a..300e640bae4 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -650,8 +650,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; @@ -662,11 +661,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; } @@ -679,19 +688,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 9e3b93cb9a1..739d6d0f17c 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -667,8 +667,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; @@ -679,12 +678,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; } @@ -697,25 +705,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..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 -#include -#include using eprosima::fastrtps::types::ReturnCode_t; @@ -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 05c697afa75..bd42987fb09 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 924e738d352..d19ab023647 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 f6b0d07855e..61844f44f7b 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/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/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 31dff974f47..4cbb6e29ef2 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( @@ -295,131 +270,58 @@ 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); - } - + 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; - 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); - } - + status_retrieved = conns_queryable_->get_entity_connections(local_entity_guid, conns); + data.connection_list(conns); break; } 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{}); + 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); + static_cast(local_entity_guid); break; } 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)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, - "Could not retrieve the liveliness lost entity status "); - status_retrieved = false; - assert(false); - } - + data.liveliness_lost_status(LivelinessLostStatus_s{}); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } 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)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, - "Could not retrieve the liveliness changed entity status"); - status_retrieved = false; - assert(false); - } - + data.liveliness_changed_status(LivelinessChangedStatus_s{}); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } 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)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the deadline missed entity status"); - status_retrieved = false; - assert(false); - } + data.deadline_missed_status(DeadlineMissedStatus_s{}); + status_retrieved = status_queryable_.get_monitoring_status(local_entity_guid, data); break; } 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)) - { - EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Could not retrieve the sample lost entity status"); - status_retrieved = false; - assert(false); - } + data.sample_lost_status(SampleLostStatus_s{}); + status_retrieved = 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); + static_cast(local_entity_guid); break; } } @@ -430,6 +332,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); + } } } } 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 27354bb3e74..8a364cbfee9 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 { 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; }; 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 58372c47cdd..0a438a5a97e 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