From bcc11eb455c5e6e1cb27acc0a877095d1ce438b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 3 Apr 2024 09:50:09 +0200 Subject: [PATCH] Refs #20738. Refactor monitor service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- include/fastdds/rtps/reader/RTPSReader.h | 5 +- include/fastdds/rtps/writer/RTPSWriter.h | 5 +- .../statistics/monitorservice_types.idl | 191 +++++++++--------- .../rtps/monitor_service/connections_fwd.hpp | 42 ++++ include/fastdds/statistics/types.idl | 34 ++-- 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 | 6 +- .../rtps/builtin/discovery/participant/PDP.h | 4 +- .../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 | 12 +- .../rtps/monitor-service/MonitorService.cpp | 84 ++------ .../rtps/monitor-service/MonitorService.hpp | 5 +- .../MonitorServiceListener.hpp | 3 +- .../interfaces/IConnectionsObserver.hpp | 5 +- .../interfaces/IConnectionsQueryable.hpp | 11 +- .../interfaces/IProxyObserver.hpp | 0 .../interfaces/IProxyQueryable.hpp | 0 .../interfaces/IStatusObserver.hpp | 0 .../interfaces/IStatusQueryable.hpp | 13 +- src/cpp/statistics/types/types.hpp | 34 ++-- test/blackbox/types/statistics/types.hpp | 34 ++-- .../rtps/builtin/discovery/participant/PDP.h | 2 +- .../rtps/participant/RTPSParticipant.h | 3 +- ...sDomainParticipantStatusQueryableTests.cpp | 65 +++--- .../statistics/rtps/MonitorServiceTests.cpp | 15 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 2 +- .../rtps/monitor-service/MonitorService.hpp | 2 +- 32 files changed, 339 insertions(+), 332 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 (62%) 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/IProxyQueryable.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/reader/RTPSReader.h b/include/fastdds/rtps/reader/RTPSReader.h index c7977931235..0a6de1de600 100644 --- a/include/fastdds/rtps/reader/RTPSReader.h +++ b/include/fastdds/rtps/reader/RTPSReader.h @@ -30,10 +30,7 @@ #include #include #include -#ifdef FASTDDS_STATISTICS -#include -#include -#endif // ifdef FASTDDS_STATISTICS +#include #include #include diff --git a/include/fastdds/rtps/writer/RTPSWriter.h b/include/fastdds/rtps/writer/RTPSWriter.h index 43c8f4bd207..1955bfafabf 100644 --- a/include/fastdds/rtps/writer/RTPSWriter.h +++ b/include/fastdds/rtps/writer/RTPSWriter.h @@ -36,10 +36,7 @@ #include #include #include -#ifdef FASTDDS_STATISTICS -#include -#include -#endif // ifdef FASTDDS_STATISTICS +#include #include namespace eprosima { diff --git a/include/fastdds/statistics/monitorservice_types.idl b/include/fastdds/statistics/monitorservice_types.idl index 2bfe59fd2e2..5ae98a8160b 100644 --- a/include/fastdds/statistics/monitorservice_types.idl +++ b/include/fastdds/statistics/monitorservice_types.idl @@ -22,103 +22,102 @@ 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; - - module StatusKind - { - typedef unsigned long StatusKind; - - const StatusKind PROXY = 0; - const StatusKind CONNECTION_LIST = 1; - const StatusKind INCOMPATIBLE_QOS = 2; - const StatusKind INCONSISTENT_TOPIC = 3; - const StatusKind LIVELINESS_LOST = 4; - const StatusKind LIVELINESS_CHANGED = 5; - const StatusKind DEADLINE_MISSED = 6; - const StatusKind SAMPLE_LOST = 7; - const StatusKind STATUSES_SIZE = 8; - }; // module StatusKind - - union MonitorServiceData switch(StatusKind::StatusKind) - { - case StatusKind::PROXY: - sequence entity_proxy; - case StatusKind::CONNECTION_LIST: - sequence connection_list; - case StatusKind::INCOMPATIBLE_QOS: - IncompatibleQoSStatus_s incompatible_qos_status; - case StatusKind::INCONSISTENT_TOPIC: - InconsistentTopicStatus_s inconsistent_topic_status; - case StatusKind::LIVELINESS_LOST: - LivelinessLostStatus_s liveliness_lost_status; - case StatusKind::LIVELINESS_CHANGED: - LivelinessChangedStatus_s liveliness_changed_status; - case StatusKind::DEADLINE_MISSED: - DeadlineMissedStatus_s deadline_missed_status; - case StatusKind::SAMPLE_LOST: - SampleLostStatus_s sample_lost_status; - case StatusKind::STATUSES_SIZE: - octet statuses_size; - }; - - struct MonitorServiceStatusData - { - @Key detail::GUID_s local_entity; - @Key StatusKind::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; + + module StatusKind + { + typedef unsigned long StatusKind; + + const StatusKind PROXY = 0; + const StatusKind CONNECTION_LIST = 1; + const StatusKind INCOMPATIBLE_QOS = 2; + const StatusKind INCONSISTENT_TOPIC = 3; + const StatusKind LIVELINESS_LOST = 4; + const StatusKind LIVELINESS_CHANGED = 5; + const StatusKind DEADLINE_MISSED = 6; + const StatusKind SAMPLE_LOST = 7; + const StatusKind STATUSES_SIZE = 8; + }; // module StatusKind + + union MonitorServiceData switch(StatusKind::StatusKind) + { + case StatusKind::PROXY: + sequence entity_proxy; + case StatusKind::CONNECTION_LIST: + sequence connection_list; + case StatusKind::INCOMPATIBLE_QOS: + IncompatibleQoSStatus_s incompatible_qos_status; + case StatusKind::INCONSISTENT_TOPIC: + InconsistentTopicStatus_s inconsistent_topic_status; + case StatusKind::LIVELINESS_LOST: + LivelinessLostStatus_s liveliness_lost_status; + case StatusKind::LIVELINESS_CHANGED: + LivelinessChangedStatus_s liveliness_changed_status; + case StatusKind::DEADLINE_MISSED: + DeadlineMissedStatus_s deadline_missed_status; + case StatusKind::SAMPLE_LOST: + SampleLostStatus_s sample_lost_status; + case StatusKind::STATUSES_SIZE: + octet statuses_size; + }; + + struct MonitorServiceStatusData + { + @Key detail::GUID_s local_entity; + @Key StatusKind::StatusKind status_kind; + MonitorServiceData value; + }; }; // namespace statisitcs }; // namespace fastdds }; // namespace eprosima - 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..97dd2135b32 --- /dev/null +++ b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp @@ -0,0 +1,42 @@ +// 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_ + +#ifdef FASTDDS_STATISTICS + +namespace eprosima { +namespace fastdds { +namespace statistics { + +class Connection; + +namespace rtps { + +using ConnectionList = std::vector; + +} // rtps +} // statistics +} // fastdds +} // eprosima + +#endif // ifdef FASTDDS_STATISTICS + +#endif // _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_ diff --git a/include/fastdds/statistics/types.idl b/include/fastdds/statistics/types.idl index ddf62fb44ff..96654a165b0 100644 --- a/include/fastdds/statistics/types.idl +++ b/include/fastdds/statistics/types.idl @@ -121,23 +121,23 @@ struct PhysicalData module EventKind { - const unsigned long HISTORY2HISTORY_LATENCY = 1; - const unsigned long NETWORK_LATENCY = 2; - const unsigned long PUBLICATION_THROUGHPUT = 4; - const unsigned long SUBSCRIPTION_THROUGHPUT = 8; - const unsigned long RTPS_SENT = 16; - const unsigned long RTPS_LOST = 32; - const unsigned long RESENT_DATAS = 64; - const unsigned long HEARTBEAT_COUNT = 128; - const unsigned long ACKNACK_COUNT = 256; - const unsigned long NACKFRAG_COUNT = 512; - const unsigned long GAP_COUNT = 1024; - const unsigned long DATA_COUNT = 2048; - const unsigned long PDP_PACKETS = 4096; - const unsigned long EDP_PACKETS = 8192; - const unsigned long DISCOVERED_ENTITY = 16384; - const unsigned long SAMPLE_DATAS = 32768; - const unsigned long PHYSICAL_DATA = 65536; + const unsigned long HISTORY2HISTORY_LATENCY = 0x1; + const unsigned long NETWORK_LATENCY = 0x2; + const unsigned long PUBLICATION_THROUGHPUT = 0x4; + const unsigned long SUBSCRIPTION_THROUGHPUT = 0x8; + const unsigned long RTPS_SENT = 0x10; + const unsigned long RTPS_LOST = 0x20; + const unsigned long RESENT_DATAS = 0x40; + const unsigned long HEARTBEAT_COUNT = 0x80; + const unsigned long ACKNACK_COUNT = 0x100; + const unsigned long NACKFRAG_COUNT = 0x200; + const unsigned long GAP_COUNT = 0x400; + const unsigned long DATA_COUNT = 0x800; + const unsigned long PDP_PACKETS = 0x1000; + const unsigned long EDP_PACKETS = 0x2000; + const unsigned long DISCOVERED_ENTITY = 0x4000; + const unsigned long SAMPLE_DATAS = 0x8000; + const unsigned long PHYSICAL_DATA = 0x10000; }; union Data switch(unsigned long) diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index 57cb5d5cb7f..02ba591e529 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -664,8 +664,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; @@ -676,11 +675,21 @@ bool PublisherImpl::get_monitoring_status( { if (writer->guid() == entity_guid) { - switch (status_id) + switch (status._d()) { case statistics::StatusKind::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; } @@ -693,19 +702,27 @@ bool PublisherImpl::get_monitoring_status( }*/ case statistics::StatusKind::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::StatusKind::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 44caae68e6b..0ae03d54728 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.hpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.hpp @@ -34,7 +34,7 @@ #include #ifdef FASTDDS_STATISTICS -#include +#include #endif // ifdef FASTDDS_STATISTICS namespace eprosima { @@ -202,8 +202,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 ac0fc979142..f4086726e0f 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -682,8 +682,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; @@ -694,12 +693,21 @@ bool SubscriberImpl::get_monitoring_status( { if (reader->guid() == entity_guid) { - switch (status_id) + switch (status._d()) { case statistics::StatusKind::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; } @@ -712,25 +720,40 @@ bool SubscriberImpl::get_monitoring_status( }*/ case statistics::StatusKind::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::StatusKind::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::StatusKind::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 069f5089f05..3c0c5c1d9a0 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -29,7 +29,8 @@ #include #include #include -#include + +#include namespace eprosima { namespace fastrtps { @@ -226,8 +227,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/participant/PDP.h b/src/cpp/rtps/builtin/discovery/participant/PDP.h index 397cf00e578..972db546cb8 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.h +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.h @@ -34,10 +34,10 @@ #include #include #include -#include -#include #include +#include +#include #include namespace eprosima { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index f7177a2892e..98aee8fc88f 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -35,7 +35,7 @@ #include #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 838c2a93a17..43cc8d9f47d 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -45,7 +45,6 @@ #include #include #include -#include #include "../flowcontrol/FlowControllerFactory.hpp" #include @@ -53,6 +52,8 @@ #include #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 58b4d3a424e..9eb6c315f6e 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 = efd::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 = efd::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 = efd::RETCODE_OK; break; diff --git a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp index 16739c6ab24..08b64d57d6b 100644 --- a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.hpp @@ -35,11 +35,11 @@ #include #include #include -#include #include #include "DomainParticipantStatisticsListener.hpp" +#include namespace efd = eprosima::fastdds::dds; @@ -288,8 +288,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 62% rename from include/fastdds/statistics/rtps/monitor_service/Interfaces.hpp rename to src/cpp/statistics/rtps/monitor-service/Interfaces.hpp index df63506ff5a..9d7ece0a162 100644 --- a/include/fastdds/statistics/rtps/monitor_service/Interfaces.hpp +++ b/src/cpp/statistics/rtps/monitor-service/Interfaces.hpp @@ -20,12 +20,12 @@ #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/IProxyQueryable.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 72a2c30b0c7..548492cbad9 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -33,30 +33,6 @@ 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( @@ -304,12 +280,14 @@ bool MonitorService::write_status( assert(false); } + data.entity_proxy({}); data.entity_proxy().assign(msg.buffer, msg.buffer + msg.length); break; } case StatusKind::CONNECTION_LIST: { + data.connection_list({}); std::vector conns; if (conns_queryable_->get_entity_connections(local_entity_guid, conns)) { @@ -326,25 +304,14 @@ bool MonitorService::write_status( } case StatusKind::INCOMPATIBLE_QOS: { - rtps::DDSEntityStatus* dds_entity_status = new rtps::DDSEntityStatus; - status_queryable_.get_monitoring_status(local_entity_guid, StatusKind::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 @@ -356,12 +323,8 @@ bool MonitorService::write_status( } case StatusKind::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, StatusKind::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 "); @@ -373,12 +336,8 @@ bool MonitorService::write_status( } case StatusKind::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, StatusKind::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"); @@ -390,12 +349,8 @@ bool MonitorService::write_status( } case StatusKind::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, StatusKind::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; @@ -405,11 +360,8 @@ bool MonitorService::write_status( } case StatusKind::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, StatusKind::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 4eeedb0714f..14d90c0bd3a 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp @@ -32,8 +32,8 @@ #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 { 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..56d977c8e81 100644 --- a/include/fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp +++ b/src/cpp/statistics/rtps/monitor-service/interfaces/IConnectionsQueryable.hpp @@ -17,22 +17,19 @@ * */ -#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 +51,5 @@ 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/IProxyQueryable.hpp b/src/cpp/statistics/rtps/monitor-service/interfaces/IProxyQueryable.hpp similarity index 100% rename from include/fastdds/statistics/rtps/monitor_service/interfaces/IProxyQueryable.hpp rename to src/cpp/statistics/rtps/monitor-service/interfaces/IProxyQueryable.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..5b50d4e0ca8 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/src/cpp/statistics/types/types.hpp b/src/cpp/statistics/types/types.hpp index 511511317d7..308a3dae3d7 100644 --- a/src/cpp/statistics/types/types.hpp +++ b/src/cpp/statistics/types/types.hpp @@ -2927,23 +2927,23 @@ class PhysicalData }; namespace EventKind { -const uint32_t HISTORY2HISTORY_LATENCY = 1; -const uint32_t NETWORK_LATENCY = 2; -const uint32_t PUBLICATION_THROUGHPUT = 4; -const uint32_t SUBSCRIPTION_THROUGHPUT = 8; -const uint32_t RTPS_SENT = 16; -const uint32_t RTPS_LOST = 32; -const uint32_t RESENT_DATAS = 64; -const uint32_t HEARTBEAT_COUNT = 128; -const uint32_t ACKNACK_COUNT = 256; -const uint32_t NACKFRAG_COUNT = 512; -const uint32_t GAP_COUNT = 1024; -const uint32_t DATA_COUNT = 2048; -const uint32_t PDP_PACKETS = 4096; -const uint32_t EDP_PACKETS = 8192; -const uint32_t DISCOVERED_ENTITY = 16384; -const uint32_t SAMPLE_DATAS = 32768; -const uint32_t PHYSICAL_DATA = 65536; +const uint32_t HISTORY2HISTORY_LATENCY = 0x1; +const uint32_t NETWORK_LATENCY = 0x2; +const uint32_t PUBLICATION_THROUGHPUT = 0x4; +const uint32_t SUBSCRIPTION_THROUGHPUT = 0x8; +const uint32_t RTPS_SENT = 0x10; +const uint32_t RTPS_LOST = 0x20; +const uint32_t RESENT_DATAS = 0x40; +const uint32_t HEARTBEAT_COUNT = 0x80; +const uint32_t ACKNACK_COUNT = 0x100; +const uint32_t NACKFRAG_COUNT = 0x200; +const uint32_t GAP_COUNT = 0x400; +const uint32_t DATA_COUNT = 0x800; +const uint32_t PDP_PACKETS = 0x1000; +const uint32_t EDP_PACKETS = 0x2000; +const uint32_t DISCOVERED_ENTITY = 0x4000; +const uint32_t SAMPLE_DATAS = 0x8000; +const uint32_t PHYSICAL_DATA = 0x10000; } // namespace EventKind /*! diff --git a/test/blackbox/types/statistics/types.hpp b/test/blackbox/types/statistics/types.hpp index 511511317d7..308a3dae3d7 100644 --- a/test/blackbox/types/statistics/types.hpp +++ b/test/blackbox/types/statistics/types.hpp @@ -2927,23 +2927,23 @@ class PhysicalData }; namespace EventKind { -const uint32_t HISTORY2HISTORY_LATENCY = 1; -const uint32_t NETWORK_LATENCY = 2; -const uint32_t PUBLICATION_THROUGHPUT = 4; -const uint32_t SUBSCRIPTION_THROUGHPUT = 8; -const uint32_t RTPS_SENT = 16; -const uint32_t RTPS_LOST = 32; -const uint32_t RESENT_DATAS = 64; -const uint32_t HEARTBEAT_COUNT = 128; -const uint32_t ACKNACK_COUNT = 256; -const uint32_t NACKFRAG_COUNT = 512; -const uint32_t GAP_COUNT = 1024; -const uint32_t DATA_COUNT = 2048; -const uint32_t PDP_PACKETS = 4096; -const uint32_t EDP_PACKETS = 8192; -const uint32_t DISCOVERED_ENTITY = 16384; -const uint32_t SAMPLE_DATAS = 32768; -const uint32_t PHYSICAL_DATA = 65536; +const uint32_t HISTORY2HISTORY_LATENCY = 0x1; +const uint32_t NETWORK_LATENCY = 0x2; +const uint32_t PUBLICATION_THROUGHPUT = 0x4; +const uint32_t SUBSCRIPTION_THROUGHPUT = 0x8; +const uint32_t RTPS_SENT = 0x10; +const uint32_t RTPS_LOST = 0x20; +const uint32_t RESENT_DATAS = 0x40; +const uint32_t HEARTBEAT_COUNT = 0x80; +const uint32_t ACKNACK_COUNT = 0x100; +const uint32_t NACKFRAG_COUNT = 0x200; +const uint32_t GAP_COUNT = 0x400; +const uint32_t DATA_COUNT = 0x800; +const uint32_t PDP_PACKETS = 0x1000; +const uint32_t EDP_PACKETS = 0x2000; +const uint32_t DISCOVERED_ENTITY = 0x4000; +const uint32_t SAMPLE_DATAS = 0x8000; +const uint32_t PHYSICAL_DATA = 0x10000; } // namespace EventKind /*! diff --git a/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h b/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h index 84fb9a6a61e..297ab86bbb4 100644 --- a/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h +++ b/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h @@ -29,7 +29,7 @@ #include #ifdef FASTDDS_STATISTICS -#include +#include #endif // ifdef FASTDDS_STATISTICS namespace eprosima { diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h index 93d21dd5ef0..0ea712ba9c5 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h @@ -28,9 +28,10 @@ #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 74209e880f0..e924f1eb453 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp @@ -128,10 +128,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); } }; @@ -185,17 +184,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(); @@ -204,9 +206,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 } @@ -248,15 +247,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(1, liv_lost_status_dw_1.liveliness_lost_status().total_count()); + ASSERT_EQ(1, liv_lost_status_dw_2.liveliness_lost_status().total_count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -265,9 +265,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 } @@ -309,15 +306,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(); @@ -326,9 +324,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 b955ff3d7a4..bb35df72573 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 1fa17765aac..2bf525fe701 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -42,10 +42,10 @@ #include #include #include -#include #include #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 cd608af8251..636a93084af 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 @@ -32,9 +32,9 @@ #include #include #include -#include #include +#include #include #include #include