Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeater Implementation [14951] #249

Merged
merged 28 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0ad16ed
Refs #15188: Implement Initial peers in core
Jul 19, 2022
157f757
Refs #15188: Add blackbox tests to initial peers
Jul 19, 2022
97fc301
Refs #15188: Add initial peers to yaml
Jul 19, 2022
e01d043
Refs #15188: Update Yaml schema
Jul 19, 2022
dbf14ad
Refs #15191: Add it to tool tests
Jul 19, 2022
3d0f92c
Refs #15191: Add example resources
Jul 19, 2022
b4ad447
Refs #15191: Correct and tie up loose ends
Jul 19, 2022
2328983
Refs #14951: Move payload Pool to subfolder
Jul 13, 2022
ff8157c
Refs #14951: Implement Repeater Participant
Jul 14, 2022
a622376
Refs #14951: Add documentation
Jul 14, 2022
7fdd6fb
Refs #14951: Add release notes
Jul 14, 2022
0bb4887
Refs #14951: Allow only one Participant if repeater
Jul 14, 2022
a44b4c5
Refs #14951: Update yaml schema configuration
Jul 14, 2022
5a6e539
Refs #14951: Implement generic limitless Pool
Jul 14, 2022
6bd3045
Refs #14951: Add code comments and refactor LimitlessPool
Jul 15, 2022
27c1dce
Refs #14951: Apply suggestions (except name changes)
Jul 18, 2022
ff0ff53
Refs #14951: Apply docs documentation
Jul 18, 2022
643d8cd
Refs #14951: Change classes names
Jul 18, 2022
18bb2ae
Refs #14951: Rebase over initial peers
Jul 20, 2022
2eaa57c
Refs #14951: fix repeater configuration test
Jul 20, 2022
5febc09
Refs #14951: Refactor Participant Kind names
Jul 27, 2022
2d73550
Refs #14951: fix rebase
Jul 28, 2022
add43cf
Refs #14951: apply code suggestions
Jul 29, 2022
0fdc41f
Refs #14951: change Participant classes names
Jul 29, 2022
b6cd2c1
Refs #14951: apply documentation changes
Jul 29, 2022
6a0cd08
Refs #14951: apply docs suggestions
Jul 29, 2022
1f22f17
Refs #14951: remove number_of_participants test
Aug 8, 2022
7a58317
Refs #14951: uncrustify
Aug 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct DDSRouterConfiguration : public DDSRouterReloadConfiguration
// VARIABLES
/////////////////////////

std::set<std::shared_ptr<ParticipantConfiguration>> participants_configurations_ = {};
std::set<std::shared_ptr<ParticipantConfiguration>> participants_configurations = {};

