Skip to content

Commit

Permalink
Refs #20714: correctly use new statistics IDL
Browse files Browse the repository at this point in the history
Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
  • Loading branch information
JLBuenoLopez committed Apr 1, 2024
1 parent 0bbc08d commit b3f47ee
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 182 deletions.
48 changes: 24 additions & 24 deletions src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,44 +79,44 @@ constexpr const char* PHYSICAL_DATA_TOPIC_ALIAS = "PHYSICAL_DATA_TOPIC";
constexpr const char* MONITOR_SERVICE_TOPIC_ALIAS = "MONITOR_SERVICE_TOPIC";

static constexpr uint32_t participant_statistics_mask =
EventKindBits::RTPS_SENT | EventKindBits::RTPS_LOST | EventKindBits::NETWORK_LATENCY |
EventKindBits::EDP_PACKETS | EventKindBits::PDP_PACKETS |
EventKindBits::PHYSICAL_DATA | EventKindBits::DISCOVERED_ENTITY;
EventKind::RTPS_SENT | EventKind::RTPS_LOST | EventKind::NETWORK_LATENCY |
EventKind::EDP_PACKETS | EventKind::PDP_PACKETS |
EventKind::PHYSICAL_DATA | EventKind::DISCOVERED_ENTITY;

struct ValidEntry
{
const char* alias;
const char* name;
EventKind event_kind;
uint32_t event_kind;
};

