Loading examples/cxx/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ foreach(example IN LISTS examples_cxx) add_executable(${example}_cxx) target_sources(${example}_cxx PRIVATE ${example}.cpp) target_link_libraries(${example}_cxx PUBLIC common::network::engine fmt::fmt adm_iosched cxx_examples_common) PUBLIC fmt::fmt adm_iosched cxx_examples_common) set_target_properties(${example}_cxx PROPERTIES OUTPUT_NAME ${example}) endforeach() Loading src/common/CMakeLists.txt +3 −4 Original line number Diff line number Diff line Loading @@ -38,13 +38,12 @@ target_include_directories(_logger INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::logger ALIAS _logger) add_subdirectory(net) target_include_directories(_network_engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::network::engine ALIAS _network_engine) target_include_directories(_rpc_server INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::network::rpc_server ALIAS _rpc_server) target_include_directories(_rpc_client INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::network::rpc_client ALIAS _rpc_client) target_include_directories(_rpc_types INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) Loading src/common/net/CMakeLists.txt +7 −10 Original line number Diff line number Diff line Loading @@ -22,18 +22,15 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ add_library(_network_engine STATIC) add_library(_rpc_client STATIC) target_sources( _network_engine INTERFACE engine.hpp PRIVATE detail/address.hpp _rpc_client INTERFACE endpoint.hpp client.hpp request.hpp PRIVATE endpoint.cpp client.cpp ) target_link_libraries( _network_engine PUBLIC common::logger transport_library Mercury::Mercury Argobots::Argobots Margo::Margo ) set_property(TARGET _network_engine PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(_rpc_client PUBLIC common::config common::logger thallium) set_property(TARGET _rpc_client PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(_rpc_server STATIC) target_sources( Loading @@ -42,6 +39,6 @@ target_sources( PRIVATE server.cpp ) target_link_libraries(_rpc_server PUBLIC common::config _network_engine) target_link_libraries(_rpc_server PUBLIC common::config common::logger thallium) add_subdirectory(proto) src/common/net/client.cpp 0 → 100644 +59 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2023, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #include <optional> #include <logger/logger.hpp> #include "client.hpp" #include "endpoint.hpp" using namespace std::literals; namespace scord::network { client::client(const std::string& protocol) : m_engine(std::make_shared<thallium::engine>(protocol, THALLIUM_CLIENT_MODE)) {} std::optional<endpoint> client::lookup(const std::string& address) noexcept { try { return endpoint{m_engine, m_engine->lookup(address)}; } catch(const std::exception& ex) { LOGGER_ERROR("client::lookup() failed: {}", ex.what()); return std::nullopt; } } std::string client::self_address() const noexcept { try { return m_engine->self(); } catch(const std::exception& ex) { LOGGER_ERROR("client::self_address() failed: {}", ex.what()); return "unknown"s; } } } // namespace scord::network src/common/net/client.hpp 0 → 100644 +50 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2023, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #ifndef SCORD_CLIENT_HPP #define SCORD_CLIENT_HPP #include <optional> #include <thallium.hpp> namespace scord::network { class endpoint; class client { public: explicit client(const std::string& protocol); std::optional<endpoint> lookup(const std::string& address) noexcept; std::string self_address() const noexcept; private: std::shared_ptr<thallium::engine> m_engine; }; } // namespace scord::network #endif // SCORD_CLIENT_HPP Loading
examples/cxx/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ foreach(example IN LISTS examples_cxx) add_executable(${example}_cxx) target_sources(${example}_cxx PRIVATE ${example}.cpp) target_link_libraries(${example}_cxx PUBLIC common::network::engine fmt::fmt adm_iosched cxx_examples_common) PUBLIC fmt::fmt adm_iosched cxx_examples_common) set_target_properties(${example}_cxx PROPERTIES OUTPUT_NAME ${example}) endforeach() Loading
src/common/CMakeLists.txt +3 −4 Original line number Diff line number Diff line Loading @@ -38,13 +38,12 @@ target_include_directories(_logger INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::logger ALIAS _logger) add_subdirectory(net) target_include_directories(_network_engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::network::engine ALIAS _network_engine) target_include_directories(_rpc_server INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::network::rpc_server ALIAS _rpc_server) target_include_directories(_rpc_client INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(common::network::rpc_client ALIAS _rpc_client) target_include_directories(_rpc_types INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) Loading
src/common/net/CMakeLists.txt +7 −10 Original line number Diff line number Diff line Loading @@ -22,18 +22,15 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ add_library(_network_engine STATIC) add_library(_rpc_client STATIC) target_sources( _network_engine INTERFACE engine.hpp PRIVATE detail/address.hpp _rpc_client INTERFACE endpoint.hpp client.hpp request.hpp PRIVATE endpoint.cpp client.cpp ) target_link_libraries( _network_engine PUBLIC common::logger transport_library Mercury::Mercury Argobots::Argobots Margo::Margo ) set_property(TARGET _network_engine PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(_rpc_client PUBLIC common::config common::logger thallium) set_property(TARGET _rpc_client PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(_rpc_server STATIC) target_sources( Loading @@ -42,6 +39,6 @@ target_sources( PRIVATE server.cpp ) target_link_libraries(_rpc_server PUBLIC common::config _network_engine) target_link_libraries(_rpc_server PUBLIC common::config common::logger thallium) add_subdirectory(proto)
src/common/net/client.cpp 0 → 100644 +59 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2023, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #include <optional> #include <logger/logger.hpp> #include "client.hpp" #include "endpoint.hpp" using namespace std::literals; namespace scord::network { client::client(const std::string& protocol) : m_engine(std::make_shared<thallium::engine>(protocol, THALLIUM_CLIENT_MODE)) {} std::optional<endpoint> client::lookup(const std::string& address) noexcept { try { return endpoint{m_engine, m_engine->lookup(address)}; } catch(const std::exception& ex) { LOGGER_ERROR("client::lookup() failed: {}", ex.what()); return std::nullopt; } } std::string client::self_address() const noexcept { try { return m_engine->self(); } catch(const std::exception& ex) { LOGGER_ERROR("client::self_address() failed: {}", ex.what()); return "unknown"s; } } } // namespace scord::network
src/common/net/client.hpp 0 → 100644 +50 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2023, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #ifndef SCORD_CLIENT_HPP #define SCORD_CLIENT_HPP #include <optional> #include <thallium.hpp> namespace scord::network { class endpoint; class client { public: explicit client(const std::string& protocol); std::optional<endpoint> lookup(const std::string& address) noexcept; std::string self_address() const noexcept; private: std::shared_ptr<thallium::engine> m_engine; }; } // namespace scord::network #endif // SCORD_CLIENT_HPP