Skip to content

Commit 8bf93a3

Browse files
authored
Calculate DDS vendor and add it to participant info (#263)
* Calculate DDS vendor and add to participant info Signed-off-by: Raul Sanchez-Mateos <[email protected]> * Update tests Signed-off-by: Raul Sanchez-Mateos <[email protected]> * Add tests covering dds vendor calculation Signed-off-by: Raul Sanchez-Mateos <[email protected]> * Update docs Signed-off-by: Raul Sanchez-Mateos <[email protected]> * Uncrustify Signed-off-by: Raul Sanchez-Mateos <[email protected]> * Remove uncrustify backup files Signed-off-by: Raul Sanchez-Mateos <[email protected]> --------- Signed-off-by: Raul Sanchez-Mateos <[email protected]>
1 parent aa9dc25 commit 8bf93a3

28 files changed

+403
-208
lines changed

docs/code/datareader_info_example.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"metatraffic": false,
88
"status": "OK",
99
"guid": "01.0f.22.cd.59.64.04.00.05.00.00.00|00.00.01.04",
10+
"dds_vendor": "FASTDDS",
1011
"qos":
1112
{
1213
"data_sharing":

docs/code/datawriter_info_example.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"metatraffic": false,
88
"status": "OK",
99
"guid": "01.0f.22.cd.59.64.04.00.02.00.00.00|00.00.01.03",
10+
"dds_vendor": "FASTDDS",
1011
"qos":
1112
{
1213
"data_sharing":

docs/code/dump_example.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
{
6262
"name": "participant_0",
6363
"guid": "01.0f.00.00.00.00.00.00.00.00.00.00|00.00.00.00",
64+
"dds_vendor": "FASTDDS",
6465
"qos": {"qos": "empty"},
6566
"app_id": "SHAPES_DEMO",
6667
"process": "3",

docs/code/graph_example.json

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"alias": "shapes_demo_participant_1_alias",
4545
"status": "OK",
4646
"app_id": "SHAPES_DEMO",
47+
"dds_vendor": "FASTDDS",
4748
"endpoints":
4849
{
4950
"6":
@@ -75,6 +76,7 @@
7576
"alias": "shapes_demo_participant_2_alias",
7677
"status": "OK",
7778
"app_id": "SHAPES_DEMO",
79+
"dds_vendor": "FASTDDS",
7880
"endpoints":
7981
{
8082
"9":

docs/code/participant_info_example.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"metatraffic": false,
88
"status": "OK",
99
"guid": "01.0f.22.cd.59.64.04.00.05.00.00.00|00.00.01.c1",
10+
"dds_vendor": "FASTDDS",
1011
"qos": {
1112
"available_builtin_endpoints": 3135,
1213
"lease_duration":

include/fastdds_statistics_backend/types/JSONTags.h

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ constexpr const char* APP_ID_TAG = "app_id";
125125
constexpr const char* APP_METADATA_TAG = "app_metadata";
126126
//! Key tag for meta traffic flag of a virtual endpoint
127127
constexpr const char* VIRTUAL_METATRAFFIC_TAG = "virtual_metatraffic";
128+
//! Key tag for vendor id of a participant entity
129+
constexpr const char* DDS_VENDOR_TAG = "dds_vendor";
128130

129131
//! Conversion from EntityKind to string
130132
constexpr const char* entity_kind_str[] =

include/fastdds_statistics_backend/types/types.hpp

+20
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ enum class AppId
195195
SUSTAINML,
196196
};
197197

198+
/**
199+
* Indicates the Vendor of a participant in Statistics Backend structure
200+
*/
201+
enum class DdsVendor
202+
{
203+
/// Unknown Vendor
204+
UNKNOWN,
205+
206+
/// Fast DDS Vendor
207+
FASTDDS,
208+
209+
/// Safe DDS Vendor
210+
SAFEDDS,
211+
};
212+
213+
/**
214+
* Conversion from EntityKind to string
215+
*/
216+
constexpr const char* dds_vendor_str[] = {"UNKNOWN", "FASTDDS", "SAFEDDS"};
217+
198218
/**
199219
* Indicates the Type of Data stored by the Backend
200220
*

src/cpp/database/database.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -4057,6 +4057,11 @@ Graph Database::get_entity_subgraph_nts(
40574057
entity_graph[APP_METADATA_TAG] = participant->app_metadata;
40584058
entity_graph_updated = true;
40594059
}
4060+
if (entity_graph[DDS_VENDOR_TAG] != dds_vendor_str[static_cast<int>(participant->dds_vendor)])
4061+
{
4062+
entity_graph[DDS_VENDOR_TAG] = dds_vendor_str[static_cast<int>(participant->dds_vendor)];
4063+
entity_graph_updated = true;
4064+
}
40604065
break;
40614066
}
40624067
case (EntityKind::DATAWRITER):
@@ -5733,6 +5738,7 @@ Info Database::get_info(
57335738
info[QOS_TAG] = participant->qos;
57345739
info[APP_ID_TAG] = app_id_str[(int)participant->app_id];
57355740
info[APP_METADATA_TAG] = participant->app_metadata;
5741+
info[DDS_VENDOR_TAG] = participant->dds_vendor;
57365742

57375743
// Locators associated to endpoints
57385744
std::set<std::string> locator_set;
@@ -5774,6 +5780,7 @@ Info Database::get_info(
57745780
info[QOS_TAG] = dds_entity->qos;
57755781
info[APP_ID_TAG] = app_id_str[(int)dds_entity->app_id];
57765782
info[APP_METADATA_TAG] = dds_entity->app_metadata;
5783+
info[DDS_VENDOR_TAG] = dds_entity->dds_vendor;
57775784
break;
57785785
}
57795786
default:

src/cpp/database/entities.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ bool Entity::is_metatraffic_topic(
5454
return is_metatraffic;
5555
}
5656

57+
DdsVendor DDSEntity::dds_vendor_by_guid(
58+
const std::string& guid)
59+
{
60+
// GUID vendor prefixes
61+
const std::map<std::string, DdsVendor> dds_vendor_prefixes = {
62+
{"01.0f", DdsVendor::FASTDDS},
63+
{"01.15", DdsVendor::SAFEDDS}
64+
};
65+
66+
std::string prefix = guid.substr(0, 5); // Assuming the prefix is the first 5 characters
67+
68+
auto it = dds_vendor_prefixes.find(prefix);
69+
if (it != dds_vendor_prefixes.end())
70+
{
71+
return it->second;
72+
}
73+
return DdsVendor::UNKNOWN;
74+
}
75+
5776
DDSEndpoint::DDSEndpoint(
5877
EntityKind entity_kind, /* EntityKind::INVALID */
5978
std::string endpoint_name, /* "INVALID" */

src/cpp/database/entities.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,19 @@ struct DDSEntity : Entity
241241
, guid(dds_entity_guid)
242242
, app_id(dds_entity_app_id)
243243
, app_metadata(dds_entity_app_metadata)
244+
, dds_vendor(dds_vendor_by_guid(dds_entity_guid))
244245
{
245246
}
246247

248+
/**
249+
* @brief Check whether the vendor is known based on the GUID.
250+
*
251+
* @param guid The GUID to check.
252+
* @return The vendor name if known, "Unknown" otherwise.
253+
*/
254+
static DdsVendor dds_vendor_by_guid(
255+
const std::string& guid);
256+
247257
//! Quality of Service configuration of the entities in a tree structure.
248258
Qos qos;
249259

@@ -253,6 +263,9 @@ struct DDSEntity : Entity
253263
//! DDS entity app properties.
254264
AppId app_id;
255265
std::string app_metadata;
266+
267+
//! The vendor of the DomainParticipant
268+
DdsVendor dds_vendor;
256269
};
257270

258271
/*

test/unittest/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ add_subdirectory(Container)
7777
add_subdirectory(Database)
7878
add_subdirectory(DatabaseQueue)
7979
add_subdirectory(EntityId)
80+
add_subdirectory(DdsVendor)
8081
add_subdirectory(EntityMetatraffic)
8182
add_subdirectory(fragile_ptr)
8283
add_subdirectory(QosSerializer)

test/unittest/Database/DatabaseDomainViewGraphTests.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class database_domain_view_graph_tests : public ::testing::Test
7979
participant_1 = std::make_shared<database::DomainParticipant>(
8080
"participant_1",
8181
entity_qos,
82-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1",
82+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1",
8383
std::shared_ptr<database::Process>(),
8484
domain,
8585
StatusLevel::OK_STATUS,
@@ -89,7 +89,7 @@ class database_domain_view_graph_tests : public ::testing::Test
8989
datawriter_1 = std::make_shared<database::DataWriter>(
9090
"publisher",
9191
entity_qos,
92-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c2",
92+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c2",
9393
participant_1,
9494
topic,
9595
StatusLevel::OK_STATUS,
@@ -101,7 +101,7 @@ class database_domain_view_graph_tests : public ::testing::Test
101101
participant_2 = std::make_shared<database::DomainParticipant>(
102102
"participant_2",
103103
entity_qos,
104-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c3",
104+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c3",
105105
std::shared_ptr<database::Process>(),
106106
domain,
107107
StatusLevel::OK_STATUS,
@@ -111,7 +111,7 @@ class database_domain_view_graph_tests : public ::testing::Test
111111
datareader_2 = std::make_shared<database::DataReader>(
112112
"subscriber",
113113
entity_qos,
114-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c4",
114+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c4",
115115
participant_2,
116116
topic,
117117
StatusLevel::OK_STATUS,
@@ -161,7 +161,8 @@ class database_domain_view_graph_tests : public ::testing::Test
161161

162162
};
163163

164-
// Complete test with two participants (datawriter and datareader), testing add to graph and delete from graph funcionalities
164+
// Complete test with two participants (datawriter and datareader),
165+
// testing add to graph and delete from graph funcionalities
165166
TEST_F(database_domain_view_graph_tests, complete_with_two_participants)
166167
{
167168
nlohmann::json json_graph;

test/unittest/Database/DatabaseProcessEntitiesTests.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ class database_process_entities_tests : public ::testing::Test
4747
domain_name = "test_domain";
4848

4949
participant_name = "test_participant";
50-
participant_guid = "01.02.03.04.05.06.07.08.09.10.11.12";
50+
participant_guid = "01.0f.03.04.05.06.07.08.09.10.11.12";
5151

5252
topic_name = "test_topic";
5353
topic_alias = topic_name;
5454
topic_type = "test_topic_type";
5555

5656
writer_name = "test_writer";
5757
writer_alias = writer_name;
58-
writer_guid = "01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.3";
58+
writer_guid = "01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.3";
5959

6060
reader_name = "test_reader";
6161
reader_alias = reader_name;
62-
reader_guid = "01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.4";
62+
reader_guid = "01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.4";
6363

6464
unicast_locator_str = "UDPv4:[127.0.0.1]:1024";
6565
multicast_locator_str = "UDPv4:[239.1.1.1]:1024";
@@ -123,6 +123,7 @@ TEST_F(database_process_entities_tests, insert_new_participant)
123123
ASSERT_EQ(AppId::UNKNOWN, participants[domain_id][participant_id]->app_id);
124124
ASSERT_EQ("", participants[domain_id][participant_id]->app_metadata);
125125
ASSERT_EQ(domain->participants[participant_id].get(), participants[domain_id][participant_id].get());
126+
ASSERT_EQ(DdsVendor::FASTDDS, participants[domain_id][participant_id]->dds_vendor);
126127
}
127128

128129
TEST_F(database_process_entities_tests, insert_new_participant_already_exists)

test/unittest/Database/DatabaseStatusTests.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ TEST_F(database_status_tests, participant)
690690

691691
// The new entity will be active
692692
auto participant1 = std::make_shared<DomainParticipant>("participant1", "qos",
693-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
693+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
694694
domain);
695695
db.insert(participant1);
696696
ASSERT_TRUE(participant1->active);
@@ -844,7 +844,7 @@ TEST_F(database_status_tests, link_active_participant_with_inactive_process)
844844

845845
// The new entity will be active
846846
auto participant1 = std::make_shared<DomainParticipant>("participant1", "qos",
847-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
847+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
848848
domain);
849849
db.insert(participant1);
850850

@@ -878,7 +878,7 @@ TEST_F(database_status_tests, link_inactive_participant_with_active_process)
878878
{
879879
// The new entity will be inactive
880880
auto participant1 = std::make_shared<DomainParticipant>("participant1", "qos",
881-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
881+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
882882
domain);
883883
db.insert(participant1);
884884
db.change_entity_status(participant1->id, false);
@@ -926,7 +926,7 @@ TEST_F(database_status_tests, link_inactive_participant_with_inactive_process)
926926

927927
// The new entity will be inactive
928928
auto participant1 = std::make_shared<DomainParticipant>("participant1", "qos",
929-
"01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
929+
"01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1", nullptr,
930930
domain);
931931
db.insert(participant1);
932932
db.change_entity_status(participant1->id, false);

test/unittest/Database/DatabaseTests.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ class database_tests : public ::testing::Test
600600
std::shared_ptr<Domain> domain;
601601
EntityId domain_id;
602602
std::string participant_name = "test_participant";
603-
std::string participant_guid = "01.02.03.04.05.06.07.08.09.10.11.12";
603+
std::string participant_guid = "01.0f.03.04.05.06.07.08.09.10.11.12";
604604
std::shared_ptr<DomainParticipant> participant;
605605
EntityId participant_id;
606606
std::string topic_name = "test_topic";
@@ -610,13 +610,13 @@ class database_tests : public ::testing::Test
610610
std::string writer_locator_name = "test_writer_locator";
611611
std::shared_ptr<Locator> writer_locator;
612612
std::string writer_name = "test_writer";
613-
std::string writer_guid = "01.02.03.04.05.06.07.08.09.10.11.12|0.0.0.1";
613+
std::string writer_guid = "01.0f.03.04.05.06.07.08.09.10.11.12|0.0.0.1";
614614
std::shared_ptr<DataWriter> writer;
615615
EntityId writer_id;
616616
std::string reader_locator_name = "test_reader_locator";
617617
std::shared_ptr<Locator> reader_locator;
618618
std::string reader_name = "test_reader";
619-
std::string reader_guid = "01.02.03.04.05.06.07.08.09.10.11.12|0.0.0.2";
619+
std::string reader_guid = "01.0f.03.04.05.06.07.08.09.10.11.12|0.0.0.2";
620620
std::shared_ptr<DataReader> reader;
621621
EntityId reader_id;
622622

@@ -2658,7 +2658,7 @@ TEST_F(database_tests, insert_monitor_service_sample_connection_list)
26582658
eprosima::fastdds::statistics::detail::GUID_s guid_s;
26592659
eprosima::fastdds::
26602660
rtps::GUID_t guid_t;
2661-
std::stringstream guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
2661+
std::stringstream guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
26622662
guid_str >> guid_t;
26632663
memcpy(guid_s.guidPrefix().value().data(), guid_t.guidPrefix.value, eprosima::fastdds::
26642664
rtps::GuidPrefix_t::size);
@@ -2688,7 +2688,7 @@ TEST_F(database_tests, insert_monitor_service_sample_connection_list)
26882688
eprosima::fastdds::statistics::detail::GUID_s guid_s_2;
26892689
eprosima::fastdds::
26902690
rtps::GUID_t guid_t_2;
2691-
std::stringstream guid_str_2("01.02.03.04.05.06.07.08.09.0a.0b.1c|0.0.1.c1");
2691+
std::stringstream guid_str_2("01.0f.03.04.05.06.07.08.09.0a.0b.1c|0.0.1.c1");
26922692
guid_str_2 >> guid_t_2;
26932693
memcpy(guid_s_2.guidPrefix().value().data(), guid_t_2.guidPrefix.value,
26942694
eprosima::fastdds::
@@ -2734,7 +2734,7 @@ TEST_F(database_tests, insert_monitor_service_sample_connection_list_wrong_entit
27342734
eprosima::fastdds::statistics::detail::GUID_s guid_s;
27352735
eprosima::fastdds::
27362736
rtps::GUID_t guid_t;
2737-
std::stringstream guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
2737+
std::stringstream guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
27382738
guid_str >> guid_t;
27392739
memcpy(guid_s.guidPrefix().value().data(), guid_t.guidPrefix.value, eprosima::fastdds::
27402740
rtps::GuidPrefix_t::size);
@@ -3083,7 +3083,7 @@ TEST_F(database_tests, insert_monitor_service_sample_extended_incompatible_qos)
30833083
{
30843084
ExtendedIncompatibleQosSample sample;
30853085
eprosima::fastdds::statistics::ExtendedIncompatibleQoSStatus_s status;
3086-
std::stringstream remote_entity_guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
3086+
std::stringstream remote_entity_guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
30873087
eprosima::fastdds::statistics::detail::GUID_s remote_entity_guid_s;
30883088
eprosima::fastdds::rtps::GUID_t remote_entity_guid_t;
30893089

@@ -3137,7 +3137,7 @@ TEST_F(database_tests, insert_monitor_service_sample_extended_incompatible_qos_w
31373137
{
31383138
ExtendedIncompatibleQosSample sample;
31393139
eprosima::fastdds::statistics::ExtendedIncompatibleQoSStatus_s status;
3140-
std::stringstream remote_entity_guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
3140+
std::stringstream remote_entity_guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
31413141
eprosima::fastdds::statistics::detail::GUID_s remote_entity_guid_s;
31423142
eprosima::fastdds::rtps::GUID_t remote_entity_guid_t;
31433143

@@ -3554,10 +3554,10 @@ TEST_F(database_tests, get_entity_kind_by_guid)
35543554
eprosima::fastdds::rtps::GUID_t reader_guid_t;
35553555
eprosima::fastdds::rtps::GUID_t writer_guid_t;
35563556
eprosima::fastdds::rtps::GUID_t other_guid_t;
3557-
std::stringstream participant_guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
3558-
std::stringstream reader_guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.4");
3559-
std::stringstream writer_guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.3");
3560-
std::stringstream other_guid_str("01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.1");
3557+
std::stringstream participant_guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.c1");
3558+
std::stringstream reader_guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.4");
3559+
std::stringstream writer_guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.3");
3560+
std::stringstream other_guid_str("01.0f.03.04.05.06.07.08.09.0a.0b.0c|0.0.1.1");
35613561

35623562
participant_guid_str >> participant_guid_t;
35633563
memcpy(

0 commit comments

Comments
 (0)