static const ValidEntry valid_entries[] =
{
{HISTORY_LATENCY_TOPIC_ALIAS, HISTORY_LATENCY_TOPIC, HISTORY2HISTORY_LATENCY},
{NETWORK_LATENCY_TOPIC_ALIAS, NETWORK_LATENCY_TOPIC, NETWORK_LATENCY},
{PUBLICATION_THROUGHPUT_TOPIC_ALIAS, PUBLICATION_THROUGHPUT_TOPIC, PUBLICATION_THROUGHPUT},
{SUBSCRIPTION_THROUGHPUT_TOPIC_ALIAS, SUBSCRIPTION_THROUGHPUT_TOPIC, SUBSCRIPTION_THROUGHPUT},
{RTPS_SENT_TOPIC_ALIAS, RTPS_SENT_TOPIC, RTPS_SENT},
{RTPS_LOST_TOPIC_ALIAS, RTPS_LOST_TOPIC, RTPS_LOST},
{RESENT_DATAS_TOPIC_ALIAS, RESENT_DATAS_TOPIC, RESENT_DATAS},
{HEARTBEAT_COUNT_TOPIC_ALIAS, HEARTBEAT_COUNT_TOPIC, HEARTBEAT_COUNT},
{ACKNACK_COUNT_TOPIC_ALIAS, ACKNACK_COUNT_TOPIC, ACKNACK_COUNT},
{NACKFRAG_COUNT_TOPIC_ALIAS, NACKFRAG_COUNT_TOPIC, NACKFRAG_COUNT},
{GAP_COUNT_TOPIC_ALIAS, GAP_COUNT_TOPIC, GAP_COUNT},
{DATA_COUNT_TOPIC_ALIAS, DATA_COUNT_TOPIC, DATA_COUNT},
{PDP_PACKETS_TOPIC_ALIAS, PDP_PACKETS_TOPIC, PDP_PACKETS},
{EDP_PACKETS_TOPIC_ALIAS, EDP_PACKETS_TOPIC, EDP_PACKETS},
{DISCOVERY_TOPIC_ALIAS, DISCOVERY_TOPIC, DISCOVERED_ENTITY},
{SAMPLE_DATAS_TOPIC_ALIAS, SAMPLE_DATAS_TOPIC, SAMPLE_DATAS},
{PHYSICAL_DATA_TOPIC_ALIAS, PHYSICAL_DATA_TOPIC, PHYSICAL_DATA}
{HISTORY_LATENCY_TOPIC_ALIAS, HISTORY_LATENCY_TOPIC, EventKind::HISTORY2HISTORY_LATENCY},
{NETWORK_LATENCY_TOPIC_ALIAS, NETWORK_LATENCY_TOPIC, EventKind::NETWORK_LATENCY},
{PUBLICATION_THROUGHPUT_TOPIC_ALIAS, PUBLICATION_THROUGHPUT_TOPIC, EventKind::PUBLICATION_THROUGHPUT},
{SUBSCRIPTION_THROUGHPUT_TOPIC_ALIAS, SUBSCRIPTION_THROUGHPUT_TOPIC, EventKind::SUBSCRIPTION_THROUGHPUT},
{RTPS_SENT_TOPIC_ALIAS, RTPS_SENT_TOPIC, EventKind::RTPS_SENT},
{RTPS_LOST_TOPIC_ALIAS, RTPS_LOST_TOPIC, EventKind::RTPS_LOST},
{RESENT_DATAS_TOPIC_ALIAS, RESENT_DATAS_TOPIC, EventKind::RESENT_DATAS},
{HEARTBEAT_COUNT_TOPIC_ALIAS, HEARTBEAT_COUNT_TOPIC, EventKind::HEARTBEAT_COUNT},
{ACKNACK_COUNT_TOPIC_ALIAS, ACKNACK_COUNT_TOPIC, EventKind::ACKNACK_COUNT},
{NACKFRAG_COUNT_TOPIC_ALIAS, NACKFRAG_COUNT_TOPIC, EventKind::NACKFRAG_COUNT},
{GAP_COUNT_TOPIC_ALIAS, GAP_COUNT_TOPIC, EventKind::GAP_COUNT},
{DATA_COUNT_TOPIC_ALIAS, DATA_COUNT_TOPIC, EventKind::DATA_COUNT},
{PDP_PACKETS_TOPIC_ALIAS, PDP_PACKETS_TOPIC, EventKind::PDP_PACKETS},
{EDP_PACKETS_TOPIC_ALIAS, EDP_PACKETS_TOPIC, EventKind::EDP_PACKETS},
{DISCOVERY_TOPIC_ALIAS, DISCOVERY_TOPIC, EventKind::DISCOVERED_ENTITY},
{SAMPLE_DATAS_TOPIC_ALIAS, SAMPLE_DATAS_TOPIC, EventKind::SAMPLE_DATAS},
{PHYSICAL_DATA_TOPIC_ALIAS, PHYSICAL_DATA_TOPIC, EventKind::PHYSICAL_DATA}
};

