Skip to content

Commit

Permalink
Discovery Server refactor (#4716)
Browse files Browse the repository at this point in the history
* Refs #20629: Spelling

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Random GUID function

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Update CLI for GUID_LESS DS when no server_id is provided

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Improve CLI

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: GUID less env.var.

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Turn servers_ into vector so it is modifyable

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Check participant type from ParameterPropertyList

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Refactor PDPClient

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Refactor PDPServer

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Send Data(p) of servers to create a mesh topology

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Do not send Data(p) of remote clients

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Update Servers' ping routine

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Refactor update_attributes

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Avoid trying to create extra resources

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Support match with security

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Modify DS example to work wo/ GUID

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Use LocatorList for remote servers

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Use LocatorList for remote servers - XML

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Use LocatorList for remote servers - TESTS

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Avoid deleting direct servers senders resources

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Fix tsan

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Add server pdp to queue on client match

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Avoid sending non-direct client Data(Uw|Ur)

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Change Warning into Info

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Protect assign during backup

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Use Participant Type in PDPServerListener

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Match EDP of SUPERCLIENTS too

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Avoid Warning when using dns with env_var

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Uncrustify

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Ping always Remote_servers and initial ping after list update

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Avoid SC matching with remote servers

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Fix windows build

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Fix Mac test and improve Inconsistent test

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Match EDP with virtual EDP of SC

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Protect servers list

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Protect pdp_to_send

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Refactor RTPSParticipantImpl constructor.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20629: Revision - Doxygen and comments

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Revision - major changes

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Rebase

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Review - Make ServerAttributes private

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Minor fix after rebase

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Fix security DS

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Review 2 - Minor fixes

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Use new locator_entry method

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Move ServerAttributes implementation

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Move ServerClientEnvironment tests to unittests & fix discovery of TST

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Fix mac & windows builds

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Review 3

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Add server only in assignRemoteEndpoints

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20629: Add versions.md

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

---------

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
cferreiragonz and MiguelCompany authored Jul 3, 2024
1 parent 9961e61 commit ee84af2
Show file tree
Hide file tree
Showing 99 changed files with 2,326 additions and 3,000 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ bool HelloWorldPublisher::init(
const std::string& topic_name,
const std::string& server_address,
unsigned short server_port,
unsigned short server_id,
TransportKind transport)
{
hello_.index(0);
Expand Down Expand Up @@ -142,7 +141,14 @@ bool HelloWorldPublisher::init(

server_locator.kind = LOCATOR_KIND_TCPv6;
eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, server_port);
eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, ip_server_address);
if (eprosima::fastdds::rtps::IPLocator::isIPv6(ip_server_address))
{
eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, ip_server_address);
}
else
{
eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, "::1");
}
break;
}

Expand All @@ -154,15 +160,8 @@ bool HelloWorldPublisher::init(
pqos.wire_protocol().builtin.discovery_config.discoveryProtocol =
eprosima::fastdds::rtps::DiscoveryProtocol::CLIENT;

// Set SERVER's GUID prefix
RemoteServerAttributes remote_server_att;
remote_server_att.guidPrefix = get_discovery_server_guid_from_id(server_id);

// Set SERVER's listening locator for PDP
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);

// Add remote SERVER to CLIENT's list of SERVERs
pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);

// Add descriptor
pqos.transport().user_transports.push_back(descriptor);
Expand All @@ -179,7 +178,6 @@ bool HelloWorldPublisher::init(
"Publisher Participant " << pqos.name() <<
" created with GUID " << participant_->guid() <<
" connecting to server <" << server_locator << "> " <<
" with Guid: <" << remote_server_att.guidPrefix << "> " <<
std::endl;

// REGISTER THE TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class HelloWorldPublisher
const std::string& topic_name,
const std::string& server_address,
unsigned short server_port,
unsigned short server_id,
TransportKind transport);