unsigned int number_of_threads = 12;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct DiscoveryServerParticipantConfiguration : public SimpleParticipantConfigu
DDSROUTER_CORE_DllAPI DiscoveryServerParticipantConfiguration(
const types::ParticipantId& id,
const types::ParticipantKind& kind,
const bool is_repeater,
const types::DomainId& domain_id,
const types::GuidPrefix& discovery_server_guid_prefix,
const std::set<types::Address>& listening_addresses,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2022 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 InitialPeersParticipantConfiguration.hpp
*/

#ifndef _DDSROUTERCORE_CONFIGURATION_PARTICIPANT_INITIALPEERSPARTICIPANTCONFIGURATION_HPP_
#define _DDSROUTERCORE_CONFIGURATION_PARTICIPANT_INITIALPEERSPARTICIPANTCONFIGURATION_HPP_

#include <ddsrouter_core/configuration/participant/SimpleParticipantConfiguration.hpp>
#include <ddsrouter_core/library/library_dll.h>
#include <ddsrouter_core/types/security/tls/TlsConfiguration.hpp>
#include <ddsrouter_core/types/address/Address.hpp>
#include <ddsrouter_core/types/address/DiscoveryServerConnectionAddress.hpp>
#include <ddsrouter_core/types/dds/DomainId.hpp>
#include <ddsrouter_core/types/dds/GuidPrefix.hpp>
#include <ddsrouter_core/types/participant/ParticipantKind.hpp>

namespace eprosima {
namespace ddsrouter {
namespace core {
namespace configuration {

/**
* This data struct joins Initial Peers Participant Configuration features
*/
struct InitialPeersParticipantConfiguration : public SimpleParticipantConfiguration
{

/////////////////////////
// CONSTRUCTORS
/////////////////////////

DDSROUTER_CORE_DllAPI InitialPeersParticipantConfiguration() = default;

DDSROUTER_CORE_DllAPI InitialPeersParticipantConfiguration(
const types::ParticipantId& id,
const types::ParticipantKind& kind,
const bool is_repeater,
const types::DomainId& domain_id,
const std::set<types::Address>& listening_addresses,
const std::set<types::Address>& connection_addresses,
const types::security::TlsConfiguration tls_configuration);

/////////////////////////
// METHODS
/////////////////////////

DDSROUTER_CORE_DllAPI virtual bool is_valid(
utils::Formatter& error_msg) const noexcept override;

DDSROUTER_CORE_DllAPI bool operator ==(
const InitialPeersParticipantConfiguration& other) const noexcept;

/////////////////////////
// VARIABLES
/////////////////////////

std::set<types::Address> listening_addresses = {};

std::set<types::Address> connection_addresses = {};

types::security::TlsConfiguration tls_configuration = types::security::TlsConfiguration();
};

} /* namespace configuration */
} /* namespace core */
} /* namespace ddsrouter */
} /* namespace eprosima */

#endif /* _DDSROUTERCORE_CONFIGURATION_PARTICIPANT_INITIALPEERSPARTICIPANTCONFIGURATION_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ struct ParticipantConfiguration : public BaseConfiguration

DDSROUTER_CORE_DllAPI ParticipantConfiguration(
const types::ParticipantId& id,
const types::ParticipantKind& kind) noexcept;
const types::ParticipantKind& kind,
const bool is_repeater) noexcept;

/////////////////////////
// METHODS
Expand All @@ -58,15 +59,14 @@ struct ParticipantConfiguration : public BaseConfiguration
DDSROUTER_CORE_DllAPI virtual bool is_valid(
utils::Formatter& error_msg) const noexcept override;

/////////////////////////
// VARIABLES
/////////////////////////

//! Participant Id associated with this configuration
types::ParticipantId id;

//! Participant Kind of the Participant that this configuration refers.
types::ParticipantKind kind;

//! Whether this Participant should connect its readers with its writers.
bool is_repeater = false;
};

} /* namespace configuration */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct SimpleParticipantConfiguration : public ParticipantConfiguration
DDSROUTER_CORE_DllAPI SimpleParticipantConfiguration(
const types::ParticipantId& id,
const types::ParticipantKind& kind,
const bool is_repeater,
const types::DomainId& domain_id) noexcept;

/////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Address
DDSROUTER_CORE_DllAPI bool is_ipv6() const noexcept;

//! Get FastDDS Locator kind
DDSROUTER_CORE_DllAPI LocatorType get_locator_kind() noexcept;
DDSROUTER_CORE_DllAPI LocatorType get_locator_kind() const noexcept;

