Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#901 from ApexAI/iox-#900-multipubl…
Browse files Browse the repository at this point in the history
…isher-support-gateways

iox-eclipse-iceoryx#900 Gateway creates services with correct interface
  • Loading branch information
elfenpiff authored Aug 30, 2021
2 parents 816270e + 3d73e63 commit d193464
Show file tree
Hide file tree
Showing 23 changed files with 325 additions and 157 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
**Features:**

- Enhance MacOS performance with timed{send,receive} functionality in unix domain socket[\#903](https://github.com/eclipse-iceoryx/iceoryx/issues/903)
- Multi-Publisher support for DDS gateway and generic gateway class [\#900](https://github.com/eclipse-iceoryx/iceoryx/issues/900)
- Replace `iox-gw-iceoryx2dds` and `iox-gw-dds2iceoryx` gateways with `iox-dds-gateway` [\#900](https://github.com/eclipse-iceoryx/iceoryx/issues/900)
- Enhance posixCall[\#805](https://github.com/eclipse-iceoryx/iceoryx/issues/805)
- New chunk available callback for the new C++[\#391](https://github.com/eclipse-iceoryx/iceoryx/issues/391)
- Git Hooks on iceoryx[\#486](https://github.com/eclipse-iceoryx/iceoryx/issues/486)
Expand Down
13 changes: 1 addition & 12 deletions cmake/cyclonedds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ if(NOT N EQUAL 0)
endif()
endif()

if(WIN32)
set(CREATE_PATH_COMMAND mkdir)
else()
set(CREATE_PATH_COMMAND mkdir -p)
endif(WIN32)

if(DEFINED CMAKE_TOOLCHAIN_FILE)
set(TOOLCHAIN_FILE "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
endif()
Expand Down Expand Up @@ -67,12 +61,7 @@ function(fetch_and_install name)
endif()

# Build
execute_process(COMMAND ${CREATE_PATH_COMMAND} "${BUILD_DIR}"
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
if(result)
message(FATAL_ERROR "CMake step [create build dir] for ${name} failed: ${result}")
endif()
file(MAKE_DIRECTORY "${BUILD_DIR}")

# Parse additional CMake flags
set(ADDITIONAL_CMAKE_FLAGS "")
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.5)

set(IOX_VERSION_STRING "1.90.0")

Expand Down
26 changes: 7 additions & 19 deletions iceoryx_dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,33 +124,21 @@ endif()
target_compile_options(iceoryx_dds PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

#
########## build gateway apps ##########
########## build gateway app ##########
#
add_executable(iox-gw-iceoryx2dds
source/iceoryx2dds_app/main.cpp
add_executable(iox-dds-gateway
source/gateway/main.cpp
)
target_link_libraries(iox-gw-iceoryx2dds
target_link_libraries(iox-dds-gateway
iceoryx_posh::iceoryx_posh
iceoryx_posh::iceoryx_posh_gateway
iceoryx_posh::iceoryx_posh_config
${PROJECT_NAMESPACE}::iceoryx_dds
)

target_compile_options(iox-gw-iceoryx2dds PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})
target_compile_options(iox-dds-gateway PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

add_executable(iox-gw-dds2iceoryx
source/dds2iceoryx_app/main.cpp
)
target_link_libraries(iox-gw-dds2iceoryx
iceoryx_posh::iceoryx_posh
iceoryx_posh::iceoryx_posh_gateway
iceoryx_posh::iceoryx_posh_config
${PROJECT_NAMESPACE}::iceoryx_dds
)

target_compile_options(iox-gw-dds2iceoryx PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

set_target_properties(iox-gw-iceoryx2dds iox-gw-dds2iceoryx iceoryx_dds
set_target_properties(iox-dds-gateway iceoryx_dds
PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD ${ICEORYX_CXX_STANDARD}
Expand All @@ -167,7 +155,7 @@ endif()
########## export library ##########
#
setup_install_directories_and_export_package(
TARGETS iceoryx_dds iox-gw-iceoryx2dds iox-gw-dds2iceoryx
TARGETS iceoryx_dds iox-dds-gateway
INCLUDE_DIRECTORY include/
)

2 changes: 1 addition & 1 deletion iceoryx_dds/examples/docker/publisher_node.entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ EOF
fi

/usr/bin/iox-roudi &
/usr/bin/iox-gw-iceoryx2dds &
/usr/bin/iox-dds-gateway &
/usr/bin/iox-cpp-publisher-untyped
2 changes: 1 addition & 1 deletion iceoryx_dds/examples/docker/subscriber_node.entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ EOF
fi

/usr/bin/iox-roudi &
/usr/bin/iox-gw-dds2iceoryx &
/usr/bin/iox-dds-gateway &
/usr/bin/iox-cpp-subscriber-untyped
94 changes: 0 additions & 94 deletions iceoryx_dds/source/dds2iceoryx_app/main.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
//
// SPDX-License-Identifier: Apache-2.0

#include <atomic>

#include "iceoryx_dds/gateway/dds_to_iox.hpp"
#include "iceoryx_dds/gateway/iox_to_dds.hpp"
#include "iceoryx_dds/internal/log/logging.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
Expand Down Expand Up @@ -63,22 +62,26 @@ int main()
iox::posix::registerSignalHandler(iox::posix::Signal::TERM, ShutdownManager::scheduleShutdown);

// Start application
iox::runtime::PoshRuntime::initRuntime("iox-gw-iceoryx2dds");
iox::runtime::PoshRuntime::initRuntime("iox-dds-gateway");

iox::dds::Iceoryx2DDSGateway<> gw;
iox::config::GatewayConfig gatewayConfig;
iox::dds::Iceoryx2DDSGateway<> iox2ddsGateway;
iox::dds::DDS2IceoryxGateway<> dds2ioxGateway;

iox::config::TomlGatewayConfigParser::parse()
.and_then([&](auto config) { gw.loadConfiguration(config); })
.and_then([&](auto config) { gatewayConfig = config; })
.or_else([&](auto err) {
iox::dds::LogWarn() << "[Main] Failed to parse gateway config with error: "
<< iox::config::TOML_GATEWAY_CONFIG_FILE_PARSE_ERROR_STRINGS[err];
iox::dds::LogWarn() << "[Main] Using default configuration.";
iox::config::GatewayConfig defaultConfig;
defaultConfig.setDefaults();
gw.loadConfiguration(defaultConfig);
gatewayConfig.setDefaults();
});

gw.runMultithreaded();
iox2ddsGateway.loadConfiguration(gatewayConfig);
dds2ioxGateway.loadConfiguration(gatewayConfig);

iox2ddsGateway.runMultithreaded();
dds2ioxGateway.runMultithreaded();

// Run until SIGINT or SIGTERM
ShutdownManager::waitUntilShutdown();
Expand Down
12 changes: 12 additions & 0 deletions iceoryx_dds/source/iceoryx_dds/dds/cyclone_data_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ void iox::dds::CycloneDataReader::connect() noexcept
auto subscriber = ::dds::sub::Subscriber(CycloneContext::getParticipant());

auto qos = ::dds::sub::qos::DataReaderQos();

/// Is required for the Gateway. When two iceoryx publisher are publishing on the same
/// topic and one publisher is located on a remote iceoryx instance connected via a
/// bidirectional dds gateway (iceoryx2dds & dds2iceoryx) then every sample is delivered
/// twice to the local subscriber.
/// Once via the local iceoryx publisher and once via dds2iceoryx which received the
/// sample from the iceoryx2dds gateway. But when we ignore the local dds writer the
/// sample is not forwarded to the local dds gateway and delivered a second time.
auto* cqos = qos.delegate().ddsc_qos();
dds_qset_ignorelocal(cqos, DDS_IGNORELOCAL_PROCESS);
qos.delegate().ddsc_qos(cqos);
qos << ::dds::core::policy::History::KeepAll();

m_impl = ::dds::sub::DataReader<Mempool::Chunk>(subscriber, topic, qos);

LogDebug() << "[CycloneDataReader] Connected to topic: " << topicString;

m_isConnected.store(true, std::memory_order_relaxed);
free(cqos);
}
}

Expand Down
27 changes: 24 additions & 3 deletions iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/watch_dog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ using namespace iox::units::duration_literals;
class Watchdog
{
public:
Watchdog(const iox::units::Duration& timeToWait) noexcept
explicit Watchdog(const iox::units::Duration& timeToWait) noexcept
: m_timeToWait(timeToWait)
{
}

Watchdog(const Watchdog&) = delete;
Watchdog(Watchdog&&) = delete;
Watchdog& operator=(const Watchdog&) = delete;
Watchdog& operator=(Watchdog&&) = delete;

~Watchdog() noexcept
{
reset();
}

void reset() noexcept
{
if (m_watchdog.joinable())
{
Expand All @@ -44,14 +54,25 @@ class Watchdog
}
}

void watchAndActOnFailure(std::function<void()> f) noexcept
void watchAndActOnFailure(const std::function<void()>& actionOnFailure = std::function<void()>()) noexcept
{
reset();

m_watchdog = std::thread([=] {
m_watchdogSemaphore.timedWait(m_timeToWait)
.and_then([&](auto& result) {
if (result == iox::posix::SemaphoreWaitState::TIMEOUT)
{
f();
std::cerr << "Watchdog observed no reaction after " << m_timeToWait << ". Taking measures!"
<< std::endl;
if (actionOnFailure)
{
actionOnFailure();
}
else
{
std::terminate();
}
EXPECT_TRUE(false);
}
})
Expand Down
2 changes: 2 additions & 0 deletions iceoryx_posh/include/iceoryx_posh/gateway/gateway_base.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,6 +60,7 @@ class GatewayBase
protected:
// Needed for unit testing
GatewayBase() noexcept = default;
capro::Interfaces getInterface() const noexcept;

protected:
popo::InterfacePort m_interfaceImpl{nullptr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ static constexpr const char GATEWAY_CONFIG_SERVICE_EVENT_NAME[] = "event";
class TomlGatewayConfigParser
{
public:
static cxx::expected<GatewayConfig, TomlGatewayConfigParseError> parse();
static cxx::expected<GatewayConfig, TomlGatewayConfigParseError> parse(const roudi::ConfigFilePathString_t& path);
static cxx::expected<GatewayConfig, TomlGatewayConfigParseError>
parse(const roudi::ConfigFilePathString_t& path = roudi::ConfigFilePathString_t(DEFAULT_CONFIG_FILE_PATH));

protected:
static cxx::expected<TomlGatewayConfigParseError> validate(const cpptoml::table& parsedToml) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ GatewayGeneric<channel_t, gateway_t>::addChannel(const capro::ServiceDescription
}
else
{
auto result = channel_t::create(service, options);
auto result = channel_t::create({service.getServiceIDString(),
service.getInstanceIDString(),
service.getEventIDString(),
{0U, 0U, 0U, 0U},
this->getInterface()},
options);
if (result.has_error())
{
return cxx::error<GatewayError>(GatewayError::UNSUCCESSFUL_CHANNEL_CREATION);
Expand Down
7 changes: 6 additions & 1 deletion iceoryx_posh/source/gateway/gateway_base.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,6 +36,11 @@ GatewayBase::~GatewayBase() noexcept
}
}

capro::Interfaces GatewayBase::getInterface() const noexcept
{
return m_interfaceImpl.getCaProServiceDescription().getSourceInterface();
}

bool GatewayBase::getCaProMessage(CaproMessage& msg) noexcept
{
auto maybeCaproMessage = m_interfaceImpl.tryGetCaProMessage();
Expand All @@ -49,6 +55,5 @@ bool GatewayBase::getCaProMessage(CaproMessage& msg) noexcept
return false;
}
}

} // namespace gw
} // namespace iox
Loading

0 comments on commit d193464

Please sign in to comment.