//! Publish a sample
Expand Down
28 changes: 11 additions & 17 deletions examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ void DiscoveryServer::stop()
bool DiscoveryServer::init(
const std::string& server_address,
unsigned short server_port,
unsigned short server_id,
TransportKind transport,
bool has_connection_server,
const std::string& connection_server_address,
unsigned short connection_server_port,
unsigned short connection_server_id)
unsigned short connection_server_port)
{
DomainParticipantQos pqos;
pqos.name("DS-Server");
Expand Down Expand Up @@ -163,7 +161,14 @@ bool DiscoveryServer::init(

listening_locator.kind = LOCATOR_KIND_TCPv6;
eprosima::fastdds::rtps::IPLocator::setLogicalPort(listening_locator, server_port);
eprosima::fastdds::rtps::IPLocator::setIPv6(listening_locator, ip_listening_address);
if (eprosima::fastdds::rtps::IPLocator::isIPv6(ip_listening_address))
{
eprosima::fastdds::rtps::IPLocator::setIPv6(listening_locator, ip_listening_address);
}
else
{
eprosima::fastdds::rtps::IPLocator::setIPv6(listening_locator, "::1");
}
connection_locator.kind = LOCATOR_KIND_TCPv6;
eprosima::fastdds::rtps::IPLocator::setIPv6(connection_locator, ip_connection_address);
eprosima::fastdds::rtps::IPLocator::setLogicalPort(connection_locator, connection_server_port);
Expand All @@ -181,27 +186,17 @@ bool DiscoveryServer::init(
pqos.wire_protocol().builtin.discovery_config.discoveryProtocol =
eprosima::fastdds::rtps::DiscoveryProtocol::SERVER;

// Set SERVER's GUID prefix
pqos.wire_protocol().prefix = get_discovery_server_guid_from_id(server_id);

// Set SERVER's listening locator for PDP
pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);

///////////////////////////////
// Configure Connection address
///////////////////////////////

RemoteServerAttributes remote_server_att;
if (has_connection_server)
{
// Set SERVER's GUID prefix
remote_server_att.guidPrefix = get_discovery_server_guid_from_id(connection_server_id);

// Set SERVER's listening locator for PDP
remote_server_att.metatrafficUnicastLocatorList.push_back(connection_locator);

// Add remote SERVER to CLIENT's list of SERVERs
pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(connection_locator);
}


Expand All @@ -224,8 +219,7 @@ bool DiscoveryServer::init(
"Server Participant " << pqos.name() <<
" created with GUID " << participant_->guid() <<
" listening in address <" << listening_locator << "> " <<
" connecting with Discovery Server <" << remote_server_att.guidPrefix << "> "
" with address <" << connection_locator << "> " <<
" connecting with Discovery Server <" << connection_locator << "> " <<
std::endl;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ class DiscoveryServer
bool init(
const std::string& server_address,
unsigned short server_port,
unsigned short server_id,
TransportKind transport,
bool has_connection_server,
const std::string& connection_server_address,
unsigned short connection_server_port,
unsigned short connection_server_id);
unsigned short connection_server_port);

//! Run
void run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ bool HelloWorldSubscriber::init(
uint32_t max_messages,
const std::string& server_address,
unsigned short server_port,
unsigned short server_id,
TransportKind transport)
{
DomainParticipantQos pqos;
Expand Down Expand Up @@ -145,7 +144,14 @@ bool HelloWorldSubscriber::init(

server_locator.kind = LOCATOR_KIND_TCPv6;
eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, server_port);
eprosima::fastdds::rtps::IPLocator::setIPv4(server_locator, ip_server_address);
if (eprosima::fastdds::rtps::IPLocator::isIPv6(ip_server_address))
{
eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, ip_server_address);
}
else
{
eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, "::1");
}
break;
}

Expand All @@ -157,15 +163,8 @@ bool HelloWorldSubscriber::init(
pqos.wire_protocol().builtin.discovery_config.discoveryProtocol =
eprosima::fastdds::rtps::DiscoveryProtocol::CLIENT;

// Set SERVER's GUID prefix
RemoteServerAttributes remote_server_att;
remote_server_att.guidPrefix = get_discovery_server_guid_from_id(server_id);

// Set SERVER's listening locator for PDP
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);

// Add remote SERVER to CLIENT's list of SERVERs
pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);

// Add descriptor
pqos.transport().user_transports.push_back(descriptor);
Expand All @@ -183,7 +182,6 @@ bool HelloWorldSubscriber::init(
"Subscriber Participant " << pqos.name() <<
" created with GUID " << participant_->guid() <<
" connecting to server <" << server_locator << "> " <<
" with Guid: <" << remote_server_att.guidPrefix << "> " <<
std::endl;

// REGISTER THE TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class HelloWorldSubscriber
uint32_t max_messages,
const std::string& server_address,
unsigned short server_port,
unsigned short server_id,
TransportKind transport);