ReturnCode_t DomainParticipantImpl::enable_statistics_datawriter(
const std::string& topic_name,
const efd::DataWriterQos& dwqos)
{
std::string use_topic_name;
EventKind event_kind;
uint32_t event_kind;
if (!transform_and_check_topic_name(topic_name, use_topic_name, event_kind))
{
return ReturnCode_t::RETCODE_BAD_PARAMETER;
Expand Down Expand Up @@ -215,7 +215,7 @@ ReturnCode_t DomainParticipantImpl::disable_statistics_datawriter(
{
ReturnCode_t ret = ReturnCode_t::RETCODE_OK;
std::string use_topic_name;
EventKind event_kind;
uint32_t event_kind;
if (!transform_and_check_topic_name(topic_name, use_topic_name, event_kind))
{
return ReturnCode_t::RETCODE_BAD_PARAMETER;
Expand Down Expand Up @@ -499,7 +499,7 @@ bool DomainParticipantImpl::is_statistics_topic_name(
bool DomainParticipantImpl::transform_and_check_topic_name(
const std::string& topic_name_or_alias,
std::string& topic_name,
EventKind& event_kind) noexcept
uint32_t& event_kind) noexcept
{
for (const ValidEntry& entry : valid_entries)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class DomainParticipantImpl : public efd::DomainParticipantImpl,
bool transform_and_check_topic_name(
const std::string& topic_name_or_alias,
std::string& topic_name,
EventKind& event_kind) noexcept;
uint32_t& event_kind) noexcept;

/**
* Auxiliary function to register the statistics type depending on the statistics topic name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace statistics {
namespace dds {

void DomainParticipantStatisticsListener::set_datawriter(
EventKind kind,
uint32_t kind,
DataWriter* writer)
{
std::lock_guard<std::mutex> guard(mtx_);
Expand All @@ -51,7 +51,7 @@ void DomainParticipantStatisticsListener::on_statistics_data(
const Data& statistics_data)
{
DataWriter* writer = nullptr;
EventKind data_kind = statistics_data._d();
uint32_t data_kind = statistics_data._d();

// Find corresponding writer
{
Expand All @@ -69,44 +69,44 @@ void DomainParticipantStatisticsListener::on_statistics_data(

switch (data_kind)
{
case EventKindBits::HISTORY2HISTORY_LATENCY:
case EventKind::HISTORY2HISTORY_LATENCY:
data_sample = &statistics_data.writer_reader_data();
break;

case EventKindBits::NETWORK_LATENCY:
case EventKind::NETWORK_LATENCY:
data_sample = &statistics_data.locator2locator_data();
break;

case EventKindBits::PUBLICATION_THROUGHPUT:
case EventKindBits::SUBSCRIPTION_THROUGHPUT:
case EventKind::PUBLICATION_THROUGHPUT:
case EventKind::SUBSCRIPTION_THROUGHPUT:
data_sample = &statistics_data.entity_data();
break;

case EventKindBits::RTPS_SENT:
case EventKindBits::RTPS_LOST:
case EventKind::RTPS_SENT:
case EventKind::RTPS_LOST:
data_sample = &statistics_data.entity2locator_traffic();
break;

case EventKindBits::RESENT_DATAS:
case EventKindBits::HEARTBEAT_COUNT:
case EventKindBits::ACKNACK_COUNT:
case EventKindBits::NACKFRAG_COUNT:
case EventKindBits::GAP_COUNT:
case EventKindBits::DATA_COUNT:
case EventKindBits::PDP_PACKETS:
case EventKindBits::EDP_PACKETS:
case EventKind::RESENT_DATAS:
case EventKind::HEARTBEAT_COUNT:
case EventKind::ACKNACK_COUNT:
case EventKind::NACKFRAG_COUNT:
case EventKind::GAP_COUNT:
case EventKind::DATA_COUNT:
case EventKind::PDP_PACKETS:
case EventKind::EDP_PACKETS:
data_sample = &statistics_data.entity_count();
break;

case EventKindBits::DISCOVERED_ENTITY:
case EventKind::DISCOVERED_ENTITY:
data_sample = &statistics_data.discovery_time();
break;

case EventKindBits::SAMPLE_DATAS:
case EventKind::SAMPLE_DATAS:
data_sample = &statistics_data.sample_identity_count();
break;

case EventKindBits::PHYSICAL_DATA:
case EventKind::PHYSICAL_DATA:
data_sample = &statistics_data.physical_data();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct DomainParticipantStatisticsListener : public IListener
using DataWriter = eprosima::fastdds::dds::DataWriter;

void set_datawriter(
EventKind kind,
uint32_t kind,
DataWriter* writer);

void on_statistics_data(
Expand All @@ -54,7 +54,7 @@ struct DomainParticipantStatisticsListener : public IListener
private:

std::mutex mtx_;
std::map<EventKind, DataWriter*> writers_;
std::map<uint32_t, DataWriter*> writers_;
std::atomic<uint32_t> enabled_writers_mask_{0};
};

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/statistics/rtps/GuidUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline bool is_statistics_builtin(
* @param [out] entity_id The corresponding entity id.
*/
inline void set_statistics_entity_id(
EventKind kind,
uint32_t kind,
fastrtps::rtps::EntityId_t& entity_id)
{
entity_id.value[3] = 0x62;
Expand Down
38 changes: 19 additions & 19 deletions src/cpp/statistics/rtps/StatisticsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ bool StatisticsParticipantImpl::are_writers_involved(
{
using namespace fastdds::statistics;

constexpr uint32_t writers_maks = PUBLICATION_THROUGHPUT \
| RESENT_DATAS \
| HEARTBEAT_COUNT \
| GAP_COUNT \
| DATA_COUNT \
| SAMPLE_DATAS;
constexpr uint32_t writers_maks = EventKind::PUBLICATION_THROUGHPUT \
| EventKind::RESENT_DATAS \
| EventKind::HEARTBEAT_COUNT \
| EventKind::GAP_COUNT \
| EventKind::DATA_COUNT \
| EventKind::SAMPLE_DATAS;

return writers_maks & mask;
}
Expand All @@ -225,10 +225,10 @@ bool StatisticsParticipantImpl::are_readers_involved(
{
using namespace fastdds::statistics;

constexpr uint32_t readers_maks = HISTORY2HISTORY_LATENCY \
| SUBSCRIPTION_THROUGHPUT \
| ACKNACK_COUNT \
| NACKFRAG_COUNT;
constexpr uint32_t readers_maks = EventKind::HISTORY2HISTORY_LATENCY \
| EventKind::SUBSCRIPTION_THROUGHPUT \
| EventKind::ACKNACK_COUNT \
| EventKind::NACKFRAG_COUNT;

return readers_maks & mask;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ void StatisticsParticipantImpl::process_network_timestamp(
{
using namespace eprosima::fastrtps::rtps;

if (!are_statistics_writers_enabled(EventKindBits::NETWORK_LATENCY))
if (!are_statistics_writers_enabled(EventKind::NETWORK_LATENCY))
{
return;
}
Expand Down Expand Up @@ -432,7 +432,7 @@ void StatisticsParticipantImpl::process_network_sequence(
const rtps::StatisticsSubmessageData::Sequence& seq,
uint64_t datagram_size)
{
if (!are_statistics_writers_enabled(EventKindBits::RTPS_LOST))
if (!are_statistics_writers_enabled(EventKind::RTPS_LOST))
{
return;
}
Expand Down Expand Up @@ -490,7 +490,7 @@ void StatisticsParticipantImpl::process_network_sequence(
Data data;
// note that the setter sets RTPS_SENT by default
data.entity2locator_traffic(notification);
data._d(EventKindBits::RTPS_LOST);
data._d(EventKind::RTPS_LOST);

for_each_listener([&data](const Key& listener)
{
Expand All @@ -506,7 +506,7 @@ void StatisticsParticipantImpl::on_rtps_sent(
using namespace std;
using eprosima::fastrtps::rtps::RTPSParticipantImpl;

if (!are_statistics_writers_enabled(EventKindBits::RTPS_SENT))
if (!are_statistics_writers_enabled(EventKind::RTPS_SENT))
{
return;
}
Expand Down Expand Up @@ -542,7 +542,7 @@ void StatisticsParticipantImpl::on_entity_discovery(
{
using namespace fastrtps;

if (!are_statistics_writers_enabled(EventKindBits::DISCOVERED_ENTITY))
if (!are_statistics_writers_enabled(EventKind::DISCOVERED_ENTITY))
{
return;
}
Expand Down Expand Up @@ -601,7 +601,7 @@ void StatisticsParticipantImpl::on_entity_discovery(
void StatisticsParticipantImpl::on_pdp_packet(
const uint32_t packages)
{
if (!are_statistics_writers_enabled(EventKindBits::PDP_PACKETS))
if (!are_statistics_writers_enabled(EventKind::PDP_PACKETS))
{
return;
}
Expand All @@ -619,7 +619,7 @@ void StatisticsParticipantImpl::on_pdp_packet(
Data data;
// note that the setter sets RESENT_DATAS by default
data.entity_count(notification);
data._d(EventKindBits::PDP_PACKETS);
data._d(EventKind::PDP_PACKETS);

for_each_listener([&data](const std::shared_ptr<IListener>& listener)
{
Expand All @@ -630,7 +630,7 @@ void StatisticsParticipantImpl::on_pdp_packet(
void StatisticsParticipantImpl::on_edp_packet(
const uint32_t packages)
{
if (!are_statistics_writers_enabled(EventKindBits::EDP_PACKETS))
if (!are_statistics_writers_enabled(EventKind::EDP_PACKETS))
{
return;
}
Expand All @@ -648,7 +648,7 @@ void StatisticsParticipantImpl::on_edp_packet(
Data data;
// note that the setter sets RESENT_DATAS by default
data.entity_count(notification);
data._d(EventKindBits::EDP_PACKETS);
data._d(EventKind::EDP_PACKETS);

for_each_listener([&data](const std::shared_ptr<IListener>& listener)
{
Expand Down
14 changes: 7 additions & 7 deletions src/cpp/statistics/rtps/reader/StatisticsReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void StatisticsReaderImpl::on_data_notify(
const fastrtps::rtps::GUID_t& writer_guid,
const fastrtps::rtps::Time_t& source_timestamp)
{
if (!are_statistics_writers_enabled(EventKindBits::HISTORY2HISTORY_LATENCY))
if (!are_statistics_writers_enabled(EventKind::HISTORY2HISTORY_LATENCY))
{
return;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ void StatisticsReaderImpl::on_data_notify(
void StatisticsReaderImpl::on_acknack(
int32_t count)
{
if (!are_statistics_writers_enabled(EventKindBits::ACKNACK_COUNT))
if (!are_statistics_writers_enabled(EventKind::ACKNACK_COUNT))
{
return;
}
Expand All @@ -109,7 +109,7 @@ void StatisticsReaderImpl::on_acknack(
Data data;
// note that the setter sets RESENT_DATAS by default
data.entity_count(notification);
data._d(EventKindBits::ACKNACK_COUNT);
data._d(EventKind::ACKNACK_COUNT);

for_each_listener([&data](const std::shared_ptr<IListener>& listener)
{
Expand All @@ -120,7 +120,7 @@ void StatisticsReaderImpl::on_acknack(
void StatisticsReaderImpl::on_nackfrag(
int32_t count)
{
if (!are_statistics_writers_enabled(EventKindBits::NACKFRAG_COUNT))
if (!are_statistics_writers_enabled(EventKind::NACKFRAG_COUNT))
{
return;
}
Expand All @@ -133,7 +133,7 @@ void StatisticsReaderImpl::on_nackfrag(
Data data;
// note that the setter sets RESENT_DATAS by default
data.entity_count(notification);
data._d(EventKindBits::NACKFRAG_COUNT);
data._d(EventKind::NACKFRAG_COUNT);

for_each_listener([&data](const std::shared_ptr<IListener>& listener)
{
Expand All @@ -149,7 +149,7 @@ void StatisticsReaderImpl::on_subscribe_throughput(

if (payload > 0 )
{
if (!are_statistics_writers_enabled(EventKindBits::SUBSCRIPTION_THROUGHPUT))
if (!are_statistics_writers_enabled(EventKind::SUBSCRIPTION_THROUGHPUT))
{
return;
}
Expand All @@ -170,7 +170,7 @@ void StatisticsReaderImpl::on_subscribe_throughput(
Data data;
// note that the setter sets PUBLICATION_THROUGHPUT by default
data.entity_data(std::move(notification));
data._d(EventKindBits::SUBSCRIPTION_THROUGHPUT);
data._d(EventKind::SUBSCRIPTION_THROUGHPUT);

for_each_listener([&data](const std::shared_ptr<IListener>& listener)
{
Expand Down
Loading

0 comments on commit b3f47ee

Please sign in to comment.