/**
* @brief Whether the address is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ enum class ParticipantKind : ParticipantKindType
echo, //! Echo Participant Kind
dummy, //! Dummy Participant Kind
simple_rtps, //! Simple RTPS Participant Kind
local_discovery_server, //! Discovery Server RTPS UDP Participant Kind
wan, //! Discovery Server RTPS TCP Participant Kind
local_discovery_server, //! Discovery Server RTPS Participant Kind
wan_discovery_server, //! Discovery Server Inter Router Participant Kind
wan_initial_peers, //! Initial Peers Inter Router Participant Kind
};

static constexpr unsigned PARTICIPANT_KIND_COUNT = 7;
static constexpr unsigned PARTICIPANT_KIND_COUNT = 8;

/**
* @brief All ParticipantKind enum values as a std::array.
Expand All @@ -54,7 +55,8 @@ constexpr std::array<ParticipantKind, PARTICIPANT_KIND_COUNT> ALL_PARTICIPANT_KI
ParticipantKind::dummy,
ParticipantKind::simple_rtps,
ParticipantKind::local_discovery_server,
ParticipantKind::wan
ParticipantKind::wan_discovery_server,
ParticipantKind::wan_initial_peers,
};

/**
Expand All @@ -67,17 +69,19 @@ constexpr std::array<ParticipantKind, PARTICIPANT_KIND_COUNT - 1> ALL_VALID_PART
ParticipantKind::dummy,
ParticipantKind::simple_rtps,
ParticipantKind::local_discovery_server,
ParticipantKind::wan
ParticipantKind::wan_discovery_server,
ParticipantKind::wan_initial_peers,
};

constexpr std::array<const char*, PARTICIPANT_KIND_COUNT> PARTICIPANT_KIND_STRINGS = {
"invalid",
"blank",
"echo",
"dummy",
"simple_rtps",
"local_discovery_server",
"wan",
"simple-rtps",
"local-discovery-server",
"wan-ds",
"wan-initial-peers",
};

static constexpr unsigned MAX_PARTICIPANT_KIND_ALIASES = 4;
Expand All @@ -94,7 +98,8 @@ constexpr std::array<ParticipantKindAliasesType, PARTICIPANT_KIND_COUNT> PARTICI
ParticipantKindAliasesType({"dummy", "", "", ""}),
ParticipantKindAliasesType({"local", "simple", "", ""}),
ParticipantKindAliasesType({"discovery-server", "ds", "local-ds", "local-discovery-server"}),
ParticipantKindAliasesType({"wan", "router", "", ""}),
ParticipantKindAliasesType({"wan-ds", "wan-discovery-server", "", ""}),
ParticipantKindAliasesType({"wan", "router", "initial-peers", ""}),
};

DDSROUTER_CORE_DllAPI std::ostream& operator <<(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#define _DDSROUTERCORE_SECURITY_TLS_TLSCONFIGURATION_HPP_

#include <string>
#include <memory>

#include <fastdds/rtps/transport/TCPTransportDescriptor.h>

#include <ddsrouter_core/library/library_dll.h>

Expand Down Expand Up @@ -152,6 +155,20 @@ class TlsConfiguration
*/
DDSROUTER_CORE_DllAPI const std::string& dh_params_file() const;

//! Activate TLS configuration in a TCP transport descriptor
DDSROUTER_CORE_DllAPI void enable_tls(
std::shared_ptr<eprosima::fastdds::rtps::TCPTransportDescriptor> descriptor,
bool client = false) const;

//! Activate TLS client configuration in a TCP transport descriptor
DDSROUTER_CORE_DllAPI void enable_tls_client(
std::shared_ptr<eprosima::fastdds::rtps::TCPTransportDescriptor> descriptor,
bool only_client) const;

//! Activate TLS server configuration in a TCP transport descriptor
DDSROUTER_CORE_DllAPI void enable_tls_server(
std::shared_ptr<eprosima::fastdds::rtps::TCPTransportDescriptor> descriptor) const;

private:

//! Internal throwing check
Expand Down
11 changes: 9 additions & 2 deletions ddsrouter_core/src/cpp/communication/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ Bridge::Bridge(
std::map<ParticipantId, std::shared_ptr<IWriter>> writers_except_one =
writers_; // Create a copy of the map

// Get this Track source participant before removing it from map
writers_except_one.erase(id); // TODO: check if this element is removed in erase or if source is still valid
if (!participants_->get_participant(id)->is_repeater())
{
// Remove this Track source participant because it is not repeater
writers_except_one.erase(id);

logDebug(
DDSROUTER_BRIDGE,
"Not adding own Writer to Track in " << *this << " in Participant " << id << ".");
}

// This insert is required as there is no copy method for Track
// Tracks are always created disabled and then enabled with Bridge enable() method
Expand Down
4 changes: 4 additions & 0 deletions ddsrouter_core/src/cpp/communication/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ void Track::transmit_() noexcept
// Send data through writers
for (auto& writer_it : writers_)
{
logDebug(
DDSROUTER_TRACK,
"Forwarding data to writer " << writer_it.first << ".");

ret = writer_it.second->write(data);

if (!ret)
Expand Down
16 changes: 10 additions & 6 deletions ddsrouter_core/src/cpp/configuration/DDSRouterConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <ddsrouter_core/configuration/DDSRouterConfiguration.hpp>
#include <ddsrouter_core/configuration/participant/DiscoveryServerParticipantConfiguration.hpp>
#include <ddsrouter_core/configuration/participant/InitialPeersParticipantConfiguration.hpp>
#include <ddsrouter_core/configuration/participant/ParticipantConfiguration.hpp>
#include <ddsrouter_core/configuration/participant/SimpleParticipantConfiguration.hpp>
#include <ddsrouter_utils/Log.hpp>
Expand All @@ -40,7 +41,7 @@ DDSRouterConfiguration::DDSRouterConfiguration(
std::set<std::shared_ptr<ParticipantConfiguration>> participants_configurations,
unsigned int number_of_threads /* = default_number_of_threads() */)
: DDSRouterReloadConfiguration (allowlist, blocklist, builtin_topics)
, participants_configurations_(participants_configurations)
, participants_configurations(participants_configurations)
, number_of_threads(number_of_threads)
{
}
Expand All @@ -55,16 +56,16 @@ bool DDSRouterConfiguration::is_valid(
}

// Check there are at least two participants
if (participants_configurations_.size() < 2)
if (participants_configurations.size() < 1)
{
error_msg << "There must be at least 2 participants. ";
error_msg << "There must be at least 1 participant.";
return false;
}

// Check Participant Configurations AND
// check Participant Configuration IDs are not repeated
std::set<ParticipantId> ids;
for (std::shared_ptr<ParticipantConfiguration> configuration : participants_configurations_)
for (std::shared_ptr<ParticipantConfiguration> configuration : participants_configurations)
{
// Check configuration is not null
if (!configuration)
Expand Down Expand Up @@ -93,7 +94,7 @@ bool DDSRouterConfiguration::is_valid(
}

// If the number of ids are not equal the number of configurations, is because they are repeated
if (ids.size() != participants_configurations_.size())
if (ids.size() != participants_configurations.size())
{
error_msg << "Participant ids are not unique. ";
return false;
Expand Down Expand Up @@ -126,9 +127,12 @@ bool DDSRouterConfiguration::check_correct_configuration_object_(
return check_correct_configuration_object_by_type_<SimpleParticipantConfiguration>(configuration);

case ParticipantKind::local_discovery_server:
case ParticipantKind::wan:
case ParticipantKind::wan_discovery_server:
return check_correct_configuration_object_by_type_<DiscoveryServerParticipantConfiguration>(configuration);

case ParticipantKind::wan_initial_peers:
return check_correct_configuration_object_by_type_<InitialPeersParticipantConfiguration>(configuration);

default:
return check_correct_configuration_object_by_type_<ParticipantConfiguration>(configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ namespace configuration {
using namespace eprosima::ddsrouter::core::types;

DiscoveryServerParticipantConfiguration::DiscoveryServerParticipantConfiguration(
const types::ParticipantId& id,
const types::ParticipantKind& kind,
const types::DomainId& domain_id,
const types::GuidPrefix& discovery_server_guid_prefix,
const std::set<types::Address>& listening_addresses,
const std::set<types::DiscoveryServerConnectionAddress>& connection_addresses,
const ParticipantId& id,
const ParticipantKind& kind,
const bool is_repeater,
const DomainId& domain_id,
const GuidPrefix& discovery_server_guid_prefix,
const std::set<Address>& listening_addresses,
const std::set<DiscoveryServerConnectionAddress>& connection_addresses,
const types::security::TlsConfiguration tls_configuration)
: SimpleParticipantConfiguration(id, kind, domain_id)
: SimpleParticipantConfiguration(id, kind, is_repeater, domain_id)
, discovery_server_guid_prefix(discovery_server_guid_prefix)
, listening_addresses(listening_addresses)
, connection_addresses(connection_addresses)
Expand Down
Loading