//! RUN the subscriber until number samples are received
Expand Down
33 changes: 3 additions & 30 deletions examples/cpp/dds/DiscoveryServerExample/DiscoveryServer_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ int main(
// Discovery Server connection
std::string connection_address = "127.0.0.1"; // default ip address
uint16_t connection_port = 16166; // default physical port
uint16_t connection_ds_id = 0; // default DS id
bool id_ds_set = false;

// Discovery Server listening
std::string listening_address = "127.0.0.1"; // default ip address
uint16_t listening_port = 16166; // default physical port
uint16_t listening_ds_id = 0; // default DS id
uint32_t timeout = 0; // default DS id

if (argc > 1)
Expand Down Expand Up @@ -190,16 +188,13 @@ int main(
}

case optionIndex::CONNECTION_PORT:
id_ds_set = true;
connection_port = static_cast<uint16_t>(strtol(opt.arg, nullptr, 10));
break;

case optionIndex::CONNECTION_ADDRESS:
connection_address = opt.arg;
break;

case optionIndex::CONNECTION_DISCOVERY_SERVER_ID:
id_ds_set = true;
connection_ds_id = static_cast<uint16_t>(strtol(opt.arg, nullptr, 10));
connection_address = opt.arg;
break;

case optionIndex::LISTENING_PORT:
Expand All @@ -221,15 +216,6 @@ int main(

break;

case optionIndex::LISTENING_DISCOVERY_SERVER_ID:
if (type != EntityKind::SERVER)
{
print_warning("server", opt.name);
break;
}
listening_ds_id = static_cast<uint16_t>(strtol(opt.arg, nullptr, 10));
break;

case optionIndex::TIMEOUT:
if (type != EntityKind::SERVER)
{
Expand Down Expand Up @@ -268,15 +254,6 @@ int main(
// return 1;
// }

// Check that a DS has not same id itself and connection
if (id_ds_set && type == EntityKind::SERVER && listening_ds_id == connection_ds_id)
{
std::cerr << "ERROR: Discovery Servers ids must be different, "
<< " cannot connect to a server with same id " << listening_ds_id << std::endl;
option::printUsage(fwrite, stdout, usage, columns);
return 1;
}

// Check that a DS has not same ip and port in listening and connection
if (id_ds_set &&
type == EntityKind::SERVER &&
Expand All @@ -299,7 +276,6 @@ int main(
topic_name,
connection_address,
connection_port,
connection_ds_id,
transport))
{
mypub.run(static_cast<uint32_t>(count), static_cast<uint32_t>(sleep));
Expand All @@ -319,7 +295,6 @@ int main(
static_cast<uint32_t>(count),
connection_address,
connection_port,
connection_ds_id,
transport))
{
mysub.run(static_cast<uint32_t>(count));
Expand All @@ -337,12 +312,10 @@ int main(
if (myserver.init(
listening_address,
listening_port,
listening_ds_id,
transport,
id_ds_set,
connection_address,
connection_port,
connection_ds_id))
connection_port))
{
myserver.run(timeout);
}
Expand Down
13 changes: 0 additions & 13 deletions examples/cpp/dds/DiscoveryServerExample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ Publisher options:
Server listening port (Default port: 16166).
--transport=<udpv4|udpv6|tcpv4|tcpv6>
Use Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (Default: udpv4).
-d <num> --connection-discovery-server-id <num>
Id of the Discovery Server to connect with. GUID will be
calculated from id (Default: 0).

Subscriber options:
-t <topic_name> --topic=<topic_name>
Expand All @@ -51,16 +48,10 @@ Subscriber options:
Server listening port (Default port: 16166).
--transport=<udpv4|udpv6|tcpv4|tcpv6>
Use Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (Default: udpv4).
-d <num> --connection-discovery-server-id <num>
Id of the Discovery Server to connect with. GUID will be
calculated from id (Default: 0).

DiscoveryServer options:
--listening-address=<IPaddress>
Server address (Default address: 127.0.0.1).
--id=<num>
Id of this Discovery Server.
GUID will be calculated from id (Default: 0).
--listening-port=<num>
Server listening port (Default port: 16166).
--transport=<udpv4|udpv6|tcpv4|tcpv6>
Expand All @@ -69,10 +60,6 @@ DiscoveryServer options:
Server address (Default address: 127.0.0.1).
-p <num> --connection-port=<num>
Server listening port (Default port: 16166).
-d <num> --connection-discovery-server-id <num>
Id of the Discovery Server to connect with. GUID will be
calculated from id (if not set, this DS will not connect
to other server).
-z <num> --timeout <num>
Number of seconds before finish the process (Default: 0 = till ^C).
```
Loading

0 comments on commit ee84af2

Please sign in to comment.