From ee89ffec50464e345d42335ee82456e5c5358d3f Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 30 Jun 2022 15:07:26 +0200 Subject: [PATCH 1/6] Add separate targets and sources for scord and scord-ctl --- src/CMakeLists.txt | 17 +++- src/{main.cpp => scord-ctl.cpp} | 0 src/scord.cpp | 162 ++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+), 1 deletion(-) rename src/{main.cpp => scord-ctl.cpp} (100%) create mode 100644 src/scord.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84cf47cf..16cb5b93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,7 +27,8 @@ add_subdirectory(utils) add_subdirectory(logger) add_subdirectory(network) -add_executable(scord server.cpp main.cpp) +# scord daemon +add_executable(scord server.cpp scord.cpp) target_include_directories( scord PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} @@ -39,4 +40,18 @@ target_link_libraries( install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) +# scord-ctl daemon +add_executable(scord-ctl server.cpp scord-ctl.cpp) + +target_include_directories( + scord-ctl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} +) + +target_link_libraries( + scord-ctl PRIVATE config logger network_engine fmt::fmt Boost::program_options +) + +install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# public api libraries add_subdirectory(api) diff --git a/src/main.cpp b/src/scord-ctl.cpp similarity index 100% rename from src/main.cpp rename to src/scord-ctl.cpp diff --git a/src/scord.cpp b/src/scord.cpp new file mode 100644 index 00000000..8686cd37 --- /dev/null +++ b/src/scord.cpp @@ -0,0 +1,162 @@ +/****************************************************************************** + * Copyright 2021, 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace fs = std::filesystem; +namespace bpo = boost::program_options; + +void +print_version(const std::string& progname) { + fmt::print("{} {}\n", progname, scord::version_string); +} + +void +print_help(const std::string& progname, + const bpo::options_description& opt_desc) { + fmt::print("Usage: {} [options]\n\n", progname); + fmt::print("{}", opt_desc); +} + + +int +main(int argc, char* argv[]) { + + scord::config::settings cfg; + + // define the command line options allowed + bpo::options_description opt_desc("Options"); + opt_desc.add_options() + // run in foreground + (",f", + bpo::bool_switch()->default_value(false)->notifier( + [&](const bool& flag_value) { + cfg.daemonize(!flag_value); + }), + "foreground operation") + + // force logging messages to the console + ("force-console,C", + bpo::value() + ->implicit_value("") + ->zero_tokens() + ->notifier([&](const std::string&) { + cfg.use_console(true); + }), + "override any logging options defined in configuration files and " + "send all daemon output to the console") + + // use provided configuration file instead of the system-wide + // configuration file defined when building the daemon + ("config-file,c", + bpo::value() + ->value_name("FILENAME") + ->implicit_value("") + ->notifier([&](const std::string& filename) { + cfg.config_file(filename); + }), + "override the system-wide configuration file with FILENAME") + + // print the daemon version + ("version,v", + bpo::value()->implicit_value("")->zero_tokens(), + "print version string") + + // print help + ("help,h", + bpo::value()->implicit_value("")->zero_tokens(), + "produce help message"); + + // parse the command line + bpo::variables_map vm; + + try { + bpo::store(bpo::parse_command_line(argc, argv, opt_desc), vm); + + // the --help and --version arguments are special, since we want + // to process them even if the global configuration file doesn't exist + if(vm.count("help")) { + print_help(cfg.progname(), opt_desc); + return EXIT_SUCCESS; + } + + if(vm.count("version")) { + print_version(cfg.progname()); + return EXIT_SUCCESS; + } + + const fs::path config_file = (vm.count("config-file") == 0) + ? cfg.config_file() + : vm["config-file"].as(); + + if(!fs::exists(config_file)) { + fmt::print(stderr, + "Failed to access daemon configuration file {}\n", + config_file); + return EXIT_FAILURE; + } + + try { + cfg.load_from_file(config_file); + } catch(const std::exception& ex) { + fmt::print(stderr, + "Failed reading daemon configuration file:\n" + " {}\n", + ex.what()); + return EXIT_FAILURE; + } + + // calling notify() here basically invokes all define notifiers, thus + // overriding any configuration loaded from the global configuration + // file with its command-line counterparts if provided (for those + // options where this is available) + bpo::notify(vm); + } catch(const bpo::error& ex) { + fmt::print(stderr, "ERROR: {}\n\n", ex.what()); + return EXIT_FAILURE; + } + + try { + scord::server daemon; + daemon.configure(cfg); + return daemon.run(); + } catch(const std::exception& ex) { + fmt::print(stderr, + "An unhandled exception reached the top of main(), " + "{} will exit:\n what(): {}\n", + cfg.progname(), ex.what()); + return EXIT_FAILURE; + } +} -- GitLab From e29108b2df2f4d36ee62f550c2743a45e866c81e Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 30 Jun 2022 15:15:40 +0200 Subject: [PATCH 2/6] Rename rpcs.[ch]pp to public.[ch]pp Also, rpc definitions have now moved into the `src/rpc` folder and have their own CMake target --- src/CMakeLists.txt | 1 + src/network/CMakeLists.txt | 4 +-- src/network/engine.hpp | 2 +- src/rpcs/CMakeLists.txt | 31 +++++++++++++++++++++++ src/{network/rpcs.cpp => rpcs/public.cpp} | 2 +- src/{network/rpcs.hpp => rpcs/public.hpp} | 8 +++--- 6 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 src/rpcs/CMakeLists.txt rename src/{network/rpcs.cpp => rpcs/public.cpp} (99%) rename src/{network/rpcs.hpp => rpcs/public.hpp} (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16cb5b93..3ac95c95 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,6 +26,7 @@ add_subdirectory(config) add_subdirectory(utils) add_subdirectory(logger) add_subdirectory(network) +add_subdirectory(rpcs) # scord daemon add_executable(scord server.cpp scord.cpp) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 38e7e5b6..42a31e2d 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -26,12 +26,12 @@ add_library(network_engine STATIC) target_sources( network_engine INTERFACE engine.hpp - PRIVATE rpcs.hpp rpcs.cpp detail/address.hpp + PRIVATE detail/address.hpp ) target_include_directories(network_engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries( - network_engine PUBLIC logger transport_library Mercury::Mercury + network_engine PUBLIC rpcs logger transport_library Mercury::Mercury Argobots::Argobots Margo::Margo ) set_property(TARGET network_engine PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 3ecd5963..6d97fd24 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -31,7 +31,7 @@ #include #include #include -#include "rpcs.hpp" +#include "public.hpp" namespace scord::network { diff --git a/src/rpcs/CMakeLists.txt b/src/rpcs/CMakeLists.txt new file mode 100644 index 00000000..f3cabfd3 --- /dev/null +++ b/src/rpcs/CMakeLists.txt @@ -0,0 +1,31 @@ +################################################################################ +# Copyright 2021-2022, 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 . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +add_library(rpcs STATIC) +target_sources(rpcs + PRIVATE public.cpp public.hpp) + +target_include_directories(rpcs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(rpcs PUBLIC logger Margo::Margo) +set_property(TARGET rpcs PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/network/rpcs.cpp b/src/rpcs/public.cpp similarity index 99% rename from src/network/rpcs.cpp rename to src/rpcs/public.cpp index 3f6dd766..83dbfae8 100644 --- a/src/network/rpcs.cpp +++ b/src/rpcs/public.cpp @@ -22,7 +22,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ -#include "rpcs.hpp" +#include "public.hpp" static void ADM_ping(hg_handle_t h) { diff --git a/src/network/rpcs.hpp b/src/rpcs/public.hpp similarity index 98% rename from src/network/rpcs.hpp rename to src/rpcs/public.hpp index 23931fb0..0d3a9b43 100644 --- a/src/network/rpcs.hpp +++ b/src/rpcs/public.hpp @@ -22,8 +22,9 @@ * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ -#ifndef SCORD_NETWORK_RPCS_HPP -#define SCORD_NETWORK_RPCS_HPP +// clang-format off +#ifndef SCORD_RPCS_PUBLIC_HPP +#define SCORD_RPCS_PUBLIC_HPP #include #include @@ -342,4 +343,5 @@ DECLARE_MARGO_RPC_HANDLER(ADM_get_statistics); //} // namespace scord::network::rpc -#endif // SCORD_NETWORK_RPCS_HPP +#endif // SCORD_RPCS_PUBLIC_HPP +// clang-format on -- GitLab From 1c24afc1d8553076852b80eca345de042aab8c46 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 30 Jun 2022 15:28:39 +0200 Subject: [PATCH 3/6] RPC clients and servers can now choose which RPCs to register --- src/api/admire.cpp | 166 ++++++++++++++++++++++++---------- src/api/detail/impl.cpp | 106 +++++++++++++++++++++- src/network/engine.hpp | 196 ++++------------------------------------ src/scord-ctl.cpp | 10 +- src/scord.cpp | 115 ++++++++++++++++++++++- src/server.cpp | 6 +- src/server.hpp | 23 +++++ 7 files changed, 390 insertions(+), 232 deletions(-) diff --git a/src/api/admire.cpp b/src/api/admire.cpp index 39113f40..daafa9f7 100644 --- a/src/api/admire.cpp +++ b/src/api/admire.cpp @@ -48,6 +48,105 @@ init_logger() { scord::logger::create_global_logger("libadm_iosched", "console color"); } +void +rpc_registration_cb(scord::network::rpc_client* client) { + + REGISTER_RPC(client, "ADM_ping", void, void, ADM_ping, false); + REGISTER_RPC(client, "ADM_input", ADM_input_in_t, ADM_input_out_t, + ADM_input, true); + + + REGISTER_RPC(client, "ADM_output", ADM_output_in_t, ADM_output_out_t, + ADM_output, true); + + REGISTER_RPC(client, "ADM_inout", ADM_inout_in_t, ADM_inout_out_t, + ADM_inout, true); + + REGISTER_RPC(client, "ADM_adhoc_context", ADM_adhoc_context_in_t, + ADM_adhoc_context_out_t, ADM_adhoc_context, true); + + REGISTER_RPC(client, "ADM_adhoc_context_id", ADM_adhoc_context_id_in_t, + ADM_adhoc_context_id_out_t, ADM_adhoc_context_id, true); + + REGISTER_RPC(client, "ADM_adhoc_nodes", ADM_adhoc_nodes_in_t, + ADM_adhoc_nodes_out_t, ADM_adhoc_nodes, true); + + REGISTER_RPC(client, "ADM_adhoc_walltime", ADM_adhoc_walltime_in_t, + ADM_adhoc_walltime_out_t, ADM_adhoc_walltime, true); + + REGISTER_RPC(client, "ADM_adhoc_access", ADM_adhoc_access_in_t, + ADM_adhoc_access_out_t, ADM_adhoc_access, true); + + REGISTER_RPC(client, "ADM_adhoc_distribution", ADM_adhoc_distribution_in_t, + ADM_adhoc_distribution_out_t, ADM_adhoc_distribution, true); + + REGISTER_RPC(client, "ADM_adhoc_background_flush", + ADM_adhoc_background_flush_in_t, + ADM_adhoc_background_flush_out_t, ADM_adhoc_background_flush, + true); + + REGISTER_RPC(client, "ADM_in_situ_ops", ADM_in_situ_ops_in_t, + ADM_in_situ_ops_out_t, ADM_in_situ_ops, true); + + REGISTER_RPC(client, "ADM_in_transit_ops", ADM_in_transit_ops_in_t, + ADM_in_transit_ops_out_t, ADM_in_transit_ops, true); + + REGISTER_RPC(client, "ADM_transfer_dataset", ADM_transfer_dataset_in_t, + ADM_transfer_dataset_out_t, ADM_transfer_dataset, true); + + REGISTER_RPC(client, "ADM_set_dataset_information", + ADM_set_dataset_information_in_t, + ADM_set_dataset_information_out_t, ADM_set_dataset_information, + true); + + REGISTER_RPC(client, "ADM_set_io_resources", ADM_set_io_resources_in_t, + ADM_set_io_resources_out_t, ADM_set_io_resources, true); + + REGISTER_RPC( + client, "ADM_get_transfer_priority", ADM_get_transfer_priority_in_t, + ADM_get_transfer_priority_out_t, ADM_get_transfer_priority, true); + + REGISTER_RPC( + client, "ADM_set_transfer_priority", ADM_set_transfer_priority_in_t, + ADM_set_transfer_priority_out_t, ADM_set_transfer_priority, true); + + REGISTER_RPC(client, "ADM_cancel_transfer", ADM_cancel_transfer_in_t, + ADM_cancel_transfer_out_t, ADM_cancel_transfer, true); + + REGISTER_RPC( + client, "ADM_get_pending_transfers", ADM_get_pending_transfers_in_t, + ADM_get_pending_transfers_out_t, ADM_get_pending_transfers, true); + + REGISTER_RPC(client, "ADM_set_qos_constraints", + ADM_set_qos_constraints_in_t, ADM_set_qos_constraints_out_t, + ADM_set_qos_constraints, true); + + REGISTER_RPC(client, "ADM_get_qos_constraints", + ADM_get_qos_constraints_in_t, ADM_get_qos_constraints_out_t, + ADM_get_qos_constraints, true); + + REGISTER_RPC( + client, "ADM_define_data_operation", ADM_define_data_operation_in_t, + ADM_define_data_operation_out_t, ADM_define_data_operation, true); + + REGISTER_RPC(client, "ADM_connect_data_operation", + ADM_connect_data_operation_in_t, + ADM_connect_data_operation_out_t, ADM_connect_data_operation, + true); + + REGISTER_RPC(client, "ADM_finalize_data_operation", + ADM_finalize_data_operation_in_t, + ADM_finalize_data_operation_out_t, ADM_finalize_data_operation, + true); + + REGISTER_RPC(client, "ADM_link_transfer_to_data_operation", + ADM_link_transfer_to_data_operation_in_t, + ADM_link_transfer_to_data_operation_out_t, + ADM_link_transfer_to_data_operation, true); + + REGISTER_RPC(client, "ADM_get_statistics", ADM_get_statistics_in_t, + ADM_get_statistics_out_t, ADM_get_statistics, true); +} } // namespace @@ -83,8 +182,7 @@ update_job(const server& srv, ADM_job_t job, ADM_job_requirements_t reqs) { (void) job; (void) reqs; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -109,8 +207,7 @@ remove_job(const server& srv, ADM_job_t job) { (void) srv; (void) job; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -139,8 +236,7 @@ register_adhoc_storage(const server& srv, ADM_job_t job, (void) ctx; (void) adhoc_handle; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -168,8 +264,7 @@ update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, (void) ctx; (void) adhoc_handle; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -196,8 +291,7 @@ remove_adhoc_storage(const server& srv, ADM_job_t job, (void) job; (void) adhoc_handle; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -224,8 +318,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, (void) job; (void) adhoc_handle; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -258,8 +351,7 @@ transfer_dataset(const server& srv, ADM_job_t job, (void) mapping; (void) tx_handle; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -287,8 +379,7 @@ set_dataset_information(const server& srv, ADM_job_t job, (void) target; (void) info; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -316,8 +407,7 @@ set_io_resources(const server& srv, ADM_job_t job, ADM_storage_handle_t tier, (void) tier; (void) resources; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -346,8 +436,7 @@ get_transfer_priority(const server& srv, ADM_job_t job, (void) tx_handle; (void) priority; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -375,8 +464,7 @@ set_transfer_priority(const server& srv, ADM_job_t job, (void) tx_handle; (void) incr; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -403,8 +491,7 @@ cancel_transfer(const server& srv, ADM_job_t job, (void) job; (void) tx_handle; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -432,8 +519,7 @@ get_pending_transfers(const server& srv, ADM_job_t job, (void) job; (void) pending_transfers; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -460,9 +546,7 @@ set_qos_constraints(const server& srv, ADM_job_t job, ADM_limit_t limit) { (void) job; (void) limit; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -492,9 +576,7 @@ get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_scope_t scope, (void) entity; (void) limits; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -524,9 +606,7 @@ define_data_operation(const server& srv, ADM_job_t job, const char* path, (void) op; (void) args; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -558,9 +638,7 @@ connect_data_operation(const server& srv, ADM_job_t job, (void) should_stream; (void) args; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -590,9 +668,7 @@ finalize_data_operation(const server& srv, ADM_job_t job, (void) op; (void) status; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -623,9 +699,7 @@ link_transfer_to_data_operation(const server& srv, ADM_job_t job, (void) should_stream; (void) args; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -652,9 +726,7 @@ get_statistics(const server& srv, ADM_job_t job, ADM_job_stats_t** stats) { (void) job; (void) stats; - scord::network::rpc_client rpc_client{srv.m_protocol}; - - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); diff --git a/src/api/detail/impl.cpp b/src/api/detail/impl.cpp index ba09387a..797a05e3 100644 --- a/src/api/detail/impl.cpp +++ b/src/api/detail/impl.cpp @@ -26,13 +26,112 @@ #include #include "impl.hpp" +void +rpc_registration_cb(scord::network::rpc_client* client) { + + REGISTER_RPC(client, "ADM_ping", void, void, ADM_ping, false); + REGISTER_RPC(client, "ADM_input", ADM_input_in_t, ADM_input_out_t, + ADM_input, true); + + + REGISTER_RPC(client, "ADM_output", ADM_output_in_t, ADM_output_out_t, + ADM_output, true); + + REGISTER_RPC(client, "ADM_inout", ADM_inout_in_t, ADM_inout_out_t, + ADM_inout, true); + + REGISTER_RPC(client, "ADM_adhoc_context", ADM_adhoc_context_in_t, + ADM_adhoc_context_out_t, ADM_adhoc_context, true); + + REGISTER_RPC(client, "ADM_adhoc_context_id", ADM_adhoc_context_id_in_t, + ADM_adhoc_context_id_out_t, ADM_adhoc_context_id, true); + + REGISTER_RPC(client, "ADM_adhoc_nodes", ADM_adhoc_nodes_in_t, + ADM_adhoc_nodes_out_t, ADM_adhoc_nodes, true); + + REGISTER_RPC(client, "ADM_adhoc_walltime", ADM_adhoc_walltime_in_t, + ADM_adhoc_walltime_out_t, ADM_adhoc_walltime, true); + + REGISTER_RPC(client, "ADM_adhoc_access", ADM_adhoc_access_in_t, + ADM_adhoc_access_out_t, ADM_adhoc_access, true); + + REGISTER_RPC(client, "ADM_adhoc_distribution", ADM_adhoc_distribution_in_t, + ADM_adhoc_distribution_out_t, ADM_adhoc_distribution, true); + + REGISTER_RPC(client, "ADM_adhoc_background_flush", + ADM_adhoc_background_flush_in_t, + ADM_adhoc_background_flush_out_t, ADM_adhoc_background_flush, + true); + + REGISTER_RPC(client, "ADM_in_situ_ops", ADM_in_situ_ops_in_t, + ADM_in_situ_ops_out_t, ADM_in_situ_ops, true); + + REGISTER_RPC(client, "ADM_in_transit_ops", ADM_in_transit_ops_in_t, + ADM_in_transit_ops_out_t, ADM_in_transit_ops, true); + + REGISTER_RPC(client, "ADM_transfer_dataset", ADM_transfer_dataset_in_t, + ADM_transfer_dataset_out_t, ADM_transfer_dataset, true); + + REGISTER_RPC(client, "ADM_set_dataset_information", + ADM_set_dataset_information_in_t, + ADM_set_dataset_information_out_t, ADM_set_dataset_information, + true); + + REGISTER_RPC(client, "ADM_set_io_resources", ADM_set_io_resources_in_t, + ADM_set_io_resources_out_t, ADM_set_io_resources, true); + + REGISTER_RPC( + client, "ADM_get_transfer_priority", ADM_get_transfer_priority_in_t, + ADM_get_transfer_priority_out_t, ADM_get_transfer_priority, true); + + REGISTER_RPC( + client, "ADM_set_transfer_priority", ADM_set_transfer_priority_in_t, + ADM_set_transfer_priority_out_t, ADM_set_transfer_priority, true); + + REGISTER_RPC(client, "ADM_cancel_transfer", ADM_cancel_transfer_in_t, + ADM_cancel_transfer_out_t, ADM_cancel_transfer, true); + + REGISTER_RPC( + client, "ADM_get_pending_transfers", ADM_get_pending_transfers_in_t, + ADM_get_pending_transfers_out_t, ADM_get_pending_transfers, true); + + REGISTER_RPC(client, "ADM_set_qos_constraints", + ADM_set_qos_constraints_in_t, ADM_set_qos_constraints_out_t, + ADM_set_qos_constraints, true); + + REGISTER_RPC(client, "ADM_get_qos_constraints", + ADM_get_qos_constraints_in_t, ADM_get_qos_constraints_out_t, + ADM_get_qos_constraints, true); + + REGISTER_RPC( + client, "ADM_define_data_operation", ADM_define_data_operation_in_t, + ADM_define_data_operation_out_t, ADM_define_data_operation, true); + + REGISTER_RPC(client, "ADM_connect_data_operation", + ADM_connect_data_operation_in_t, + ADM_connect_data_operation_out_t, ADM_connect_data_operation, + true); + + REGISTER_RPC(client, "ADM_finalize_data_operation", + ADM_finalize_data_operation_in_t, + ADM_finalize_data_operation_out_t, ADM_finalize_data_operation, + true); + + REGISTER_RPC(client, "ADM_link_transfer_to_data_operation", + ADM_link_transfer_to_data_operation_in_t, + ADM_link_transfer_to_data_operation_out_t, + ADM_link_transfer_to_data_operation, true); + + REGISTER_RPC(client, "ADM_get_statistics", ADM_get_statistics_in_t, + ADM_get_statistics_out_t, ADM_get_statistics, true); +} + namespace admire::detail { admire::error_code ping(const server& srv) { - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); @@ -48,8 +147,7 @@ register_job(const admire::server& srv, ADM_job_requirements_t reqs) { (void) srv; (void) reqs; - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; auto endp = rpc_client.lookup(srv.m_address); diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 6d97fd24..9c832cba 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -38,15 +38,23 @@ namespace scord::network { namespace detail { -#define REGISTER_RPC(__mid, __m_rpc_names, __func_name, __in_t, __out_t, \ - __handler, requires_response) \ +#define REGISTER_RPC(__engine, __func_name, __in_t, __out_t, __handler, \ + requires_response) \ + { \ + REGISTER_RPC_IMPL((__engine)->m_context->m_mid, \ + (__engine)->m_context->m_rpc_names, __func_name, \ + __in_t, __out_t, __handler, requires_response); \ + } + +#define REGISTER_RPC_IMPL(__mid, __rpc_names, __func_name, __in_t, __out_t, \ + __handler, requires_response) \ { \ hg_id_t id = margo_provider_register_name( \ __mid, __func_name, BOOST_PP_CAT(hg_proc_, __in_t), \ BOOST_PP_CAT(hg_proc_, __out_t), _handler_for_##__handler, \ MARGO_DEFAULT_PROVIDER_ID, ABT_POOL_NULL); \ - __m_rpc_names.emplace(__func_name, id); \ - if(!requires_response) { \ + (__rpc_names).emplace(__func_name, id); \ + if(!(requires_response)) { \ ::margo_registered_disable_response(__mid, id, HG_TRUE); \ } \ } @@ -56,16 +64,6 @@ struct margo_context { explicit margo_context(::margo_instance_id mid) : m_mid(mid) {} - void - register_rpc(const std::string& name, bool requires_response) { - auto id = MARGO_REGISTER(m_mid, name.c_str(), void, void, ADM_ping); - m_rpc_names.emplace(name, id); - - if(!requires_response) { - ::margo_registered_disable_response(m_mid, id, HG_TRUE); - } - } - margo_instance_id m_mid; std::unordered_map m_rpc_names; }; @@ -100,169 +98,6 @@ struct engine { } } - void - register_rpcs() { - - // register RPCs manually for now - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_ping", void, - void, ADM_ping, false); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_register_job", ADM_register_job_in_t, - ADM_register_job_out_t, ADM_register_job, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_update_job", - ADM_update_job_in_t, ADM_update_job_out_t, ADM_update_job, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_remove_job", - ADM_remove_job_in_t, ADM_remove_job_out_t, ADM_remove_job, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_register_adhoc_storage", - ADM_register_adhoc_storage_in_t, - ADM_register_adhoc_storage_out_t, - ADM_register_adhoc_storage, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_update_adhoc_storage", ADM_update_adhoc_storage_in_t, - ADM_update_adhoc_storage_out_t, ADM_update_adhoc_storage, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_remove_adhoc_storage", ADM_remove_adhoc_storage_in_t, - ADM_remove_adhoc_storage_out_t, ADM_remove_adhoc_storage, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_deploy_adhoc_storage", ADM_deploy_adhoc_storage_in_t, - ADM_deploy_adhoc_storage_out_t, ADM_deploy_adhoc_storage, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_input", - ADM_input_in_t, ADM_input_out_t, ADM_input, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_output", - ADM_output_in_t, ADM_output_out_t, ADM_output, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_inout", - ADM_inout_in_t, ADM_inout_out_t, ADM_inout, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_context", ADM_adhoc_context_in_t, - ADM_adhoc_context_out_t, ADM_adhoc_context, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_context_id", ADM_adhoc_context_id_in_t, - ADM_adhoc_context_id_out_t, ADM_adhoc_context_id, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_nodes", ADM_adhoc_nodes_in_t, - ADM_adhoc_nodes_out_t, ADM_adhoc_nodes, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_walltime", ADM_adhoc_walltime_in_t, - ADM_adhoc_walltime_out_t, ADM_adhoc_walltime, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_access", ADM_adhoc_access_in_t, - ADM_adhoc_access_out_t, ADM_adhoc_access, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_distribution", ADM_adhoc_distribution_in_t, - ADM_adhoc_distribution_out_t, ADM_adhoc_distribution, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_adhoc_background_flush", - ADM_adhoc_background_flush_in_t, - ADM_adhoc_background_flush_out_t, - ADM_adhoc_background_flush, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_in_situ_ops", ADM_in_situ_ops_in_t, - ADM_in_situ_ops_out_t, ADM_in_situ_ops, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_in_transit_ops", ADM_in_transit_ops_in_t, - ADM_in_transit_ops_out_t, ADM_in_transit_ops, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_transfer_dataset", ADM_transfer_dataset_in_t, - ADM_transfer_dataset_out_t, ADM_transfer_dataset, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_set_dataset_information", - ADM_set_dataset_information_in_t, - ADM_set_dataset_information_out_t, - ADM_set_dataset_information, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_set_io_resources", ADM_set_io_resources_in_t, - ADM_set_io_resources_out_t, ADM_set_io_resources, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_get_transfer_priority", - ADM_get_transfer_priority_in_t, - ADM_get_transfer_priority_out_t, ADM_get_transfer_priority, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_set_transfer_priority", - ADM_set_transfer_priority_in_t, - ADM_set_transfer_priority_out_t, ADM_set_transfer_priority, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_cancel_transfer", ADM_cancel_transfer_in_t, - ADM_cancel_transfer_out_t, ADM_cancel_transfer, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_get_pending_transfers", - ADM_get_pending_transfers_in_t, - ADM_get_pending_transfers_out_t, ADM_get_pending_transfers, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_set_qos_constraints", ADM_set_qos_constraints_in_t, - ADM_set_qos_constraints_out_t, ADM_set_qos_constraints, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_get_qos_constraints", ADM_get_qos_constraints_in_t, - ADM_get_qos_constraints_out_t, ADM_get_qos_constraints, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_define_data_operation", - ADM_define_data_operation_in_t, - ADM_define_data_operation_out_t, ADM_define_data_operation, - true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_connect_data_operation", - ADM_connect_data_operation_in_t, - ADM_connect_data_operation_out_t, - ADM_connect_data_operation, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_finalize_data_operation", - ADM_finalize_data_operation_in_t, - ADM_finalize_data_operation_out_t, - ADM_finalize_data_operation, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_link_transfer_to_data_operation", - ADM_link_transfer_to_data_operation_in_t, - ADM_link_transfer_to_data_operation_out_t, - ADM_link_transfer_to_data_operation, true); - - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_get_statistics", ADM_get_statistics_in_t, - ADM_get_statistics_out_t, ADM_get_statistics, true); - } - void listen() const { @@ -420,6 +255,13 @@ engine::lookup(const std::string& address) const { struct rpc_client : engine { explicit rpc_client(const std::string& protocol) : engine(protocol, execution_mode::client) {} + + template + rpc_client(const std::string& protocol, + Callback&& rpc_registration_callback) + : engine(protocol, execution_mode::client) { + rpc_registration_callback(this); + } }; struct rpc_acceptor : engine { diff --git a/src/scord-ctl.cpp b/src/scord-ctl.cpp index 8686cd37..6fa97822 100644 --- a/src/scord-ctl.cpp +++ b/src/scord-ctl.cpp @@ -150,7 +150,15 @@ main(int argc, char* argv[]) { try { scord::server daemon; - daemon.configure(cfg); + const auto rpc_registration_cb = [](auto&& ctx) { + LOGGER_INFO(" * Registering RPCs handlers..."); + + REGISTER_RPC(ctx, "ADM_ping", void, void, ADM_ping, false); + + // TODO: add internal RPCs for communication with scord + }; + + daemon.configure(cfg, rpc_registration_cb); return daemon.run(); } catch(const std::exception& ex) { fmt::print(stderr, diff --git a/src/scord.cpp b/src/scord.cpp index 8686cd37..3cdc3235 100644 --- a/src/scord.cpp +++ b/src/scord.cpp @@ -150,7 +150,120 @@ main(int argc, char* argv[]) { try { scord::server daemon; - daemon.configure(cfg); + + const auto rpc_registration_cb = [](auto&& ctx) { + LOGGER_INFO(" * Registering RPCs handlers..."); + + REGISTER_RPC(ctx, "ADM_ping", void, void, ADM_ping, false); + REGISTER_RPC(ctx, "ADM_input", ADM_input_in_t, ADM_input_out_t, + ADM_input, true); + + + REGISTER_RPC(ctx, "ADM_output", ADM_output_in_t, ADM_output_out_t, + ADM_output, true); + + REGISTER_RPC(ctx, "ADM_inout", ADM_inout_in_t, ADM_inout_out_t, + ADM_inout, true); + + REGISTER_RPC(ctx, "ADM_adhoc_context", ADM_adhoc_context_in_t, + ADM_adhoc_context_out_t, ADM_adhoc_context, true); + + REGISTER_RPC(ctx, "ADM_adhoc_context_id", ADM_adhoc_context_id_in_t, + ADM_adhoc_context_id_out_t, ADM_adhoc_context_id, + true); + + REGISTER_RPC(ctx, "ADM_adhoc_nodes", ADM_adhoc_nodes_in_t, + ADM_adhoc_nodes_out_t, ADM_adhoc_nodes, true); + + REGISTER_RPC(ctx, "ADM_adhoc_walltime", ADM_adhoc_walltime_in_t, + ADM_adhoc_walltime_out_t, ADM_adhoc_walltime, true); + + REGISTER_RPC(ctx, "ADM_adhoc_access", ADM_adhoc_access_in_t, + ADM_adhoc_access_out_t, ADM_adhoc_access, true); + + REGISTER_RPC( + ctx, "ADM_adhoc_distribution", ADM_adhoc_distribution_in_t, + ADM_adhoc_distribution_out_t, ADM_adhoc_distribution, true); + + REGISTER_RPC(ctx, "ADM_adhoc_background_flush", + ADM_adhoc_background_flush_in_t, + ADM_adhoc_background_flush_out_t, + ADM_adhoc_background_flush, true); + + REGISTER_RPC(ctx, "ADM_in_situ_ops", ADM_in_situ_ops_in_t, + ADM_in_situ_ops_out_t, ADM_in_situ_ops, true); + + REGISTER_RPC(ctx, "ADM_in_transit_ops", ADM_in_transit_ops_in_t, + ADM_in_transit_ops_out_t, ADM_in_transit_ops, true); + + REGISTER_RPC(ctx, "ADM_transfer_dataset", ADM_transfer_dataset_in_t, + ADM_transfer_dataset_out_t, ADM_transfer_dataset, + true); + + REGISTER_RPC(ctx, "ADM_set_dataset_information", + ADM_set_dataset_information_in_t, + ADM_set_dataset_information_out_t, + ADM_set_dataset_information, true); + + REGISTER_RPC(ctx, "ADM_set_io_resources", ADM_set_io_resources_in_t, + ADM_set_io_resources_out_t, ADM_set_io_resources, + true); + + REGISTER_RPC(ctx, "ADM_get_transfer_priority", + ADM_get_transfer_priority_in_t, + ADM_get_transfer_priority_out_t, + ADM_get_transfer_priority, true); + + REGISTER_RPC(ctx, "ADM_set_transfer_priority", + ADM_set_transfer_priority_in_t, + ADM_set_transfer_priority_out_t, + ADM_set_transfer_priority, true); + + REGISTER_RPC(ctx, "ADM_cancel_transfer", ADM_cancel_transfer_in_t, + ADM_cancel_transfer_out_t, ADM_cancel_transfer, true); + + REGISTER_RPC(ctx, "ADM_get_pending_transfers", + ADM_get_pending_transfers_in_t, + ADM_get_pending_transfers_out_t, + ADM_get_pending_transfers, true); + + REGISTER_RPC(ctx, "ADM_set_qos_constraints", + ADM_set_qos_constraints_in_t, + ADM_set_qos_constraints_out_t, ADM_set_qos_constraints, + true); + + REGISTER_RPC(ctx, "ADM_get_qos_constraints", + ADM_get_qos_constraints_in_t, + ADM_get_qos_constraints_out_t, ADM_get_qos_constraints, + true); + + REGISTER_RPC(ctx, "ADM_define_data_operation", + ADM_define_data_operation_in_t, + ADM_define_data_operation_out_t, + ADM_define_data_operation, true); + + REGISTER_RPC(ctx, "ADM_connect_data_operation", + ADM_connect_data_operation_in_t, + ADM_connect_data_operation_out_t, + ADM_connect_data_operation, true); + + REGISTER_RPC(ctx, "ADM_finalize_data_operation", + ADM_finalize_data_operation_in_t, + ADM_finalize_data_operation_out_t, + ADM_finalize_data_operation, true); + + REGISTER_RPC(ctx, "ADM_link_transfer_to_data_operation", + ADM_link_transfer_to_data_operation_in_t, + ADM_link_transfer_to_data_operation_out_t, + ADM_link_transfer_to_data_operation, true); + + REGISTER_RPC(ctx, "ADM_get_statistics", ADM_get_statistics_in_t, + ADM_get_statistics_out_t, ADM_get_statistics, true); + + // TODO: add internal RPCs for communication with scord-ctl + }; + + daemon.configure(cfg, rpc_registration_cb); return daemon.run(); } catch(const std::exception& ex) { fmt::print(stderr, diff --git a/src/server.cpp b/src/server.cpp index c8899f6d..23c1e1aa 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -264,8 +264,10 @@ server::install_rpc_handlers() { m_settings->transport_protocol(), m_settings->bind_address(), m_settings->remote_port()); - m_network_engine->register_rpcs(); -} // namespace scord + if(m_rpc_registration_callback) { + m_rpc_registration_callback(m_network_engine); + } +} void server::check_configuration() { diff --git a/src/server.hpp b/src/server.hpp index 7c767323..77d2ce48 100644 --- a/src/server.hpp +++ b/src/server.hpp @@ -46,6 +46,15 @@ public: ~server(); void configure(const config::settings& settings); + + template + void + configure(const config::settings& settings, + Callback rpc_registration_callback) { + configure(settings); + m_rpc_registration_callback = rpc_registration_callback; + } + config::settings get_configuration() const; int @@ -57,6 +66,18 @@ public: void teardown_and_exit(); + + template + void + install_rpc_handlers(Callable fun) { + + install_rpc_handlers(); + + // FIXME: improve network_engine so that we don't need to rely on + // calling a lambda here to register RPCs + fun(m_network_engine); + } + private: int daemonize(); @@ -82,6 +103,8 @@ private: std::unique_ptr m_settings; std::unique_ptr m_network_engine; std::unique_ptr m_signal_listener; + std::function&)> + m_rpc_registration_callback; }; -- GitLab From e75b397df856180ba605472edfea985c49b188f2 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 30 Jun 2022 21:17:19 +0200 Subject: [PATCH 4/6] Disable ADM_in_[situ|transit]_ops examples --- examples/cxx/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/cxx/CMakeLists.txt b/examples/cxx/CMakeLists.txt index c1e49ffb..c2a94c63 100644 --- a/examples/cxx/CMakeLists.txt +++ b/examples/cxx/CMakeLists.txt @@ -27,7 +27,8 @@ list(APPEND examples_cxx ADM_register_job ADM_update_job ADM_remove_job ADM_register_adhoc_storage ADM_update_adhoc_storage ADM_remove_adhoc_storage ADM_deploy_adhoc_storage - ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset + # ADM_in_situ_ops ADM_in_transit_ops + ADM_transfer_dataset ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers ADM_set_qos_constraints ADM_get_qos_constraints ADM_define_data_operation ADM_connect_data_operation -- GitLab From de4632cf23ad686b1ff717036c71c34383de5b03 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 22 Jun 2022 16:01:23 +0200 Subject: [PATCH 5/6] Move server.[ch]pp to network subdirectory --- src/CMakeLists.txt | 8 ++++---- src/network/CMakeLists.txt | 15 +++++++++++++++ src/{ => network}/server.cpp | 2 +- src/{ => network}/server.hpp | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) rename src/{ => network}/server.cpp (99%) rename src/{ => network}/server.hpp (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ac95c95..c4cd6f24 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,27 +29,27 @@ add_subdirectory(network) add_subdirectory(rpcs) # scord daemon -add_executable(scord server.cpp scord.cpp) +add_executable(scord scord.cpp) target_include_directories( scord PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries( - scord PRIVATE config logger network_engine fmt::fmt Boost::program_options + scord PRIVATE config logger rpc_server fmt::fmt Boost::program_options ) install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) # scord-ctl daemon -add_executable(scord-ctl server.cpp scord-ctl.cpp) +add_executable(scord-ctl scord-ctl.cpp) target_include_directories( scord-ctl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries( - scord-ctl PRIVATE config logger network_engine fmt::fmt Boost::program_options + scord-ctl PRIVATE config logger rpc_server fmt::fmt Boost::program_options ) install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 42a31e2d..343a6829 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -35,3 +35,18 @@ target_link_libraries( Argobots::Argobots Margo::Margo ) set_property(TARGET network_engine PROPERTY POSITION_INDEPENDENT_CODE ON) + +add_library(rpc_server STATIC) +target_sources( + rpc_server + INTERFACE server.hpp + PRIVATE server.cpp +) + +target_include_directories( + rpc_server + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_SOURCE_DIR}/src +) + +target_link_libraries(rpc_server PUBLIC config network_engine) diff --git a/src/server.cpp b/src/network/server.cpp similarity index 99% rename from src/server.cpp rename to src/network/server.cpp index 23c1e1aa..98c99148 100644 --- a/src/server.cpp +++ b/src/network/server.cpp @@ -33,10 +33,10 @@ #include #include +#include #include #include #include -#include #include namespace scord { diff --git a/src/server.hpp b/src/network/server.hpp similarity index 98% rename from src/server.hpp rename to src/network/server.hpp index 77d2ce48..aeef7a66 100644 --- a/src/server.hpp +++ b/src/network/server.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace scord { -- GitLab From 4d12b240bfd3ffdf871e1e63c71d23fdc5c2fb35 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 30 Jun 2022 21:56:06 +0200 Subject: [PATCH 6/6] Reorganize source code - `scord` daemon now has its own directory in `src/scord` - `scord-ctl` daemon now has its own directory in `src/scord-ctl` - library code now lives under the `lib` directory - public rpc definitions now live in `src/lib/rpcs/` - private rpc definitions for each daemon now live in `src/scord/rpcs/` and `src/scord-ctl/rpcs/`, respectively - `config`, `logger`, and `network` code now live under the `common` directory --- examples/cxx/CMakeLists.txt | 2 +- src/CMakeLists.txt | 38 ++--------- src/common/CMakeLists.txt | 46 +++++++++++++ src/{ => common}/config/CMakeLists.txt | 10 +-- src/{ => common}/config/config.hpp | 0 src/{ => common}/config/defaults.cpp.in | 0 src/{ => common}/config/defaults.hpp | 0 src/{ => common}/config/file_options.yml | 0 src/{ => common}/config/genopts.yml.in | 0 src/{ => common}/config/parsers.cpp | 2 +- src/{ => common}/config/parsers.hpp | 0 src/{ => common}/config/settings.cpp | 0 src/{ => common}/config/settings.hpp | 0 src/{ => common}/logger/CMakeLists.txt | 8 +-- src/{ => common}/logger/logger.hpp | 0 src/{ => common}/network/CMakeLists.txt | 21 ++---- src/{ => common}/network/detail/address.hpp | 0 src/{ => common}/network/engine.hpp | 5 +- src/{ => common}/network/server.cpp | 4 +- src/{ => common}/network/server.hpp | 2 +- src/{ => common}/utils/CMakeLists.txt | 7 +- src/{ => common}/utils/signal_listener.hpp | 0 src/{ => common}/utils/utils.cpp | 2 +- src/{ => common}/utils/utils.hpp | 0 src/{api => lib}/CMakeLists.txt | 13 +++- src/{api => lib}/admire.cpp | 5 +- src/{api => lib}/admire.h | 0 src/{api => lib}/admire.hpp | 0 src/{api => lib}/c_wrapper.cpp | 2 +- src/{api => lib}/detail/impl.cpp | 3 +- src/{api => lib}/detail/impl.hpp | 0 src/{api => lib}/errors.c | 0 src/{ => lib}/rpcs/public.cpp | 0 src/{ => lib}/rpcs/public.hpp | 3 +- src/scord-ctl/CMakeLists.txt | 42 ++++++++++++ src/{ => scord-ctl}/rpcs/CMakeLists.txt | 12 ++-- src/scord-ctl/rpcs/private.cpp | 41 ++++++++++++ src/scord-ctl/rpcs/private.hpp | 32 +++++++++ src/{ => scord-ctl}/scord-ctl.cpp | 4 +- src/scord/CMakeLists.txt | 72 +++++++++++++++++++++ src/scord/rpcs/CMakeLists.txt | 31 +++++++++ src/scord/rpcs/private.cpp | 41 ++++++++++++ src/scord/rpcs/private.hpp | 32 +++++++++ src/{ => scord}/scord.cpp | 4 +- 44 files changed, 399 insertions(+), 85 deletions(-) create mode 100644 src/common/CMakeLists.txt rename src/{ => common}/config/CMakeLists.txt (94%) rename src/{ => common}/config/config.hpp (100%) rename src/{ => common}/config/defaults.cpp.in (100%) rename src/{ => common}/config/defaults.hpp (100%) rename src/{ => common}/config/file_options.yml (100%) rename src/{ => common}/config/genopts.yml.in (100%) rename src/{ => common}/config/parsers.cpp (99%) rename src/{ => common}/config/parsers.hpp (100%) rename src/{ => common}/config/settings.cpp (100%) rename src/{ => common}/config/settings.hpp (100%) rename src/{ => common}/logger/CMakeLists.txt (89%) rename src/{ => common}/logger/logger.hpp (100%) rename src/{ => common}/network/CMakeLists.txt (80%) rename src/{ => common}/network/detail/address.hpp (100%) rename src/{ => common}/network/engine.hpp (99%) rename src/{ => common}/network/server.cpp (99%) rename src/{ => common}/network/server.hpp (99%) rename src/{ => common}/utils/CMakeLists.txt (89%) rename src/{ => common}/utils/signal_listener.hpp (100%) rename src/{ => common}/utils/utils.cpp (99%) rename src/{ => common}/utils/utils.hpp (100%) rename src/{api => lib}/CMakeLists.txt (80%) rename src/{api => lib}/admire.cpp (99%) rename src/{api => lib}/admire.h (100%) rename src/{api => lib}/admire.hpp (100%) rename src/{api => lib}/c_wrapper.cpp (99%) rename src/{api => lib}/detail/impl.cpp (99%) rename src/{api => lib}/detail/impl.hpp (100%) rename src/{api => lib}/errors.c (100%) rename src/{ => lib}/rpcs/public.cpp (100%) rename src/{ => lib}/rpcs/public.hpp (99%) create mode 100644 src/scord-ctl/CMakeLists.txt rename src/{ => scord-ctl}/rpcs/CMakeLists.txt (84%) create mode 100644 src/scord-ctl/rpcs/private.cpp create mode 100644 src/scord-ctl/rpcs/private.hpp rename src/{ => scord-ctl}/scord-ctl.cpp (98%) create mode 100644 src/scord/CMakeLists.txt create mode 100644 src/scord/rpcs/CMakeLists.txt create mode 100644 src/scord/rpcs/private.cpp create mode 100644 src/scord/rpcs/private.hpp rename src/{ => scord}/scord.cpp (99%) diff --git a/examples/cxx/CMakeLists.txt b/examples/cxx/CMakeLists.txt index c2a94c63..4df33f0d 100644 --- a/examples/cxx/CMakeLists.txt +++ b/examples/cxx/CMakeLists.txt @@ -38,6 +38,6 @@ foreach (example IN LISTS examples_cxx) add_executable(${example}_cxx) target_sources(${example}_cxx PRIVATE ${example}.cpp) target_link_libraries(${example}_cxx - PUBLIC network_engine fmt::fmt adm_iosched) + PUBLIC common::network::engine fmt::fmt adm_iosched) set_target_properties(${example}_cxx PROPERTIES OUTPUT_NAME ${example}) endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c4cd6f24..7c2edf2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,37 +22,9 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_subdirectory(config) -add_subdirectory(utils) -add_subdirectory(logger) -add_subdirectory(network) -add_subdirectory(rpcs) +add_subdirectory(common) +add_subdirectory(scord) +add_subdirectory(scord-ctl) -# scord daemon -add_executable(scord scord.cpp) - -target_include_directories( - scord PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} -) - -target_link_libraries( - scord PRIVATE config logger rpc_server fmt::fmt Boost::program_options -) - -install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) - -# scord-ctl daemon -add_executable(scord-ctl scord-ctl.cpp) - -target_include_directories( - scord-ctl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} -) - -target_link_libraries( - scord-ctl PRIVATE config logger rpc_server fmt::fmt Boost::program_options -) - -install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) - -# public api libraries -add_subdirectory(api) +# public libraries +add_subdirectory(lib) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 00000000..f3fbb8b2 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,46 @@ +################################################################################ +# Copyright 2021-2022, 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 . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +add_library(common INTERFACE) +target_include_directories(common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +add_subdirectory(utils) +target_include_directories(_utils INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +add_library(common::utils ALIAS _utils) + +add_subdirectory(config) +target_include_directories(_config INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +add_library(common::config ALIAS _config) + +add_subdirectory(logger) +target_include_directories(_logger INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +add_library(common::logger ALIAS _logger) + +add_subdirectory(network) +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) diff --git a/src/config/CMakeLists.txt b/src/common/config/CMakeLists.txt similarity index 94% rename from src/config/CMakeLists.txt rename to src/common/config/CMakeLists.txt index 872dfb27..fa464f06 100644 --- a/src/config/CMakeLists.txt +++ b/src/common/config/CMakeLists.txt @@ -23,18 +23,18 @@ ################################################################################ # Create a config target for all configuration code -add_library(config STATIC) +add_library(_config STATIC) # Since some of the sources will be auto-generated, we need to search for # includes in ${CMAKE_CURRENT_BINARY_DIR} target_include_directories( - config PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} + _config PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -set_property(TARGET config PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET _config PROPERTY POSITION_INDEPENDENT_CODE ON) target_sources( - config + _config PRIVATE config.hpp defaults.hpp ${CMAKE_CURRENT_BINARY_DIR}/defaults.cpp @@ -46,7 +46,7 @@ target_sources( settings.hpp ) -target_link_libraries(config PRIVATE utils file_options::file_options) +target_link_libraries(_config PRIVATE common::utils file_options::file_options) # ############################################################################## # Produce several auto-generated files for 'config' diff --git a/src/config/config.hpp b/src/common/config/config.hpp similarity index 100% rename from src/config/config.hpp rename to src/common/config/config.hpp diff --git a/src/config/defaults.cpp.in b/src/common/config/defaults.cpp.in similarity index 100% rename from src/config/defaults.cpp.in rename to src/common/config/defaults.cpp.in diff --git a/src/config/defaults.hpp b/src/common/config/defaults.hpp similarity index 100% rename from src/config/defaults.hpp rename to src/common/config/defaults.hpp diff --git a/src/config/file_options.yml b/src/common/config/file_options.yml similarity index 100% rename from src/config/file_options.yml rename to src/common/config/file_options.yml diff --git a/src/config/genopts.yml.in b/src/common/config/genopts.yml.in similarity index 100% rename from src/config/genopts.yml.in rename to src/common/config/genopts.yml.in diff --git a/src/config/parsers.cpp b/src/common/config/parsers.cpp similarity index 99% rename from src/config/parsers.cpp rename to src/common/config/parsers.cpp index 0fdc9706..a45d853a 100644 --- a/src/config/parsers.cpp +++ b/src/common/config/parsers.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include "parsers.hpp" namespace fs = std::filesystem; diff --git a/src/config/parsers.hpp b/src/common/config/parsers.hpp similarity index 100% rename from src/config/parsers.hpp rename to src/common/config/parsers.hpp diff --git a/src/config/settings.cpp b/src/common/config/settings.cpp similarity index 100% rename from src/config/settings.cpp rename to src/common/config/settings.cpp diff --git a/src/config/settings.hpp b/src/common/config/settings.hpp similarity index 100% rename from src/config/settings.hpp rename to src/common/config/settings.hpp diff --git a/src/logger/CMakeLists.txt b/src/common/logger/CMakeLists.txt similarity index 89% rename from src/logger/CMakeLists.txt rename to src/common/logger/CMakeLists.txt index a56254f6..6836b124 100644 --- a/src/logger/CMakeLists.txt +++ b/src/common/logger/CMakeLists.txt @@ -22,10 +22,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_library(logger INTERFACE) +add_library(_logger INTERFACE) -target_include_directories(logger INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_sources(_logger INTERFACE logger.hpp) -target_sources(logger INTERFACE logger.hpp) - -target_link_libraries(logger INTERFACE spdlog::spdlog fmt::fmt) +target_link_libraries(_logger INTERFACE spdlog::spdlog fmt::fmt) diff --git a/src/logger/logger.hpp b/src/common/logger/logger.hpp similarity index 100% rename from src/logger/logger.hpp rename to src/common/logger/logger.hpp diff --git a/src/network/CMakeLists.txt b/src/common/network/CMakeLists.txt similarity index 80% rename from src/network/CMakeLists.txt rename to src/common/network/CMakeLists.txt index 343a6829..5aa5930d 100644 --- a/src/network/CMakeLists.txt +++ b/src/common/network/CMakeLists.txt @@ -22,31 +22,24 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_library(network_engine STATIC) +add_library(_network_engine STATIC) target_sources( - network_engine + _network_engine INTERFACE engine.hpp PRIVATE detail/address.hpp ) -target_include_directories(network_engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries( - network_engine PUBLIC rpcs logger transport_library Mercury::Mercury + _network_engine PUBLIC common::logger transport_library Mercury::Mercury Argobots::Argobots Margo::Margo ) -set_property(TARGET network_engine PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET _network_engine PROPERTY POSITION_INDEPENDENT_CODE ON) -add_library(rpc_server STATIC) +add_library(_rpc_server STATIC) target_sources( - rpc_server + _rpc_server INTERFACE server.hpp PRIVATE server.cpp ) -target_include_directories( - rpc_server - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_SOURCE_DIR}/src -) - -target_link_libraries(rpc_server PUBLIC config network_engine) +target_link_libraries(_rpc_server PUBLIC common::config _network_engine) diff --git a/src/network/detail/address.hpp b/src/common/network/detail/address.hpp similarity index 100% rename from src/network/detail/address.hpp rename to src/common/network/detail/address.hpp diff --git a/src/network/engine.hpp b/src/common/network/engine.hpp similarity index 99% rename from src/network/engine.hpp rename to src/common/network/engine.hpp index 9c832cba..79c36d8e 100644 --- a/src/network/engine.hpp +++ b/src/common/network/engine.hpp @@ -28,10 +28,9 @@ #include #include #include -#include +#include #include -#include -#include "public.hpp" +#include "detail/address.hpp" namespace scord::network { diff --git a/src/network/server.cpp b/src/common/network/server.cpp similarity index 99% rename from src/network/server.cpp rename to src/common/network/server.cpp index 98c99148..1818650a 100644 --- a/src/network/server.cpp +++ b/src/common/network/server.cpp @@ -33,11 +33,11 @@ #include #include -#include -#include #include #include #include +#include "engine.hpp" +#include "server.hpp" namespace scord { diff --git a/src/network/server.hpp b/src/common/network/server.hpp similarity index 99% rename from src/network/server.hpp rename to src/common/network/server.hpp index aeef7a66..930cc847 100644 --- a/src/network/server.hpp +++ b/src/common/network/server.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include "engine.hpp" namespace scord { diff --git a/src/utils/CMakeLists.txt b/src/common/utils/CMakeLists.txt similarity index 89% rename from src/utils/CMakeLists.txt rename to src/common/utils/CMakeLists.txt index 37360b29..576d08a1 100644 --- a/src/utils/CMakeLists.txt +++ b/src/common/utils/CMakeLists.txt @@ -22,9 +22,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_library(utils STATIC) +add_library(_utils STATIC) -target_include_directories(utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -set_property(TARGET utils PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET _utils PROPERTY POSITION_INDEPENDENT_CODE ON) -target_sources(utils PRIVATE utils.hpp utils.cpp signal_listener.hpp) +target_sources(_utils PRIVATE utils.hpp utils.cpp signal_listener.hpp) diff --git a/src/utils/signal_listener.hpp b/src/common/utils/signal_listener.hpp similarity index 100% rename from src/utils/signal_listener.hpp rename to src/common/utils/signal_listener.hpp diff --git a/src/utils/utils.cpp b/src/common/utils/utils.cpp similarity index 99% rename from src/utils/utils.cpp rename to src/common/utils/utils.cpp index 05284e19..59d992f8 100644 --- a/src/utils/utils.cpp +++ b/src/common/utils/utils.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include "utils.hpp" namespace scord::utils { diff --git a/src/utils/utils.hpp b/src/common/utils/utils.hpp similarity index 100% rename from src/utils/utils.hpp rename to src/common/utils/utils.hpp diff --git a/src/api/CMakeLists.txt b/src/lib/CMakeLists.txt similarity index 80% rename from src/api/CMakeLists.txt rename to src/lib/CMakeLists.txt index e6a5eddb..94a90638 100644 --- a/src/api/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -22,6 +22,16 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ +# target for the public rpcs defined by the API that need to be shared by scord +add_library(api_rpcs STATIC) +target_sources(api_rpcs + PRIVATE rpcs/public.cpp rpcs/public.hpp) + +target_include_directories(api_rpcs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rpcs) +target_link_libraries(api_rpcs PUBLIC common::logger Margo::Margo) +set_property(TARGET api_rpcs PROPERTY POSITION_INDEPENDENT_CODE ON) + +# the client library implementing the actual API add_library(adm_iosched SHARED) target_sources(adm_iosched @@ -30,7 +40,8 @@ target_sources(adm_iosched target_include_directories(adm_iosched PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(adm_iosched PRIVATE network_engine PUBLIC tl::expected) +target_link_libraries(adm_iosched PRIVATE common::network::engine api_rpcs PUBLIC + tl::expected) install( TARGETS adm_iosched diff --git a/src/api/admire.cpp b/src/lib/admire.cpp similarity index 99% rename from src/api/admire.cpp rename to src/lib/admire.cpp index daafa9f7..ebc64a8a 100644 --- a/src/api/admire.cpp +++ b/src/lib/admire.cpp @@ -23,8 +23,9 @@ *****************************************************************************/ #include -#include -#include +#include +#include +#include "rpcs/public.hpp" #include "detail/impl.hpp" diff --git a/src/api/admire.h b/src/lib/admire.h similarity index 100% rename from src/api/admire.h rename to src/lib/admire.h diff --git a/src/api/admire.hpp b/src/lib/admire.hpp similarity index 100% rename from src/api/admire.hpp rename to src/lib/admire.hpp diff --git a/src/api/c_wrapper.cpp b/src/lib/c_wrapper.cpp similarity index 99% rename from src/api/c_wrapper.cpp rename to src/lib/c_wrapper.cpp index 1a4e03c2..1ffffe06 100644 --- a/src/api/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include "detail/impl.hpp" struct adm_server { diff --git a/src/api/detail/impl.cpp b/src/lib/detail/impl.cpp similarity index 99% rename from src/api/detail/impl.cpp rename to src/lib/detail/impl.cpp index 797a05e3..116d2112 100644 --- a/src/api/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -23,7 +23,8 @@ *****************************************************************************/ #include -#include +#include +#include "rpcs/public.hpp" #include "impl.hpp" void diff --git a/src/api/detail/impl.hpp b/src/lib/detail/impl.hpp similarity index 100% rename from src/api/detail/impl.hpp rename to src/lib/detail/impl.hpp diff --git a/src/api/errors.c b/src/lib/errors.c similarity index 100% rename from src/api/errors.c rename to src/lib/errors.c diff --git a/src/rpcs/public.cpp b/src/lib/rpcs/public.cpp similarity index 100% rename from src/rpcs/public.cpp rename to src/lib/rpcs/public.cpp diff --git a/src/rpcs/public.hpp b/src/lib/rpcs/public.hpp similarity index 99% rename from src/rpcs/public.hpp rename to src/lib/rpcs/public.hpp index 0d3a9b43..6b9f9d4f 100644 --- a/src/rpcs/public.hpp +++ b/src/lib/rpcs/public.hpp @@ -27,11 +27,10 @@ #define SCORD_RPCS_PUBLIC_HPP #include -#include #include #include #include - +#include // FIXME: cannot be in a namespace due to Margo limitations // namespace scord::network::rpc { diff --git a/src/scord-ctl/CMakeLists.txt b/src/scord-ctl/CMakeLists.txt new file mode 100644 index 00000000..26dfc86b --- /dev/null +++ b/src/scord-ctl/CMakeLists.txt @@ -0,0 +1,42 @@ +################################################################################ +# Copyright 2021-2022, 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 . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +# import rpc definitions for scord-ctl +add_subdirectory(rpcs) + +# scord-ctl daemon +add_executable(scord-ctl scord-ctl.cpp) + +target_include_directories( + scord-ctl + PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_BINARY_DIR}/src ${CMAKE_CURRENT_BINARY_DIR} +) + +target_link_libraries( + scord-ctl PRIVATE common::config common::logger common::network::rpc_server + scord_ctl_private_rpcs fmt::fmt Boost::program_options +) + +install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/rpcs/CMakeLists.txt b/src/scord-ctl/rpcs/CMakeLists.txt similarity index 84% rename from src/rpcs/CMakeLists.txt rename to src/scord-ctl/rpcs/CMakeLists.txt index f3cabfd3..ae011dd9 100644 --- a/src/rpcs/CMakeLists.txt +++ b/src/scord-ctl/rpcs/CMakeLists.txt @@ -22,10 +22,10 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_library(rpcs STATIC) -target_sources(rpcs - PRIVATE public.cpp public.hpp) +add_library(scord_private_rpcs STATIC) +target_sources(scord_private_rpcs + PRIVATE private.cpp private.hpp) -target_include_directories(rpcs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(rpcs PUBLIC logger Margo::Margo) -set_property(TARGET rpcs PROPERTY POSITION_INDEPENDENT_CODE ON) +target_include_directories(scord_private_rpcs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(scord_private_rpcs PUBLIC common::logger Margo::Margo) +set_property(TARGET scord_private_rpcs PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/scord-ctl/rpcs/private.cpp b/src/scord-ctl/rpcs/private.cpp new file mode 100644 index 00000000..d472d44e --- /dev/null +++ b/src/scord-ctl/rpcs/private.cpp @@ -0,0 +1,41 @@ +/****************************************************************************** + * Copyright 2021-2022, 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include "private.hpp" + +static void +ADM_ping(hg_handle_t h) { + + hg_return_t ret; + + [[maybe_unused]] margo_instance_id mid = margo_hg_handle_get_instance(h); + + LOGGER_INFO("PING(noargs)"); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_ping); diff --git a/src/scord-ctl/rpcs/private.hpp b/src/scord-ctl/rpcs/private.hpp new file mode 100644 index 00000000..6429eade --- /dev/null +++ b/src/scord-ctl/rpcs/private.hpp @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright 2021-2022, 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#ifndef SCORD_CTL_RPCS_PRIVATE_HPP +#define SCORD_CTL_RPCS_PRIVATE_HPP + +#include + +DECLARE_MARGO_RPC_HANDLER(ADM_ping); + +#endif // SCORD_CTL_RPCS_PRIVATE_HPP diff --git a/src/scord-ctl.cpp b/src/scord-ctl/scord-ctl.cpp similarity index 98% rename from src/scord-ctl.cpp rename to src/scord-ctl/scord-ctl.cpp index 6fa97822..b99caff9 100644 --- a/src/scord-ctl.cpp +++ b/src/scord-ctl/scord-ctl.cpp @@ -32,8 +32,10 @@ #include #include -#include +#include #include +#include +#include "rpcs/private.hpp" namespace fs = std::filesystem; namespace bpo = boost::program_options; diff --git a/src/scord/CMakeLists.txt b/src/scord/CMakeLists.txt new file mode 100644 index 00000000..b7d7d6d1 --- /dev/null +++ b/src/scord/CMakeLists.txt @@ -0,0 +1,72 @@ +################################################################################ +# Copyright 2021-2022, 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 . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +################################################################################ +# Copyright 2021-2022, 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 . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +# import rpc definitions for scord +add_subdirectory(rpcs) + +# scord daemon +add_executable(scord scord.cpp) + +target_include_directories( + scord + PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_BINARY_DIR}/src ${CMAKE_CURRENT_BINARY_DIR} +) + +target_link_libraries( + scord + PRIVATE common::config + common::logger + common::network::rpc_server + api_rpcs + scord_private_rpcs + fmt::fmt + Boost::program_options +) + +install(TARGETS scord DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/scord/rpcs/CMakeLists.txt b/src/scord/rpcs/CMakeLists.txt new file mode 100644 index 00000000..38b0acf5 --- /dev/null +++ b/src/scord/rpcs/CMakeLists.txt @@ -0,0 +1,31 @@ +################################################################################ +# Copyright 2021-2022, 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 . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +add_library(scord_ctl_private_rpcs STATIC) +target_sources(scord_ctl_private_rpcs + PRIVATE private.cpp private.hpp) + +target_include_directories(scord_ctl_private_rpcs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(scord_ctl_private_rpcs PUBLIC common::logger Margo::Margo) +set_property(TARGET scord_ctl_private_rpcs PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/scord/rpcs/private.cpp b/src/scord/rpcs/private.cpp new file mode 100644 index 00000000..d472d44e --- /dev/null +++ b/src/scord/rpcs/private.cpp @@ -0,0 +1,41 @@ +/****************************************************************************** + * Copyright 2021-2022, 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include "private.hpp" + +static void +ADM_ping(hg_handle_t h) { + + hg_return_t ret; + + [[maybe_unused]] margo_instance_id mid = margo_hg_handle_get_instance(h); + + LOGGER_INFO("PING(noargs)"); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_ping); diff --git a/src/scord/rpcs/private.hpp b/src/scord/rpcs/private.hpp new file mode 100644 index 00000000..3af7df82 --- /dev/null +++ b/src/scord/rpcs/private.hpp @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright 2021-2022, 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#ifndef SCORD_RPCS_PRIVATE_HPP +#define SCORD_RPCS_PRIVATE_HPP + +#include + +DECLARE_MARGO_RPC_HANDLER(ADM_ping); + +#endif // SCORD_RPCS_PRIVATE_HPP diff --git a/src/scord.cpp b/src/scord/scord.cpp similarity index 99% rename from src/scord.cpp rename to src/scord/scord.cpp index 3cdc3235..b1430ff9 100644 --- a/src/scord.cpp +++ b/src/scord/scord.cpp @@ -32,8 +32,10 @@ #include #include -#include +#include #include +#include +#include "rpcs/private.hpp" namespace fs = std::filesystem; namespace bpo = boost::program_options; -- GitLab