Skip to content

Commit 1db8cbd

Browse files
Discovery Server refactor (#76)
* Refs #20629: Remove useless XML field Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Use locatorlist instead of RemoteServerAttribute Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Add TCP tests Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Improve DS Tests infrastructure Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Use LocatorList in XML config files Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Update snapshots with new architecture Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Fix test_params Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Add GUIDLess tests Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Use whitelist to avoid interfaces translation problem Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Avoid SC matching with remote servers Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Add participant name to snapshot generated Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Update GroundTruthValidator with new parameter Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Update guidless snapshots Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #20629: Update Backup tests with mesh topology Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> --------- Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
1 parent c323886 commit 1db8cbd

107 files changed

Lines changed: 5696 additions & 6886 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/HelloWorldExampleDS/HelloWorldPublisher.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ bool HelloWorldPublisher::init(
4949
m_hello.index(0);
5050
m_hello.message("HelloWorld");
5151

52-
RemoteServerAttributes ratt;
53-
54-
ratt.ReadguidPrefix("44.49.53.43.53.45.52.56.45.52.5F.31");
52+
LocatorList_t remote_server;
5553

5654
DomainParticipantQos participant_qos = PARTICIPANT_QOS_DEFAULT;
5755

@@ -70,8 +68,8 @@ bool HelloWorldPublisher::init(
7068
IPLocator::setPhysicalPort(server_address, default_port);
7169
IPLocator::setLogicalPort(server_address, 65215);
7270

73-
ratt.metatrafficUnicastLocatorList.push_back(server_address);
74-
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
71+
remote_server.push_back(server_address);
72+
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
7573
participant_qos.transport().use_builtin_transports = false;
7674
std::shared_ptr<TCPv4TransportDescriptor> descriptor = std::make_shared<TCPv4TransportDescriptor>();
7775

@@ -90,8 +88,8 @@ bool HelloWorldPublisher::init(
9088
IPLocator::setIPv4(server_address, 127, 0, 0, 1);
9189
}
9290

93-
ratt.metatrafficUnicastLocatorList.push_back(server_address);
94-
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
91+
remote_server.push_back(server_address);
92+
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
9593
}
9694

9795
participant_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;

examples/HelloWorldExampleDS/HelloWorldSubscriber.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ bool HelloWorldSubscriber::init(
4646
Locator server_address)
4747
{
4848

49-
RemoteServerAttributes ratt;
50-
ratt.ReadguidPrefix("44.49.53.43.53.45.52.56.45.52.5F.31");
49+
LocatorList_t remote_server;
5150

5251
DomainParticipantQos participant_qos = PARTICIPANT_QOS_DEFAULT;
5352

@@ -66,8 +65,8 @@ bool HelloWorldSubscriber::init(
6665
IPLocator::setPhysicalPort(server_address, default_port);
6766
IPLocator::setLogicalPort(server_address, 65215);
6867

69-
ratt.metatrafficUnicastLocatorList.push_back(server_address);
70-
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
68+
remote_server.push_back(server_address);
69+
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
7170
participant_qos.transport().use_builtin_transports = false;
7271
std::shared_ptr<TCPv4TransportDescriptor> descriptor = std::make_shared<TCPv4TransportDescriptor>();
7372

@@ -86,8 +85,8 @@ bool HelloWorldSubscriber::init(
8685
IPLocator::setIPv4(server_address, 127, 0, 0, 1);
8786
}
8887

89-
ratt.metatrafficUnicastLocatorList.push_back(server_address);
90-
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
88+
remote_server.push_back(server_address);
89+
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
9190
}
9291

9392
participant_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;

include/DiscoveryItem.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ struct ParticipantDiscoveryDatabase : public DiscoveryItem, public std::set<Part
326326
typedef std::set<ParticipantDiscoveryItem>::size_type size_type;
327327
typedef ParticipantDiscoveryDatabase::iterator iterator;
328328

329+
std::string participant_name_;
330+
329331
// we need a special iterator that ignores zombie members
330332
struct smart_iterator
331333
: std::iterator<
@@ -365,8 +367,10 @@ struct ParticipantDiscoveryDatabase : public DiscoveryItem, public std::set<Part
365367
};
366368

367369
ParticipantDiscoveryDatabase(
368-
const GUID_t& id )
370+
const GUID_t& id,
371+
const std::string& name = std::string())
369372
: DiscoveryItem(id)
373+
, participant_name_(name)
370374
{
371375
}
372376

@@ -481,6 +485,10 @@ struct Snapshot : public std::set<ParticipantDiscoveryDatabase>
481485
const ParticipantDiscoveryDatabase* operator [](
482486
const GUID_t&) const;
483487

488+
ParticipantDiscoveryDatabase& access_snapshot(
489+
const GUID_t& ptid,
490+
const std::string& name);
491+
484492
void to_xml(
485493
tinyxml2::XMLElement* pRoot,
486494
tinyxml2::XMLDocument& xmlDoc) const;
@@ -508,6 +516,7 @@ class DiscoveryItemDatabase
508516
class T>
509517
bool AddEndPoint(T & (ParticipantDiscoveryItem::* m)() const,
510518
const GUID_t& spokesman,
519+
const std::string& srcName,
511520
const GUID_t& ptid,
512521
const GUID_t& sid,
513522
const std::string& _typename,
@@ -542,6 +551,7 @@ class DiscoveryItemDatabase
542551
//! Adds a new participant, returns false if allocation fails
543552
bool AddParticipant(
544553
const GUID_t& spokesman,
554+
const std::string& srcName,
545555
const GUID_t& ptid,
546556
const std::string& name = std::string(),
547557
const std::chrono::steady_clock::time_point& discovered_timestamp = std::chrono::steady_clock::now(),
@@ -559,6 +569,7 @@ class DiscoveryItemDatabase
559569
//! Adds a new Subscriber, returns false if allocation fails
560570
bool AddDataReader(
561571
const GUID_t& spokesman,
572+
const std::string& srcName,
562573
const GUID_t& ptid,
563574
const GUID_t& sid,
564575
const std::string& _typename,
@@ -573,6 +584,7 @@ class DiscoveryItemDatabase
573584
//! Adds a new Publisher, returns false if allocation fails
574585
bool AddDataWriter(
575586
const GUID_t& spokesman,
587+
const std::string& srcName,
576588
const GUID_t& ptid,
577589
const GUID_t& pid,
578590
const std::string& _typename,

include/IDs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ static const std::string s_sSimples("simples");
3131
static const std::string s_sSimple("simple");
3232
static const std::string s_sPersist("persist");
3333
static const std::string s_sLP("ListeningPorts");
34-
static const std::string s_sSL("ServersList");
35-
static const std::string s_sRServer("RServer");
3634
static const std::string s_sTime("time");
3735
static const std::string s_sSomeone("someone");
3836
static const std::string s_sShowLiveliness("show_liveliness");

resources/xml/test_schema.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@
2525
<builtin>
2626
<discoveryProtocol>CLIENT</discoveryProtocol>
2727
<discoveryServersList>
28-
<RemoteServer prefix="4D.49.47.55.45.4c.5f.42.41.52.52.4f">
29-
<metatrafficUnicastLocatorList>
30-
<locator>
31-
<udpv4>
32-
<address>127.0.0.1</address>
33-
<port>65215</port>
34-
</udpv4>
35-
</locator>
36-
</metatrafficUnicastLocatorList>
37-
</RemoteServer>
28+
<locator>
29+
<udpv4>
30+
<address>127.0.0.1</address>
31+
<port>65215</port>
32+
</udpv4>
33+
</locator>
3834
</discoveryServersList>
3935
</builtin>
4036
</rtps>

resources/xml/test_schema2.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@
4343
<builtin>
4444
<discoveryProtocol>CLIENT</discoveryProtocol>
4545
<discoveryServersList>
46-
<RemoteServer prefix="4D.49.47.55.45.4c.5f.42.41.52.52.4f">
47-
<metatrafficUnicastLocatorList>
48-
<locator>
49-
<udpv4>
50-
<address>127.0.0.1</address>
51-
<port>65215</port>
52-
</udpv4>
53-
</locator>
54-
</metatrafficUnicastLocatorList>
55-
</RemoteServer>
46+
<locator>
47+
<udpv4>
48+
<address>127.0.0.1</address>
49+
<port>65215</port>
50+
</udpv4>
51+
</locator>
5652
</discoveryServersList>
5753
</builtin>
5854
</rtps>

resources/xsd/discovery-server.xsd

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,6 @@
349349
<xs:attribute name="prefix" type="guid" use="required"/>
350350
</xs:complexType>
351351

352-
<xs:complexType name="DiscoveryServerList">
353-
<xs:sequence>
354-
<xs:element name="RemoteServer" type="RemoteServerAttributes" minOccurs="1" maxOccurs="unbounded"/>
355-
</xs:sequence>
356-
</xs:complexType>
357-
358352
<xs:complexType name="initialAnnouncementsType">
359353
<xs:all minOccurs="0">
360354
<xs:element name="count" type="uint32Type" minOccurs="0"/>
@@ -372,7 +366,7 @@
372366
<xs:element name="initialAnnouncements" type="initialAnnouncementsType" minOccurs="0"/>
373367
<xs:element name="simpleEDP" type="simpleEDPType" minOccurs="0"/>
374368
<xs:element name="clientAnnouncementPeriod" type="durationType" minOccurs="0"/>
375-
<xs:element name="discoveryServersList" type="DiscoveryServerList" minOccurs="0"/>
369+
<xs:element name="discoveryServersList" type="locatorListType" minOccurs="0"/>
376370
<xs:element name="staticEndpointXMLFilename" type="stringType" minOccurs="0"/>
377371
</xs:all>
378372
</xs:complexType>
@@ -915,7 +909,6 @@
915909
</xs:choice>
916910
</xs:complexType>
917911
</xs:element>
918-
<xs:element name="ServersList" type="ServersListType" minOccurs="0" maxOccurs="1" />
919912
<!-- not mandatory may be present in the profile -->
920913
<xs:choice minOccurs="0">
921914
<!-- publisher and subscriber must be contiguous but in any order -->
@@ -942,19 +935,8 @@
942935
<!-- removal time in seconds from startup-->
943936
</xs:complexType>
944937

945-
<xs:complexType name="ServersListType">
946-
<xs:sequence>
947-
<xs:element name="RServer" minOccurs="1" maxOccurs="unbounded">
948-
<xs:complexType>
949-
<xs:attribute name="prefix" type="guid" use="required" />
950-
</xs:complexType>
951-
</xs:element>
952-
</xs:sequence>
953-
</xs:complexType>
954-
955938
<xs:complexType name="clientType">
956939
<xs:sequence >
957-
<xs:element name="ServersList" type="ServersListType" minOccurs="0" maxOccurs="1" />
958940
<xs:choice minOccurs="0">
959941
<!-- publisher and subscriber must be contiguous but in any order -->
960942
<xs:sequence>

src/DiscoveryItem.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,15 @@ std::vector<const ParticipantDiscoveryItem*> DiscoveryItemDatabase::FindParticip
382382

383383
bool DiscoveryItemDatabase::AddParticipant(
384384
const GUID_t& spokesman,
385+
const std::string& srcName,
385386
const GUID_t& ptid,
386387
const std::string& name,
387388
const std::chrono::steady_clock::time_point& discovered_timestamp,
388389
bool server /* = false*/)
389390
{
390391
std::lock_guard<std::mutex> lock(database_mutex);
391392

392-
ParticipantDiscoveryDatabase& _database = image[spokesman];
393+
ParticipantDiscoveryDatabase& _database = image.access_snapshot(spokesman, srcName);
393394
ParticipantDiscoveryDatabase::iterator it = std::lower_bound(_database.begin(), _database.end(), ptid);
394395

395396
if (it == _database.end() || *it != ptid)
@@ -455,6 +456,7 @@ template<class T>
455456
bool DiscoveryItemDatabase::AddEndPoint(
456457
T& (ParticipantDiscoveryItem::* m)() const,
457458
const GUID_t& spokesman,
459+
const std::string& srcName,
458460
const GUID_t& ptid,
459461
const GUID_t& id,
460462
const std::string& _typename,
@@ -463,7 +465,7 @@ bool DiscoveryItemDatabase::AddEndPoint(
463465
{
464466
std::lock_guard<std::mutex> lock(database_mutex);
465467

466-
ParticipantDiscoveryDatabase& _database = image[spokesman];
468+
ParticipantDiscoveryDatabase& _database = image.access_snapshot(spokesman, srcName);
467469
ParticipantDiscoveryDatabase::iterator it = std::lower_bound(_database.begin(), _database.end(), ptid);
468470

469471
if (it == _database.end() || ptid == spokesman )
@@ -534,13 +536,14 @@ bool DiscoveryItemDatabase::RemoveEndPoint(
534536

535537
bool DiscoveryItemDatabase::AddDataReader(
536538
const GUID_t& spokesman,
539+
const std::string& srcName,
537540
const GUID_t& ptid,
538541
const GUID_t& sid,
539542
const std::string& _typename,
540543
const std::string& topicname,
541544
const std::chrono::steady_clock::time_point& discovered_timestamp)
542545
{
543-
return AddEndPoint(&ParticipantDiscoveryItem::getDataReaders, spokesman, ptid, sid, _typename, topicname,
546+
return AddEndPoint(&ParticipantDiscoveryItem::getDataReaders, spokesman, srcName, ptid, sid, _typename, topicname,
544547
discovered_timestamp);
545548
}
546549

@@ -554,13 +557,14 @@ bool DiscoveryItemDatabase::RemoveDataReader(
554557

555558
bool DiscoveryItemDatabase::AddDataWriter(
556559
const GUID_t& spokesman,
560+
const std::string& srcName,
557561
const GUID_t& ptid,
558562
const GUID_t& pid,
559563
const std::string& _typename,
560564
const std::string& topicname,
561565
const std::chrono::steady_clock::time_point& discovered_timestamp)
562566
{
563-
return AddEndPoint(&ParticipantDiscoveryItem::getDataWriters, spokesman, ptid, pid, _typename, topicname,
567+
return AddEndPoint(&ParticipantDiscoveryItem::getDataWriters, spokesman, srcName, ptid, pid, _typename, topicname,
564568
discovered_timestamp);
565569
}
566570

@@ -806,6 +810,26 @@ bool eprosima::discovery_server::operator ==(
806810
return false;
807811
}
808812

813+
ParticipantDiscoveryDatabase& Snapshot::access_snapshot (
814+
const GUID_t& id,
815+
const std::string& name)
816+
{
817+
auto it = std::lower_bound(begin(), end(), id);
818+
const ParticipantDiscoveryDatabase* p = nullptr;
819+
820+
if (it == end() || *it != id)
821+
{
822+
// not there, emplace
823+
p = &(*emplace(id, name).first);
824+
}
825+
else
826+
{
827+
p = &*it;
828+
}
829+
830+
return const_cast<ParticipantDiscoveryDatabase&>(*p);
831+
}
832+
809833
ParticipantDiscoveryDatabase& Snapshot::operator [](
810834
const GUID_t& id)
811835
{
@@ -815,7 +839,8 @@ ParticipantDiscoveryDatabase& Snapshot::operator [](
815839
if (it == end() || *it != id)
816840
{
817841
// not there, emplace
818-
p = &(*emplace(id).first);
842+
// should never be called from this operator
843+
p = &(*emplace(id, "").first);
819844
}
820845
else
821846
{
@@ -877,6 +902,11 @@ void Snapshot::to_xml(
877902
sstream << discovery_database.endpoint_guid.entityId;
878903
pPtdb->SetAttribute(s_sGUID_entity.c_str(), sstream.str().c_str());
879904
}
905+
{
906+
std::stringstream sstream;
907+
sstream << discovery_database.participant_name_;
908+
pPtdb->SetAttribute(s_sName.c_str(), sstream.str().c_str());
909+
}
880910

881911
for (const ParticipantDiscoveryItem& discovery_item : discovery_database)
882912
{

0 commit comments

Comments
 (0)