From 764d1d763dd8cf12d23dc3c2eaa3c6afafdc645f Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 6 May 2022 11:47:19 +0200 Subject: [PATCH 01/76] ADM_input RPC added ADM_output RPC added ADM_inout RPC added ADM_adhoc_context RPC added CMakeLists and engine.hpp fixed ADM_adhoc_context_id added Generic call + specific call collision avoided ADM_inout RPC added Update examples/CMakeLists.txt, src/network/engine.hpp, src/network/rpcs.cpp, src/network/rpcs.hpp files --- examples/ADM_adhoc_context.cpp | 41 ++++++ examples/ADM_adhoc_context_id.cpp | 46 +++++++ examples/ADM_inout.cpp | 39 ++++++ examples/ADM_input.cpp | 40 ++++++ examples/ADM_output.cpp | 39 ++++++ examples/CMakeLists.txt | 12 +- src/network/engine.hpp | 42 ++++-- src/network/rpcs.cpp | 219 ++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 40 ++++++ 9 files changed, 502 insertions(+), 16 deletions(-) create mode 100644 examples/ADM_adhoc_context.cpp create mode 100644 examples/ADM_adhoc_context_id.cpp create mode 100644 examples/ADM_inout.cpp create mode 100644 examples/ADM_input.cpp create mode 100644 examples/ADM_output.cpp diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp new file mode 100644 index 00000000..f4745004 --- /dev/null +++ b/examples/ADM_adhoc_context.cpp @@ -0,0 +1,41 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_context \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_context remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_context_in_t in; + in.context = argv[2]; + ADM_adhoc_context_out_t out; + + endp.call("ADM_adhoc_context", &in, &out); + + fmt::print(stdout, "Outputs {} {}", out.ret, out.adhoc_context); + + if(out.ret < 0 || out.adhoc_context < 0) { + fmt::print( + stdout, + "ADM_adhoc_context remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_context remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_adhoc_context_id.cpp b/examples/ADM_adhoc_context_id.cpp new file mode 100644 index 00000000..4cc255b9 --- /dev/null +++ b/examples/ADM_adhoc_context_id.cpp @@ -0,0 +1,46 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_context_id \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_context_id remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_context_id_in_t in; + + try { + in.context_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_context_id_out_t out; + + endp.call("ADM_adhoc_context_id", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_context_id remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_context_id remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_inout.cpp b/examples/ADM_inout.cpp new file mode 100644 index 00000000..9dbfa118 --- /dev/null +++ b/examples/ADM_inout.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_inout \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_inout remote procedure on {} : {} -> {} ...\n", + argv[1], argv[2], argv[3]); + ADM_inout_in_t in; + in.origin = argv[2]; + in.target = argv[3]; + ADM_inout_out_t out; + + endp.call("ADM_inout", &in, &out); + + if(out.ret < 0) { + fmt::print(stdout, + "ADM_inout remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_inout remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_input.cpp b/examples/ADM_input.cpp new file mode 100644 index 00000000..5be2f5f8 --- /dev/null +++ b/examples/ADM_input.cpp @@ -0,0 +1,40 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_input \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_input remote procedure on {} : {} -> {} ...\n", + argv[1], argv[2], argv[3]); + ADM_input_in_t in; + in.origin = argv[2]; + in.target = argv[3]; + ADM_input_out_t out; + + endp.call("ADM_input", &in, &out); + + + if(out.ret < 0) { + fmt::print(stdout, + "ADM_input remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_input remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_output.cpp b/examples/ADM_output.cpp new file mode 100644 index 00000000..f63a2726 --- /dev/null +++ b/examples/ADM_output.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_output \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_output remote procedure on {} : {} -> {} ...\n", + argv[1], argv[2], argv[3]); + ADM_output_in_t in; + in.origin = argv[2]; + in.target = argv[3]; + ADM_output_out_t out; + + endp.call("ADM_output", &in, &out); + + if(out.ret < 0) { + fmt::print(stdout, + "ADM_output remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_output remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 97ef05ea..b56ee007 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_executable(ping) -target_sources(ping PRIVATE ping.cpp) +set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context) +# list(APPEND examples ADM_adhoc_access ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_walltime) +# list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) + +foreach (example IN LISTS examples) + add_executable(${example}) + target_sources(${example} PRIVATE ${example}.cpp) + target_link_libraries(${example} PUBLIC network_engine fmt::fmt) +endforeach() -target_link_libraries(ping PUBLIC network_engine fmt::fmt) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 54b99dc0..06ae2db5 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -38,17 +38,18 @@ namespace scord::network { namespace detail { -#define REGISTER_RPC(__mid, __m_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) { \ - ::margo_registered_disable_response(__mid, id, HG_TRUE); \ - } \ -} +#define REGISTER_RPC(__mid, __m_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) { \ + ::margo_registered_disable_response(__mid, id, HG_TRUE); \ + } \ + } struct margo_context { @@ -103,7 +104,22 @@ struct engine { register_rpcs() { // register RPCs manually for now - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ping", void, void, ping, false); + REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ping", void, + void, ping, false); + + 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); } @@ -224,7 +240,7 @@ public: ::HG_Error_to_string(ret))); } - if (output != nullptr) { + if(output != nullptr) { ret = ::margo_get_output(handle, output); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 2d393d64..8b1653bb 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -38,3 +38,222 @@ ping(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ping); + +/** + * Specifes the origin location in a storage tier where input is located, as + * well as the target location where it should be placed in a different storage + * tier. + * + * @param in.origin An origin location for the source dataset. + * @param in.target A target location for the destination dataset. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_input(hg_handle_t h) { + hg_return_t ret; + + ADM_input_in_t in; + ADM_input_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_input"); + LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); + + if(in.origin != nullptr && in.target != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_input not null ({},{})", in.origin, + in.target); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_input null ({},{})", in.origin, + in.target); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_input) + +/** + * Specifies the origin location in a storage tier where output is located, as + * well as the target location where it should be placed in a different storage + * tier. + * + * @param in.origin An origin location for the source dataset. + * @param in.target A target location for the destination dataset. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_output(hg_handle_t h) { + hg_return_t ret; + + ADM_output_in_t in; + ADM_output_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_output"); + LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); + + if(in.origin != nullptr && in.target != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_output not null ({},{})", in.origin, + in.target); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_output null ({},{})", in.origin, + in.target); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_output) + +/** + * Specifies both the input and output locations in a storage tier. This + * combines both ADM_input and ADM_output for user convenience: the input data + * provided by origin is overwritten by the output data generated at target. + * + * @param in.origin An origin location for the source dataset. + * @param in.target A target location for the destination dataset. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_inout(hg_handle_t h) { + hg_return_t ret; + + ADM_inout_in_t in; + ADM_inout_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_inout"); + LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); + + if(in.origin != nullptr && in.target != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_inout not null ({},{})", in.origin, + in.target); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_inout null ({},{})", in.origin, + in.target); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_inout) + +/** + * Specifies the execution_mode an Ad hoc Storage System should use. Valid + options: in_job:shared (run while + * sharing the application’s compute nodes), in_job:dedicated (run using a + subset of the application’s + * compute nodes), separate:new (ask the system to allocate a separate job with + separate runtime and + * number of nodes) and separate:existing (ask the system to reuse an already + running Ad hoc Storage System instance). + * The number of nodes assigned for the Ad hoc Storage System must be specified + with ADM_adhoc_nodes. + * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System + will be controlled with + * ADM_adhoc_walltime. In the separate:existing execution_mode, a valid context + ID must be provided with + * ADM_adhoc_context_id + * + * @param in.context A valid execution_mode describing how the Ad hoc Storage + System should behave. + * @return out.ret Returns if the remote procedure has been completed + successfully or not. + * @return out.adhoc_context_id A number that identifies the context. + + */ +static void +ADM_adhoc_context(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_context_in_t in; + ADM_adhoc_context_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_context"); + LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); + + if(in.context != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_context not null ({})", + in.context); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context null or invalid ({}). Please use", + in.context); + } + + if((strcmp(in.context, "in_job:shared")) == 0 || + (strcmp(in.context, "in_job:dedicated")) == 0 || + (strcmp(in.context, "separate:new")) == 0 || + (strcmp(in.context, "separate:existing")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context value is acceptable ({})", + in.context); + out.adhoc_context = rand(); + } else { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", + in.context); + out.adhoc_context = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index df1302a2..d1a2e54c 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -27,6 +27,10 @@ #include #include +#include +#include +#include + // FIXME: cannot be in a namespace due to Margo limitations // namespace scord::network::rpc { @@ -34,6 +38,42 @@ /// ping DECLARE_MARGO_RPC_HANDLER(ping); +/// ADM_input +MERCURY_GEN_PROC(ADM_input_in_t, + ((hg_const_string_t) (origin))((hg_const_string_t) (target))) + +MERCURY_GEN_PROC(ADM_input_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_input); + +/// ADM_output + +MERCURY_GEN_PROC(ADM_output_in_t, + ((hg_const_string_t) (origin))((hg_const_string_t) (target))) + +MERCURY_GEN_PROC(ADM_output_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_output); + +/// ADM_inout + +MERCURY_GEN_PROC(ADM_inout_in_t, + ((hg_const_string_t) (origin))((hg_const_string_t) (target))) + +MERCURY_GEN_PROC(ADM_inout_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_inout); + +/// ADM_adhoc_context + +MERCURY_GEN_PROC(ADM_adhoc_context_in_t, ((hg_const_string_t) (context))) + +MERCURY_GEN_PROC(ADM_adhoc_context_out_t, + ((int32_t) (ret))((int32_t) (adhoc_context))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context); + + //} // namespace scord::network::rpc #endif // SCORD_NETWORK_RPCS_HPP -- GitLab From d60e98c810b52eee54aa92a7f744a7a5ed4f66b3 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 09:57:38 +0200 Subject: [PATCH 02/76] ADM_adhoc_context_id tested successfully --- examples/ADM_adhoc_context.cpp | 2 -- examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 46 ++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++++ 5 files changed, 60 insertions(+), 3 deletions(-) diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp index f4745004..48bef96b 100644 --- a/examples/ADM_adhoc_context.cpp +++ b/examples/ADM_adhoc_context.cpp @@ -27,8 +27,6 @@ main(int argc, char* argv[]) { endp.call("ADM_adhoc_context", &in, &out); - fmt::print(stdout, "Outputs {} {}", out.ret, out.adhoc_context); - if(out.ret < 0 || out.adhoc_context < 0) { fmt::print( stdout, diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b56ee007..ba96915a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context) +set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) # list(APPEND examples ADM_adhoc_access ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_walltime) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 06ae2db5..288aff6f 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -120,6 +120,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8b1653bb..1ccf65bc 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -257,3 +257,49 @@ ADM_adhoc_context(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context) +/** + * Specifies an existing Ad hoc Storage System to use via its ID. + * + * @param in.context_id A valid context_id for a separate instance of an Ad hoc + * Storage System. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_context_id(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_context_id_in_t in; + ADM_adhoc_context_id_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_context_id"); + LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); + + if(in.context_id >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_context_id not null ({})", + in.context_id); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context_id null or invalid ({}). Please use", + in.context_id); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context_id) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index d1a2e54c..a6abf8bc 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -73,6 +73,15 @@ MERCURY_GEN_PROC(ADM_adhoc_context_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context); +/// ADM_adhoc_context_id + +MERCURY_GEN_PROC(ADM_adhoc_context_id_in_t, ((int32_t) (context_id))) + +MERCURY_GEN_PROC(ADM_adhoc_context_id_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context_id); + + //} // namespace scord::network::rpc -- GitLab From 5f6be47d79fc648c3dd1d67cd8b692012c333c57 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:06:52 +0200 Subject: [PATCH 03/76] ADM_adhoc_nodes implemented and tested successfully --- examples/ADM_adhoc_nodes.cpp | 45 ++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 14 ++++++---- src/network/rpcs.cpp | 53 ++++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 8 ++++++ 5 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 examples/ADM_adhoc_nodes.cpp diff --git a/examples/ADM_adhoc_nodes.cpp b/examples/ADM_adhoc_nodes.cpp new file mode 100644 index 00000000..220f2972 --- /dev/null +++ b/examples/ADM_adhoc_nodes.cpp @@ -0,0 +1,45 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_nodes \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_nodes remote procedure on {} -> node numbers: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_nodes_in_t in; + + try { + in.nodes = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_nodes_out_t out; + + endp.call("ADM_adhoc_nodes", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_nodes remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_adhoc_nodes remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ba96915a..d5e1408d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -# list(APPEND examples ADM_adhoc_access ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_walltime) +list(APPEND examples ADM_adhoc_nodes) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 288aff6f..c8b9095f 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -120,11 +120,14 @@ struct engine { 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); } void @@ -211,12 +214,11 @@ public: } /** - * Deprecated call, used to support Margo directly - * - **/ + * Deprecated call, used to support Margo directly + * + **/ template - [[deprecated("It should be eventually replaced by a generic call")]] - void + [[deprecated("It should be eventually replaced by a generic call")]] void call(const std::string& id, T1 input = nullptr, T2 output = nullptr) { const auto it = m_margo_context->m_rpc_names.find(id); diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 1ccf65bc..16ce8994 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -303,3 +303,56 @@ ADM_adhoc_context_id(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context_id) +/** + * Specifies the number of nodes for the Ad hoc Storage System. If the + * ADM_adhoc_execution_mode is shared, the number cannot exceed the number of + * allocated nodes within the compute job. If the ADM_adhoc_execution_mode is + * dedicated, the number of nodes is not restricted. + * + * @param in.number_of_nodes The desired number_of_nodes. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_nodes(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_nodes_in_t in; + ADM_adhoc_nodes_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_nodes"); + LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); + + if(in.nodes > 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_nodes not null ({})", + in.nodes); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_adhoc_nodes null ({})", in.nodes); + } + + /*Specifies the number of nodes for the Ad hoc Storage System. If the + ADM_adhoc_execution_mode is shared, the number cannot exceed the number of + allocated nodes within the compute job. If the ADM_adhoc_execution_mode is + dedicated, the number of nodes is not restricted. Should this be checked + now? */ + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index a6abf8bc..49274cc7 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -81,6 +81,14 @@ MERCURY_GEN_PROC(ADM_adhoc_context_id_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context_id); +/// ADM_adhoc_nodes + +MERCURY_GEN_PROC(ADM_adhoc_nodes_in_t, ((int32_t) (nodes))) + +MERCURY_GEN_PROC(ADM_adhoc_nodes_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) + //} // namespace scord::network::rpc -- GitLab From 6a9ce6af8ec9699fee503be24638ac09443d4a18 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:14:44 +0200 Subject: [PATCH 04/76] ADM_adhoc_walltime implemented and tested successfully --- examples/ADM_adhoc_walltime.cpp | 46 +++++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 46 +++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 7 +++++ 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_walltime.cpp diff --git a/examples/ADM_adhoc_walltime.cpp b/examples/ADM_adhoc_walltime.cpp new file mode 100644 index 00000000..28df9b48 --- /dev/null +++ b/examples/ADM_adhoc_walltime.cpp @@ -0,0 +1,46 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_walltime \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_walltime remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_walltime_in_t in; + + try { + in.walltime = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_walltime_out_t out; + + endp.call("ADM_adhoc_walltime", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_walltime remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_walltime remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d5e1408d..44b513f5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes) +list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index c8b9095f..0dffbc59 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -128,6 +128,10 @@ struct engine { 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); } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 16ce8994..8af1a0f1 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -355,4 +355,50 @@ ADM_adhoc_nodes(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) +/** + * Specifies for how long the ad hoc storage system should run before should + * down. Only relevant in the context of the ADM_adhoc_context function. + * + * @param in.walltime The desired walltime in minutes. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_walltime(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_walltime_in_t in; + ADM_adhoc_walltime_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_walltime"); + LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); + + if(in.walltime >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_walltime not null ({})", + in.walltime); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_walltime null or invalid ({}). Please use", + in.walltime); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_walltime) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 49274cc7..f466ee23 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -89,6 +89,13 @@ MERCURY_GEN_PROC(ADM_adhoc_nodes_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) +/// ADM_adhoc_walltime + +MERCURY_GEN_PROC(ADM_adhoc_walltime_in_t, ((int32_t) (walltime))) + +MERCURY_GEN_PROC(ADM_adhoc_walltime_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_walltime); //} // namespace scord::network::rpc -- GitLab From 8bfae76cbda492bf6a2007fa83de1b0b506be059 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:25:23 +0200 Subject: [PATCH 05/76] ADM_adhoc_access implemented and tested successfully --- examples/ADM_adhoc_access.cpp | 40 ++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 ++++ src/network/rpcs.cpp | 62 +++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_access.cpp diff --git a/examples/ADM_adhoc_access.cpp b/examples/ADM_adhoc_access.cpp new file mode 100644 index 00000000..df18e95d --- /dev/null +++ b/examples/ADM_adhoc_access.cpp @@ -0,0 +1,40 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_access \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_access remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_access_in_t in; + in.access = argv[2]; + ADM_adhoc_access_out_t out; + + endp.call("ADM_adhoc_access", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_access remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_access remote procedure completed successfully\n"); + } +} + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 44b513f5..bf3b1b2f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime) +list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 0dffbc59..5742a982 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -132,6 +132,12 @@ struct engine { 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); + + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8af1a0f1..65e842af 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -401,4 +401,66 @@ ADM_adhoc_walltime(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_walltime) +/** + * Specifies access to the ad hoc storage system: write-only, read-only, + * read-write. Cannot be used when using an existing Ad hoc Storage System + * instance. + * + * @param in.access The desired access method + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_access(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_access_in_t in; + ADM_adhoc_access_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_access"); + LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); + + if(in.access != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_access not null ({})", + in.access); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access null or invalid ({}). Please use", + in.access); + } + + if((strcmp(in.access, "write-only")) == 0 || + (strcmp(in.access, "read-only")) == 0 || + (strcmp(in.access, "read-write") == 0)) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access value is acceptable ({})", + in.access); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", + in.access); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_access) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index f466ee23..f2cb5405 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -98,6 +98,15 @@ MERCURY_GEN_PROC(ADM_adhoc_walltime_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_walltime); +/// ADM_adhoc_access + +MERCURY_GEN_PROC(ADM_adhoc_access_in_t, ((hg_const_string_t) (access))) + +MERCURY_GEN_PROC(ADM_adhoc_access_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_access); + + //} // namespace scord::network::rpc #endif // SCORD_NETWORK_RPCS_HPP -- GitLab From 7ecec39ef62cc734b94ad980a84b792ed2416bff Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:45:20 +0200 Subject: [PATCH 06/76] ADM_adhoc_distribution implemented and tested successfully --- examples/ADM_adhoc_distribution.cpp | 40 ++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 48 +++++++++++++++++++++++++++++ src/network/rpcs.hpp | 10 ++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_distribution.cpp diff --git a/examples/ADM_adhoc_distribution.cpp b/examples/ADM_adhoc_distribution.cpp new file mode 100644 index 00000000..aacb4911 --- /dev/null +++ b/examples/ADM_adhoc_distribution.cpp @@ -0,0 +1,40 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_adhoc_distribution \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_distribution remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_distribution_in_t in; + in.data_distribution = argv[2]; + ADM_adhoc_distribution_out_t out; + + endp.call("ADM_adhoc_distribution", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_distribution remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_distribution remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bf3b1b2f..23d0480c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access) +list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 5742a982..2fa1ce54 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -137,6 +137,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 65e842af..0d1625ef 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -463,4 +463,52 @@ ADM_adhoc_access(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_access) +/** + * Specifies the data distribution within the ad hoc storage system, e.g., + * wide-striping, local, local-data-global-metadata. + * + * @param in.data_distribution The desired data distribution + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_distribution(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_distribution_in_t in; + ADM_adhoc_distribution_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_distribution"); + LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", + in.data_distribution); + + if(in.data_distribution != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_distribution not null ({})", + in.data_distribution); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_distribution null or invalid ({}). Please use", + in.data_distribution); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_distribution) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index f2cb5405..cff5077d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -106,6 +106,16 @@ MERCURY_GEN_PROC(ADM_adhoc_access_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_access); +/// ADM_adhoc_distribution + +MERCURY_GEN_PROC(ADM_adhoc_distribution_in_t, + ((hg_const_string_t) (data_distribution))) + +MERCURY_GEN_PROC(ADM_adhoc_distribution_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_distribution); + + //} // namespace scord::network::rpc -- GitLab From 7e22d865a35746f6a0d1a8352eddf0461f6567a2 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:59:41 +0200 Subject: [PATCH 07/76] ADM_adhoc_background_flush implemented and tested successfully --- examples/ADM_adhoc_background_flush.cpp | 57 +++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 47 ++++++++++++++++++++ src/network/rpcs.hpp | 8 ++++ 5 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_background_flush.cpp diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp new file mode 100644 index 00000000..b7774a06 --- /dev/null +++ b/examples/ADM_adhoc_background_flush.cpp @@ -0,0 +1,57 @@ +#include +#include + +int +String2Convert(std::string var) { + if(var == "true" || var == "TRUE") { + return 0; + } else if(var == "false" || var == "FALSE") { + return 1; + } else { + return -1; + } +} + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_adhoc_background_flush \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_background_flush_in_t in; + + try { + in.b_flush = String2Convert(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_background_flush_out_t out; + + endp.call("ADM_adhoc_background_flush", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_background_flush remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_background_flush remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 23d0480c..9963078a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -# list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) +list(APPEND examples ADM_adhoc_background_flush) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 2fa1ce54..a222ae9b 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -140,6 +140,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 0d1625ef..b4e82032 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -510,5 +510,52 @@ ADM_adhoc_distribution(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_distribution) +/** + * Specifies if data in the output location should be moved to the shared + * backend storage system in the background (default false). + * + * @param in.b_flush A boolean enabling or disabling the option. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_background_flush(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_background_flush_in_t in; + ADM_adhoc_background_flush_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_background_flush"); + LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); + + if(in.b_flush == 0 || in.b_flush == 1) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_background_flush not null ({})", + in.b_flush); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush null ({})", + in.b_flush); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index cff5077d..573722dc 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -115,6 +115,14 @@ MERCURY_GEN_PROC(ADM_adhoc_distribution_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_distribution); +/// ADM_adhoc_background_flush + +MERCURY_GEN_PROC(ADM_adhoc_background_flush_in_t, ((hg_bool_t) (b_flush))) + +MERCURY_GEN_PROC(ADM_adhoc_background_flush_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush); + //} // namespace scord::network::rpc -- GitLab From 45f66083262891e3cc0117e003b6410780bfbedc Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 11:07:10 +0200 Subject: [PATCH 08/76] ADM_in_situ_ops implemented and tested successfully --- examples/ADM_in_situ_ops.cpp | 38 +++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 +++++ src/network/rpcs.cpp | 44 ++++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 7 ++++++ 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_in_situ_ops.cpp diff --git a/examples/ADM_in_situ_ops.cpp b/examples/ADM_in_situ_ops.cpp new file mode 100644 index 00000000..f258a48e --- /dev/null +++ b/examples/ADM_in_situ_ops.cpp @@ -0,0 +1,38 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_in_situ_ops \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_in_situ_ops remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_in_situ_ops_in_t in; + in.in_situ = argv[2]; + ADM_in_situ_ops_out_t out; + + endp.call("ADM_in_situ_ops", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_in_situ_ops remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_in_situ_ops remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9963078a..71ab6c5f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush) +list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index a222ae9b..61d20ed4 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -144,6 +144,12 @@ struct engine { 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); + + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index b4e82032..671d26c3 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -556,6 +556,50 @@ ADM_adhoc_background_flush(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush) +/** + * In situ data operations specified in a given configuration file. + * + * @param in.in_situ A path to the configuration file. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_in_situ_ops(hg_handle_t h) { + hg_return_t ret; + + ADM_in_situ_ops_in_t in; + ADM_in_situ_ops_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_in_situ_ops"); + LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); + + if(in.in_situ != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_in_situ_ops not null ({})", + in.in_situ); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_in_situ_ops null or invalid ({}). Please use", + in.in_situ); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_in_situ_ops) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 573722dc..208d79ab 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -123,6 +123,13 @@ MERCURY_GEN_PROC(ADM_adhoc_background_flush_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush); +/// ADM_in_situ_ops + +MERCURY_GEN_PROC(ADM_in_situ_ops_in_t, ((hg_const_string_t) (in_situ))) + +MERCURY_GEN_PROC(ADM_in_situ_ops_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_in_situ_ops); //} // namespace scord::network::rpc -- GitLab From 143b61c04977f68b0c21fa9dcebc232157f504b0 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 11:14:55 +0200 Subject: [PATCH 09/76] ADM_in_transit_ops implemented and tested successfully --- examples/ADM_in_transit_ops.cpp | 39 ++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++- src/network/rpcs.cpp | 45 +++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++++ 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 examples/ADM_in_transit_ops.cpp diff --git a/examples/ADM_in_transit_ops.cpp b/examples/ADM_in_transit_ops.cpp new file mode 100644 index 00000000..06bd3ec2 --- /dev/null +++ b/examples/ADM_in_transit_ops.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_in_transit_ops \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_in_transit_ops remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_in_transit_ops_in_t in; + in.in_transit = argv[2]; + ADM_in_transit_ops_out_t out; + + endp.call("ADM_in_transit_ops", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_in_transit_ops remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_in_transit_ops remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71ab6c5f..56ddaf99 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops) +list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 61d20ed4..e86ce717 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -149,7 +149,9 @@ struct engine { "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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 671d26c3..51755d5d 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -601,5 +601,50 @@ ADM_in_situ_ops(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_in_situ_ops) +/** + * In transit data operations specified in a given configuration file. + * + * @param in.in_transit A path to the configuration file. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_in_transit_ops(hg_handle_t h) { + hg_return_t ret; + + ADM_in_transit_ops_in_t in; + ADM_in_transit_ops_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_in_transit_ops"); + LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); + + if(in.in_transit != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_in_transit_ops not null ({})", + in.in_transit); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_in_transit_ops null or invalid ({}). Please use", + in.in_transit); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_in_transit_ops) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 208d79ab..249a0007 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -131,6 +131,15 @@ MERCURY_GEN_PROC(ADM_in_situ_ops_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_in_situ_ops); +/// ADM_in_transit_ops + +MERCURY_GEN_PROC(ADM_in_transit_ops_in_t, ((hg_const_string_t) (in_transit))) + +MERCURY_GEN_PROC(ADM_in_transit_ops_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_in_transit_ops); + + //} // namespace scord::network::rpc -- GitLab From b8223e78b55f71bf9bdaf7433a91036e3253ae97 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 11:51:45 +0200 Subject: [PATCH 10/76] ADM_transfer_dataset implemented and tested successfully --- examples/ADM_transfer_dataset.cpp | 53 +++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 70 +++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 13 ++++++ 5 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_transfer_dataset.cpp diff --git a/examples/ADM_transfer_dataset.cpp b/examples/ADM_transfer_dataset.cpp new file mode 100644 index 00000000..0a2064bd --- /dev/null +++ b/examples/ADM_transfer_dataset.cpp @@ -0,0 +1,53 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 7) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_transfer_dataset " + " \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_transfer_dataset remote procedure on {} : {} -> {} using " + " qos constraints {}, distribution {} and job id {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); + ADM_transfer_dataset_in_t in; + in.source = argv[2]; + in.destination = argv[3]; + in.qos_constraints = argv[4]; + in.distribution = argv[5]; + try { + in.job_id = std::stoi(argv[6]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_transfer_dataset_out_t out; + + endp.call("ADM_transfer_dataset", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_transfer_dataset remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_transfer_dataset remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 56ddaf99..39a927cb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops) +list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index e86ce717..a44e62ec 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -153,6 +153,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 51755d5d..afc2672e 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -647,4 +647,74 @@ ADM_in_transit_ops(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_in_transit_ops) +/** + * Transfers the dataset identified by the source_name to the storage tier + * defined by destination_name, and apply the provided constraints during the + * transfer. This function returns a handle that can be used to track the + * operation (i.e., get statistics, or status). + * + * @param in.source A source_location identifying the source dataset/s in the + * source storage tier. + * @param in.destination A destination_location identifying the destination + * dataset/s in its desired location in a storage tier. + * @param in.qos_constraints A list of qos_constraints that must be applied to + * the transfer. These may not exceed the global ones set at node, application, + * or resource level (see Section 3.4). + * @param in.distribution A distribution strategy for data (e.g. one-to-one, + * one-to-many, many-to-many) + * @param in.job_id A job_id identifying the originating job. + * @param out.transfer_handle A transfer_handle allowing clients to interact + * with the transfer (e.g. wait for its completion, query its status, cancel it, + * etc. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_transfer_dataset(hg_handle_t h) { + hg_return_t ret; + + ADM_transfer_dataset_in_t in; + ADM_transfer_dataset_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_transfer_dataset"); + LOGGER_INFO("remote_procedure::ADM_transfer_dataset({},{},{},{},{})", + in.source, in.destination, in.qos_constraints, in.distribution, + in.job_id); + + if(in.source != nullptr && in.destination != nullptr && + in.qos_constraints != nullptr && in.distribution != nullptr && + in.job_id >= 0) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset not null ({},{},{},{},{})", + in.source, in.destination, in.qos_constraints, in.distribution, + in.job_id); + out.transfer_handle = "ok"; + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset null ({},{},{},{},{})", + in.source, in.destination, in.qos_constraints, in.distribution, + in.job_id); + out.transfer_handle = "fail"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_transfer_dataset) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 249a0007..14052a54 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -140,6 +140,19 @@ MERCURY_GEN_PROC(ADM_in_transit_ops_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_in_transit_ops); +/// ADM_transfer_dataset + +MERCURY_GEN_PROC( + ADM_transfer_dataset_in_t, + ((hg_const_string_t) (source))((hg_const_string_t) (destination))( + (hg_const_string_t) (qos_constraints))( + (hg_const_string_t) (distribution))((int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_transfer_dataset_out_t, + ((int32_t) (ret))((hg_const_string_t) (transfer_handle))) + +DECLARE_MARGO_RPC_HANDLER(ADM_transfer_dataset); + //} // namespace scord::network::rpc -- GitLab From b3f5f58b9db9465d5e8b81f57dad4fa3d7b0a20d Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:00:59 +0200 Subject: [PATCH 11/76] ADM_set_dataset_information implemented and tested successfully --- examples/ADM_set_dataset_information.cpp | 55 ++++++++++++++++++++++++ examples/CMakeLists.txt | 1 + src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 53 +++++++++++++++++++++++ src/network/rpcs.hpp | 12 ++++++ 5 files changed, 125 insertions(+) create mode 100644 examples/ADM_set_dataset_information.cpp diff --git a/examples/ADM_set_dataset_information.cpp b/examples/ADM_set_dataset_information.cpp new file mode 100644 index 00000000..b621f076 --- /dev/null +++ b/examples/ADM_set_dataset_information.cpp @@ -0,0 +1,55 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 5) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_dataset_information \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_dataset_information remote procedure on {} with resource id {}, info {} and" + " job id {} ...\n", + argv[1], argv[2], argv[3], argv[4]); + ADM_set_dataset_information_in_t in; + try { + in.resource_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.info = argv[3]; + try { + in.job_id = std::stoi(argv[4]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_set_dataset_information_out_t out; + + endp.call("ADM_set_dataset_information", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_dataset_information remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_dataset_information remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 39a927cb..6a7abebd 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,6 +25,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) +list(APPEND examples ADM_set_dataset_information) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index a44e62ec..58b568a7 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -157,6 +157,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index afc2672e..66ebbcde 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -716,5 +716,58 @@ ADM_transfer_dataset(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_transfer_dataset) +/** + * Sets information for the dataset identified by resource_id. + * + * @param in.resource_id A resource_id identifying the dataset of interest. + * @param in.info An opaque inf o argument containing information about the + * dataset (e.g. its lifespan, access methods, intended usage, etc.). + * @param in.job_id A job_id identifying the originating job. + * @param out.status A status code determining whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_dataset_information(hg_handle_t h) { + hg_return_t ret; + + ADM_set_dataset_information_in_t in; + ADM_set_dataset_information_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_dataset_information"); + LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", + in.resource_id, in.info, in.job_id); + + if(in.resource_id >= 0 && in.info != nullptr && in.job_id >= 0) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset not null ({},{},{})", + in.resource_id, in.info, in.job_id); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", + in.resource_id, in.info, in.job_id); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_dataset_information) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 14052a54..4b96b7ea 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -153,6 +153,18 @@ MERCURY_GEN_PROC(ADM_transfer_dataset_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_transfer_dataset); +/// ADM_set_dataset_information + +MERCURY_GEN_PROC(ADM_set_dataset_information_in_t, + ((int32_t) (resource_id))((hg_const_string_t) (info))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_set_dataset_information_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_dataset_information); + + //} // namespace scord::network::rpc -- GitLab From c5e7d1516d486d8fcd6556aa6b95ab15cc439288 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:12:43 +0200 Subject: [PATCH 12/76] ADM_set_io_resources implemented and tested successfully --- examples/ADM_set_io_resources.cpp | 54 +++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 54 +++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 11 +++++++ 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_set_io_resources.cpp diff --git a/examples/ADM_set_io_resources.cpp b/examples/ADM_set_io_resources.cpp new file mode 100644 index 00000000..6b8bb7bd --- /dev/null +++ b/examples/ADM_set_io_resources.cpp @@ -0,0 +1,54 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 5) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_io_resources \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_io_resources remote procedure on {} with tier id {}, resources {} and" + " job id {} ...\n", + argv[1], argv[2], argv[3], argv[4]); + ADM_set_io_resources_in_t in; + try { + in.tier_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.resources = argv[3]; + try { + in.job_id = std::stoi(argv[4]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_set_io_resources_out_t out; + + endp.call("ADM_set_io_resources", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_io_resources remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_io_resources remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6a7abebd..f1d1ecef 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,7 +25,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) -list(APPEND examples ADM_set_dataset_information) +list(APPEND examples ADM_set_dataset_information ADM_set_io_resources) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 58b568a7..995373cb 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -161,6 +161,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 66ebbcde..7897d4ef 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -769,5 +769,59 @@ ADM_set_dataset_information(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_dataset_information) +/** + * Changes the I/O resources used by a storage tier, typically an Ad hoc Storage + * System. + * + * @param in.tier_id A tier_id specifying the target storage tier. + * @param in.resources An opaque resources argument containing information about + * the I/O resources to modify (e.g. number of I/O nodes.). + * @param in.job_id A job_id identifying the originating job. + * @param out.status A status code determining whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_io_resources(hg_handle_t h) { + hg_return_t ret; + + ADM_set_io_resources_in_t in; + ADM_set_io_resources_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_io_resources"); + LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, + in.resources, in.job_id); + + if(in.tier_id >= 0 && in.resources != nullptr && in.job_id >= 0) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset not null ({},{},{})", + in.tier_id, in.resources, in.job_id); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", + in.tier_id, in.resources, in.job_id); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_io_resources) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 4b96b7ea..7a26c3cd 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -164,6 +164,17 @@ MERCURY_GEN_PROC(ADM_set_dataset_information_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_dataset_information); +/// ADM_set_io_resources + +MERCURY_GEN_PROC(ADM_set_io_resources_in_t, + ((int32_t) (tier_id))((hg_const_string_t) (resources))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_set_io_resources_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_io_resources); + //} // namespace scord::network::rpc -- GitLab From 74a22776f46c65cc0471a5266c8be0c11edecdac Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:27:49 +0200 Subject: [PATCH 13/76] ADM_get_transfer_priority implemented and tested successfully --- examples/ADM_get_transfer_priority.cpp | 46 ++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 3 ++ src/network/rpcs.cpp | 48 ++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_get_transfer_priority.cpp diff --git a/examples/ADM_get_transfer_priority.cpp b/examples/ADM_get_transfer_priority.cpp new file mode 100644 index 00000000..8edf6ba8 --- /dev/null +++ b/examples/ADM_get_transfer_priority.cpp @@ -0,0 +1,46 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_get_transfer_priority \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_get_transfer_priority remote procedure on {} with transfer id {} ...\n", + argv[1], argv[2]); + ADM_get_transfer_priority_in_t in; + try { + in.transfer_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_get_transfer_priority_out_t out; + + endp.call("ADM_get_transfer_priority", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_get_transfer_priority remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_get_transfer_priority remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f1d1ecef..cfe0dda4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,7 +25,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) -list(APPEND examples ADM_set_dataset_information ADM_set_io_resources) +list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 995373cb..bc5c139e 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -165,6 +165,9 @@ struct engine { "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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 7897d4ef..86221574 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -824,4 +824,52 @@ ADM_set_io_resources(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_io_resources) +/** + * Returns the priority of the pending transfer identified by transfer_id. + * + * @param in.transfer_id A tier_id specifying the target storage tier. + * @param out.priority The priority of the pending transfer or an error code if + * it didn’t exist or is no longer pending. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_get_transfer_priority(hg_handle_t h) { + hg_return_t ret; + + ADM_get_transfer_priority_in_t in; + ADM_get_transfer_priority_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_get_transfer_priority"); + LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", + in.transfer_id); + + if(in.transfer_id >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_get_transfer_priority not null ({})", + in.transfer_id); + out.priority = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_get_transfer_priority null ({})", + in.transfer_id); + out.priority = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_get_transfer_priority) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 7a26c3cd..baeef29d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -175,6 +175,15 @@ MERCURY_GEN_PROC(ADM_set_io_resources_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_io_resources); +/// ADM_get_transfer_priority + +MERCURY_GEN_PROC(ADM_get_transfer_priority_in_t, ((int32_t) (transfer_id))) + +MERCURY_GEN_PROC(ADM_get_transfer_priority_out_t, + ((int32_t) (ret))((int32_t) (priority))) + +DECLARE_MARGO_RPC_HANDLER(ADM_get_transfer_priority); + //} // namespace scord::network::rpc -- GitLab From 0144f91bdf2fa6c74c7e97db01b78413aa13a6b0 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:34:24 +0200 Subject: [PATCH 14/76] ADM_set_transfer_priority implemented and tested successfully --- examples/ADM_set_transfer_priority.cpp | 52 +++++++++++++++++++++++++ examples/CMakeLists.txt | 1 + src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 53 ++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++ 5 files changed, 119 insertions(+) create mode 100644 examples/ADM_set_transfer_priority.cpp diff --git a/examples/ADM_set_transfer_priority.cpp b/examples/ADM_set_transfer_priority.cpp new file mode 100644 index 00000000..2dbfffcc --- /dev/null +++ b/examples/ADM_set_transfer_priority.cpp @@ -0,0 +1,52 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_transfer_priority \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_transfer_priority remote procedure on {} with transfer id {} and number of positions {}...\n", + argv[1], argv[2], argv[3]); + ADM_set_transfer_priority_in_t in; + try { + in.transfer_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.n_positions = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_set_transfer_priority_out_t out; + + endp.call("ADM_set_transfer_priority", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_transfer_priority remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_transfer_priority remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cfe0dda4..5b68ecb3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,6 +26,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_con list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) +list(APPEND examples ADM_set_transfer_priority) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index bc5c139e..b69f8581 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -168,6 +168,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 86221574..7770cdd5 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -873,3 +873,56 @@ ADM_get_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_get_transfer_priority) +/** + * Moves the operation identified by transf er_id up or down by n positions in + * its scheduling queue. + * + * @param in.transfer_id A transf er_id identifying a pending transfer. + * @param in.n_positions A positive or negative number n for the number of + * positions the transfer should go up or down in its scheduling queue. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_transfer_priority(hg_handle_t h) { + hg_return_t ret; + + ADM_set_transfer_priority_in_t in; + ADM_set_transfer_priority_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_transfer_priority"); + LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", + in.transfer_id, in.n_positions); + + if(in.transfer_id >= 0 && (in.n_positions >= 0 || in.n_positions < 0)) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_set_transfer_priority not null ({}, {})", + in.transfer_id, in.n_positions); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_set_transfer_priority null ({}, {})", + in.transfer_id, in.n_positions); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_transfer_priority) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index baeef29d..08f1d6d7 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -184,6 +184,15 @@ MERCURY_GEN_PROC(ADM_get_transfer_priority_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_get_transfer_priority); +/// ADM_set_transfer_priority + +MERCURY_GEN_PROC(ADM_set_transfer_priority_in_t, + ((int32_t) (transfer_id))((int32_t) (n_positions))) + +MERCURY_GEN_PROC(ADM_set_transfer_priority_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_transfer_priority); //} // namespace scord::network::rpc -- GitLab From 9ebe9a618cec3c8a9ff4ff5fec6be7a7f941d557 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:46:26 +0200 Subject: [PATCH 15/76] ADM_cancel_transfer implemented and tested successfully --- examples/ADM_cancel_transfer.cpp | 45 ++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 +++- src/network/rpcs.cpp | 51 ++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 10 +++++++ 5 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 examples/ADM_cancel_transfer.cpp diff --git a/examples/ADM_cancel_transfer.cpp b/examples/ADM_cancel_transfer.cpp new file mode 100644 index 00000000..52dfd5d2 --- /dev/null +++ b/examples/ADM_cancel_transfer.cpp @@ -0,0 +1,45 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_cancel_transfer \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_cancel_transfer remote procedure on {} with transfer id {} ...\n", + argv[1], argv[2]); + ADM_cancel_transfer_in_t in; + try { + in.transfer_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_cancel_transfer_out_t out; + + endp.call("ADM_cancel_transfer", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_cancel_transfer remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_cancel_transfer remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5b68ecb3..432aa04a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,7 +26,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_con list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) -list(APPEND examples ADM_set_transfer_priority) +list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index b69f8581..781b8778 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -172,7 +172,11 @@ struct engine { 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); + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 7770cdd5..cc85a8e1 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -926,3 +926,54 @@ ADM_set_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_transfer_priority) +/** + * Moves the operation identified by transf er_id up or down by n positions in + * its scheduling queue. + * + * @param in.transfer_id A transf er_id identifying a pending transfer. + * @param in.n_positions A positive or negative number n for the number of + * positions the transfer should go up or down in its scheduling queue. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_cancel_transfer(hg_handle_t h) { + hg_return_t ret; + + ADM_cancel_transfer_in_t in; + ADM_cancel_transfer_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_cancel_transfer"); + LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); + + if(in.transfer_id >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_cancel_transfer not null ({})", + in.transfer_id); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_cancel_transfer null ({})", + in.transfer_id); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_cancel_transfer) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 08f1d6d7..79ba01e4 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -194,6 +194,16 @@ MERCURY_GEN_PROC(ADM_set_transfer_priority_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_transfer_priority); +/// ADM_cancel_transfer + +MERCURY_GEN_PROC(ADM_cancel_transfer_in_t, ((int32_t) (transfer_id))) + +MERCURY_GEN_PROC(ADM_cancel_transfer_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_cancel_transfer); + + //} // namespace scord::network::rpc -- GitLab From da66e54505e1722f9fc6d0beb0e01859f3797041 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:58:41 +0200 Subject: [PATCH 16/76] ADM_get_pending_transfers implemented and tested successfully --- examples/ADM_get_pending_transfers.cpp | 38 +++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 39 ++++++++++++++++++++++++++ src/network/rpcs.hpp | 8 ++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_get_pending_transfers.cpp diff --git a/examples/ADM_get_pending_transfers.cpp b/examples/ADM_get_pending_transfers.cpp new file mode 100644 index 00000000..479e2efb --- /dev/null +++ b/examples/ADM_get_pending_transfers.cpp @@ -0,0 +1,38 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 2) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "Usage: ADM_get_pending_transfers \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_get_pending_transfers remote procedure on {} ...\n", + argv[1]); + ADM_get_pending_transfers_in_t in; + in.value = NULL; + ADM_get_pending_transfers_out_t out; + + endp.call("ADM_get_pending_transfers", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_get_pending_transfers remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_get_pending_transfers remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 432aa04a..633e23e1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,7 +26,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_con list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) -list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer) +list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 781b8778..b936b999 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -177,6 +177,10 @@ struct engine { "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); + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index cc85a8e1..1ee0009c 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -977,3 +977,42 @@ ADM_cancel_transfer(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_cancel_transfer) +/** + * Returns a list of pending transfers. Each operation will include a transf + * er_id as well as information about the involved resources and tiers. + * + * @param out.pending_transfers A list of pending_transfers. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_get_pending_transfers(hg_handle_t h) { + hg_return_t ret; + + ADM_get_pending_transfers_in_t in; + ADM_get_pending_transfers_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_get_pending_transfers"); + LOGGER_INFO("remote_procedure::ADM_get_pending_transfers"); + + out.ret = 0; + out.pending_transfers = "list"; + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_get_pending_transfers) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 79ba01e4..7763f80a 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -203,6 +203,14 @@ MERCURY_GEN_PROC(ADM_cancel_transfer_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_cancel_transfer); +/// ADM_get_pending_transfers + +MERCURY_GEN_PROC(ADM_get_pending_transfers_in_t, ((hg_const_string_t) (value))) + +MERCURY_GEN_PROC(ADM_get_pending_transfers_out_t, + ((int32_t) (ret))((hg_const_string_t) (pending_transfers))) + +DECLARE_MARGO_RPC_HANDLER(ADM_get_pending_transfers); //} // namespace scord::network::rpc -- GitLab From 5f9c2f02ceafbb3218c779108e8c2f34a326bb5c Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 13:15:16 +0200 Subject: [PATCH 17/76] ADM_set_qos_constraints_push implemented and tested successfully --- examples/ADM_set_qos_constraints_push.cpp | 50 ++++++++++++++++ examples/CMakeLists.txt | 1 + src/network/engine.hpp | 5 ++ src/network/rpcs.cpp | 70 +++++++++++++++++++++++ src/network/rpcs.hpp | 13 +++++ 5 files changed, 139 insertions(+) create mode 100644 examples/ADM_set_qos_constraints_push.cpp diff --git a/examples/ADM_set_qos_constraints_push.cpp b/examples/ADM_set_qos_constraints_push.cpp new file mode 100644 index 00000000..d9612eaa --- /dev/null +++ b/examples/ADM_set_qos_constraints_push.cpp @@ -0,0 +1,50 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 6) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_qos_constraints_push \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_qos_constraints_push remote procedure on {} with scope {}, QoS class {}, element id {} and class value {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5]); + ADM_set_qos_constraints_push_in_t in; + in.scope = argv[2]; + in.qos_class = argv[3]; + try { + in.element_id = std::stoi(argv[4]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.class_value = argv[4]; + + ADM_set_qos_constraints_push_out_t out; + + endp.call("ADM_set_qos_constraints_push", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_qos_constraints_push remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_qos_constraints_push remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 633e23e1..71838cef 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -27,6 +27,7 @@ list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adh list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers) +list(APPEND examples ADM_set_qos_constraints_push) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index b936b999..806103b9 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -181,6 +181,11 @@ struct engine { "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_push", ADM_set_qos_constraints_push_in_t, + ADM_set_qos_constraints_push_out_t, ADM_set_qos_constraints_push, true); + + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 1ee0009c..f63c9d13 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1015,4 +1015,74 @@ ADM_get_pending_transfers(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_get_pending_transfers) +/** + * Registers a QoS constraint defined by class, scope, and value for the element + * identified by id. + * + * @param in.scope The scope it should be applied to: dataset, node, or job. + * @param in.qos_class A QoS class (e.g. "badwidth", "iops", etc.). + * @param in.element_id A valid id for the element that should be constrained, + * i.e. a resource ID, a node hostname, or a Job ID. + * @param in.class_value An appropriate value for the selected class. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_qos_constraints_push(hg_handle_t h) { + hg_return_t ret; + + ADM_set_qos_constraints_push_in_t in; + ADM_set_qos_constraints_push_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_qos_constraints_push"); + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", + in.scope, in.qos_class, in.element_id, in.class_value); + + if(in.scope != nullptr && in.qos_class != nullptr && in.element_id >= 0 && + in.class_value != nullptr){ + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", + in.scope, in.qos_class, in.element_id, in.class_value); + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.status = 0; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.status = -1; + } + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push null ({}, {}, {}, {})", + in.scope, in.qos_class, in.element_id, in.class_value); + out.ret = -1; + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 7763f80a..550e7a8d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -212,6 +212,19 @@ MERCURY_GEN_PROC(ADM_get_pending_transfers_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_get_pending_transfers); +/// ADM_set_qos_constraints_push + +MERCURY_GEN_PROC( + ADM_set_qos_constraints_push_in_t, + ((hg_const_string_t) (scope))((hg_const_string_t) (qos_class))( + (int32_t) (element_id))((hg_const_string_t) (class_value))) + +MERCURY_GEN_PROC(ADM_set_qos_constraints_push_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push); + + //} // namespace scord::network::rpc -- GitLab From c1de69d80a31769daddcf492c328997148a032a3 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 11 May 2022 12:28:21 +0200 Subject: [PATCH 18/76] ADM_set_qos_constraints_pull implemented and tested successfully and CMakeList fixed --- examples/ADM_set_qos_constraints_pull.cpp | 48 +++++++++++++++++ examples/CMakeLists.txt | 13 ++--- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 65 +++++++++++++++++++++++ src/network/rpcs.hpp | 10 ++++ 5 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 examples/ADM_set_qos_constraints_pull.cpp diff --git a/examples/ADM_set_qos_constraints_pull.cpp b/examples/ADM_set_qos_constraints_pull.cpp new file mode 100644 index 00000000..60c174b2 --- /dev/null +++ b/examples/ADM_set_qos_constraints_pull.cpp @@ -0,0 +1,48 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_qos_constraints_pull \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_qos_constraints_pull remote procedure on {} with scope {} and element id {} ...\n", + argv[1], argv[2], argv[3]); + ADM_set_qos_constraints_pull_in_t in; + in.scope = argv[2]; + try { + in.element_id = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_set_qos_constraints_pull_out_t out; + + endp.call("ADM_set_qos_constraints_pull", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_qos_constraints_pull remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_qos_constraints_pull remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71838cef..94a563b9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,12 +22,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) -list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) -list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers) -list(APPEND examples ADM_set_qos_constraints_push) +set(examples) +list(APPEND ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id + ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution + ADM_adhoc_background_flush 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_push) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 806103b9..4415d2fc 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -185,6 +185,10 @@ struct engine { "ADM_set_qos_constraints_push", ADM_set_qos_constraints_push_in_t, ADM_set_qos_constraints_push_out_t, ADM_set_qos_constraints_push, true); + REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, + "ADM_set_qos_constraints_pull", ADM_set_qos_constraints_pull_in_t, + ADM_set_qos_constraints_pull_out_t, ADM_set_qos_constraints_pull, true); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index f63c9d13..089afdcd 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1085,4 +1085,69 @@ ADM_set_qos_constraints_push(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push) +/** + * Returns a list of QoS constraints defined for an element identified for id. + * + * @param in.scope The scope being queried: dataset, node, or job. + * @param in.element_id A valid id for the element of interest, i.e. a resource + * ID, a node hostname, or a Job ID. + * @param out.list A list of QoS constraints that includes all the classes + * currently defined for the element as well as the values set for them. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_qos_constraints_pull(hg_handle_t h) { + hg_return_t ret; + + ADM_set_qos_constraints_pull_in_t in; + ADM_set_qos_constraints_pull_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_qos_constraints_pull"); + LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", + in.scope, in.element_id); + + if(in.scope != nullptr && in.element_id >= 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", + in.scope, in.element_id); + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.list = "list"; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.list = nullptr; + } + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull null ({}, {})", + in.scope, in.element_id); + out.ret = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 550e7a8d..d13f6207 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -224,6 +224,16 @@ MERCURY_GEN_PROC(ADM_set_qos_constraints_push_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push); +/// ADM_set_qos_constraints_pull + +MERCURY_GEN_PROC(ADM_set_qos_constraints_pull_in_t, + ((hg_const_string_t) (scope))((int32_t) (element_id))) + +MERCURY_GEN_PROC(ADM_set_qos_constraints_pull_out_t, + ((int32_t) (ret))((hg_const_string_t) (list))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull); + //} // namespace scord::network::rpc -- GitLab From 05132b9a494501fa6dbb407e8974dc91993ea993 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 11 May 2022 12:44:59 +0200 Subject: [PATCH 19/76] LOGGER_INFO(LOADED {rcp}) sentence removed --- src/network/rpcs.cpp | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 089afdcd..7d05f9fb 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -61,7 +61,6 @@ ADM_input(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_input"); LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); if(in.origin != nullptr && in.target != nullptr) { @@ -74,6 +73,7 @@ ADM_input(hg_handle_t h) { in.target); } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -108,7 +108,6 @@ ADM_output(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_output"); LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); if(in.origin != nullptr && in.target != nullptr) { @@ -155,7 +154,6 @@ ADM_inout(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_inout"); LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); if(in.origin != nullptr && in.target != nullptr) { @@ -216,7 +214,6 @@ ADM_adhoc_context(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_context"); LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); if(in.context != nullptr) { @@ -277,7 +274,6 @@ ADM_adhoc_context_id(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_context_id"); LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); if(in.context_id >= 0) { @@ -325,7 +321,6 @@ ADM_adhoc_nodes(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_nodes"); LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); if(in.nodes > 0) { @@ -375,7 +370,6 @@ ADM_adhoc_walltime(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_walltime"); LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); if(in.walltime >= 0) { @@ -422,7 +416,6 @@ ADM_adhoc_access(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_access"); LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); if(in.access != nullptr) { @@ -483,7 +476,6 @@ ADM_adhoc_distribution(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_distribution"); LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", in.data_distribution); @@ -530,7 +522,6 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_background_flush"); LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); if(in.b_flush == 0 || in.b_flush == 1) { @@ -575,7 +566,6 @@ ADM_in_situ_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_in_situ_ops"); LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); if(in.in_situ != nullptr) { @@ -620,7 +610,6 @@ ADM_in_transit_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_in_transit_ops"); LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); if(in.in_transit != nullptr) { @@ -681,7 +670,6 @@ ADM_transfer_dataset(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_transfer_dataset"); LOGGER_INFO("remote_procedure::ADM_transfer_dataset({},{},{},{},{})", in.source, in.destination, in.qos_constraints, in.distribution, in.job_id); @@ -740,7 +728,6 @@ ADM_set_dataset_information(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_dataset_information"); LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", in.resource_id, in.info, in.job_id); @@ -794,7 +781,6 @@ ADM_set_io_resources(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_io_resources"); LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, in.resources, in.job_id); @@ -845,7 +831,6 @@ ADM_get_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_get_transfer_priority"); LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", in.transfer_id); @@ -897,7 +882,6 @@ ADM_set_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_transfer_priority"); LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); @@ -950,7 +934,6 @@ ADM_cancel_transfer(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_cancel_transfer"); LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); if(in.transfer_id >= 0) { @@ -997,7 +980,6 @@ ADM_get_pending_transfers(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_get_pending_transfers"); LOGGER_INFO("remote_procedure::ADM_get_pending_transfers"); out.ret = 0; @@ -1041,7 +1023,6 @@ ADM_set_qos_constraints_push(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_qos_constraints_push"); LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); @@ -1108,7 +1089,6 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_qos_constraints_pull"); LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); -- GitLab From c4a93a744af645a08d1e44f7073ae74e6aec8026 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 11 May 2022 14:31:35 +0200 Subject: [PATCH 20/76] set function removed in CMakeList --- examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 94a563b9..1310e1a3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -set(examples) list(APPEND ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset -- GitLab From 253a4b22ba0778b95666b5a3d705e5401f74a88d Mon Sep 17 00:00:00 2001 From: amanzano Date: Thu, 12 May 2022 10:42:39 +0200 Subject: [PATCH 21/76] CMakeLists.txt fixed --- examples/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1310e1a3..3356dab9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -list(APPEND ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id +list(APPEND examples + ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority -- GitLab From ce77bb99e436bb7d48c5040f3cd82588359348b5 Mon Sep 17 00:00:00 2001 From: amanzano Date: Thu, 12 May 2022 11:03:01 +0200 Subject: [PATCH 22/76] Badly formatted comment fixed --- src/network/rpcs.cpp | 146 +++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 76 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 7d05f9fb..c8525659 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -63,17 +63,17 @@ ADM_input(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); - if(in.origin != nullptr && in.target != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_input not null ({},{})", in.origin, - in.target); + out.ret = -1; + + if(in.origin == nullptr) { + LOGGER_ERROR("ADM_input(): invalid origin (nullptr)"); + } else if(in.target == nullptr) { + LOGGER_ERROR("ADM_input(): invalid target (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_input null ({},{})", in.origin, - in.target); + LOGGER_INFO("ADM_input({}, {})", in.origin, in.target); + out.ret = 0; } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -110,14 +110,15 @@ ADM_output(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); - if(in.origin != nullptr && in.target != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_output not null ({},{})", in.origin, - in.target); + out.ret = -1; + + if(in.origin == nullptr) { + LOGGER_ERROR("ADM_output(): invalid origin (nullptr)"); + } else if(in.target == nullptr) { + LOGGER_ERROR("ADM_output(): invalid target (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_output null ({},{})", in.origin, - in.target); + LOGGER_INFO("ADM_output({}, {})", in.origin, in.target); + out.ret = 0; } ret = margo_respond(h, &out); @@ -156,14 +157,15 @@ ADM_inout(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); - if(in.origin != nullptr && in.target != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_inout not null ({},{})", in.origin, - in.target); + out.ret = -1; + + if(in.origin == nullptr) { + LOGGER_ERROR("ADM_inout(): invalid origin (nullptr)"); + } else if(in.target == nullptr) { + LOGGER_ERROR("ADM_inout(): invalid target (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_inout null ({},{})", in.origin, - in.target); + LOGGER_INFO("ADM_inout({}, {})", in.origin, in.target); + out.ret = 0; } ret = margo_respond(h, &out); @@ -179,28 +181,23 @@ ADM_inout(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_inout) /** - * Specifies the execution_mode an Ad hoc Storage System should use. Valid - options: in_job:shared (run while - * sharing the application’s compute nodes), in_job:dedicated (run using a - subset of the application’s - * compute nodes), separate:new (ask the system to allocate a separate job with - separate runtime and - * number of nodes) and separate:existing (ask the system to reuse an already - running Ad hoc Storage System instance). - * The number of nodes assigned for the Ad hoc Storage System must be specified - with ADM_adhoc_nodes. - * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System - will be controlled with - * ADM_adhoc_walltime. In the separate:existing execution_mode, a valid context - ID must be provided with - * ADM_adhoc_context_id + * Specifies the execution_mode an Ad hoc Storage System should use. Valid + * options: in_job:shared (run while sharing the application’s compute nodes), + * in_job:dedicated (run using a subset of the application’s compute nodes), + * separate:new (ask the system to allocate a separate job with separate runtime + * and number of nodes) and separate:existing (ask the system to reuse an already + * running Ad hoc Storage System instance). + * The number of nodes assigned for the Ad hoc Storage System must be specified + * with ADM_adhoc_nodes. + * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System + * will be controlled with ADM_adhoc_walltime. In the separate:existing + * execution_mode, a valid context ID must be provided with ADM_adhoc_context_id. * * @param in.context A valid execution_mode describing how the Ad hoc Storage - System should behave. + * System should behave. * @return out.ret Returns if the remote procedure has been completed - successfully or not. + * successfully or not. * @return out.adhoc_context_id A number that identifies the context. - */ static void ADM_adhoc_context(hg_handle_t h) { @@ -1028,32 +1025,32 @@ ADM_set_qos_constraints_push(hg_handle_t h) { in.scope, in.qos_class, in.element_id, in.class_value); if(in.scope != nullptr && in.qos_class != nullptr && in.element_id >= 0 && - in.class_value != nullptr){ + in.class_value != nullptr) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", - in.scope); - out.ret = 0; - out.status = 0; - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.status = -1; - } + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.status = 0; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.status = -1; + } } else { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push null ({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - out.ret = -1; - out.status = -1; + out.ret = -1; + out.status = -1; } - + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1096,25 +1093,25 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", in.scope, in.element_id); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", - in.scope); - out.ret = 0; - out.list = "list"; - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.list = nullptr; - } + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.list = "list"; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.list = nullptr; + } } else { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull null ({}, {})", in.scope, in.element_id); - out.ret = -1; + out.ret = -1; } ret = margo_respond(h, &out); @@ -1128,6 +1125,3 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull) - - - -- GitLab From 1b579eb744e456bdcaed03ed11a2f6532a7938bc Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 10:11:26 +0200 Subject: [PATCH 23/76] Simplified string comparison --- src/network/rpcs.cpp | 94 +++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index c8525659..d4d53f51 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -181,17 +181,17 @@ ADM_inout(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_inout) /** - * Specifies the execution_mode an Ad hoc Storage System should use. Valid - * options: in_job:shared (run while sharing the application’s compute nodes), - * in_job:dedicated (run using a subset of the application’s compute nodes), - * separate:new (ask the system to allocate a separate job with separate runtime - * and number of nodes) and separate:existing (ask the system to reuse an already - * running Ad hoc Storage System instance). - * The number of nodes assigned for the Ad hoc Storage System must be specified - * with ADM_adhoc_nodes. - * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System - * will be controlled with ADM_adhoc_walltime. In the separate:existing - * execution_mode, a valid context ID must be provided with ADM_adhoc_context_id. + * Specifies the execution_mode an Ad hoc Storage System should use. Valid + * options: in_job:shared (run while sharing the application’s compute nodes), + * in_job:dedicated (run using a subset of the application’s compute nodes), + * separate:new (ask the system to allocate a separate job with separate runtime + * and number of nodes) and separate:existing (ask the system to reuse an + * already running Ad hoc Storage System instance). The number of nodes assigned + * for the Ad hoc Storage System must be specified with ADM_adhoc_nodes. In the + * separate:new execution_mode, the lifetime of the Ad hoc Storage System will + * be controlled with ADM_adhoc_walltime. In the separate:existing + * execution_mode, a valid context ID must be provided with + * ADM_adhoc_context_id. * * @param in.context A valid execution_mode describing how the Ad hoc Storage * System should behave. @@ -211,12 +211,29 @@ ADM_adhoc_context(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string ctx(in.context); + LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); if(in.context != nullptr) { + out.ret = 0; LOGGER_INFO("remote_procedure::ADM_adhoc_context not null ({})", in.context); + + if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || + ctx == "separate:new" || ctx == "separate:existing") { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context value is acceptable ({})", + in.context); + out.adhoc_context = rand(); + } else { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", + in.context); + out.adhoc_context = -1; + } + } else { out.ret = -1; LOGGER_INFO( @@ -224,21 +241,6 @@ ADM_adhoc_context(hg_handle_t h) { in.context); } - if((strcmp(in.context, "in_job:shared")) == 0 || - (strcmp(in.context, "in_job:dedicated")) == 0 || - (strcmp(in.context, "separate:new")) == 0 || - (strcmp(in.context, "separate:existing")) == 0) { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context value is acceptable ({})", - in.context); - out.adhoc_context = rand(); - } else { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", - in.context); - out.adhoc_context = -1; - } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -413,12 +415,26 @@ ADM_adhoc_access(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string acc(in.access); + LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); if(in.access != nullptr) { - out.ret = 0; LOGGER_INFO("remote_procedure::ADM_adhoc_access not null ({})", in.access); + + if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access value is acceptable ({})", + in.access); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", + in.access); + } + } else { out.ret = -1; LOGGER_INFO( @@ -426,20 +442,6 @@ ADM_adhoc_access(hg_handle_t h) { in.access); } - if((strcmp(in.access, "write-only")) == 0 || - (strcmp(in.access, "read-only")) == 0 || - (strcmp(in.access, "read-write") == 0)) { - out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access value is acceptable ({})", - in.access); - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", - in.access); - } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1020,6 +1022,8 @@ ADM_set_qos_constraints_push(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string scp(in.scope); + LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); @@ -1029,8 +1033,7 @@ ADM_set_qos_constraints_push(hg_handle_t h) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", in.scope); @@ -1086,6 +1089,8 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string scp(in.scope); + LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); @@ -1093,8 +1098,7 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", in.scope, in.element_id); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", in.scope); -- GitLab From cf7ae7fda2f07333b02321fa5a0e7739f60bddbc Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 12:52:38 +0200 Subject: [PATCH 24/76] RPCs rewritten changing input validation type --- src/network/rpcs.cpp | 356 ++++++++++++++++++++++--------------------- 1 file changed, 180 insertions(+), 176 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index d4d53f51..504a5b71 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -215,30 +215,25 @@ ADM_adhoc_context(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); - if(in.context != nullptr) { - - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_context not null ({})", - in.context); + out.ret = -1; + out.adhoc_context = -1; + + if(in.context == nullptr) { + LOGGER_ERROR("ADM_adhoc_context(): invalid context (nullptr)"); + } else { + LOGGER_INFO("ADM_adhoc_context({})", in.context); if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { LOGGER_INFO( "remote_procedure::ADM_adhoc_context value is acceptable ({})", in.context); + out.ret = 0; out.adhoc_context = rand(); } else { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", - in.context); - out.adhoc_context = -1; + LOGGER_ERROR( + "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing"); } - - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context null or invalid ({}). Please use", - in.context); } ret = margo_respond(h, &out); @@ -275,17 +270,16 @@ ADM_adhoc_context_id(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); - if(in.context_id >= 0) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_context_id not null ({})", - in.context_id); + out.ret = -1; + + if(in.context_id < 0) { + LOGGER_ERROR("ADM_adhoc_context_id(): invalid context_id (< 0)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context_id null or invalid ({}). Please use", - in.context_id); + LOGGER_INFO("ADM_input({})", in.context_id); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -322,15 +316,16 @@ ADM_adhoc_nodes(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); - if(in.nodes > 0) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_nodes not null ({})", - in.nodes); + out.ret = -1; + + if(in.nodes <= 0) { + LOGGER_ERROR("ADM_adhoc_nodes(): invalid n_nodes (<= 0)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_adhoc_nodes null ({})", in.nodes); + LOGGER_INFO("ADM_adhoc_nodes({})", in.nodes); + out.ret = 0; } + /*Specifies the number of nodes for the Ad hoc Storage System. If the ADM_adhoc_execution_mode is shared, the number cannot exceed the number of allocated nodes within the compute job. If the ADM_adhoc_execution_mode is @@ -371,17 +366,16 @@ ADM_adhoc_walltime(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); - if(in.walltime >= 0) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_walltime not null ({})", - in.walltime); + out.ret = -1; + + if(in.walltime < 0) { + LOGGER_ERROR("ADM_adhoc_walltime(): invalid walltime (< 0)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_walltime null or invalid ({}). Please use", - in.walltime); + LOGGER_INFO("ADM_adhoc_walltime({})", in.walltime); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -419,29 +413,26 @@ ADM_adhoc_access(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); - if(in.access != nullptr) { - LOGGER_INFO("remote_procedure::ADM_adhoc_access not null ({})", - in.access); - - if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { + out.ret = -1; + + if(in.access == nullptr) { + LOGGER_ERROR("ADM_adhoc_access(): invalid access (nullptr)"); + } else { + LOGGER_INFO("ADM_adhoc_access({}, {})", in.access); + + if((acc == "write-only") || (acc == "read-only") || + (acc == "read-write")) { out.ret = 0; LOGGER_INFO( "remote_procedure::ADM_adhoc_access value is acceptable ({})", in.access); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", - in.access); + LOGGER_ERROR( + "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); } - - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access null or invalid ({}). Please use", - in.access); } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -478,17 +469,17 @@ ADM_adhoc_distribution(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", in.data_distribution); - if(in.data_distribution != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_distribution not null ({})", - in.data_distribution); + out.ret = -1; + + if(in.data_distribution == nullptr) { + LOGGER_ERROR( + "ADM_adhoc_distribution(): invalid data_distribution (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_distribution null or invalid ({}). Please use", - in.data_distribution); + LOGGER_INFO("ADM_adhoc_distribution({})", in.data_distribution); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -523,17 +514,17 @@ ADM_adhoc_background_flush(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); - if(in.b_flush == 0 || in.b_flush == 1) { - out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_background_flush not null ({})", - in.b_flush); + out.ret = -1; + + if(in.b_flush != 0 && in.b_flush != 1) { + LOGGER_ERROR( + "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush null ({})", - in.b_flush); + LOGGER_INFO("ADM_adhoc_background_flush({})", in.b_flush); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -567,17 +558,16 @@ ADM_in_situ_ops(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); - if(in.in_situ != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_in_situ_ops not null ({})", - in.in_situ); + out.ret = -1; + + if(in.in_situ == nullptr) { + LOGGER_ERROR("ADM_in_situ_ops(): invalid in_situ_ops (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_in_situ_ops null or invalid ({}). Please use", - in.in_situ); + LOGGER_INFO("ADM_in_situ_ops({})", in.in_situ); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -611,17 +601,16 @@ ADM_in_transit_ops(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); - if(in.in_transit != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_in_transit_ops not null ({})", - in.in_transit); + out.ret = -1; + + if(in.in_transit == nullptr) { + LOGGER_ERROR("ADM_in_transit_ops(): invalid in_transit (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_in_transit_ops null or invalid ({}). Please use", - in.in_transit); + LOGGER_INFO("ADM_in_transit_ops({})", in.in_transit); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -673,24 +662,29 @@ ADM_transfer_dataset(hg_handle_t h) { in.source, in.destination, in.qos_constraints, in.distribution, in.job_id); - if(in.source != nullptr && in.destination != nullptr && - in.qos_constraints != nullptr && in.distribution != nullptr && - in.job_id >= 0) { + out.ret = -1; + out.transfer_handle = "fail"; + + if(in.source == nullptr) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid source (nullptr)"); + } else if(in.destination == nullptr) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid destination (nullptr)"); + } else if(in.qos_constraints == nullptr) { + LOGGER_ERROR( + "ADM_transfer_dataset(): invalid qos_constraints (nullptr)"); + } else if(in.distribution == nullptr) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid distribution (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_transfer_dataset({},{},{},{},{})", in.source, + in.destination, in.qos_constraints, in.distribution, + in.job_id); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset not null ({},{},{},{},{})", - in.source, in.destination, in.qos_constraints, in.distribution, - in.job_id); out.transfer_handle = "ok"; - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset null ({},{},{},{},{})", - in.source, in.destination, in.qos_constraints, in.distribution, - in.job_id); - out.transfer_handle = "fail"; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -730,19 +724,24 @@ ADM_set_dataset_information(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", in.resource_id, in.info, in.job_id); - if(in.resource_id >= 0 && in.info != nullptr && in.job_id >= 0) { + out.ret = -1; + out.status = -1; + + if(in.resource_id < 0) { + LOGGER_ERROR( + "ADM_set_dataset_information(): invalid resource_id (< 0)"); + } else if(in.info == nullptr) { + LOGGER_ERROR("ADM_set_dataset_information(): invalid info (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_set_dataset_information(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_set_dataset_information({},{},{})", in.resource_id, + in.info, in.job_id); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset not null ({},{},{})", - in.resource_id, in.info, in.job_id); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", - in.resource_id, in.info, in.job_id); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -783,19 +782,23 @@ ADM_set_io_resources(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, in.resources, in.job_id); - if(in.tier_id >= 0 && in.resources != nullptr && in.job_id >= 0) { + out.ret = -1; + out.status = -1; + + if(in.tier_id < 0) { + LOGGER_ERROR("ADM_set_io_resources(): invalid tier_id (nullptr)"); + } else if(in.resources == nullptr) { + LOGGER_ERROR("ADM_set_io_resources(): invalid resources (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_set_io_resources(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_set_io_resources({},{},{})", in.tier_id, in.resources, + in.job_id); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset not null ({},{},{})", - in.tier_id, in.resources, in.job_id); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", - in.tier_id, in.resources, in.job_id); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -833,16 +836,16 @@ ADM_get_transfer_priority(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", in.transfer_id); - if(in.transfer_id >= 0) { + out.ret = -1; + out.priority = -1; + + if(in.transfer_id < 0) { + LOGGER_ERROR( + "ADM_get_transfer_priority(): invalid transfer_id (nullptr)"); + } else { + LOGGER_INFO("ADM_get_transfer_priority({})", in.transfer_id); out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_get_transfer_priority not null ({})", - in.transfer_id); out.priority = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_get_transfer_priority null ({})", - in.transfer_id); - out.priority = -1; } ret = margo_respond(h, &out); @@ -858,7 +861,7 @@ ADM_get_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_get_transfer_priority) /** - * Moves the operation identified by transf er_id up or down by n positions in + * Moves the operation identified by transfer_id up or down by n positions in * its scheduling queue. * * @param in.transfer_id A transf er_id identifying a pending transfer. @@ -884,19 +887,20 @@ ADM_set_transfer_priority(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); - if(in.transfer_id >= 0 && (in.n_positions >= 0 || in.n_positions < 0)) { + out.ret = -1; + out.status = -1; + + if(in.transfer_id < 0) { + LOGGER_ERROR( + "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); + }else { + LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, + in.n_positions); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_set_transfer_priority not null ({}, {})", - in.transfer_id, in.n_positions); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_set_transfer_priority null ({}, {})", - in.transfer_id, in.n_positions); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -910,12 +914,9 @@ ADM_set_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_transfer_priority) /** - * Moves the operation identified by transf er_id up or down by n positions in - * its scheduling queue. + * Cancels the pending transfer identified by transfer_id. * - * @param in.transfer_id A transf er_id identifying a pending transfer. - * @param in.n_positions A positive or negative number n for the number of - * positions the transfer should go up or down in its scheduling queue. + * @param in.transfer_id A transfer_id identifying a pending transfer. * @param out.status A status code indicating whether the operation was * successful. * @return out.ret Returns if the remote procedure has been completed @@ -935,18 +936,18 @@ ADM_cancel_transfer(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); - if(in.transfer_id >= 0) { + out.ret = -1; + out.status = -1; + + if(in.transfer_id < 0) { + LOGGER_ERROR("ADM_cancel_transfer(): invalid transfer_id (< 0)"); + } else { + LOGGER_INFO("ADM_cancel_transfer({})", in.transfer_id); out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_cancel_transfer not null ({})", - in.transfer_id); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_cancel_transfer null ({})", - in.transfer_id); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1028,11 +1029,24 @@ ADM_set_qos_constraints_push(hg_handle_t h) { "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - if(in.scope != nullptr && in.qos_class != nullptr && in.element_id >= 0 && - in.class_value != nullptr) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", - in.scope, in.qos_class, in.element_id, in.class_value); + out.ret = -1; + out.status = -1; + + if(in.scope == nullptr) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid scopee (nullptr)"); + } else if(in.qos_class == nullptr) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid qos_class (nullptr)"); + } else if(in.element_id < 0) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid element_id (< 0)"); + } else if(in.class_value == nullptr) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid class_value (nullptr)"); + } else { + LOGGER_INFO("ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, + in.qos_class, in.element_id, in.class_value); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", @@ -1040,20 +1054,12 @@ ADM_set_qos_constraints_push(hg_handle_t h) { out.ret = 0; out.status = 0; } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.status = -1; + LOGGER_ERROR( + "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job"); } - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push null ({}, {}, {}, {})", - in.scope, in.qos_class, in.element_id, in.class_value); - out.ret = -1; - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1094,10 +1100,15 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); - if(in.scope != nullptr && in.element_id >= 0) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", - in.scope, in.element_id); + out.ret = -1; + out.list = nullptr; + + if(in.scope == nullptr) { + LOGGER_ERROR("ADM_input(): invalid scope (nullptr)"); + } else if(in.element_id < 0) { + LOGGER_ERROR("ADM_input(): invalid element_id (< 0)"); + } else { + LOGGER_INFO("ADM_input({}, {})", in.scope, in.element_id); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", @@ -1106,18 +1117,11 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { out.list = "list"; } else { LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.list = nullptr; + "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); } - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull null ({}, {})", - in.scope, in.element_id); - out.ret = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab From a8cdef9b8c1e52cb0967096870c09fddb1b01227 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 12:57:04 +0200 Subject: [PATCH 25/76] LOGGER ERROR fixed --- src/network/rpcs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 504a5b71..8c2555ad 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1116,7 +1116,7 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { out.ret = 0; out.list = "list"; } else { - LOGGER_INFO( + LOGGER_ERROR( "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); } } -- GitLab From f8e330d67f8ba39ec757b25f4cd6f5a69d4ece70 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 13:08:03 +0200 Subject: [PATCH 26/76] All remote_procedure:: sentences delated --- examples/ADM_adhoc_context.cpp | 1 + src/network/rpcs.cpp | 78 ++++++---------------------------- 2 files changed, 13 insertions(+), 66 deletions(-) diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp index 48bef96b..d98d21af 100644 --- a/examples/ADM_adhoc_context.cpp +++ b/examples/ADM_adhoc_context.cpp @@ -27,6 +27,7 @@ main(int argc, char* argv[]) { endp.call("ADM_adhoc_context", &in, &out); + if(out.ret < 0 || out.adhoc_context < 0) { fmt::print( stdout, diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8c2555ad..43a2b694 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -31,7 +31,7 @@ ping(hg_handle_t h) { margo_instance_id mid = margo_hg_handle_get_instance(h); - LOGGER_INFO("remote_procedure::PING(noargs)"); + LOGGER_INFO("PING(noargs)"); ret = margo_destroy(h); assert(ret == HG_SUCCESS); @@ -61,8 +61,6 @@ ADM_input(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); - out.ret = -1; if(in.origin == nullptr) { @@ -108,8 +106,6 @@ ADM_output(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); - out.ret = -1; if(in.origin == nullptr) { @@ -155,8 +151,6 @@ ADM_inout(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); - out.ret = -1; if(in.origin == nullptr) { @@ -213,8 +207,6 @@ ADM_adhoc_context(hg_handle_t h) { const std::string ctx(in.context); - LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); - out.ret = -1; out.adhoc_context = -1; @@ -225,14 +217,13 @@ ADM_adhoc_context(hg_handle_t h) { if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context value is acceptable ({})", - in.context); + LOGGER_INFO("ADM_adhoc_context value is acceptable ({})", + in.context); out.ret = 0; out.adhoc_context = rand(); } else { LOGGER_ERROR( - "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing"); + "ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing"); } } @@ -268,14 +259,13 @@ ADM_adhoc_context_id(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); out.ret = -1; if(in.context_id < 0) { LOGGER_ERROR("ADM_adhoc_context_id(): invalid context_id (< 0)"); } else { - LOGGER_INFO("ADM_input({})", in.context_id); + LOGGER_INFO("ADM_adhoc_context_id({})", in.context_id); out.ret = 0; } @@ -314,8 +304,6 @@ ADM_adhoc_nodes(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); - out.ret = -1; if(in.nodes <= 0) { @@ -364,8 +352,6 @@ ADM_adhoc_walltime(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); - out.ret = -1; if(in.walltime < 0) { @@ -411,8 +397,6 @@ ADM_adhoc_access(hg_handle_t h) { const std::string acc(in.access); - LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); - out.ret = -1; if(in.access == nullptr) { @@ -423,12 +407,10 @@ ADM_adhoc_access(hg_handle_t h) { if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access value is acceptable ({})", - in.access); + LOGGER_INFO("ADM_adhoc_access value is acceptable ({})", in.access); } else { LOGGER_ERROR( - "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); + "ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); } } @@ -466,9 +448,6 @@ ADM_adhoc_distribution(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", - in.data_distribution); - out.ret = -1; if(in.data_distribution == nullptr) { @@ -512,8 +491,6 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); - out.ret = -1; if(in.b_flush != 0 && in.b_flush != 1) { @@ -556,8 +533,6 @@ ADM_in_situ_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); - out.ret = -1; if(in.in_situ == nullptr) { @@ -599,8 +574,6 @@ ADM_in_transit_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); - out.ret = -1; if(in.in_transit == nullptr) { @@ -658,10 +631,6 @@ ADM_transfer_dataset(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_transfer_dataset({},{},{},{},{})", - in.source, in.destination, in.qos_constraints, in.distribution, - in.job_id); - out.ret = -1; out.transfer_handle = "fail"; @@ -721,9 +690,6 @@ ADM_set_dataset_information(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", - in.resource_id, in.info, in.job_id); - out.ret = -1; out.status = -1; @@ -779,9 +745,6 @@ ADM_set_io_resources(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, - in.resources, in.job_id); - out.ret = -1; out.status = -1; @@ -833,9 +796,6 @@ ADM_get_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", - in.transfer_id); - out.ret = -1; out.priority = -1; @@ -884,16 +844,13 @@ ADM_set_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", - in.transfer_id, in.n_positions); - out.ret = -1; out.status = -1; if(in.transfer_id < 0) { LOGGER_ERROR( "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); - }else { + } else { LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); out.ret = 0; @@ -934,8 +891,6 @@ ADM_cancel_transfer(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); - out.ret = -1; out.status = -1; @@ -980,8 +935,6 @@ ADM_get_pending_transfers(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_get_pending_transfers"); - out.ret = 0; out.pending_transfers = "list"; @@ -1025,10 +978,6 @@ ADM_set_qos_constraints_push(hg_handle_t h) { const std::string scp(in.scope); - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", - in.scope, in.qos_class, in.element_id, in.class_value); - out.ret = -1; out.status = -1; @@ -1049,13 +998,13 @@ ADM_set_qos_constraints_push(hg_handle_t h) { in.qos_class, in.element_id, in.class_value); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", + "ADM_set_qos_constraints_push scope value is acceptable ({})", in.scope); out.ret = 0; out.status = 0; } else { LOGGER_ERROR( - "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job"); + "ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job"); } } @@ -1097,9 +1046,6 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { const std::string scp(in.scope); - LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", - in.scope, in.element_id); - out.ret = -1; out.list = nullptr; @@ -1111,13 +1057,13 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO("ADM_input({}, {})", in.scope, in.element_id); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", + "ADM_set_qos_constraints_pull scope value is acceptable ({})", in.scope); out.ret = 0; out.list = "list"; } else { LOGGER_ERROR( - "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); + "ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); } } -- GitLab From 9a9462377e3e3d912e532584c50b866a8b4b90ea Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 08:19:46 +0200 Subject: [PATCH 27/76] string_to_convert function name changed --- examples/ADM_adhoc_background_flush.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index b7774a06..cfec2064 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -2,10 +2,10 @@ #include int -String2Convert(std::string var) { - if(var == "true" || var == "TRUE") { +string_to_convert(std::string s) { + if(s == "true" || s == "TRUE") { return 0; - } else if(var == "false" || var == "FALSE") { + } else if(s == "false" || s == "FALSE") { return 1; } else { return -1; @@ -35,7 +35,7 @@ main(int argc, char* argv[]) { ADM_adhoc_background_flush_in_t in; try { - in.b_flush = String2Convert(argv[2]); + in.b_flush = string_to_convert(argv[2]); } catch(const std::exception& e) { fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); exit(EXIT_FAILURE); -- GitLab From 1de44be0d0d283ea30e37acb6411268974e2c483 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 10:07:45 +0200 Subject: [PATCH 28/76] Input incorrect error modified --- examples/ADM_adhoc_background_flush.cpp | 20 ++++++++------------ src/network/rpcs.cpp | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index cfec2064..fa8201a4 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -3,12 +3,13 @@ int string_to_convert(std::string s) { - if(s == "true" || s == "TRUE") { - return 0; - } else if(s == "false" || s == "FALSE") { - return 1; + if(s == "true" || s == "TRUE" || s == "True") { + return true; + } else if(s == "false" || s == "FALSE" || s == "False") { + return false; } else { - return -1; + fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); + exit(EXIT_FAILURE); } } @@ -33,13 +34,8 @@ main(int argc, char* argv[]) { "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n", argv[1], argv[2]); ADM_adhoc_background_flush_in_t in; - - try { - in.b_flush = string_to_convert(argv[2]); - } catch(const std::exception& e) { - fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); - exit(EXIT_FAILURE); - } + + in.b_flush = string_to_convert(argv[2]); ADM_adhoc_background_flush_out_t out; diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 43a2b694..ed9edb50 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -217,8 +217,9 @@ ADM_adhoc_context(hg_handle_t h) { if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { - LOGGER_INFO("ADM_adhoc_context value is acceptable ({})", - in.context); + LOGGER_INFO( + "ADM_adhoc_context value is acceptable ({})", + in.context); out.ret = 0; out.adhoc_context = rand(); } else { @@ -407,7 +408,9 @@ ADM_adhoc_access(hg_handle_t h) { if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { out.ret = 0; - LOGGER_INFO("ADM_adhoc_access value is acceptable ({})", in.access); + LOGGER_INFO( + "ADM_adhoc_access value is acceptable ({})", + in.access); } else { LOGGER_ERROR( "ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); @@ -491,9 +494,9 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - out.ret = -1; - - if(in.b_flush != 0 && in.b_flush != 1) { + out.ret = 0; + + if(in.b_flush != true && in.b_flush != false) { LOGGER_ERROR( "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); } else { @@ -501,7 +504,6 @@ ADM_adhoc_background_flush(hg_handle_t h) { out.ret = 0; } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -850,7 +852,7 @@ ADM_set_transfer_priority(hg_handle_t h) { if(in.transfer_id < 0) { LOGGER_ERROR( "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); - } else { + }else { LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); out.ret = 0; -- GitLab From f9f29b368d9a112d0fdf56cebb05ddd7bdddf9a1 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 11:05:00 +0200 Subject: [PATCH 29/76] ADM_adhoc_background_flush modified --- examples/ADM_adhoc_background_flush.cpp | 16 +++++++++++----- src/network/rpcs.cpp | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index fa8201a4..1fa299bd 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -1,15 +1,14 @@ #include #include -int +bool string_to_convert(std::string s) { if(s == "true" || s == "TRUE" || s == "True") { return true; } else if(s == "false" || s == "FALSE" || s == "False") { return false; } else { - fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); - exit(EXIT_FAILURE); + throw std::invalid_argument("ERROR: Incorrect input value. Please try again.\n"); } } @@ -34,8 +33,15 @@ main(int argc, char* argv[]) { "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n", argv[1], argv[2]); ADM_adhoc_background_flush_in_t in; - - in.b_flush = string_to_convert(argv[2]); + + try { + in.b_flush = string_to_convert(argv[2]); + } catch(const std::invalid_argument& ia) { + fmt::print( + stderr, + "ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n"); + exit(EXIT_FAILURE); + } ADM_adhoc_background_flush_out_t out; diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index ed9edb50..d10824db 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -494,7 +494,7 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - out.ret = 0; + out.ret = -1; if(in.b_flush != true && in.b_flush != false) { LOGGER_ERROR( -- GitLab From 854d87dd6b8c8036f3ab08176b9dae92d8736d98 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 11:40:22 +0200 Subject: [PATCH 30/76] ADM_define_data_operation implemented and tested successfully --- examples/ADM_adhoc_background_flush.cpp | 2 +- examples/ADM_define_data_operation.cpp | 50 +++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 60 ++++++++++++++++++++++++- src/network/rpcs.hpp | 10 +++++ 6 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 examples/ADM_define_data_operation.cpp diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index 1fa299bd..074f4fc5 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -56,4 +56,4 @@ main(int argc, char* argv[]) { stdout, "ADM_adhoc_background_flush remote procedure completed successfully\n"); } -} +} \ No newline at end of file diff --git a/examples/ADM_define_data_operation.cpp b/examples/ADM_define_data_operation.cpp new file mode 100644 index 00000000..a484c1d8 --- /dev/null +++ b/examples/ADM_define_data_operation.cpp @@ -0,0 +1,50 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 5) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_define_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_define_data_operation remote procedure on {} -> {} with operation id {} and arguments {} ...\n", + argv[1], argv[2], argv[3], argv[4]); + + ADM_define_data_operation_in_t in; + in.path = argv[2]; + try { + in.operation_id = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.arguments = argv[4]; + + ADM_define_data_operation_out_t out; + + endp.call("ADM_define_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_define_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_define_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3356dab9..4ff4ffb9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,7 @@ list(APPEND examples ADM_adhoc_background_flush 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_push) + ADM_set_qos_constraints_push ADM_define_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 4415d2fc..14909894 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -189,6 +189,10 @@ struct engine { "ADM_set_qos_constraints_pull", ADM_set_qos_constraints_pull_in_t, ADM_set_qos_constraints_pull_out_t, ADM_set_qos_constraints_pull, 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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index d10824db..59d415fb 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -985,7 +985,7 @@ ADM_set_qos_constraints_push(hg_handle_t h) { if(in.scope == nullptr) { LOGGER_ERROR( - "ADM_set_qos_constraints_push(): invalid scopee (nullptr)"); + "ADM_set_qos_constraints_push(): invalid scope (nullptr)"); } else if(in.qos_class == nullptr) { LOGGER_ERROR( "ADM_set_qos_constraints_push(): invalid qos_class (nullptr)"); @@ -1081,3 +1081,61 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull) + +/** + * Defines a new operation, with the code found in path. The code will be + * identified by the user-provided operation_id and will accept the arguments + * defined, using the next format "arg0, arg1, arg2, . . . ". + * + * @param in.path A valid path for the operation code. + * @param in.operation_id A user-defined operation_id for the operation. + * @param in.arguments A list of arguments for the operation. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_define_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_define_data_operation_in_t in; + ADM_define_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.status = -1; + + if(in.path == nullptr) { + LOGGER_ERROR( + "ADM_define_data_operation(): invalid path (nullptr)"); + } else if(in.operation_id < 0) { + LOGGER_ERROR( + "ADM_define_data_operation(): invalid operation_id (< 0)"); + } else if(in.arguments == nullptr) { + LOGGER_ERROR( + "ADM_define_data_operation(): invalid arguments (nullptr)"); + } else { + LOGGER_INFO("ADM_define_data_operation ({}, {}, {})", + in.path, in.operation_id, in.arguments); + out.ret = 0; + out.status = 0; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_define_data_operation) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index d13f6207..95956c08 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -234,6 +234,16 @@ MERCURY_GEN_PROC(ADM_set_qos_constraints_pull_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull); +/// ADM_define_data_operation + +MERCURY_GEN_PROC(ADM_define_data_operation_in_t, + ((hg_const_string_t) (path))((int32_t) (operation_id))( + (hg_const_string_t) (arguments))) + +MERCURY_GEN_PROC(ADM_define_data_operation_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_define_data_operation); //} // namespace scord::network::rpc -- GitLab From 4892e43c6635aeedae8a001b6376a12a76586158 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:00:54 +0200 Subject: [PATCH 31/76] ADM_connect_data_operation implemented and tested successfully --- examples/ADM_connect_data_operation.cpp | 74 +++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 96 ++++++++++++++++++++----- src/network/rpcs.hpp | 14 ++++ 5 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 examples/ADM_connect_data_operation.cpp diff --git a/examples/ADM_connect_data_operation.cpp b/examples/ADM_connect_data_operation.cpp new file mode 100644 index 00000000..5643fb97 --- /dev/null +++ b/examples/ADM_connect_data_operation.cpp @@ -0,0 +1,74 @@ +#include +#include + +bool +string_to_convert(std::string s) { + if(s == "true" || s == "TRUE" || s == "True") { + return true; + } else if(s == "false" || s == "FALSE" || s == "False") { + return false; + } else { + throw std::invalid_argument( + "ERROR: Incorrect input value. Please try again.\n"); + } +} + +int +main(int argc, char* argv[]) { + + if(argc != 7) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_connect_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_connect_data_operation remote procedure on {} with operation id {}, input {}, stream {}, arguments {} and job id {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); + ADM_connect_data_operation_in_t in; + try { + in.operation_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.input = argv[3]; + try { + in.stream = string_to_convert(argv[4]); + } catch(const std::invalid_argument& ia) { + fmt::print(stderr, "ERROR: Incorrect input value. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.arguments = argv[5]; + try { + in.job_id = std::stoi(argv[6]); + } catch(const std::exception& e) { + fmt::print( + stderr, + "ERROR: ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n"); + exit(EXIT_FAILURE); + } + + ADM_connect_data_operation_out_t out; + + endp.call("ADM_connect_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_connect_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_connect_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4ff4ffb9..2bb4849b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,7 @@ list(APPEND examples ADM_adhoc_background_flush 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_push ADM_define_data_operation) + ADM_set_qos_constraints_push ADM_define_data_operation ADM_connect_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 14909894..242884fc 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -192,6 +192,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 59d415fb..67da74aa 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -217,9 +217,8 @@ ADM_adhoc_context(hg_handle_t h) { if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { - LOGGER_INFO( - "ADM_adhoc_context value is acceptable ({})", - in.context); + LOGGER_INFO("ADM_adhoc_context value is acceptable ({})", + in.context); out.ret = 0; out.adhoc_context = rand(); } else { @@ -408,9 +407,7 @@ ADM_adhoc_access(hg_handle_t h) { if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { out.ret = 0; - LOGGER_INFO( - "ADM_adhoc_access value is acceptable ({})", - in.access); + LOGGER_INFO("ADM_adhoc_access value is acceptable ({})", in.access); } else { LOGGER_ERROR( "ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); @@ -495,7 +492,7 @@ ADM_adhoc_background_flush(hg_handle_t h) { assert(ret == HG_SUCCESS); out.ret = -1; - + if(in.b_flush != true && in.b_flush != false) { LOGGER_ERROR( "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); @@ -852,7 +849,7 @@ ADM_set_transfer_priority(hg_handle_t h) { if(in.transfer_id < 0) { LOGGER_ERROR( "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); - }else { + } else { LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); out.ret = 0; @@ -984,8 +981,7 @@ ADM_set_qos_constraints_push(hg_handle_t h) { out.status = -1; if(in.scope == nullptr) { - LOGGER_ERROR( - "ADM_set_qos_constraints_push(): invalid scope (nullptr)"); + LOGGER_ERROR("ADM_set_qos_constraints_push(): invalid scope (nullptr)"); } else if(in.qos_class == nullptr) { LOGGER_ERROR( "ADM_set_qos_constraints_push(): invalid qos_class (nullptr)"); @@ -1111,17 +1107,15 @@ ADM_define_data_operation(hg_handle_t h) { out.status = -1; if(in.path == nullptr) { - LOGGER_ERROR( - "ADM_define_data_operation(): invalid path (nullptr)"); + LOGGER_ERROR("ADM_define_data_operation(): invalid path (nullptr)"); } else if(in.operation_id < 0) { - LOGGER_ERROR( - "ADM_define_data_operation(): invalid operation_id (< 0)"); + LOGGER_ERROR("ADM_define_data_operation(): invalid operation_id (< 0)"); } else if(in.arguments == nullptr) { LOGGER_ERROR( "ADM_define_data_operation(): invalid arguments (nullptr)"); } else { - LOGGER_INFO("ADM_define_data_operation ({}, {}, {})", - in.path, in.operation_id, in.arguments); + LOGGER_INFO("ADM_define_data_operation ({}, {}, {})", in.path, + in.operation_id, in.arguments); out.ret = 0; out.status = 0; } @@ -1139,3 +1133,73 @@ ADM_define_data_operation(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_define_data_operation) +/** + * Connects and starts the data operation defined with operation_id and with the + * arguments, using the input and output data storage (i.e., files). If the + * operation can be executed in a streaming fashion (i.e., it can start even if + * the input data is not entirely available), the stream parameter must be set + * to true. + * + * @param in.operation_id The operation_id of the operation to be connected. + * @param in.input An input data resource for the operation. + * @param in.stream A stream boolean indicating if the operation should be + * executed in a streaming fashion. + * @param in.arguments The values for the arguments required by the operation. + * @param in.job_id A job_id identifying the originating job. + * @param out.data An output data resource where the result of the operation + * should be stored. + * @return out.operation_handle An operation_handle for the operation that + * allows clients to further interact with the operation (e.g query its status, + * cancel it, etc.). + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_connect_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_connect_data_operation_in_t in; + ADM_connect_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.data = nullptr; + out.operation_handle = nullptr; + + if(in.operation_id < 0) { + LOGGER_ERROR( + "ADM_connect_data_operation(): invalid operation_id (< 0)"); + } else if(in.input == nullptr) { + LOGGER_ERROR("ADM_define_data_operation(): invalid input (nullptr)"); + } else if(in.stream != true && in.stream != false) { + LOGGER_ERROR( + "ADM_connect_data_operation(): invalid stream (not true/false)"); + } else if(in.arguments == nullptr) { + LOGGER_ERROR( + "ADM_connect_data_operation(): invalid arguments (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_connect_data_operation(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_connect_data_operation({}, {}, {}, {}, {})", + in.operation_id, in.input, in.stream, in.arguments, + in.job_id); + out.ret = 0; + out.data = "ouput"; + out.operation_handle = "operation_handle"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_connect_data_operation) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 95956c08..b7edb91d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -245,6 +245,20 @@ MERCURY_GEN_PROC(ADM_define_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_define_data_operation); +/// ADM_connect_data_operation + +MERCURY_GEN_PROC(ADM_connect_data_operation_in_t, + ((int32_t) (operation_id))((hg_const_string_t) (input))( + (hg_bool_t) (stream))((hg_const_string_t) (arguments))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_connect_data_operation_out_t, + ((int32_t) (ret))((hg_const_string_t) (data))( + (hg_const_string_t) (operation_handle))) + +DECLARE_MARGO_RPC_HANDLER(ADM_connect_data_operation); + + //} // namespace scord::network::rpc -- GitLab From 525ed071c968aa7138867d6980d9640ee3873e0f Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:10:45 +0200 Subject: [PATCH 32/76] ADM_finalize_data_operation implemented and tested successfully --- examples/ADM_finalize_data_operation.cpp | 45 +++++++++++++++ examples/CMakeLists.txt | 3 +- src/network/engine.hpp | 71 ++++++++++++++++-------- src/network/rpcs.cpp | 45 +++++++++++++++ src/network/rpcs.hpp | 10 ++++ 5 files changed, 149 insertions(+), 25 deletions(-) create mode 100644 examples/ADM_finalize_data_operation.cpp diff --git a/examples/ADM_finalize_data_operation.cpp b/examples/ADM_finalize_data_operation.cpp new file mode 100644 index 00000000..e1e75f2e --- /dev/null +++ b/examples/ADM_finalize_data_operation.cpp @@ -0,0 +1,45 @@ +#include +#include + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_finalize_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_finalize_data_operation remote procedure on {} with operation id {} ...\n", + argv[1], argv[2]); + ADM_finalize_data_operation_in_t in; + try { + in.operation_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_finalize_data_operation_out_t out; + + endp.call("ADM_finalize_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_finalize_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_finalize_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2bb4849b..e36512ba 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,8 @@ list(APPEND examples ADM_adhoc_background_flush 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_push ADM_define_data_operation ADM_connect_data_operation) + ADM_set_qos_constraints_push ADM_define_data_operation ADM_connect_data_operation + ADM_finalize_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 242884fc..7b9136f0 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -139,12 +139,15 @@ struct engine { 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); - + 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); - + "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); @@ -158,46 +161,66 @@ struct engine { 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); + "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); - + "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); + "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); + "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_push", ADM_set_qos_constraints_push_in_t, - ADM_set_qos_constraints_push_out_t, ADM_set_qos_constraints_push, true); + "ADM_set_qos_constraints_push", + ADM_set_qos_constraints_push_in_t, + ADM_set_qos_constraints_push_out_t, + ADM_set_qos_constraints_push, true); REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_set_qos_constraints_pull", ADM_set_qos_constraints_pull_in_t, - ADM_set_qos_constraints_pull_out_t, ADM_set_qos_constraints_pull, true); + "ADM_set_qos_constraints_pull", + ADM_set_qos_constraints_pull_in_t, + ADM_set_qos_constraints_pull_out_t, + ADM_set_qos_constraints_pull, 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); + "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); } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 67da74aa..8feb7cae 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1203,3 +1203,48 @@ ADM_connect_data_operation(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_connect_data_operation) + +/** + * Finalises the operation defined with operation_id. + * + * @param in.operation_id The operation_id of the operation to be connected. + * @return out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_finalize_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_finalize_data_operation_in_t in; + ADM_finalize_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.status = -1; + + if(in.operation_id < 0) { + LOGGER_ERROR( + "ADM_finalize_data_operation(): invalid operation_id (< 0)"); + } else { + LOGGER_INFO("ADM_finalize_data_operation({})", in.operation_id); + out.ret = 0; + out.status = 0; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_finalize_data_operation) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index b7edb91d..79d7288d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -258,6 +258,16 @@ MERCURY_GEN_PROC(ADM_connect_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_connect_data_operation); +/// ADM_finalize_data_operation + +MERCURY_GEN_PROC(ADM_finalize_data_operation_in_t, ((int32_t) (operation_id))) + +MERCURY_GEN_PROC(ADM_finalize_data_operation_out_t, + ((int32_t) (ret))((int32_t) (status))) + + +DECLARE_MARGO_RPC_HANDLER(ADM_finalize_data_operation); + //} // namespace scord::network::rpc -- GitLab From 9b719a27cfeeed266565a944afbd4e8796044b58 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:24:55 +0200 Subject: [PATCH 33/76] ADM_link_transfer_to_data_operation implemented and tested successfully --- .../ADM_link_transfer_to_data_operation.cpp | 79 +++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 ++ src/network/rpcs.cpp | 67 ++++++++++++++++ src/network/rpcs.hpp | 11 +++ 5 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_link_transfer_to_data_operation.cpp diff --git a/examples/ADM_link_transfer_to_data_operation.cpp b/examples/ADM_link_transfer_to_data_operation.cpp new file mode 100644 index 00000000..11ec2587 --- /dev/null +++ b/examples/ADM_link_transfer_to_data_operation.cpp @@ -0,0 +1,79 @@ +#include +#include + +bool +string_to_convert(std::string s) { + if(s == "true" || s == "TRUE" || s == "True") { + return true; + } else if(s == "false" || s == "FALSE" || s == "False") { + return false; + } else { + throw std::invalid_argument( + "ERROR: Incorrect input value. Please try again.\n"); + } +} + +int +main(int argc, char* argv[]) { + + if(argc != 7) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_link_transfer_to_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_link_transfer_to_data_operation remote procedure on {} with operation id {}, transfer id {}, stream {}, arguments {} and job id {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); + ADM_link_transfer_to_data_operation_in_t in; + try { + in.operation_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.transfer_id = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.stream = string_to_convert(argv[4]); + } catch(const std::invalid_argument& ia) { + fmt::print( + stderr, + "ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n"); + exit(EXIT_FAILURE); + } + in.arguments = argv[5]; + try { + in.job_id = std::stoi(argv[6]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_link_transfer_to_data_operation_out_t out; + + endp.call("ADM_link_transfer_to_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_link_transfer_to_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_link_transfer_to_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e36512ba..49756705 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND examples 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_push ADM_define_data_operation ADM_connect_data_operation - ADM_finalize_data_operation) + ADM_finalize_data_operation ADM_link_transfer_to_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 7b9136f0..e63939c2 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -221,6 +221,12 @@ struct engine { 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); } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8feb7cae..33f1ebfe 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1248,3 +1248,70 @@ ADM_finalize_data_operation(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_finalize_data_operation) + +/** + * Links the data operation defined with operation_id with the pending transfer + * identified by transf er_id using the values provided as arguments. If the + * operation can be executed in a streaming fashion (i.e., it can start even if + * the input data is not entirely available), the stream parameter must be set + * to true. + * + * @param in.operation_id The operation_id of the operation to be connected. + * @param in.transfer_id The transfer_id of the pending transfer the operation + * should be linked to. + * @param in.stream A stream boolean indicating if the operation should be + * executed in a streaming fashion. + * @param in.arguments The values for the arguments required by the operation. + * @param in.job_id A job_id identifying the originating job. + * @return out.operation_handle An operation_handle for the operation that + * allows clients to further interact with the operation (e.g query its status, + * cancel it, etc.). + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_link_transfer_to_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_link_transfer_to_data_operation_in_t in; + ADM_link_transfer_to_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.operation_handle = nullptr; + + if(in.operation_id < 0) { + LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid operation_id (< 0)"); + } else if(in.transfer_id < 0) { + LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid transfer_id (< 0)"); + } else if(in.arguments == nullptr) { + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid arguments (nullptr)"); + }else if(in.stream != true && in.stream != false) { + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid stream (not true/false)"); + }else if(in.job_id < 0) { + LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_link_transfer_to_data_operation ({}, {}, {}, {}, {})", + in.operation_id, in.transfer_id, in.stream, in.arguments, + in.job_id); + out.ret = 0; + out.operation_handle = "operation_handle"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 79d7288d..5d098316 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -268,6 +268,17 @@ MERCURY_GEN_PROC(ADM_finalize_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_finalize_data_operation); +/// ADM_link_transfer_to_data_operation + +MERCURY_GEN_PROC(ADM_link_transfer_to_data_operation_in_t, + ((int32_t) (operation_id))((int32_t) (transfer_id))( + (hg_bool_t) (stream))((hg_const_string_t) (arguments))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_link_transfer_to_data_operation_out_t, + ((int32_t) (ret))((hg_const_string_t) (operation_handle))) + +DECLARE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation); //} // namespace scord::network::rpc -- GitLab From 9d17cd616bcd91e0684771d6bea2a885c3d40e51 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:36:02 +0200 Subject: [PATCH 34/76] ADM_get_statistics implemented and tested successfully --- examples/ADM_get_statistics.cpp | 52 +++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 67 +++++++++++++++++++++++++++++---- src/network/rpcs.hpp | 11 ++++++ 5 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 examples/ADM_get_statistics.cpp diff --git a/examples/ADM_get_statistics.cpp b/examples/ADM_get_statistics.cpp new file mode 100644 index 00000000..d15e4471 --- /dev/null +++ b/examples/ADM_get_statistics.cpp @@ -0,0 +1,52 @@ +#include +#include + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_get_statistics \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_get_statistics remote procedure on {} with job id {} and job step {} ...\n", + argv[1], argv[2], argv[3]); + ADM_get_statistics_in_t in; + try { + in.job_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.job_step = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_get_statistics_out_t out; + + endp.call("ADM_get_statistics", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_get_statistics remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_get_statistics remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 49756705..88453845 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND examples 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_push ADM_define_data_operation ADM_connect_data_operation - ADM_finalize_data_operation ADM_link_transfer_to_data_operation) + ADM_finalize_data_operation ADM_link_transfer_to_data_operation ADM_get_statistics) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index e63939c2..dc8a15d3 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -227,6 +227,10 @@ struct engine { 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 diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 33f1ebfe..e9c90b75 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1285,21 +1285,24 @@ ADM_link_transfer_to_data_operation(hg_handle_t h) { out.operation_handle = nullptr; if(in.operation_id < 0) { - LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid operation_id (< 0)"); + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid operation_id (< 0)"); } else if(in.transfer_id < 0) { - LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid transfer_id (< 0)"); + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid transfer_id (< 0)"); } else if(in.arguments == nullptr) { LOGGER_ERROR( "ADM_link_transfer_to_data_operation(): invalid arguments (nullptr)"); - }else if(in.stream != true && in.stream != false) { + } else if(in.stream != true && in.stream != false) { LOGGER_ERROR( "ADM_link_transfer_to_data_operation(): invalid stream (not true/false)"); - }else if(in.job_id < 0) { - LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid job_id (< 0)"); + } else if(in.job_id < 0) { + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid job_id (< 0)"); } else { LOGGER_INFO("ADM_link_transfer_to_data_operation ({}, {}, {}, {}, {})", - in.operation_id, in.transfer_id, in.stream, in.arguments, - in.job_id); + in.operation_id, in.transfer_id, in.stream, in.arguments, + in.job_id); out.ret = 0; out.operation_handle = "operation_handle"; } @@ -1315,3 +1318,53 @@ ADM_link_transfer_to_data_operation(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation) + + +/** + * Returns the current I/O statistics for a specified job_id and an optional + * corresponding job_step. The information will be returned in an + * easy-to-process format, e.g., JSON (see Listing 3.1). + * + * @param in.job_id + * @param in.job_step + * @return out.job_statistics + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_get_statistics(hg_handle_t h) { + hg_return_t ret; + + ADM_get_statistics_in_t in; + ADM_get_statistics_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.job_statistics = nullptr; + + if(in.job_id < 0) { + LOGGER_ERROR("ADM_get_statistics(): invalid job_id (< 0)"); + } else if(in.job_step < 0) { + LOGGER_ERROR("ADM_get_statistics(): invalid job_step (< 0)"); + } else { + LOGGER_INFO("ADM_get_statistics ({}, {})", + in.job_id, in.job_step); + out.ret = 0; + out.job_statistics = "job_statistics"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_get_statistics) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 5d098316..170fb249 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -280,6 +280,17 @@ MERCURY_GEN_PROC(ADM_link_transfer_to_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation); +/// ADM_get_statistics + +MERCURY_GEN_PROC(ADM_get_statistics_in_t, + ((int32_t) (job_id))((int32_t) (job_step))) + +MERCURY_GEN_PROC(ADM_get_statistics_out_t, + ((int32_t) (ret))((hg_const_string_t) (job_statistics))) + +DECLARE_MARGO_RPC_HANDLER(ADM_get_statistics); + + //} // namespace scord::network::rpc -- GitLab From 336b924a5f594f4229b34faf30548ba808198937 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 17 May 2022 11:11:08 +0200 Subject: [PATCH 35/76] ADM_adhoc_access exit failure added --- examples/ADM_adhoc_access.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/ADM_adhoc_access.cpp b/examples/ADM_adhoc_access.cpp index df18e95d..2d28cf3a 100644 --- a/examples/ADM_adhoc_access.cpp +++ b/examples/ADM_adhoc_access.cpp @@ -31,6 +31,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_access remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, -- GitLab From 9e21580e284791b34a07012f7f45baf3a5aab36b Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 17 May 2022 11:23:46 +0200 Subject: [PATCH 36/76] Exit failure added to RPCs --- examples/ADM_adhoc_background_flush.cpp | 1 + examples/ADM_adhoc_context.cpp | 1 + examples/ADM_adhoc_context_id.cpp | 1 + examples/ADM_adhoc_distribution.cpp | 1 + examples/ADM_adhoc_nodes.cpp | 1 + examples/ADM_adhoc_walltime.cpp | 1 + examples/ADM_cancel_transfer.cpp | 1 + examples/ADM_connect_data_operation.cpp | 1 + examples/ADM_define_data_operation.cpp | 1 + examples/ADM_finalize_data_operation.cpp | 1 + examples/ADM_get_pending_transfers.cpp | 1 + examples/ADM_get_statistics.cpp | 1 + examples/ADM_get_transfer_priority.cpp | 1 + examples/ADM_in_situ_ops.cpp | 1 + examples/ADM_in_transit_ops.cpp | 1 + examples/ADM_inout.cpp | 1 + examples/ADM_input.cpp | 1 + examples/ADM_link_transfer_to_data_operation.cpp | 1 + examples/ADM_output.cpp | 1 + examples/ADM_set_dataset_information.cpp | 1 + examples/ADM_set_io_resources.cpp | 1 + examples/ADM_set_qos_constraints_pull.cpp | 1 + examples/ADM_set_qos_constraints_push.cpp | 1 + examples/ADM_set_transfer_priority.cpp | 1 + examples/ADM_transfer_dataset.cpp | 1 + 25 files changed, 25 insertions(+) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index 074f4fc5..e8b52071 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -51,6 +51,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_background_flush remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp index d98d21af..527d8747 100644 --- a/examples/ADM_adhoc_context.cpp +++ b/examples/ADM_adhoc_context.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_context remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_context_id.cpp b/examples/ADM_adhoc_context_id.cpp index 4cc255b9..cf6705b0 100644 --- a/examples/ADM_adhoc_context_id.cpp +++ b/examples/ADM_adhoc_context_id.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_context_id remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_distribution.cpp b/examples/ADM_adhoc_distribution.cpp index aacb4911..4379b735 100644 --- a/examples/ADM_adhoc_distribution.cpp +++ b/examples/ADM_adhoc_distribution.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_distribution remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_nodes.cpp b/examples/ADM_adhoc_nodes.cpp index 220f2972..91b36cf5 100644 --- a/examples/ADM_adhoc_nodes.cpp +++ b/examples/ADM_adhoc_nodes.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_nodes remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_adhoc_nodes remote procedure completed successfully\n"); diff --git a/examples/ADM_adhoc_walltime.cpp b/examples/ADM_adhoc_walltime.cpp index 28df9b48..49a38071 100644 --- a/examples/ADM_adhoc_walltime.cpp +++ b/examples/ADM_adhoc_walltime.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_walltime remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_cancel_transfer.cpp b/examples/ADM_cancel_transfer.cpp index 52dfd5d2..f8cee99f 100644 --- a/examples/ADM_cancel_transfer.cpp +++ b/examples/ADM_cancel_transfer.cpp @@ -37,6 +37,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_cancel_transfer remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_connect_data_operation.cpp b/examples/ADM_connect_data_operation.cpp index 5643fb97..26c5118e 100644 --- a/examples/ADM_connect_data_operation.cpp +++ b/examples/ADM_connect_data_operation.cpp @@ -66,6 +66,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_connect_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_define_data_operation.cpp b/examples/ADM_define_data_operation.cpp index a484c1d8..a5b737d7 100644 --- a/examples/ADM_define_data_operation.cpp +++ b/examples/ADM_define_data_operation.cpp @@ -42,6 +42,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_define_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_finalize_data_operation.cpp b/examples/ADM_finalize_data_operation.cpp index e1e75f2e..7ad3f084 100644 --- a/examples/ADM_finalize_data_operation.cpp +++ b/examples/ADM_finalize_data_operation.cpp @@ -37,6 +37,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_finalize_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_get_pending_transfers.cpp b/examples/ADM_get_pending_transfers.cpp index 479e2efb..99fdb848 100644 --- a/examples/ADM_get_pending_transfers.cpp +++ b/examples/ADM_get_pending_transfers.cpp @@ -30,6 +30,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_get_pending_transfers remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_get_statistics.cpp b/examples/ADM_get_statistics.cpp index d15e4471..6d08b25d 100644 --- a/examples/ADM_get_statistics.cpp +++ b/examples/ADM_get_statistics.cpp @@ -44,6 +44,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_get_statistics remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_get_transfer_priority.cpp b/examples/ADM_get_transfer_priority.cpp index 8edf6ba8..a09663a3 100644 --- a/examples/ADM_get_transfer_priority.cpp +++ b/examples/ADM_get_transfer_priority.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_get_transfer_priority remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_in_situ_ops.cpp b/examples/ADM_in_situ_ops.cpp index f258a48e..b870e6ec 100644 --- a/examples/ADM_in_situ_ops.cpp +++ b/examples/ADM_in_situ_ops.cpp @@ -31,6 +31,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_in_situ_ops remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_in_situ_ops remote procedure completed successfully\n"); diff --git a/examples/ADM_in_transit_ops.cpp b/examples/ADM_in_transit_ops.cpp index 06bd3ec2..4eef3e94 100644 --- a/examples/ADM_in_transit_ops.cpp +++ b/examples/ADM_in_transit_ops.cpp @@ -31,6 +31,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_in_transit_ops remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_inout.cpp b/examples/ADM_inout.cpp index 9dbfa118..4b88dcdb 100644 --- a/examples/ADM_inout.cpp +++ b/examples/ADM_inout.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { if(out.ret < 0) { fmt::print(stdout, "ADM_inout remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_inout remote procedure completed successfully\n"); diff --git a/examples/ADM_input.cpp b/examples/ADM_input.cpp index 5be2f5f8..6a319980 100644 --- a/examples/ADM_input.cpp +++ b/examples/ADM_input.cpp @@ -33,6 +33,7 @@ main(int argc, char* argv[]) { if(out.ret < 0) { fmt::print(stdout, "ADM_input remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_input remote procedure completed successfully\n"); diff --git a/examples/ADM_link_transfer_to_data_operation.cpp b/examples/ADM_link_transfer_to_data_operation.cpp index 11ec2587..e939a981 100644 --- a/examples/ADM_link_transfer_to_data_operation.cpp +++ b/examples/ADM_link_transfer_to_data_operation.cpp @@ -71,6 +71,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_link_transfer_to_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_output.cpp b/examples/ADM_output.cpp index f63a2726..b1b3c94a 100644 --- a/examples/ADM_output.cpp +++ b/examples/ADM_output.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { if(out.ret < 0) { fmt::print(stdout, "ADM_output remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_output remote procedure completed successfully\n"); diff --git a/examples/ADM_set_dataset_information.cpp b/examples/ADM_set_dataset_information.cpp index b621f076..78d5dd5f 100644 --- a/examples/ADM_set_dataset_information.cpp +++ b/examples/ADM_set_dataset_information.cpp @@ -47,6 +47,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_dataset_information remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_io_resources.cpp b/examples/ADM_set_io_resources.cpp index 6b8bb7bd..8cbebb1a 100644 --- a/examples/ADM_set_io_resources.cpp +++ b/examples/ADM_set_io_resources.cpp @@ -46,6 +46,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_io_resources remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_qos_constraints_pull.cpp b/examples/ADM_set_qos_constraints_pull.cpp index 60c174b2..eb18fdb0 100644 --- a/examples/ADM_set_qos_constraints_pull.cpp +++ b/examples/ADM_set_qos_constraints_pull.cpp @@ -40,6 +40,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_qos_constraints_pull remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_qos_constraints_push.cpp b/examples/ADM_set_qos_constraints_push.cpp index d9612eaa..e5c2b1f5 100644 --- a/examples/ADM_set_qos_constraints_push.cpp +++ b/examples/ADM_set_qos_constraints_push.cpp @@ -42,6 +42,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_qos_constraints_push remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_transfer_priority.cpp b/examples/ADM_set_transfer_priority.cpp index 2dbfffcc..a82e3c09 100644 --- a/examples/ADM_set_transfer_priority.cpp +++ b/examples/ADM_set_transfer_priority.cpp @@ -44,6 +44,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_transfer_priority remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_transfer_dataset.cpp b/examples/ADM_transfer_dataset.cpp index 0a2064bd..b1dd75f5 100644 --- a/examples/ADM_transfer_dataset.cpp +++ b/examples/ADM_transfer_dataset.cpp @@ -45,6 +45,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_transfer_dataset remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, -- GitLab From 0267f1a47b9611a264b130a28dd924c10a58e283 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 18 May 2022 12:58:04 +0200 Subject: [PATCH 37/76] Type error in ADM_set_qos_constraints_pull fixed --- examples/ADM_set_qos_constraints_pull.cpp | 5 ++--- src/network/rpcs.cpp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/ADM_set_qos_constraints_pull.cpp b/examples/ADM_set_qos_constraints_pull.cpp index eb18fdb0..ee57c9fb 100644 --- a/examples/ADM_set_qos_constraints_pull.cpp +++ b/examples/ADM_set_qos_constraints_pull.cpp @@ -27,7 +27,7 @@ main(int argc, char* argv[]) { try { in.element_id = std::stoi(argv[3]); } catch(const std::exception& e) { - fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); exit(EXIT_FAILURE); } @@ -35,10 +35,9 @@ main(int argc, char* argv[]) { endp.call("ADM_set_qos_constraints_pull", &in, &out); - if(out.ret < 0) { fmt::print( - stdout, + stderr, "ADM_set_qos_constraints_pull remote procedure not completed successfully\n"); exit(EXIT_FAILURE); } else { diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index e9c90b75..d7d0755d 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1048,11 +1048,11 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { out.list = nullptr; if(in.scope == nullptr) { - LOGGER_ERROR("ADM_input(): invalid scope (nullptr)"); + LOGGER_ERROR("ADM_set_qos_constraints_pull(): invalid scope (nullptr)"); } else if(in.element_id < 0) { - LOGGER_ERROR("ADM_input(): invalid element_id (< 0)"); + LOGGER_ERROR("ADM_set_qos_constraints_pull(): invalid element_id (< 0)"); } else { - LOGGER_INFO("ADM_input({}, {})", in.scope, in.element_id); + LOGGER_INFO("ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "ADM_set_qos_constraints_pull scope value is acceptable ({})", -- GitLab From f86a8fd3463b5aed4d11d3ef6a7331e86b52566e Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 6 May 2022 11:47:19 +0200 Subject: [PATCH 38/76] ADM_input RPC added ADM_output RPC added ADM_inout RPC added ADM_adhoc_context RPC added CMakeLists and engine.hpp fixed ADM_adhoc_context_id added Generic call + specific call collision avoided ADM_inout RPC added Update examples/CMakeLists.txt, src/network/engine.hpp, src/network/rpcs.cpp, src/network/rpcs.hpp files --- examples/ADM_adhoc_context.cpp | 41 ++++++ examples/ADM_adhoc_context_id.cpp | 46 +++++++ examples/ADM_inout.cpp | 39 ++++++ examples/ADM_input.cpp | 40 ++++++ examples/ADM_output.cpp | 39 ++++++ examples/CMakeLists.txt | 12 +- src/network/engine.hpp | 42 ++++-- src/network/rpcs.cpp | 219 ++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 40 ++++++ 9 files changed, 502 insertions(+), 16 deletions(-) create mode 100644 examples/ADM_adhoc_context.cpp create mode 100644 examples/ADM_adhoc_context_id.cpp create mode 100644 examples/ADM_inout.cpp create mode 100644 examples/ADM_input.cpp create mode 100644 examples/ADM_output.cpp diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp new file mode 100644 index 00000000..f4745004 --- /dev/null +++ b/examples/ADM_adhoc_context.cpp @@ -0,0 +1,41 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_context \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_context remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_context_in_t in; + in.context = argv[2]; + ADM_adhoc_context_out_t out; + + endp.call("ADM_adhoc_context", &in, &out); + + fmt::print(stdout, "Outputs {} {}", out.ret, out.adhoc_context); + + if(out.ret < 0 || out.adhoc_context < 0) { + fmt::print( + stdout, + "ADM_adhoc_context remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_context remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_adhoc_context_id.cpp b/examples/ADM_adhoc_context_id.cpp new file mode 100644 index 00000000..4cc255b9 --- /dev/null +++ b/examples/ADM_adhoc_context_id.cpp @@ -0,0 +1,46 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_context_id \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_context_id remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_context_id_in_t in; + + try { + in.context_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_context_id_out_t out; + + endp.call("ADM_adhoc_context_id", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_context_id remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_context_id remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_inout.cpp b/examples/ADM_inout.cpp new file mode 100644 index 00000000..9dbfa118 --- /dev/null +++ b/examples/ADM_inout.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_inout \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_inout remote procedure on {} : {} -> {} ...\n", + argv[1], argv[2], argv[3]); + ADM_inout_in_t in; + in.origin = argv[2]; + in.target = argv[3]; + ADM_inout_out_t out; + + endp.call("ADM_inout", &in, &out); + + if(out.ret < 0) { + fmt::print(stdout, + "ADM_inout remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_inout remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_input.cpp b/examples/ADM_input.cpp new file mode 100644 index 00000000..5be2f5f8 --- /dev/null +++ b/examples/ADM_input.cpp @@ -0,0 +1,40 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_input \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_input remote procedure on {} : {} -> {} ...\n", + argv[1], argv[2], argv[3]); + ADM_input_in_t in; + in.origin = argv[2]; + in.target = argv[3]; + ADM_input_out_t out; + + endp.call("ADM_input", &in, &out); + + + if(out.ret < 0) { + fmt::print(stdout, + "ADM_input remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_input remote procedure completed successfully\n"); + } +} diff --git a/examples/ADM_output.cpp b/examples/ADM_output.cpp new file mode 100644 index 00000000..f63a2726 --- /dev/null +++ b/examples/ADM_output.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_output \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_output remote procedure on {} : {} -> {} ...\n", + argv[1], argv[2], argv[3]); + ADM_output_in_t in; + in.origin = argv[2]; + in.target = argv[3]; + ADM_output_out_t out; + + endp.call("ADM_output", &in, &out); + + if(out.ret < 0) { + fmt::print(stdout, + "ADM_output remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_output remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 97ef05ea..b56ee007 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_executable(ping) -target_sources(ping PRIVATE ping.cpp) +set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context) +# list(APPEND examples ADM_adhoc_access ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_walltime) +# list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) + +foreach (example IN LISTS examples) + add_executable(${example}) + target_sources(${example} PRIVATE ${example}.cpp) + target_link_libraries(${example} PUBLIC network_engine fmt::fmt) +endforeach() -target_link_libraries(ping PUBLIC network_engine fmt::fmt) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 54b99dc0..06ae2db5 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -38,17 +38,18 @@ namespace scord::network { namespace detail { -#define REGISTER_RPC(__mid, __m_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) { \ - ::margo_registered_disable_response(__mid, id, HG_TRUE); \ - } \ -} +#define REGISTER_RPC(__mid, __m_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) { \ + ::margo_registered_disable_response(__mid, id, HG_TRUE); \ + } \ + } struct margo_context { @@ -103,7 +104,22 @@ struct engine { register_rpcs() { // register RPCs manually for now - REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ping", void, void, ping, false); + REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ping", void, + void, ping, false); + + 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); } @@ -224,7 +240,7 @@ public: ::HG_Error_to_string(ret))); } - if (output != nullptr) { + if(output != nullptr) { ret = ::margo_get_output(handle, output); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 2d393d64..8b1653bb 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -38,3 +38,222 @@ ping(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ping); + +/** + * Specifes the origin location in a storage tier where input is located, as + * well as the target location where it should be placed in a different storage + * tier. + * + * @param in.origin An origin location for the source dataset. + * @param in.target A target location for the destination dataset. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_input(hg_handle_t h) { + hg_return_t ret; + + ADM_input_in_t in; + ADM_input_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_input"); + LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); + + if(in.origin != nullptr && in.target != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_input not null ({},{})", in.origin, + in.target); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_input null ({},{})", in.origin, + in.target); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_input) + +/** + * Specifies the origin location in a storage tier where output is located, as + * well as the target location where it should be placed in a different storage + * tier. + * + * @param in.origin An origin location for the source dataset. + * @param in.target A target location for the destination dataset. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_output(hg_handle_t h) { + hg_return_t ret; + + ADM_output_in_t in; + ADM_output_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_output"); + LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); + + if(in.origin != nullptr && in.target != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_output not null ({},{})", in.origin, + in.target); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_output null ({},{})", in.origin, + in.target); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_output) + +/** + * Specifies both the input and output locations in a storage tier. This + * combines both ADM_input and ADM_output for user convenience: the input data + * provided by origin is overwritten by the output data generated at target. + * + * @param in.origin An origin location for the source dataset. + * @param in.target A target location for the destination dataset. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_inout(hg_handle_t h) { + hg_return_t ret; + + ADM_inout_in_t in; + ADM_inout_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_inout"); + LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); + + if(in.origin != nullptr && in.target != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_inout not null ({},{})", in.origin, + in.target); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_inout null ({},{})", in.origin, + in.target); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_inout) + +/** + * Specifies the execution_mode an Ad hoc Storage System should use. Valid + options: in_job:shared (run while + * sharing the application’s compute nodes), in_job:dedicated (run using a + subset of the application’s + * compute nodes), separate:new (ask the system to allocate a separate job with + separate runtime and + * number of nodes) and separate:existing (ask the system to reuse an already + running Ad hoc Storage System instance). + * The number of nodes assigned for the Ad hoc Storage System must be specified + with ADM_adhoc_nodes. + * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System + will be controlled with + * ADM_adhoc_walltime. In the separate:existing execution_mode, a valid context + ID must be provided with + * ADM_adhoc_context_id + * + * @param in.context A valid execution_mode describing how the Ad hoc Storage + System should behave. + * @return out.ret Returns if the remote procedure has been completed + successfully or not. + * @return out.adhoc_context_id A number that identifies the context. + + */ +static void +ADM_adhoc_context(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_context_in_t in; + ADM_adhoc_context_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_context"); + LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); + + if(in.context != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_context not null ({})", + in.context); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context null or invalid ({}). Please use", + in.context); + } + + if((strcmp(in.context, "in_job:shared")) == 0 || + (strcmp(in.context, "in_job:dedicated")) == 0 || + (strcmp(in.context, "separate:new")) == 0 || + (strcmp(in.context, "separate:existing")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context value is acceptable ({})", + in.context); + out.adhoc_context = rand(); + } else { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", + in.context); + out.adhoc_context = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index df1302a2..d1a2e54c 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -27,6 +27,10 @@ #include #include +#include +#include +#include + // FIXME: cannot be in a namespace due to Margo limitations // namespace scord::network::rpc { @@ -34,6 +38,42 @@ /// ping DECLARE_MARGO_RPC_HANDLER(ping); +/// ADM_input +MERCURY_GEN_PROC(ADM_input_in_t, + ((hg_const_string_t) (origin))((hg_const_string_t) (target))) + +MERCURY_GEN_PROC(ADM_input_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_input); + +/// ADM_output + +MERCURY_GEN_PROC(ADM_output_in_t, + ((hg_const_string_t) (origin))((hg_const_string_t) (target))) + +MERCURY_GEN_PROC(ADM_output_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_output); + +/// ADM_inout + +MERCURY_GEN_PROC(ADM_inout_in_t, + ((hg_const_string_t) (origin))((hg_const_string_t) (target))) + +MERCURY_GEN_PROC(ADM_inout_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_inout); + +/// ADM_adhoc_context + +MERCURY_GEN_PROC(ADM_adhoc_context_in_t, ((hg_const_string_t) (context))) + +MERCURY_GEN_PROC(ADM_adhoc_context_out_t, + ((int32_t) (ret))((int32_t) (adhoc_context))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context); + + //} // namespace scord::network::rpc #endif // SCORD_NETWORK_RPCS_HPP -- GitLab From acaebf6283b3f4b0575be4515c81cf537fd48a07 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 09:57:38 +0200 Subject: [PATCH 39/76] ADM_adhoc_context_id tested successfully --- examples/ADM_adhoc_context.cpp | 2 -- examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 46 ++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++++ 5 files changed, 60 insertions(+), 3 deletions(-) diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp index f4745004..48bef96b 100644 --- a/examples/ADM_adhoc_context.cpp +++ b/examples/ADM_adhoc_context.cpp @@ -27,8 +27,6 @@ main(int argc, char* argv[]) { endp.call("ADM_adhoc_context", &in, &out); - fmt::print(stdout, "Outputs {} {}", out.ret, out.adhoc_context); - if(out.ret < 0 || out.adhoc_context < 0) { fmt::print( stdout, diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b56ee007..ba96915a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context) +set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) # list(APPEND examples ADM_adhoc_access ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_walltime) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 06ae2db5..288aff6f 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -120,6 +120,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8b1653bb..1ccf65bc 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -257,3 +257,49 @@ ADM_adhoc_context(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context) +/** + * Specifies an existing Ad hoc Storage System to use via its ID. + * + * @param in.context_id A valid context_id for a separate instance of an Ad hoc + * Storage System. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_context_id(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_context_id_in_t in; + ADM_adhoc_context_id_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_context_id"); + LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); + + if(in.context_id >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_context_id not null ({})", + in.context_id); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context_id null or invalid ({}). Please use", + in.context_id); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context_id) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index d1a2e54c..a6abf8bc 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -73,6 +73,15 @@ MERCURY_GEN_PROC(ADM_adhoc_context_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context); +/// ADM_adhoc_context_id + +MERCURY_GEN_PROC(ADM_adhoc_context_id_in_t, ((int32_t) (context_id))) + +MERCURY_GEN_PROC(ADM_adhoc_context_id_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context_id); + + //} // namespace scord::network::rpc -- GitLab From bfdc7f1d470b63c4d703e29b35da1501b52d9caa Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:06:52 +0200 Subject: [PATCH 40/76] ADM_adhoc_nodes implemented and tested successfully --- examples/ADM_adhoc_nodes.cpp | 45 ++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 14 ++++++---- src/network/rpcs.cpp | 53 ++++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 8 ++++++ 5 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 examples/ADM_adhoc_nodes.cpp diff --git a/examples/ADM_adhoc_nodes.cpp b/examples/ADM_adhoc_nodes.cpp new file mode 100644 index 00000000..220f2972 --- /dev/null +++ b/examples/ADM_adhoc_nodes.cpp @@ -0,0 +1,45 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_nodes \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_nodes remote procedure on {} -> node numbers: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_nodes_in_t in; + + try { + in.nodes = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_nodes_out_t out; + + endp.call("ADM_adhoc_nodes", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_nodes remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_adhoc_nodes remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ba96915a..d5e1408d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -# list(APPEND examples ADM_adhoc_access ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_walltime) +list(APPEND examples ADM_adhoc_nodes) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 288aff6f..c8b9095f 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -120,11 +120,14 @@ struct engine { 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); } void @@ -211,12 +214,11 @@ public: } /** - * Deprecated call, used to support Margo directly - * - **/ + * Deprecated call, used to support Margo directly + * + **/ template - [[deprecated("It should be eventually replaced by a generic call")]] - void + [[deprecated("It should be eventually replaced by a generic call")]] void call(const std::string& id, T1 input = nullptr, T2 output = nullptr) { const auto it = m_margo_context->m_rpc_names.find(id); diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 1ccf65bc..16ce8994 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -303,3 +303,56 @@ ADM_adhoc_context_id(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_context_id) +/** + * Specifies the number of nodes for the Ad hoc Storage System. If the + * ADM_adhoc_execution_mode is shared, the number cannot exceed the number of + * allocated nodes within the compute job. If the ADM_adhoc_execution_mode is + * dedicated, the number of nodes is not restricted. + * + * @param in.number_of_nodes The desired number_of_nodes. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_nodes(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_nodes_in_t in; + ADM_adhoc_nodes_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_nodes"); + LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); + + if(in.nodes > 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_nodes not null ({})", + in.nodes); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_adhoc_nodes null ({})", in.nodes); + } + + /*Specifies the number of nodes for the Ad hoc Storage System. If the + ADM_adhoc_execution_mode is shared, the number cannot exceed the number of + allocated nodes within the compute job. If the ADM_adhoc_execution_mode is + dedicated, the number of nodes is not restricted. Should this be checked + now? */ + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index a6abf8bc..49274cc7 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -81,6 +81,14 @@ MERCURY_GEN_PROC(ADM_adhoc_context_id_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_context_id); +/// ADM_adhoc_nodes + +MERCURY_GEN_PROC(ADM_adhoc_nodes_in_t, ((int32_t) (nodes))) + +MERCURY_GEN_PROC(ADM_adhoc_nodes_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) + //} // namespace scord::network::rpc -- GitLab From a14cda7c6b321e393dd63cde2181ff586eddf5e8 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:14:44 +0200 Subject: [PATCH 41/76] ADM_adhoc_walltime implemented and tested successfully --- examples/ADM_adhoc_walltime.cpp | 46 +++++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 46 +++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 7 +++++ 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_walltime.cpp diff --git a/examples/ADM_adhoc_walltime.cpp b/examples/ADM_adhoc_walltime.cpp new file mode 100644 index 00000000..28df9b48 --- /dev/null +++ b/examples/ADM_adhoc_walltime.cpp @@ -0,0 +1,46 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_walltime \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_walltime remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_walltime_in_t in; + + try { + in.walltime = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_walltime_out_t out; + + endp.call("ADM_adhoc_walltime", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_walltime remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_walltime remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d5e1408d..44b513f5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes) +list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index c8b9095f..0dffbc59 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -128,6 +128,10 @@ struct engine { 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); } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 16ce8994..8af1a0f1 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -355,4 +355,50 @@ ADM_adhoc_nodes(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) +/** + * Specifies for how long the ad hoc storage system should run before should + * down. Only relevant in the context of the ADM_adhoc_context function. + * + * @param in.walltime The desired walltime in minutes. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_walltime(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_walltime_in_t in; + ADM_adhoc_walltime_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_walltime"); + LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); + + if(in.walltime >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_walltime not null ({})", + in.walltime); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_walltime null or invalid ({}). Please use", + in.walltime); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_walltime) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 49274cc7..f466ee23 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -89,6 +89,13 @@ MERCURY_GEN_PROC(ADM_adhoc_nodes_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_nodes) +/// ADM_adhoc_walltime + +MERCURY_GEN_PROC(ADM_adhoc_walltime_in_t, ((int32_t) (walltime))) + +MERCURY_GEN_PROC(ADM_adhoc_walltime_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_walltime); //} // namespace scord::network::rpc -- GitLab From 4deb41fa2811db5fa100d9b55540f5b56209ef1f Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:25:23 +0200 Subject: [PATCH 42/76] ADM_adhoc_access implemented and tested successfully --- examples/ADM_adhoc_access.cpp | 40 ++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 ++++ src/network/rpcs.cpp | 62 +++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_access.cpp diff --git a/examples/ADM_adhoc_access.cpp b/examples/ADM_adhoc_access.cpp new file mode 100644 index 00000000..df18e95d --- /dev/null +++ b/examples/ADM_adhoc_access.cpp @@ -0,0 +1,40 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_adhoc_access \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_access remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_access_in_t in; + in.access = argv[2]; + ADM_adhoc_access_out_t out; + + endp.call("ADM_adhoc_access", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_access remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_access remote procedure completed successfully\n"); + } +} + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 44b513f5..bf3b1b2f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime) +list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 0dffbc59..5742a982 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -132,6 +132,12 @@ struct engine { 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); + + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8af1a0f1..65e842af 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -401,4 +401,66 @@ ADM_adhoc_walltime(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_walltime) +/** + * Specifies access to the ad hoc storage system: write-only, read-only, + * read-write. Cannot be used when using an existing Ad hoc Storage System + * instance. + * + * @param in.access The desired access method + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_access(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_access_in_t in; + ADM_adhoc_access_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_access"); + LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); + + if(in.access != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_access not null ({})", + in.access); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access null or invalid ({}). Please use", + in.access); + } + + if((strcmp(in.access, "write-only")) == 0 || + (strcmp(in.access, "read-only")) == 0 || + (strcmp(in.access, "read-write") == 0)) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access value is acceptable ({})", + in.access); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", + in.access); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_access) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index f466ee23..f2cb5405 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -98,6 +98,15 @@ MERCURY_GEN_PROC(ADM_adhoc_walltime_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_walltime); +/// ADM_adhoc_access + +MERCURY_GEN_PROC(ADM_adhoc_access_in_t, ((hg_const_string_t) (access))) + +MERCURY_GEN_PROC(ADM_adhoc_access_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_access); + + //} // namespace scord::network::rpc #endif // SCORD_NETWORK_RPCS_HPP -- GitLab From 124af20f32447e99c9469cec32a1cb4beb34809e Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:45:20 +0200 Subject: [PATCH 43/76] ADM_adhoc_distribution implemented and tested successfully --- examples/ADM_adhoc_distribution.cpp | 40 ++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 48 +++++++++++++++++++++++++++++ src/network/rpcs.hpp | 10 ++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_distribution.cpp diff --git a/examples/ADM_adhoc_distribution.cpp b/examples/ADM_adhoc_distribution.cpp new file mode 100644 index 00000000..aacb4911 --- /dev/null +++ b/examples/ADM_adhoc_distribution.cpp @@ -0,0 +1,40 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_adhoc_distribution \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_distribution remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_distribution_in_t in; + in.data_distribution = argv[2]; + ADM_adhoc_distribution_out_t out; + + endp.call("ADM_adhoc_distribution", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_distribution remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_distribution remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bf3b1b2f..23d0480c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ ################################################################################ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access) +list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) # list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 5742a982..2fa1ce54 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -137,6 +137,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 65e842af..0d1625ef 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -463,4 +463,52 @@ ADM_adhoc_access(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_access) +/** + * Specifies the data distribution within the ad hoc storage system, e.g., + * wide-striping, local, local-data-global-metadata. + * + * @param in.data_distribution The desired data distribution + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_distribution(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_distribution_in_t in; + ADM_adhoc_distribution_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_distribution"); + LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", + in.data_distribution); + + if(in.data_distribution != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_adhoc_distribution not null ({})", + in.data_distribution); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_distribution null or invalid ({}). Please use", + in.data_distribution); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_distribution) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index f2cb5405..cff5077d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -106,6 +106,16 @@ MERCURY_GEN_PROC(ADM_adhoc_access_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_access); +/// ADM_adhoc_distribution + +MERCURY_GEN_PROC(ADM_adhoc_distribution_in_t, + ((hg_const_string_t) (data_distribution))) + +MERCURY_GEN_PROC(ADM_adhoc_distribution_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_distribution); + + //} // namespace scord::network::rpc -- GitLab From 463e427c094455271477bb5b067acc58136f8b11 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 10:59:41 +0200 Subject: [PATCH 44/76] ADM_adhoc_background_flush implemented and tested successfully --- examples/ADM_adhoc_background_flush.cpp | 57 +++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 47 ++++++++++++++++++++ src/network/rpcs.hpp | 8 ++++ 5 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_adhoc_background_flush.cpp diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp new file mode 100644 index 00000000..b7774a06 --- /dev/null +++ b/examples/ADM_adhoc_background_flush.cpp @@ -0,0 +1,57 @@ +#include +#include + +int +String2Convert(std::string var) { + if(var == "true" || var == "TRUE") { + return 0; + } else if(var == "false" || var == "FALSE") { + return 1; + } else { + return -1; + } +} + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_adhoc_background_flush \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n", + argv[1], argv[2]); + ADM_adhoc_background_flush_in_t in; + + try { + in.b_flush = String2Convert(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_adhoc_background_flush_out_t out; + + endp.call("ADM_adhoc_background_flush", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_adhoc_background_flush remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_adhoc_background_flush remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 23d0480c..9963078a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -# list(APPEND examples ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops) +list(APPEND examples ADM_adhoc_background_flush) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 2fa1ce54..a222ae9b 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -140,6 +140,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 0d1625ef..b4e82032 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -510,5 +510,52 @@ ADM_adhoc_distribution(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_distribution) +/** + * Specifies if data in the output location should be moved to the shared + * backend storage system in the background (default false). + * + * @param in.b_flush A boolean enabling or disabling the option. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_adhoc_background_flush(hg_handle_t h) { + hg_return_t ret; + + ADM_adhoc_background_flush_in_t in; + ADM_adhoc_background_flush_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_adhoc_background_flush"); + LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); + + if(in.b_flush == 0 || in.b_flush == 1) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_background_flush not null ({})", + in.b_flush); + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush null ({})", + in.b_flush); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index cff5077d..573722dc 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -115,6 +115,14 @@ MERCURY_GEN_PROC(ADM_adhoc_distribution_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_distribution); +/// ADM_adhoc_background_flush + +MERCURY_GEN_PROC(ADM_adhoc_background_flush_in_t, ((hg_bool_t) (b_flush))) + +MERCURY_GEN_PROC(ADM_adhoc_background_flush_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush); + //} // namespace scord::network::rpc -- GitLab From 59b61a2a7f833928d39eb643dead48623103cbd8 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 11:07:10 +0200 Subject: [PATCH 45/76] ADM_in_situ_ops implemented and tested successfully --- examples/ADM_in_situ_ops.cpp | 38 +++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 +++++ src/network/rpcs.cpp | 44 ++++++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 7 ++++++ 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_in_situ_ops.cpp diff --git a/examples/ADM_in_situ_ops.cpp b/examples/ADM_in_situ_ops.cpp new file mode 100644 index 00000000..f258a48e --- /dev/null +++ b/examples/ADM_in_situ_ops.cpp @@ -0,0 +1,38 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_in_situ_ops \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_in_situ_ops remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_in_situ_ops_in_t in; + in.in_situ = argv[2]; + ADM_in_situ_ops_out_t out; + + endp.call("ADM_in_situ_ops", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_in_situ_ops remote procedure not completed successfully\n"); + } else { + fmt::print(stdout, + "ADM_in_situ_ops remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9963078a..71ab6c5f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush) +list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index a222ae9b..61d20ed4 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -144,6 +144,12 @@ struct engine { 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); + + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index b4e82032..671d26c3 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -556,6 +556,50 @@ ADM_adhoc_background_flush(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush) +/** + * In situ data operations specified in a given configuration file. + * + * @param in.in_situ A path to the configuration file. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_in_situ_ops(hg_handle_t h) { + hg_return_t ret; + + ADM_in_situ_ops_in_t in; + ADM_in_situ_ops_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_in_situ_ops"); + LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); + + if(in.in_situ != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_in_situ_ops not null ({})", + in.in_situ); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_in_situ_ops null or invalid ({}). Please use", + in.in_situ); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_in_situ_ops) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 573722dc..208d79ab 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -123,6 +123,13 @@ MERCURY_GEN_PROC(ADM_adhoc_background_flush_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_adhoc_background_flush); +/// ADM_in_situ_ops + +MERCURY_GEN_PROC(ADM_in_situ_ops_in_t, ((hg_const_string_t) (in_situ))) + +MERCURY_GEN_PROC(ADM_in_situ_ops_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_in_situ_ops); //} // namespace scord::network::rpc -- GitLab From c8e43f20674361ef1b01037795c71f719380038b Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 11:14:55 +0200 Subject: [PATCH 46/76] ADM_in_transit_ops implemented and tested successfully --- examples/ADM_in_transit_ops.cpp | 39 ++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++- src/network/rpcs.cpp | 45 +++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++++ 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 examples/ADM_in_transit_ops.cpp diff --git a/examples/ADM_in_transit_ops.cpp b/examples/ADM_in_transit_ops.cpp new file mode 100644 index 00000000..06bd3ec2 --- /dev/null +++ b/examples/ADM_in_transit_ops.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_in_transit_ops \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_in_transit_ops remote procedure on {} -> access method: {} ...\n", + argv[1], argv[2]); + ADM_in_transit_ops_in_t in; + in.in_transit = argv[2]; + ADM_in_transit_ops_out_t out; + + endp.call("ADM_in_transit_ops", &in, &out); + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_in_transit_ops remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_in_transit_ops remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71ab6c5f..56ddaf99 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops) +list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 61d20ed4..e86ce717 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -149,7 +149,9 @@ struct engine { "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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 671d26c3..51755d5d 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -601,5 +601,50 @@ ADM_in_situ_ops(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_in_situ_ops) +/** + * In transit data operations specified in a given configuration file. + * + * @param in.in_transit A path to the configuration file. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_in_transit_ops(hg_handle_t h) { + hg_return_t ret; + + ADM_in_transit_ops_in_t in; + ADM_in_transit_ops_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_in_transit_ops"); + LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); + + if(in.in_transit != nullptr) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_in_transit_ops not null ({})", + in.in_transit); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_in_transit_ops null or invalid ({}). Please use", + in.in_transit); + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_in_transit_ops) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 208d79ab..249a0007 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -131,6 +131,15 @@ MERCURY_GEN_PROC(ADM_in_situ_ops_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_in_situ_ops); +/// ADM_in_transit_ops + +MERCURY_GEN_PROC(ADM_in_transit_ops_in_t, ((hg_const_string_t) (in_transit))) + +MERCURY_GEN_PROC(ADM_in_transit_ops_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_in_transit_ops); + + //} // namespace scord::network::rpc -- GitLab From 996c9247f25aba5ec453ae941b79f1074985a409 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 11:51:45 +0200 Subject: [PATCH 47/76] ADM_transfer_dataset implemented and tested successfully --- examples/ADM_transfer_dataset.cpp | 53 +++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 70 +++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 13 ++++++ 5 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_transfer_dataset.cpp diff --git a/examples/ADM_transfer_dataset.cpp b/examples/ADM_transfer_dataset.cpp new file mode 100644 index 00000000..0a2064bd --- /dev/null +++ b/examples/ADM_transfer_dataset.cpp @@ -0,0 +1,53 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 7) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_transfer_dataset " + " \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_transfer_dataset remote procedure on {} : {} -> {} using " + " qos constraints {}, distribution {} and job id {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); + ADM_transfer_dataset_in_t in; + in.source = argv[2]; + in.destination = argv[3]; + in.qos_constraints = argv[4]; + in.distribution = argv[5]; + try { + in.job_id = std::stoi(argv[6]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_transfer_dataset_out_t out; + + endp.call("ADM_transfer_dataset", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_transfer_dataset remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_transfer_dataset remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 56ddaf99..39a927cb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops) +list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index e86ce717..a44e62ec 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -153,6 +153,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 51755d5d..afc2672e 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -647,4 +647,74 @@ ADM_in_transit_ops(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_in_transit_ops) +/** + * Transfers the dataset identified by the source_name to the storage tier + * defined by destination_name, and apply the provided constraints during the + * transfer. This function returns a handle that can be used to track the + * operation (i.e., get statistics, or status). + * + * @param in.source A source_location identifying the source dataset/s in the + * source storage tier. + * @param in.destination A destination_location identifying the destination + * dataset/s in its desired location in a storage tier. + * @param in.qos_constraints A list of qos_constraints that must be applied to + * the transfer. These may not exceed the global ones set at node, application, + * or resource level (see Section 3.4). + * @param in.distribution A distribution strategy for data (e.g. one-to-one, + * one-to-many, many-to-many) + * @param in.job_id A job_id identifying the originating job. + * @param out.transfer_handle A transfer_handle allowing clients to interact + * with the transfer (e.g. wait for its completion, query its status, cancel it, + * etc. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_transfer_dataset(hg_handle_t h) { + hg_return_t ret; + + ADM_transfer_dataset_in_t in; + ADM_transfer_dataset_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_transfer_dataset"); + LOGGER_INFO("remote_procedure::ADM_transfer_dataset({},{},{},{},{})", + in.source, in.destination, in.qos_constraints, in.distribution, + in.job_id); + + if(in.source != nullptr && in.destination != nullptr && + in.qos_constraints != nullptr && in.distribution != nullptr && + in.job_id >= 0) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset not null ({},{},{},{},{})", + in.source, in.destination, in.qos_constraints, in.distribution, + in.job_id); + out.transfer_handle = "ok"; + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset null ({},{},{},{},{})", + in.source, in.destination, in.qos_constraints, in.distribution, + in.job_id); + out.transfer_handle = "fail"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_transfer_dataset) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 249a0007..14052a54 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -140,6 +140,19 @@ MERCURY_GEN_PROC(ADM_in_transit_ops_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_in_transit_ops); +/// ADM_transfer_dataset + +MERCURY_GEN_PROC( + ADM_transfer_dataset_in_t, + ((hg_const_string_t) (source))((hg_const_string_t) (destination))( + (hg_const_string_t) (qos_constraints))( + (hg_const_string_t) (distribution))((int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_transfer_dataset_out_t, + ((int32_t) (ret))((hg_const_string_t) (transfer_handle))) + +DECLARE_MARGO_RPC_HANDLER(ADM_transfer_dataset); + //} // namespace scord::network::rpc -- GitLab From 623da1748fdda1e9084e0512ad7515a2186c5667 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:00:59 +0200 Subject: [PATCH 48/76] ADM_set_dataset_information implemented and tested successfully --- examples/ADM_set_dataset_information.cpp | 55 ++++++++++++++++++++++++ examples/CMakeLists.txt | 1 + src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 53 +++++++++++++++++++++++ src/network/rpcs.hpp | 12 ++++++ 5 files changed, 125 insertions(+) create mode 100644 examples/ADM_set_dataset_information.cpp diff --git a/examples/ADM_set_dataset_information.cpp b/examples/ADM_set_dataset_information.cpp new file mode 100644 index 00000000..b621f076 --- /dev/null +++ b/examples/ADM_set_dataset_information.cpp @@ -0,0 +1,55 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 5) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_dataset_information \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_dataset_information remote procedure on {} with resource id {}, info {} and" + " job id {} ...\n", + argv[1], argv[2], argv[3], argv[4]); + ADM_set_dataset_information_in_t in; + try { + in.resource_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.info = argv[3]; + try { + in.job_id = std::stoi(argv[4]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_set_dataset_information_out_t out; + + endp.call("ADM_set_dataset_information", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_dataset_information remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_dataset_information remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 39a927cb..6a7abebd 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,6 +25,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) +list(APPEND examples ADM_set_dataset_information) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index a44e62ec..58b568a7 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -157,6 +157,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index afc2672e..66ebbcde 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -716,5 +716,58 @@ ADM_transfer_dataset(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_transfer_dataset) +/** + * Sets information for the dataset identified by resource_id. + * + * @param in.resource_id A resource_id identifying the dataset of interest. + * @param in.info An opaque inf o argument containing information about the + * dataset (e.g. its lifespan, access methods, intended usage, etc.). + * @param in.job_id A job_id identifying the originating job. + * @param out.status A status code determining whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_dataset_information(hg_handle_t h) { + hg_return_t ret; + + ADM_set_dataset_information_in_t in; + ADM_set_dataset_information_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_dataset_information"); + LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", + in.resource_id, in.info, in.job_id); + + if(in.resource_id >= 0 && in.info != nullptr && in.job_id >= 0) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset not null ({},{},{})", + in.resource_id, in.info, in.job_id); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", + in.resource_id, in.info, in.job_id); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_dataset_information) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 14052a54..4b96b7ea 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -153,6 +153,18 @@ MERCURY_GEN_PROC(ADM_transfer_dataset_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_transfer_dataset); +/// ADM_set_dataset_information + +MERCURY_GEN_PROC(ADM_set_dataset_information_in_t, + ((int32_t) (resource_id))((hg_const_string_t) (info))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_set_dataset_information_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_dataset_information); + + //} // namespace scord::network::rpc -- GitLab From 63fbb6212f502a702e57513fe1d810072507c911 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:12:43 +0200 Subject: [PATCH 49/76] ADM_set_io_resources implemented and tested successfully --- examples/ADM_set_io_resources.cpp | 54 +++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 54 +++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 11 +++++++ 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_set_io_resources.cpp diff --git a/examples/ADM_set_io_resources.cpp b/examples/ADM_set_io_resources.cpp new file mode 100644 index 00000000..6b8bb7bd --- /dev/null +++ b/examples/ADM_set_io_resources.cpp @@ -0,0 +1,54 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 5) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_io_resources \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_io_resources remote procedure on {} with tier id {}, resources {} and" + " job id {} ...\n", + argv[1], argv[2], argv[3], argv[4]); + ADM_set_io_resources_in_t in; + try { + in.tier_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.resources = argv[3]; + try { + in.job_id = std::stoi(argv[4]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_set_io_resources_out_t out; + + endp.call("ADM_set_io_resources", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_io_resources remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_io_resources remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6a7abebd..f1d1ecef 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,7 +25,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) -list(APPEND examples ADM_set_dataset_information) +list(APPEND examples ADM_set_dataset_information ADM_set_io_resources) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 58b568a7..995373cb 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -161,6 +161,10 @@ struct engine { "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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 66ebbcde..7897d4ef 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -769,5 +769,59 @@ ADM_set_dataset_information(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_dataset_information) +/** + * Changes the I/O resources used by a storage tier, typically an Ad hoc Storage + * System. + * + * @param in.tier_id A tier_id specifying the target storage tier. + * @param in.resources An opaque resources argument containing information about + * the I/O resources to modify (e.g. number of I/O nodes.). + * @param in.job_id A job_id identifying the originating job. + * @param out.status A status code determining whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_io_resources(hg_handle_t h) { + hg_return_t ret; + + ADM_set_io_resources_in_t in; + ADM_set_io_resources_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_io_resources"); + LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, + in.resources, in.job_id); + + if(in.tier_id >= 0 && in.resources != nullptr && in.job_id >= 0) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_transfer_dataset not null ({},{},{})", + in.tier_id, in.resources, in.job_id); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", + in.tier_id, in.resources, in.job_id); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_io_resources) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 4b96b7ea..7a26c3cd 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -164,6 +164,17 @@ MERCURY_GEN_PROC(ADM_set_dataset_information_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_dataset_information); +/// ADM_set_io_resources + +MERCURY_GEN_PROC(ADM_set_io_resources_in_t, + ((int32_t) (tier_id))((hg_const_string_t) (resources))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_set_io_resources_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_io_resources); + //} // namespace scord::network::rpc -- GitLab From 1264da781ce776498dd81900f90f4a66526b0242 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:27:49 +0200 Subject: [PATCH 50/76] ADM_get_transfer_priority implemented and tested successfully --- examples/ADM_get_transfer_priority.cpp | 46 ++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 3 ++ src/network/rpcs.cpp | 48 ++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_get_transfer_priority.cpp diff --git a/examples/ADM_get_transfer_priority.cpp b/examples/ADM_get_transfer_priority.cpp new file mode 100644 index 00000000..8edf6ba8 --- /dev/null +++ b/examples/ADM_get_transfer_priority.cpp @@ -0,0 +1,46 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_get_transfer_priority \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_get_transfer_priority remote procedure on {} with transfer id {} ...\n", + argv[1], argv[2]); + ADM_get_transfer_priority_in_t in; + try { + in.transfer_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_get_transfer_priority_out_t out; + + endp.call("ADM_get_transfer_priority", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_get_transfer_priority remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_get_transfer_priority remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f1d1ecef..cfe0dda4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,7 +25,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) -list(APPEND examples ADM_set_dataset_information ADM_set_io_resources) +list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 995373cb..bc5c139e 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -165,6 +165,9 @@ struct engine { "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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 7897d4ef..86221574 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -824,4 +824,52 @@ ADM_set_io_resources(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_io_resources) +/** + * Returns the priority of the pending transfer identified by transfer_id. + * + * @param in.transfer_id A tier_id specifying the target storage tier. + * @param out.priority The priority of the pending transfer or an error code if + * it didn’t exist or is no longer pending. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_get_transfer_priority(hg_handle_t h) { + hg_return_t ret; + + ADM_get_transfer_priority_in_t in; + ADM_get_transfer_priority_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_get_transfer_priority"); + LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", + in.transfer_id); + + if(in.transfer_id >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_get_transfer_priority not null ({})", + in.transfer_id); + out.priority = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_get_transfer_priority null ({})", + in.transfer_id); + out.priority = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_get_transfer_priority) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 7a26c3cd..baeef29d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -175,6 +175,15 @@ MERCURY_GEN_PROC(ADM_set_io_resources_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_io_resources); +/// ADM_get_transfer_priority + +MERCURY_GEN_PROC(ADM_get_transfer_priority_in_t, ((int32_t) (transfer_id))) + +MERCURY_GEN_PROC(ADM_get_transfer_priority_out_t, + ((int32_t) (ret))((int32_t) (priority))) + +DECLARE_MARGO_RPC_HANDLER(ADM_get_transfer_priority); + //} // namespace scord::network::rpc -- GitLab From 26b553a301e5049ffe62d85c99b9a765672be00d Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:34:24 +0200 Subject: [PATCH 51/76] ADM_set_transfer_priority implemented and tested successfully --- examples/ADM_set_transfer_priority.cpp | 52 +++++++++++++++++++++++++ examples/CMakeLists.txt | 1 + src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 53 ++++++++++++++++++++++++++ src/network/rpcs.hpp | 9 +++++ 5 files changed, 119 insertions(+) create mode 100644 examples/ADM_set_transfer_priority.cpp diff --git a/examples/ADM_set_transfer_priority.cpp b/examples/ADM_set_transfer_priority.cpp new file mode 100644 index 00000000..2dbfffcc --- /dev/null +++ b/examples/ADM_set_transfer_priority.cpp @@ -0,0 +1,52 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_transfer_priority \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_transfer_priority remote procedure on {} with transfer id {} and number of positions {}...\n", + argv[1], argv[2], argv[3]); + ADM_set_transfer_priority_in_t in; + try { + in.transfer_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.n_positions = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_set_transfer_priority_out_t out; + + endp.call("ADM_set_transfer_priority", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_transfer_priority remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_transfer_priority remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cfe0dda4..5b68ecb3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,6 +26,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_con list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) +list(APPEND examples ADM_set_transfer_priority) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index bc5c139e..b69f8581 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -168,6 +168,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 86221574..7770cdd5 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -873,3 +873,56 @@ ADM_get_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_get_transfer_priority) +/** + * Moves the operation identified by transf er_id up or down by n positions in + * its scheduling queue. + * + * @param in.transfer_id A transf er_id identifying a pending transfer. + * @param in.n_positions A positive or negative number n for the number of + * positions the transfer should go up or down in its scheduling queue. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_transfer_priority(hg_handle_t h) { + hg_return_t ret; + + ADM_set_transfer_priority_in_t in; + ADM_set_transfer_priority_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_transfer_priority"); + LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", + in.transfer_id, in.n_positions); + + if(in.transfer_id >= 0 && (in.n_positions >= 0 || in.n_positions < 0)) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_set_transfer_priority not null ({}, {})", + in.transfer_id, in.n_positions); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_set_transfer_priority null ({}, {})", + in.transfer_id, in.n_positions); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_transfer_priority) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index baeef29d..08f1d6d7 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -184,6 +184,15 @@ MERCURY_GEN_PROC(ADM_get_transfer_priority_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_get_transfer_priority); +/// ADM_set_transfer_priority + +MERCURY_GEN_PROC(ADM_set_transfer_priority_in_t, + ((int32_t) (transfer_id))((int32_t) (n_positions))) + +MERCURY_GEN_PROC(ADM_set_transfer_priority_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_transfer_priority); //} // namespace scord::network::rpc -- GitLab From 1aa0f2dbdeae8249b000c130f2955faf6a7e5971 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:46:26 +0200 Subject: [PATCH 52/76] ADM_cancel_transfer implemented and tested successfully --- examples/ADM_cancel_transfer.cpp | 45 ++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 +++- src/network/rpcs.cpp | 51 ++++++++++++++++++++++++++++++++ src/network/rpcs.hpp | 10 +++++++ 5 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 examples/ADM_cancel_transfer.cpp diff --git a/examples/ADM_cancel_transfer.cpp b/examples/ADM_cancel_transfer.cpp new file mode 100644 index 00000000..52dfd5d2 --- /dev/null +++ b/examples/ADM_cancel_transfer.cpp @@ -0,0 +1,45 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, + "Usage: ADM_cancel_transfer \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_cancel_transfer remote procedure on {} with transfer id {} ...\n", + argv[1], argv[2]); + ADM_cancel_transfer_in_t in; + try { + in.transfer_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_cancel_transfer_out_t out; + + endp.call("ADM_cancel_transfer", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_cancel_transfer remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_cancel_transfer remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5b68ecb3..432aa04a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,7 +26,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_con list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) -list(APPEND examples ADM_set_transfer_priority) +list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index b69f8581..781b8778 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -172,7 +172,11 @@ struct engine { 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); + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 7770cdd5..cc85a8e1 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -926,3 +926,54 @@ ADM_set_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_transfer_priority) +/** + * Moves the operation identified by transf er_id up or down by n positions in + * its scheduling queue. + * + * @param in.transfer_id A transf er_id identifying a pending transfer. + * @param in.n_positions A positive or negative number n for the number of + * positions the transfer should go up or down in its scheduling queue. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_cancel_transfer(hg_handle_t h) { + hg_return_t ret; + + ADM_cancel_transfer_in_t in; + ADM_cancel_transfer_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_cancel_transfer"); + LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); + + if(in.transfer_id >= 0) { + out.ret = 0; + LOGGER_INFO("remote_procedure::ADM_cancel_transfer not null ({})", + in.transfer_id); + out.status = 0; + } else { + out.ret = -1; + LOGGER_INFO("remote_procedure::ADM_cancel_transfer null ({})", + in.transfer_id); + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_cancel_transfer) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 08f1d6d7..79ba01e4 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -194,6 +194,16 @@ MERCURY_GEN_PROC(ADM_set_transfer_priority_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_transfer_priority); +/// ADM_cancel_transfer + +MERCURY_GEN_PROC(ADM_cancel_transfer_in_t, ((int32_t) (transfer_id))) + +MERCURY_GEN_PROC(ADM_cancel_transfer_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_cancel_transfer); + + //} // namespace scord::network::rpc -- GitLab From a782dc496d32425dc1c1954ab592485e01d3c558 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 12:58:41 +0200 Subject: [PATCH 53/76] ADM_get_pending_transfers implemented and tested successfully --- examples/ADM_get_pending_transfers.cpp | 38 +++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 +++ src/network/rpcs.cpp | 39 ++++++++++++++++++++++++++ src/network/rpcs.hpp | 8 ++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_get_pending_transfers.cpp diff --git a/examples/ADM_get_pending_transfers.cpp b/examples/ADM_get_pending_transfers.cpp new file mode 100644 index 00000000..479e2efb --- /dev/null +++ b/examples/ADM_get_pending_transfers.cpp @@ -0,0 +1,38 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 2) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "Usage: ADM_get_pending_transfers \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print(stdout, + "Calling ADM_get_pending_transfers remote procedure on {} ...\n", + argv[1]); + ADM_get_pending_transfers_in_t in; + in.value = NULL; + ADM_get_pending_transfers_out_t out; + + endp.call("ADM_get_pending_transfers", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_get_pending_transfers remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_get_pending_transfers remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 432aa04a..633e23e1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,7 +26,7 @@ set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_con list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) -list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer) +list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 781b8778..b936b999 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -177,6 +177,10 @@ struct engine { "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); + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index cc85a8e1..1ee0009c 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -977,3 +977,42 @@ ADM_cancel_transfer(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_cancel_transfer) +/** + * Returns a list of pending transfers. Each operation will include a transf + * er_id as well as information about the involved resources and tiers. + * + * @param out.pending_transfers A list of pending_transfers. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_get_pending_transfers(hg_handle_t h) { + hg_return_t ret; + + ADM_get_pending_transfers_in_t in; + ADM_get_pending_transfers_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_get_pending_transfers"); + LOGGER_INFO("remote_procedure::ADM_get_pending_transfers"); + + out.ret = 0; + out.pending_transfers = "list"; + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_get_pending_transfers) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 79ba01e4..7763f80a 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -203,6 +203,14 @@ MERCURY_GEN_PROC(ADM_cancel_transfer_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_cancel_transfer); +/// ADM_get_pending_transfers + +MERCURY_GEN_PROC(ADM_get_pending_transfers_in_t, ((hg_const_string_t) (value))) + +MERCURY_GEN_PROC(ADM_get_pending_transfers_out_t, + ((int32_t) (ret))((hg_const_string_t) (pending_transfers))) + +DECLARE_MARGO_RPC_HANDLER(ADM_get_pending_transfers); //} // namespace scord::network::rpc -- GitLab From 69b648d0200356dbb7044c123162549efe125424 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 10 May 2022 13:15:16 +0200 Subject: [PATCH 54/76] ADM_set_qos_constraints_push implemented and tested successfully --- examples/ADM_set_qos_constraints_push.cpp | 50 ++++++++++++++++ examples/CMakeLists.txt | 1 + src/network/engine.hpp | 5 ++ src/network/rpcs.cpp | 70 +++++++++++++++++++++++ src/network/rpcs.hpp | 13 +++++ 5 files changed, 139 insertions(+) create mode 100644 examples/ADM_set_qos_constraints_push.cpp diff --git a/examples/ADM_set_qos_constraints_push.cpp b/examples/ADM_set_qos_constraints_push.cpp new file mode 100644 index 00000000..d9612eaa --- /dev/null +++ b/examples/ADM_set_qos_constraints_push.cpp @@ -0,0 +1,50 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 6) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_qos_constraints_push \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_qos_constraints_push remote procedure on {} with scope {}, QoS class {}, element id {} and class value {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5]); + ADM_set_qos_constraints_push_in_t in; + in.scope = argv[2]; + in.qos_class = argv[3]; + try { + in.element_id = std::stoi(argv[4]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.class_value = argv[4]; + + ADM_set_qos_constraints_push_out_t out; + + endp.call("ADM_set_qos_constraints_push", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_qos_constraints_push remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_qos_constraints_push remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 633e23e1..71838cef 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -27,6 +27,7 @@ list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adh list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers) +list(APPEND examples ADM_set_qos_constraints_push) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index b936b999..806103b9 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -181,6 +181,11 @@ struct engine { "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_push", ADM_set_qos_constraints_push_in_t, + ADM_set_qos_constraints_push_out_t, ADM_set_qos_constraints_push, true); + + } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 1ee0009c..f63c9d13 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1015,4 +1015,74 @@ ADM_get_pending_transfers(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_get_pending_transfers) +/** + * Registers a QoS constraint defined by class, scope, and value for the element + * identified by id. + * + * @param in.scope The scope it should be applied to: dataset, node, or job. + * @param in.qos_class A QoS class (e.g. "badwidth", "iops", etc.). + * @param in.element_id A valid id for the element that should be constrained, + * i.e. a resource ID, a node hostname, or a Job ID. + * @param in.class_value An appropriate value for the selected class. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_qos_constraints_push(hg_handle_t h) { + hg_return_t ret; + + ADM_set_qos_constraints_push_in_t in; + ADM_set_qos_constraints_push_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_qos_constraints_push"); + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", + in.scope, in.qos_class, in.element_id, in.class_value); + + if(in.scope != nullptr && in.qos_class != nullptr && in.element_id >= 0 && + in.class_value != nullptr){ + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", + in.scope, in.qos_class, in.element_id, in.class_value); + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.status = 0; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.status = -1; + } + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push null ({}, {}, {}, {})", + in.scope, in.qos_class, in.element_id, in.class_value); + out.ret = -1; + out.status = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push) + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 7763f80a..550e7a8d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -212,6 +212,19 @@ MERCURY_GEN_PROC(ADM_get_pending_transfers_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_get_pending_transfers); +/// ADM_set_qos_constraints_push + +MERCURY_GEN_PROC( + ADM_set_qos_constraints_push_in_t, + ((hg_const_string_t) (scope))((hg_const_string_t) (qos_class))( + (int32_t) (element_id))((hg_const_string_t) (class_value))) + +MERCURY_GEN_PROC(ADM_set_qos_constraints_push_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push); + + //} // namespace scord::network::rpc -- GitLab From 64aca7892963fba0c3c77c87da6250d17cdcaa33 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 11 May 2022 12:28:21 +0200 Subject: [PATCH 55/76] ADM_set_qos_constraints_pull implemented and tested successfully and CMakeList fixed --- examples/ADM_set_qos_constraints_pull.cpp | 48 +++++++++++++++++ examples/CMakeLists.txt | 13 ++--- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 65 +++++++++++++++++++++++ src/network/rpcs.hpp | 10 ++++ 5 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 examples/ADM_set_qos_constraints_pull.cpp diff --git a/examples/ADM_set_qos_constraints_pull.cpp b/examples/ADM_set_qos_constraints_pull.cpp new file mode 100644 index 00000000..60c174b2 --- /dev/null +++ b/examples/ADM_set_qos_constraints_pull.cpp @@ -0,0 +1,48 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_set_qos_constraints_pull \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_set_qos_constraints_pull remote procedure on {} with scope {} and element id {} ...\n", + argv[1], argv[2], argv[3]); + ADM_set_qos_constraints_pull_in_t in; + in.scope = argv[2]; + try { + in.element_id = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_set_qos_constraints_pull_out_t out; + + endp.call("ADM_set_qos_constraints_pull", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_set_qos_constraints_pull remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_set_qos_constraints_pull remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71838cef..94a563b9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,12 +22,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -set(examples ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id) -list(APPEND examples ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution) -list(APPEND examples ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset) -list(APPEND examples ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority) -list(APPEND examples ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers) -list(APPEND examples ADM_set_qos_constraints_push) +set(examples) +list(APPEND ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id + ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution + ADM_adhoc_background_flush 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_push) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 806103b9..4415d2fc 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -185,6 +185,10 @@ struct engine { "ADM_set_qos_constraints_push", ADM_set_qos_constraints_push_in_t, ADM_set_qos_constraints_push_out_t, ADM_set_qos_constraints_push, true); + REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, + "ADM_set_qos_constraints_pull", ADM_set_qos_constraints_pull_in_t, + ADM_set_qos_constraints_pull_out_t, ADM_set_qos_constraints_pull, true); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index f63c9d13..089afdcd 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1085,4 +1085,69 @@ ADM_set_qos_constraints_push(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push) +/** + * Returns a list of QoS constraints defined for an element identified for id. + * + * @param in.scope The scope being queried: dataset, node, or job. + * @param in.element_id A valid id for the element of interest, i.e. a resource + * ID, a node hostname, or a Job ID. + * @param out.list A list of QoS constraints that includes all the classes + * currently defined for the element as well as the values set for them. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_set_qos_constraints_pull(hg_handle_t h) { + hg_return_t ret; + + ADM_set_qos_constraints_pull_in_t in; + ADM_set_qos_constraints_pull_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + LOGGER_INFO("LOADED ADM_set_qos_constraints_pull"); + LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", + in.scope, in.element_id); + + if(in.scope != nullptr && in.element_id >= 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", + in.scope, in.element_id); + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.list = "list"; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.list = nullptr; + } + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull null ({}, {})", + in.scope, in.element_id); + out.ret = -1; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 550e7a8d..d13f6207 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -224,6 +224,16 @@ MERCURY_GEN_PROC(ADM_set_qos_constraints_push_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_push); +/// ADM_set_qos_constraints_pull + +MERCURY_GEN_PROC(ADM_set_qos_constraints_pull_in_t, + ((hg_const_string_t) (scope))((int32_t) (element_id))) + +MERCURY_GEN_PROC(ADM_set_qos_constraints_pull_out_t, + ((int32_t) (ret))((hg_const_string_t) (list))) + +DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull); + //} // namespace scord::network::rpc -- GitLab From ba305984123d71fe0899b0e1e915473ecadc3aa4 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 11 May 2022 12:44:59 +0200 Subject: [PATCH 56/76] LOGGER_INFO(LOADED {rcp}) sentence removed --- src/network/rpcs.cpp | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 089afdcd..7d05f9fb 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -61,7 +61,6 @@ ADM_input(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_input"); LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); if(in.origin != nullptr && in.target != nullptr) { @@ -74,6 +73,7 @@ ADM_input(hg_handle_t h) { in.target); } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -108,7 +108,6 @@ ADM_output(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_output"); LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); if(in.origin != nullptr && in.target != nullptr) { @@ -155,7 +154,6 @@ ADM_inout(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_inout"); LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); if(in.origin != nullptr && in.target != nullptr) { @@ -216,7 +214,6 @@ ADM_adhoc_context(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_context"); LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); if(in.context != nullptr) { @@ -277,7 +274,6 @@ ADM_adhoc_context_id(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_context_id"); LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); if(in.context_id >= 0) { @@ -325,7 +321,6 @@ ADM_adhoc_nodes(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_nodes"); LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); if(in.nodes > 0) { @@ -375,7 +370,6 @@ ADM_adhoc_walltime(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_walltime"); LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); if(in.walltime >= 0) { @@ -422,7 +416,6 @@ ADM_adhoc_access(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_access"); LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); if(in.access != nullptr) { @@ -483,7 +476,6 @@ ADM_adhoc_distribution(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_distribution"); LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", in.data_distribution); @@ -530,7 +522,6 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_adhoc_background_flush"); LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); if(in.b_flush == 0 || in.b_flush == 1) { @@ -575,7 +566,6 @@ ADM_in_situ_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_in_situ_ops"); LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); if(in.in_situ != nullptr) { @@ -620,7 +610,6 @@ ADM_in_transit_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_in_transit_ops"); LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); if(in.in_transit != nullptr) { @@ -681,7 +670,6 @@ ADM_transfer_dataset(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_transfer_dataset"); LOGGER_INFO("remote_procedure::ADM_transfer_dataset({},{},{},{},{})", in.source, in.destination, in.qos_constraints, in.distribution, in.job_id); @@ -740,7 +728,6 @@ ADM_set_dataset_information(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_dataset_information"); LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", in.resource_id, in.info, in.job_id); @@ -794,7 +781,6 @@ ADM_set_io_resources(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_io_resources"); LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, in.resources, in.job_id); @@ -845,7 +831,6 @@ ADM_get_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_get_transfer_priority"); LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", in.transfer_id); @@ -897,7 +882,6 @@ ADM_set_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_transfer_priority"); LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); @@ -950,7 +934,6 @@ ADM_cancel_transfer(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_cancel_transfer"); LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); if(in.transfer_id >= 0) { @@ -997,7 +980,6 @@ ADM_get_pending_transfers(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_get_pending_transfers"); LOGGER_INFO("remote_procedure::ADM_get_pending_transfers"); out.ret = 0; @@ -1041,7 +1023,6 @@ ADM_set_qos_constraints_push(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_qos_constraints_push"); LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); @@ -1108,7 +1089,6 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("LOADED ADM_set_qos_constraints_pull"); LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); -- GitLab From 6c0b076ce833bcfbec3b8d8b8e646b56bd7fb962 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 11 May 2022 14:31:35 +0200 Subject: [PATCH 57/76] set function removed in CMakeList --- examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 94a563b9..1310e1a3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -set(examples) list(APPEND ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset -- GitLab From abc42f5b9b6f14b860bb1fc06c52c41562f329fb Mon Sep 17 00:00:00 2001 From: amanzano Date: Thu, 12 May 2022 10:42:39 +0200 Subject: [PATCH 58/76] CMakeLists.txt fixed --- examples/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1310e1a3..3356dab9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -list(APPEND ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id +list(APPEND examples + ping ADM_input ADM_output ADM_inout ADM_adhoc_context ADM_adhoc_context_id ADM_adhoc_nodes ADM_adhoc_walltime ADM_adhoc_access ADM_adhoc_distribution ADM_adhoc_background_flush ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority -- GitLab From b01f3e2de34246fea2432b8d7e2fa3fdc2eb585e Mon Sep 17 00:00:00 2001 From: amanzano Date: Thu, 12 May 2022 11:03:01 +0200 Subject: [PATCH 59/76] Badly formatted comment fixed --- src/network/rpcs.cpp | 146 +++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 76 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 7d05f9fb..c8525659 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -63,17 +63,17 @@ ADM_input(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); - if(in.origin != nullptr && in.target != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_input not null ({},{})", in.origin, - in.target); + out.ret = -1; + + if(in.origin == nullptr) { + LOGGER_ERROR("ADM_input(): invalid origin (nullptr)"); + } else if(in.target == nullptr) { + LOGGER_ERROR("ADM_input(): invalid target (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_input null ({},{})", in.origin, - in.target); + LOGGER_INFO("ADM_input({}, {})", in.origin, in.target); + out.ret = 0; } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -110,14 +110,15 @@ ADM_output(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); - if(in.origin != nullptr && in.target != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_output not null ({},{})", in.origin, - in.target); + out.ret = -1; + + if(in.origin == nullptr) { + LOGGER_ERROR("ADM_output(): invalid origin (nullptr)"); + } else if(in.target == nullptr) { + LOGGER_ERROR("ADM_output(): invalid target (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_output null ({},{})", in.origin, - in.target); + LOGGER_INFO("ADM_output({}, {})", in.origin, in.target); + out.ret = 0; } ret = margo_respond(h, &out); @@ -156,14 +157,15 @@ ADM_inout(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); - if(in.origin != nullptr && in.target != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_inout not null ({},{})", in.origin, - in.target); + out.ret = -1; + + if(in.origin == nullptr) { + LOGGER_ERROR("ADM_inout(): invalid origin (nullptr)"); + } else if(in.target == nullptr) { + LOGGER_ERROR("ADM_inout(): invalid target (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_inout null ({},{})", in.origin, - in.target); + LOGGER_INFO("ADM_inout({}, {})", in.origin, in.target); + out.ret = 0; } ret = margo_respond(h, &out); @@ -179,28 +181,23 @@ ADM_inout(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_inout) /** - * Specifies the execution_mode an Ad hoc Storage System should use. Valid - options: in_job:shared (run while - * sharing the application’s compute nodes), in_job:dedicated (run using a - subset of the application’s - * compute nodes), separate:new (ask the system to allocate a separate job with - separate runtime and - * number of nodes) and separate:existing (ask the system to reuse an already - running Ad hoc Storage System instance). - * The number of nodes assigned for the Ad hoc Storage System must be specified - with ADM_adhoc_nodes. - * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System - will be controlled with - * ADM_adhoc_walltime. In the separate:existing execution_mode, a valid context - ID must be provided with - * ADM_adhoc_context_id + * Specifies the execution_mode an Ad hoc Storage System should use. Valid + * options: in_job:shared (run while sharing the application’s compute nodes), + * in_job:dedicated (run using a subset of the application’s compute nodes), + * separate:new (ask the system to allocate a separate job with separate runtime + * and number of nodes) and separate:existing (ask the system to reuse an already + * running Ad hoc Storage System instance). + * The number of nodes assigned for the Ad hoc Storage System must be specified + * with ADM_adhoc_nodes. + * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System + * will be controlled with ADM_adhoc_walltime. In the separate:existing + * execution_mode, a valid context ID must be provided with ADM_adhoc_context_id. * * @param in.context A valid execution_mode describing how the Ad hoc Storage - System should behave. + * System should behave. * @return out.ret Returns if the remote procedure has been completed - successfully or not. + * successfully or not. * @return out.adhoc_context_id A number that identifies the context. - */ static void ADM_adhoc_context(hg_handle_t h) { @@ -1028,32 +1025,32 @@ ADM_set_qos_constraints_push(hg_handle_t h) { in.scope, in.qos_class, in.element_id, in.class_value); if(in.scope != nullptr && in.qos_class != nullptr && in.element_id >= 0 && - in.class_value != nullptr){ + in.class_value != nullptr) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", - in.scope); - out.ret = 0; - out.status = 0; - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.status = -1; - } + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.status = 0; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.status = -1; + } } else { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push null ({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - out.ret = -1; - out.status = -1; + out.ret = -1; + out.status = -1; } - + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1096,25 +1093,25 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", in.scope, in.element_id); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", - in.scope); - out.ret = 0; - out.list = "list"; - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.list = nullptr; - } + if((strcmp(in.scope, "dataset")) == 0 || + (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", + in.scope); + out.ret = 0; + out.list = "list"; + } else { + LOGGER_INFO( + "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", + in.scope); + out.ret = -1; + out.list = nullptr; + } } else { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull null ({}, {})", in.scope, in.element_id); - out.ret = -1; + out.ret = -1; } ret = margo_respond(h, &out); @@ -1128,6 +1125,3 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull) - - - -- GitLab From fef040759645bcdab5390cc4aef702a3d2108e48 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 10:11:26 +0200 Subject: [PATCH 60/76] Simplified string comparison --- src/network/rpcs.cpp | 94 +++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index c8525659..d4d53f51 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -181,17 +181,17 @@ ADM_inout(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_inout) /** - * Specifies the execution_mode an Ad hoc Storage System should use. Valid - * options: in_job:shared (run while sharing the application’s compute nodes), - * in_job:dedicated (run using a subset of the application’s compute nodes), - * separate:new (ask the system to allocate a separate job with separate runtime - * and number of nodes) and separate:existing (ask the system to reuse an already - * running Ad hoc Storage System instance). - * The number of nodes assigned for the Ad hoc Storage System must be specified - * with ADM_adhoc_nodes. - * In the separate:new execution_mode, the lifetime of the Ad hoc Storage System - * will be controlled with ADM_adhoc_walltime. In the separate:existing - * execution_mode, a valid context ID must be provided with ADM_adhoc_context_id. + * Specifies the execution_mode an Ad hoc Storage System should use. Valid + * options: in_job:shared (run while sharing the application’s compute nodes), + * in_job:dedicated (run using a subset of the application’s compute nodes), + * separate:new (ask the system to allocate a separate job with separate runtime + * and number of nodes) and separate:existing (ask the system to reuse an + * already running Ad hoc Storage System instance). The number of nodes assigned + * for the Ad hoc Storage System must be specified with ADM_adhoc_nodes. In the + * separate:new execution_mode, the lifetime of the Ad hoc Storage System will + * be controlled with ADM_adhoc_walltime. In the separate:existing + * execution_mode, a valid context ID must be provided with + * ADM_adhoc_context_id. * * @param in.context A valid execution_mode describing how the Ad hoc Storage * System should behave. @@ -211,12 +211,29 @@ ADM_adhoc_context(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string ctx(in.context); + LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); if(in.context != nullptr) { + out.ret = 0; LOGGER_INFO("remote_procedure::ADM_adhoc_context not null ({})", in.context); + + if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || + ctx == "separate:new" || ctx == "separate:existing") { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context value is acceptable ({})", + in.context); + out.adhoc_context = rand(); + } else { + LOGGER_INFO( + "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", + in.context); + out.adhoc_context = -1; + } + } else { out.ret = -1; LOGGER_INFO( @@ -224,21 +241,6 @@ ADM_adhoc_context(hg_handle_t h) { in.context); } - if((strcmp(in.context, "in_job:shared")) == 0 || - (strcmp(in.context, "in_job:dedicated")) == 0 || - (strcmp(in.context, "separate:new")) == 0 || - (strcmp(in.context, "separate:existing")) == 0) { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context value is acceptable ({})", - in.context); - out.adhoc_context = rand(); - } else { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", - in.context); - out.adhoc_context = -1; - } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -413,12 +415,26 @@ ADM_adhoc_access(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string acc(in.access); + LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); if(in.access != nullptr) { - out.ret = 0; LOGGER_INFO("remote_procedure::ADM_adhoc_access not null ({})", in.access); + + if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { + out.ret = 0; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access value is acceptable ({})", + in.access); + } else { + out.ret = -1; + LOGGER_INFO( + "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", + in.access); + } + } else { out.ret = -1; LOGGER_INFO( @@ -426,20 +442,6 @@ ADM_adhoc_access(hg_handle_t h) { in.access); } - if((strcmp(in.access, "write-only")) == 0 || - (strcmp(in.access, "read-only")) == 0 || - (strcmp(in.access, "read-write") == 0)) { - out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access value is acceptable ({})", - in.access); - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", - in.access); - } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1020,6 +1022,8 @@ ADM_set_qos_constraints_push(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string scp(in.scope); + LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); @@ -1029,8 +1033,7 @@ ADM_set_qos_constraints_push(hg_handle_t h) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", in.scope); @@ -1086,6 +1089,8 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); + const std::string scp(in.scope); + LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); @@ -1093,8 +1098,7 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", in.scope, in.element_id); - if((strcmp(in.scope, "dataset")) == 0 || - (strcmp(in.scope, "node")) == 0 || (strcmp(in.scope, "job")) == 0) { + if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", in.scope); -- GitLab From 7f842a8b45f81d5492c06ca73875b5e2cdbe4ea1 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 12:52:38 +0200 Subject: [PATCH 61/76] RPCs rewritten changing input validation type --- src/network/rpcs.cpp | 356 ++++++++++++++++++++++--------------------- 1 file changed, 180 insertions(+), 176 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index d4d53f51..504a5b71 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -215,30 +215,25 @@ ADM_adhoc_context(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); - if(in.context != nullptr) { - - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_context not null ({})", - in.context); + out.ret = -1; + out.adhoc_context = -1; + + if(in.context == nullptr) { + LOGGER_ERROR("ADM_adhoc_context(): invalid context (nullptr)"); + } else { + LOGGER_INFO("ADM_adhoc_context({})", in.context); if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { LOGGER_INFO( "remote_procedure::ADM_adhoc_context value is acceptable ({})", in.context); + out.ret = 0; out.adhoc_context = rand(); } else { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing ({})", - in.context); - out.adhoc_context = -1; + LOGGER_ERROR( + "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing"); } - - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context null or invalid ({}). Please use", - in.context); } ret = margo_respond(h, &out); @@ -275,17 +270,16 @@ ADM_adhoc_context_id(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); - if(in.context_id >= 0) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_context_id not null ({})", - in.context_id); + out.ret = -1; + + if(in.context_id < 0) { + LOGGER_ERROR("ADM_adhoc_context_id(): invalid context_id (< 0)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context_id null or invalid ({}). Please use", - in.context_id); + LOGGER_INFO("ADM_input({})", in.context_id); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -322,15 +316,16 @@ ADM_adhoc_nodes(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); - if(in.nodes > 0) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_nodes not null ({})", - in.nodes); + out.ret = -1; + + if(in.nodes <= 0) { + LOGGER_ERROR("ADM_adhoc_nodes(): invalid n_nodes (<= 0)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_adhoc_nodes null ({})", in.nodes); + LOGGER_INFO("ADM_adhoc_nodes({})", in.nodes); + out.ret = 0; } + /*Specifies the number of nodes for the Ad hoc Storage System. If the ADM_adhoc_execution_mode is shared, the number cannot exceed the number of allocated nodes within the compute job. If the ADM_adhoc_execution_mode is @@ -371,17 +366,16 @@ ADM_adhoc_walltime(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); - if(in.walltime >= 0) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_walltime not null ({})", - in.walltime); + out.ret = -1; + + if(in.walltime < 0) { + LOGGER_ERROR("ADM_adhoc_walltime(): invalid walltime (< 0)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_walltime null or invalid ({}). Please use", - in.walltime); + LOGGER_INFO("ADM_adhoc_walltime({})", in.walltime); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -419,29 +413,26 @@ ADM_adhoc_access(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); - if(in.access != nullptr) { - LOGGER_INFO("remote_procedure::ADM_adhoc_access not null ({})", - in.access); - - if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { + out.ret = -1; + + if(in.access == nullptr) { + LOGGER_ERROR("ADM_adhoc_access(): invalid access (nullptr)"); + } else { + LOGGER_INFO("ADM_adhoc_access({}, {})", in.access); + + if((acc == "write-only") || (acc == "read-only") || + (acc == "read-write")) { out.ret = 0; LOGGER_INFO( "remote_procedure::ADM_adhoc_access value is acceptable ({})", in.access); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write", - in.access); + LOGGER_ERROR( + "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); } - - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access null or invalid ({}). Please use", - in.access); } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -478,17 +469,17 @@ ADM_adhoc_distribution(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", in.data_distribution); - if(in.data_distribution != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_adhoc_distribution not null ({})", - in.data_distribution); + out.ret = -1; + + if(in.data_distribution == nullptr) { + LOGGER_ERROR( + "ADM_adhoc_distribution(): invalid data_distribution (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_distribution null or invalid ({}). Please use", - in.data_distribution); + LOGGER_INFO("ADM_adhoc_distribution({})", in.data_distribution); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -523,17 +514,17 @@ ADM_adhoc_background_flush(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); - if(in.b_flush == 0 || in.b_flush == 1) { - out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_background_flush not null ({})", - in.b_flush); + out.ret = -1; + + if(in.b_flush != 0 && in.b_flush != 1) { + LOGGER_ERROR( + "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush null ({})", - in.b_flush); + LOGGER_INFO("ADM_adhoc_background_flush({})", in.b_flush); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -567,17 +558,16 @@ ADM_in_situ_ops(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); - if(in.in_situ != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_in_situ_ops not null ({})", - in.in_situ); + out.ret = -1; + + if(in.in_situ == nullptr) { + LOGGER_ERROR("ADM_in_situ_ops(): invalid in_situ_ops (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_in_situ_ops null or invalid ({}). Please use", - in.in_situ); + LOGGER_INFO("ADM_in_situ_ops({})", in.in_situ); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -611,17 +601,16 @@ ADM_in_transit_ops(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); - if(in.in_transit != nullptr) { - out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_in_transit_ops not null ({})", - in.in_transit); + out.ret = -1; + + if(in.in_transit == nullptr) { + LOGGER_ERROR("ADM_in_transit_ops(): invalid in_transit (nullptr)"); } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_in_transit_ops null or invalid ({}). Please use", - in.in_transit); + LOGGER_INFO("ADM_in_transit_ops({})", in.in_transit); + out.ret = 0; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -673,24 +662,29 @@ ADM_transfer_dataset(hg_handle_t h) { in.source, in.destination, in.qos_constraints, in.distribution, in.job_id); - if(in.source != nullptr && in.destination != nullptr && - in.qos_constraints != nullptr && in.distribution != nullptr && - in.job_id >= 0) { + out.ret = -1; + out.transfer_handle = "fail"; + + if(in.source == nullptr) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid source (nullptr)"); + } else if(in.destination == nullptr) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid destination (nullptr)"); + } else if(in.qos_constraints == nullptr) { + LOGGER_ERROR( + "ADM_transfer_dataset(): invalid qos_constraints (nullptr)"); + } else if(in.distribution == nullptr) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid distribution (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_transfer_dataset(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_transfer_dataset({},{},{},{},{})", in.source, + in.destination, in.qos_constraints, in.distribution, + in.job_id); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset not null ({},{},{},{},{})", - in.source, in.destination, in.qos_constraints, in.distribution, - in.job_id); out.transfer_handle = "ok"; - } else { - out.ret = -1; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset null ({},{},{},{},{})", - in.source, in.destination, in.qos_constraints, in.distribution, - in.job_id); - out.transfer_handle = "fail"; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -730,19 +724,24 @@ ADM_set_dataset_information(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", in.resource_id, in.info, in.job_id); - if(in.resource_id >= 0 && in.info != nullptr && in.job_id >= 0) { + out.ret = -1; + out.status = -1; + + if(in.resource_id < 0) { + LOGGER_ERROR( + "ADM_set_dataset_information(): invalid resource_id (< 0)"); + } else if(in.info == nullptr) { + LOGGER_ERROR("ADM_set_dataset_information(): invalid info (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_set_dataset_information(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_set_dataset_information({},{},{})", in.resource_id, + in.info, in.job_id); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset not null ({},{},{})", - in.resource_id, in.info, in.job_id); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", - in.resource_id, in.info, in.job_id); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -783,19 +782,23 @@ ADM_set_io_resources(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, in.resources, in.job_id); - if(in.tier_id >= 0 && in.resources != nullptr && in.job_id >= 0) { + out.ret = -1; + out.status = -1; + + if(in.tier_id < 0) { + LOGGER_ERROR("ADM_set_io_resources(): invalid tier_id (nullptr)"); + } else if(in.resources == nullptr) { + LOGGER_ERROR("ADM_set_io_resources(): invalid resources (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_set_io_resources(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_set_io_resources({},{},{})", in.tier_id, in.resources, + in.job_id); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_transfer_dataset not null ({},{},{})", - in.tier_id, in.resources, in.job_id); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_transfer_dataset null ({},{},{})", - in.tier_id, in.resources, in.job_id); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -833,16 +836,16 @@ ADM_get_transfer_priority(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", in.transfer_id); - if(in.transfer_id >= 0) { + out.ret = -1; + out.priority = -1; + + if(in.transfer_id < 0) { + LOGGER_ERROR( + "ADM_get_transfer_priority(): invalid transfer_id (nullptr)"); + } else { + LOGGER_INFO("ADM_get_transfer_priority({})", in.transfer_id); out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_get_transfer_priority not null ({})", - in.transfer_id); out.priority = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_get_transfer_priority null ({})", - in.transfer_id); - out.priority = -1; } ret = margo_respond(h, &out); @@ -858,7 +861,7 @@ ADM_get_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_get_transfer_priority) /** - * Moves the operation identified by transf er_id up or down by n positions in + * Moves the operation identified by transfer_id up or down by n positions in * its scheduling queue. * * @param in.transfer_id A transf er_id identifying a pending transfer. @@ -884,19 +887,20 @@ ADM_set_transfer_priority(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); - if(in.transfer_id >= 0 && (in.n_positions >= 0 || in.n_positions < 0)) { + out.ret = -1; + out.status = -1; + + if(in.transfer_id < 0) { + LOGGER_ERROR( + "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); + }else { + LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, + in.n_positions); out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_set_transfer_priority not null ({}, {})", - in.transfer_id, in.n_positions); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_set_transfer_priority null ({}, {})", - in.transfer_id, in.n_positions); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -910,12 +914,9 @@ ADM_set_transfer_priority(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_set_transfer_priority) /** - * Moves the operation identified by transf er_id up or down by n positions in - * its scheduling queue. + * Cancels the pending transfer identified by transfer_id. * - * @param in.transfer_id A transf er_id identifying a pending transfer. - * @param in.n_positions A positive or negative number n for the number of - * positions the transfer should go up or down in its scheduling queue. + * @param in.transfer_id A transfer_id identifying a pending transfer. * @param out.status A status code indicating whether the operation was * successful. * @return out.ret Returns if the remote procedure has been completed @@ -935,18 +936,18 @@ ADM_cancel_transfer(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); - if(in.transfer_id >= 0) { + out.ret = -1; + out.status = -1; + + if(in.transfer_id < 0) { + LOGGER_ERROR("ADM_cancel_transfer(): invalid transfer_id (< 0)"); + } else { + LOGGER_INFO("ADM_cancel_transfer({})", in.transfer_id); out.ret = 0; - LOGGER_INFO("remote_procedure::ADM_cancel_transfer not null ({})", - in.transfer_id); out.status = 0; - } else { - out.ret = -1; - LOGGER_INFO("remote_procedure::ADM_cancel_transfer null ({})", - in.transfer_id); - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1028,11 +1029,24 @@ ADM_set_qos_constraints_push(hg_handle_t h) { "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, in.qos_class, in.element_id, in.class_value); - if(in.scope != nullptr && in.qos_class != nullptr && in.element_id >= 0 && - in.class_value != nullptr) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push not null ({}, {}, {}, {})", - in.scope, in.qos_class, in.element_id, in.class_value); + out.ret = -1; + out.status = -1; + + if(in.scope == nullptr) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid scopee (nullptr)"); + } else if(in.qos_class == nullptr) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid qos_class (nullptr)"); + } else if(in.element_id < 0) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid element_id (< 0)"); + } else if(in.class_value == nullptr) { + LOGGER_ERROR( + "ADM_set_qos_constraints_push(): invalid class_value (nullptr)"); + } else { + LOGGER_INFO("ADM_set_qos_constraints_push({}, {}, {}, {})", in.scope, + in.qos_class, in.element_id, in.class_value); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", @@ -1040,20 +1054,12 @@ ADM_set_qos_constraints_push(hg_handle_t h) { out.ret = 0; out.status = 0; } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.status = -1; + LOGGER_ERROR( + "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job"); } - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push null ({}, {}, {}, {})", - in.scope, in.qos_class, in.element_id, in.class_value); - out.ret = -1; - out.status = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -1094,10 +1100,15 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); - if(in.scope != nullptr && in.element_id >= 0) { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull not null ({}, {})", - in.scope, in.element_id); + out.ret = -1; + out.list = nullptr; + + if(in.scope == nullptr) { + LOGGER_ERROR("ADM_input(): invalid scope (nullptr)"); + } else if(in.element_id < 0) { + LOGGER_ERROR("ADM_input(): invalid element_id (< 0)"); + } else { + LOGGER_INFO("ADM_input({}, {})", in.scope, in.element_id); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", @@ -1106,18 +1117,11 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { out.list = "list"; } else { LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job ({})", - in.scope); - out.ret = -1; - out.list = nullptr; + "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); } - } else { - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull null ({}, {})", - in.scope, in.element_id); - out.ret = -1; } + ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab From dec72a4fc519fd3c9699740d7fc765f0e06c6168 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 12:57:04 +0200 Subject: [PATCH 62/76] LOGGER ERROR fixed --- src/network/rpcs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 504a5b71..8c2555ad 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1116,7 +1116,7 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { out.ret = 0; out.list = "list"; } else { - LOGGER_INFO( + LOGGER_ERROR( "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); } } -- GitLab From 05798adc68e741590746fde0a96f248f1bfbfe72 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 13 May 2022 13:08:03 +0200 Subject: [PATCH 63/76] All remote_procedure:: sentences delated --- examples/ADM_adhoc_context.cpp | 1 + src/network/rpcs.cpp | 78 ++++++---------------------------- 2 files changed, 13 insertions(+), 66 deletions(-) diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp index 48bef96b..d98d21af 100644 --- a/examples/ADM_adhoc_context.cpp +++ b/examples/ADM_adhoc_context.cpp @@ -27,6 +27,7 @@ main(int argc, char* argv[]) { endp.call("ADM_adhoc_context", &in, &out); + if(out.ret < 0 || out.adhoc_context < 0) { fmt::print( stdout, diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8c2555ad..43a2b694 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -31,7 +31,7 @@ ping(hg_handle_t h) { margo_instance_id mid = margo_hg_handle_get_instance(h); - LOGGER_INFO("remote_procedure::PING(noargs)"); + LOGGER_INFO("PING(noargs)"); ret = margo_destroy(h); assert(ret == HG_SUCCESS); @@ -61,8 +61,6 @@ ADM_input(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_input({},{})", in.origin, in.target); - out.ret = -1; if(in.origin == nullptr) { @@ -108,8 +106,6 @@ ADM_output(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_output({},{})", in.origin, in.target); - out.ret = -1; if(in.origin == nullptr) { @@ -155,8 +151,6 @@ ADM_inout(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_inout({},{})", in.origin, in.target); - out.ret = -1; if(in.origin == nullptr) { @@ -213,8 +207,6 @@ ADM_adhoc_context(hg_handle_t h) { const std::string ctx(in.context); - LOGGER_INFO("remote_procedure::ADM_adhoc_context({})", in.context); - out.ret = -1; out.adhoc_context = -1; @@ -225,14 +217,13 @@ ADM_adhoc_context(hg_handle_t h) { if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { - LOGGER_INFO( - "remote_procedure::ADM_adhoc_context value is acceptable ({})", - in.context); + LOGGER_INFO("ADM_adhoc_context value is acceptable ({})", + in.context); out.ret = 0; out.adhoc_context = rand(); } else { LOGGER_ERROR( - "remote_procedure::ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing"); + "ADM_adhoc_context is not valid. Please use: in_job:shared, in_job:dedicated, separate:new or separate:existing"); } } @@ -268,14 +259,13 @@ ADM_adhoc_context_id(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_context_id({})", in.context_id); out.ret = -1; if(in.context_id < 0) { LOGGER_ERROR("ADM_adhoc_context_id(): invalid context_id (< 0)"); } else { - LOGGER_INFO("ADM_input({})", in.context_id); + LOGGER_INFO("ADM_adhoc_context_id({})", in.context_id); out.ret = 0; } @@ -314,8 +304,6 @@ ADM_adhoc_nodes(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_nodes({})", in.nodes); - out.ret = -1; if(in.nodes <= 0) { @@ -364,8 +352,6 @@ ADM_adhoc_walltime(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_walltime({})", in.walltime); - out.ret = -1; if(in.walltime < 0) { @@ -411,8 +397,6 @@ ADM_adhoc_access(hg_handle_t h) { const std::string acc(in.access); - LOGGER_INFO("remote_procedure::ADM_adhoc_access({})", in.access); - out.ret = -1; if(in.access == nullptr) { @@ -423,12 +407,10 @@ ADM_adhoc_access(hg_handle_t h) { if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { out.ret = 0; - LOGGER_INFO( - "remote_procedure::ADM_adhoc_access value is acceptable ({})", - in.access); + LOGGER_INFO("ADM_adhoc_access value is acceptable ({})", in.access); } else { LOGGER_ERROR( - "remote_procedure::ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); + "ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); } } @@ -466,9 +448,6 @@ ADM_adhoc_distribution(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_distribution({})", - in.data_distribution); - out.ret = -1; if(in.data_distribution == nullptr) { @@ -512,8 +491,6 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_adhoc_background_flush({})", in.b_flush); - out.ret = -1; if(in.b_flush != 0 && in.b_flush != 1) { @@ -556,8 +533,6 @@ ADM_in_situ_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_in_situ_ops({})", in.in_situ); - out.ret = -1; if(in.in_situ == nullptr) { @@ -599,8 +574,6 @@ ADM_in_transit_ops(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_in_transit_ops({})", in.in_transit); - out.ret = -1; if(in.in_transit == nullptr) { @@ -658,10 +631,6 @@ ADM_transfer_dataset(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_transfer_dataset({},{},{},{},{})", - in.source, in.destination, in.qos_constraints, in.distribution, - in.job_id); - out.ret = -1; out.transfer_handle = "fail"; @@ -721,9 +690,6 @@ ADM_set_dataset_information(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_set_dataset_information({},{},{})", - in.resource_id, in.info, in.job_id); - out.ret = -1; out.status = -1; @@ -779,9 +745,6 @@ ADM_set_io_resources(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_set_io_resources({},{},{})", in.tier_id, - in.resources, in.job_id); - out.ret = -1; out.status = -1; @@ -833,9 +796,6 @@ ADM_get_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_get_transfer_priority({})", - in.transfer_id); - out.ret = -1; out.priority = -1; @@ -884,16 +844,13 @@ ADM_set_transfer_priority(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_set_transfer_priority({}, {})", - in.transfer_id, in.n_positions); - out.ret = -1; out.status = -1; if(in.transfer_id < 0) { LOGGER_ERROR( "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); - }else { + } else { LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); out.ret = 0; @@ -934,8 +891,6 @@ ADM_cancel_transfer(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_cancel_transfer({})", in.transfer_id); - out.ret = -1; out.status = -1; @@ -980,8 +935,6 @@ ADM_get_pending_transfers(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - LOGGER_INFO("remote_procedure::ADM_get_pending_transfers"); - out.ret = 0; out.pending_transfers = "list"; @@ -1025,10 +978,6 @@ ADM_set_qos_constraints_push(hg_handle_t h) { const std::string scp(in.scope); - LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push({}, {}, {}, {})", - in.scope, in.qos_class, in.element_id, in.class_value); - out.ret = -1; out.status = -1; @@ -1049,13 +998,13 @@ ADM_set_qos_constraints_push(hg_handle_t h) { in.qos_class, in.element_id, in.class_value); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_push scope value is acceptable ({})", + "ADM_set_qos_constraints_push scope value is acceptable ({})", in.scope); out.ret = 0; out.status = 0; } else { LOGGER_ERROR( - "remote_procedure::ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job"); + "ADM_set_qos_constraints_push scope value is not valid. Please use: dataset, node or job"); } } @@ -1097,9 +1046,6 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { const std::string scp(in.scope); - LOGGER_INFO("remote_procedure::ADM_set_qos_constraints_pull({}, {})", - in.scope, in.element_id); - out.ret = -1; out.list = nullptr; @@ -1111,13 +1057,13 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { LOGGER_INFO("ADM_input({}, {})", in.scope, in.element_id); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( - "remote_procedure::ADM_set_qos_constraints_pull scope value is acceptable ({})", + "ADM_set_qos_constraints_pull scope value is acceptable ({})", in.scope); out.ret = 0; out.list = "list"; } else { LOGGER_ERROR( - "remote_procedure::ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); + "ADM_set_qos_constraints_pull scope value is not valid. Please use: dataset, node or job "); } } -- GitLab From 5554bbbfe7362bd987616251631f4bcf53a1c331 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 08:19:46 +0200 Subject: [PATCH 64/76] string_to_convert function name changed --- examples/ADM_adhoc_background_flush.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index b7774a06..cfec2064 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -2,10 +2,10 @@ #include int -String2Convert(std::string var) { - if(var == "true" || var == "TRUE") { +string_to_convert(std::string s) { + if(s == "true" || s == "TRUE") { return 0; - } else if(var == "false" || var == "FALSE") { + } else if(s == "false" || s == "FALSE") { return 1; } else { return -1; @@ -35,7 +35,7 @@ main(int argc, char* argv[]) { ADM_adhoc_background_flush_in_t in; try { - in.b_flush = String2Convert(argv[2]); + in.b_flush = string_to_convert(argv[2]); } catch(const std::exception& e) { fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); exit(EXIT_FAILURE); -- GitLab From a8087cd01d8dac2ecadd86f000341f6d9edc2bc1 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 10:07:45 +0200 Subject: [PATCH 65/76] Input incorrect error modified --- examples/ADM_adhoc_background_flush.cpp | 20 ++++++++------------ src/network/rpcs.cpp | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index cfec2064..fa8201a4 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -3,12 +3,13 @@ int string_to_convert(std::string s) { - if(s == "true" || s == "TRUE") { - return 0; - } else if(s == "false" || s == "FALSE") { - return 1; + if(s == "true" || s == "TRUE" || s == "True") { + return true; + } else if(s == "false" || s == "FALSE" || s == "False") { + return false; } else { - return -1; + fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); + exit(EXIT_FAILURE); } } @@ -33,13 +34,8 @@ main(int argc, char* argv[]) { "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n", argv[1], argv[2]); ADM_adhoc_background_flush_in_t in; - - try { - in.b_flush = string_to_convert(argv[2]); - } catch(const std::exception& e) { - fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); - exit(EXIT_FAILURE); - } + + in.b_flush = string_to_convert(argv[2]); ADM_adhoc_background_flush_out_t out; diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 43a2b694..ed9edb50 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -217,8 +217,9 @@ ADM_adhoc_context(hg_handle_t h) { if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { - LOGGER_INFO("ADM_adhoc_context value is acceptable ({})", - in.context); + LOGGER_INFO( + "ADM_adhoc_context value is acceptable ({})", + in.context); out.ret = 0; out.adhoc_context = rand(); } else { @@ -407,7 +408,9 @@ ADM_adhoc_access(hg_handle_t h) { if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { out.ret = 0; - LOGGER_INFO("ADM_adhoc_access value is acceptable ({})", in.access); + LOGGER_INFO( + "ADM_adhoc_access value is acceptable ({})", + in.access); } else { LOGGER_ERROR( "ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); @@ -491,9 +494,9 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - out.ret = -1; - - if(in.b_flush != 0 && in.b_flush != 1) { + out.ret = 0; + + if(in.b_flush != true && in.b_flush != false) { LOGGER_ERROR( "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); } else { @@ -501,7 +504,6 @@ ADM_adhoc_background_flush(hg_handle_t h) { out.ret = 0; } - ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -850,7 +852,7 @@ ADM_set_transfer_priority(hg_handle_t h) { if(in.transfer_id < 0) { LOGGER_ERROR( "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); - } else { + }else { LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); out.ret = 0; -- GitLab From 8b11f0324e7b2dad77f5043b3f973529c164bd49 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 11:05:00 +0200 Subject: [PATCH 66/76] ADM_adhoc_background_flush modified --- examples/ADM_adhoc_background_flush.cpp | 16 +++++++++++----- src/network/rpcs.cpp | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index fa8201a4..1fa299bd 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -1,15 +1,14 @@ #include #include -int +bool string_to_convert(std::string s) { if(s == "true" || s == "TRUE" || s == "True") { return true; } else if(s == "false" || s == "FALSE" || s == "False") { return false; } else { - fmt::print(stdout, "ERROR: Incorrect input value. Please try again.\n"); - exit(EXIT_FAILURE); + throw std::invalid_argument("ERROR: Incorrect input value. Please try again.\n"); } } @@ -34,8 +33,15 @@ main(int argc, char* argv[]) { "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n", argv[1], argv[2]); ADM_adhoc_background_flush_in_t in; - - in.b_flush = string_to_convert(argv[2]); + + try { + in.b_flush = string_to_convert(argv[2]); + } catch(const std::invalid_argument& ia) { + fmt::print( + stderr, + "ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n"); + exit(EXIT_FAILURE); + } ADM_adhoc_background_flush_out_t out; diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index ed9edb50..d10824db 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -494,7 +494,7 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - out.ret = 0; + out.ret = -1; if(in.b_flush != true && in.b_flush != false) { LOGGER_ERROR( -- GitLab From 40cdcb3f669cd962ddc588083ad1121328fa7a54 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 11:40:22 +0200 Subject: [PATCH 67/76] ADM_define_data_operation implemented and tested successfully --- examples/ADM_adhoc_background_flush.cpp | 2 +- examples/ADM_define_data_operation.cpp | 50 +++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 60 ++++++++++++++++++++++++- src/network/rpcs.hpp | 10 +++++ 6 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 examples/ADM_define_data_operation.cpp diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index 1fa299bd..074f4fc5 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -56,4 +56,4 @@ main(int argc, char* argv[]) { stdout, "ADM_adhoc_background_flush remote procedure completed successfully\n"); } -} +} \ No newline at end of file diff --git a/examples/ADM_define_data_operation.cpp b/examples/ADM_define_data_operation.cpp new file mode 100644 index 00000000..a484c1d8 --- /dev/null +++ b/examples/ADM_define_data_operation.cpp @@ -0,0 +1,50 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 5) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_define_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_define_data_operation remote procedure on {} -> {} with operation id {} and arguments {} ...\n", + argv[1], argv[2], argv[3], argv[4]); + + ADM_define_data_operation_in_t in; + in.path = argv[2]; + try { + in.operation_id = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.arguments = argv[4]; + + ADM_define_data_operation_out_t out; + + endp.call("ADM_define_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_define_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_define_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3356dab9..4ff4ffb9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,7 @@ list(APPEND examples ADM_adhoc_background_flush 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_push) + ADM_set_qos_constraints_push ADM_define_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 4415d2fc..14909894 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -189,6 +189,10 @@ struct engine { "ADM_set_qos_constraints_pull", ADM_set_qos_constraints_pull_in_t, ADM_set_qos_constraints_pull_out_t, ADM_set_qos_constraints_pull, 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); + } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index d10824db..59d415fb 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -985,7 +985,7 @@ ADM_set_qos_constraints_push(hg_handle_t h) { if(in.scope == nullptr) { LOGGER_ERROR( - "ADM_set_qos_constraints_push(): invalid scopee (nullptr)"); + "ADM_set_qos_constraints_push(): invalid scope (nullptr)"); } else if(in.qos_class == nullptr) { LOGGER_ERROR( "ADM_set_qos_constraints_push(): invalid qos_class (nullptr)"); @@ -1081,3 +1081,61 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull) + +/** + * Defines a new operation, with the code found in path. The code will be + * identified by the user-provided operation_id and will accept the arguments + * defined, using the next format "arg0, arg1, arg2, . . . ". + * + * @param in.path A valid path for the operation code. + * @param in.operation_id A user-defined operation_id for the operation. + * @param in.arguments A list of arguments for the operation. + * @param out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_define_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_define_data_operation_in_t in; + ADM_define_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.status = -1; + + if(in.path == nullptr) { + LOGGER_ERROR( + "ADM_define_data_operation(): invalid path (nullptr)"); + } else if(in.operation_id < 0) { + LOGGER_ERROR( + "ADM_define_data_operation(): invalid operation_id (< 0)"); + } else if(in.arguments == nullptr) { + LOGGER_ERROR( + "ADM_define_data_operation(): invalid arguments (nullptr)"); + } else { + LOGGER_INFO("ADM_define_data_operation ({}, {}, {})", + in.path, in.operation_id, in.arguments); + out.ret = 0; + out.status = 0; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_define_data_operation) + + diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index d13f6207..95956c08 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -234,6 +234,16 @@ MERCURY_GEN_PROC(ADM_set_qos_constraints_pull_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_set_qos_constraints_pull); +/// ADM_define_data_operation + +MERCURY_GEN_PROC(ADM_define_data_operation_in_t, + ((hg_const_string_t) (path))((int32_t) (operation_id))( + (hg_const_string_t) (arguments))) + +MERCURY_GEN_PROC(ADM_define_data_operation_out_t, + ((int32_t) (ret))((int32_t) (status))) + +DECLARE_MARGO_RPC_HANDLER(ADM_define_data_operation); //} // namespace scord::network::rpc -- GitLab From 9755ae1d8f37b88c29e18033438b8471fba4ddeb Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:00:54 +0200 Subject: [PATCH 68/76] ADM_connect_data_operation implemented and tested successfully --- examples/ADM_connect_data_operation.cpp | 74 +++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 96 ++++++++++++++++++++----- src/network/rpcs.hpp | 14 ++++ 5 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 examples/ADM_connect_data_operation.cpp diff --git a/examples/ADM_connect_data_operation.cpp b/examples/ADM_connect_data_operation.cpp new file mode 100644 index 00000000..5643fb97 --- /dev/null +++ b/examples/ADM_connect_data_operation.cpp @@ -0,0 +1,74 @@ +#include +#include + +bool +string_to_convert(std::string s) { + if(s == "true" || s == "TRUE" || s == "True") { + return true; + } else if(s == "false" || s == "FALSE" || s == "False") { + return false; + } else { + throw std::invalid_argument( + "ERROR: Incorrect input value. Please try again.\n"); + } +} + +int +main(int argc, char* argv[]) { + + if(argc != 7) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_connect_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_connect_data_operation remote procedure on {} with operation id {}, input {}, stream {}, arguments {} and job id {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); + ADM_connect_data_operation_in_t in; + try { + in.operation_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.input = argv[3]; + try { + in.stream = string_to_convert(argv[4]); + } catch(const std::invalid_argument& ia) { + fmt::print(stderr, "ERROR: Incorrect input value. Please try again.\n"); + exit(EXIT_FAILURE); + } + in.arguments = argv[5]; + try { + in.job_id = std::stoi(argv[6]); + } catch(const std::exception& e) { + fmt::print( + stderr, + "ERROR: ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n"); + exit(EXIT_FAILURE); + } + + ADM_connect_data_operation_out_t out; + + endp.call("ADM_connect_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_connect_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_connect_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4ff4ffb9..2bb4849b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,7 @@ list(APPEND examples ADM_adhoc_background_flush 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_push ADM_define_data_operation) + ADM_set_qos_constraints_push ADM_define_data_operation ADM_connect_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 14909894..242884fc 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -192,6 +192,10 @@ struct engine { 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); } diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 59d415fb..67da74aa 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -217,9 +217,8 @@ ADM_adhoc_context(hg_handle_t h) { if(ctx == "in_job:shared" || ctx == "in_job:dedicated" || ctx == "separate:new" || ctx == "separate:existing") { - LOGGER_INFO( - "ADM_adhoc_context value is acceptable ({})", - in.context); + LOGGER_INFO("ADM_adhoc_context value is acceptable ({})", + in.context); out.ret = 0; out.adhoc_context = rand(); } else { @@ -408,9 +407,7 @@ ADM_adhoc_access(hg_handle_t h) { if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) { out.ret = 0; - LOGGER_INFO( - "ADM_adhoc_access value is acceptable ({})", - in.access); + LOGGER_INFO("ADM_adhoc_access value is acceptable ({})", in.access); } else { LOGGER_ERROR( "ADM_adhoc_access is not valid. Please use: write-only, read-only or read-write"); @@ -495,7 +492,7 @@ ADM_adhoc_background_flush(hg_handle_t h) { assert(ret == HG_SUCCESS); out.ret = -1; - + if(in.b_flush != true && in.b_flush != false) { LOGGER_ERROR( "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); @@ -852,7 +849,7 @@ ADM_set_transfer_priority(hg_handle_t h) { if(in.transfer_id < 0) { LOGGER_ERROR( "ADM_set_transfer_priority(): invalid transfer_id (nullptr)"); - }else { + } else { LOGGER_INFO("ADM_set_transfer_priority({}, {})", in.transfer_id, in.n_positions); out.ret = 0; @@ -984,8 +981,7 @@ ADM_set_qos_constraints_push(hg_handle_t h) { out.status = -1; if(in.scope == nullptr) { - LOGGER_ERROR( - "ADM_set_qos_constraints_push(): invalid scope (nullptr)"); + LOGGER_ERROR("ADM_set_qos_constraints_push(): invalid scope (nullptr)"); } else if(in.qos_class == nullptr) { LOGGER_ERROR( "ADM_set_qos_constraints_push(): invalid qos_class (nullptr)"); @@ -1111,17 +1107,15 @@ ADM_define_data_operation(hg_handle_t h) { out.status = -1; if(in.path == nullptr) { - LOGGER_ERROR( - "ADM_define_data_operation(): invalid path (nullptr)"); + LOGGER_ERROR("ADM_define_data_operation(): invalid path (nullptr)"); } else if(in.operation_id < 0) { - LOGGER_ERROR( - "ADM_define_data_operation(): invalid operation_id (< 0)"); + LOGGER_ERROR("ADM_define_data_operation(): invalid operation_id (< 0)"); } else if(in.arguments == nullptr) { LOGGER_ERROR( "ADM_define_data_operation(): invalid arguments (nullptr)"); } else { - LOGGER_INFO("ADM_define_data_operation ({}, {}, {})", - in.path, in.operation_id, in.arguments); + LOGGER_INFO("ADM_define_data_operation ({}, {}, {})", in.path, + in.operation_id, in.arguments); out.ret = 0; out.status = 0; } @@ -1139,3 +1133,73 @@ ADM_define_data_operation(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_define_data_operation) +/** + * Connects and starts the data operation defined with operation_id and with the + * arguments, using the input and output data storage (i.e., files). If the + * operation can be executed in a streaming fashion (i.e., it can start even if + * the input data is not entirely available), the stream parameter must be set + * to true. + * + * @param in.operation_id The operation_id of the operation to be connected. + * @param in.input An input data resource for the operation. + * @param in.stream A stream boolean indicating if the operation should be + * executed in a streaming fashion. + * @param in.arguments The values for the arguments required by the operation. + * @param in.job_id A job_id identifying the originating job. + * @param out.data An output data resource where the result of the operation + * should be stored. + * @return out.operation_handle An operation_handle for the operation that + * allows clients to further interact with the operation (e.g query its status, + * cancel it, etc.). + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_connect_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_connect_data_operation_in_t in; + ADM_connect_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.data = nullptr; + out.operation_handle = nullptr; + + if(in.operation_id < 0) { + LOGGER_ERROR( + "ADM_connect_data_operation(): invalid operation_id (< 0)"); + } else if(in.input == nullptr) { + LOGGER_ERROR("ADM_define_data_operation(): invalid input (nullptr)"); + } else if(in.stream != true && in.stream != false) { + LOGGER_ERROR( + "ADM_connect_data_operation(): invalid stream (not true/false)"); + } else if(in.arguments == nullptr) { + LOGGER_ERROR( + "ADM_connect_data_operation(): invalid arguments (nullptr)"); + } else if(in.job_id < 0) { + LOGGER_ERROR("ADM_connect_data_operation(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_connect_data_operation({}, {}, {}, {}, {})", + in.operation_id, in.input, in.stream, in.arguments, + in.job_id); + out.ret = 0; + out.data = "ouput"; + out.operation_handle = "operation_handle"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_connect_data_operation) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 95956c08..b7edb91d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -245,6 +245,20 @@ MERCURY_GEN_PROC(ADM_define_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_define_data_operation); +/// ADM_connect_data_operation + +MERCURY_GEN_PROC(ADM_connect_data_operation_in_t, + ((int32_t) (operation_id))((hg_const_string_t) (input))( + (hg_bool_t) (stream))((hg_const_string_t) (arguments))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_connect_data_operation_out_t, + ((int32_t) (ret))((hg_const_string_t) (data))( + (hg_const_string_t) (operation_handle))) + +DECLARE_MARGO_RPC_HANDLER(ADM_connect_data_operation); + + //} // namespace scord::network::rpc -- GitLab From 445c32b5f918b88f4d6a781c860ce6ea7a5ae21b Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:10:45 +0200 Subject: [PATCH 69/76] ADM_finalize_data_operation implemented and tested successfully --- examples/ADM_finalize_data_operation.cpp | 45 +++++++++++++++ examples/CMakeLists.txt | 3 +- src/network/engine.hpp | 71 ++++++++++++++++-------- src/network/rpcs.cpp | 45 +++++++++++++++ src/network/rpcs.hpp | 10 ++++ 5 files changed, 149 insertions(+), 25 deletions(-) create mode 100644 examples/ADM_finalize_data_operation.cpp diff --git a/examples/ADM_finalize_data_operation.cpp b/examples/ADM_finalize_data_operation.cpp new file mode 100644 index 00000000..e1e75f2e --- /dev/null +++ b/examples/ADM_finalize_data_operation.cpp @@ -0,0 +1,45 @@ +#include +#include + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_finalize_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_finalize_data_operation remote procedure on {} with operation id {} ...\n", + argv[1], argv[2]); + ADM_finalize_data_operation_in_t in; + try { + in.operation_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + ADM_finalize_data_operation_out_t out; + + endp.call("ADM_finalize_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_finalize_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_finalize_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2bb4849b..e36512ba 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,8 @@ list(APPEND examples ADM_adhoc_background_flush 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_push ADM_define_data_operation ADM_connect_data_operation) + ADM_set_qos_constraints_push ADM_define_data_operation ADM_connect_data_operation + ADM_finalize_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 242884fc..7b9136f0 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -139,12 +139,15 @@ struct engine { 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); - + 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); - + "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); @@ -158,46 +161,66 @@ struct engine { 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); + "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); - + "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); + "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); + "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_push", ADM_set_qos_constraints_push_in_t, - ADM_set_qos_constraints_push_out_t, ADM_set_qos_constraints_push, true); + "ADM_set_qos_constraints_push", + ADM_set_qos_constraints_push_in_t, + ADM_set_qos_constraints_push_out_t, + ADM_set_qos_constraints_push, true); REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, - "ADM_set_qos_constraints_pull", ADM_set_qos_constraints_pull_in_t, - ADM_set_qos_constraints_pull_out_t, ADM_set_qos_constraints_pull, true); + "ADM_set_qos_constraints_pull", + ADM_set_qos_constraints_pull_in_t, + ADM_set_qos_constraints_pull_out_t, + ADM_set_qos_constraints_pull, 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); + "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); } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 67da74aa..8feb7cae 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1203,3 +1203,48 @@ ADM_connect_data_operation(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_connect_data_operation) + +/** + * Finalises the operation defined with operation_id. + * + * @param in.operation_id The operation_id of the operation to be connected. + * @return out.status A status code indicating whether the operation was + * successful. + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_finalize_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_finalize_data_operation_in_t in; + ADM_finalize_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.status = -1; + + if(in.operation_id < 0) { + LOGGER_ERROR( + "ADM_finalize_data_operation(): invalid operation_id (< 0)"); + } else { + LOGGER_INFO("ADM_finalize_data_operation({})", in.operation_id); + out.ret = 0; + out.status = 0; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_finalize_data_operation) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index b7edb91d..79d7288d 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -258,6 +258,16 @@ MERCURY_GEN_PROC(ADM_connect_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_connect_data_operation); +/// ADM_finalize_data_operation + +MERCURY_GEN_PROC(ADM_finalize_data_operation_in_t, ((int32_t) (operation_id))) + +MERCURY_GEN_PROC(ADM_finalize_data_operation_out_t, + ((int32_t) (ret))((int32_t) (status))) + + +DECLARE_MARGO_RPC_HANDLER(ADM_finalize_data_operation); + //} // namespace scord::network::rpc -- GitLab From 0516fcebd6e52178ac5de27ef0dd4a63e36eb39b Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:24:55 +0200 Subject: [PATCH 70/76] ADM_link_transfer_to_data_operation implemented and tested successfully --- .../ADM_link_transfer_to_data_operation.cpp | 79 +++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 6 ++ src/network/rpcs.cpp | 67 ++++++++++++++++ src/network/rpcs.hpp | 11 +++ 5 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 examples/ADM_link_transfer_to_data_operation.cpp diff --git a/examples/ADM_link_transfer_to_data_operation.cpp b/examples/ADM_link_transfer_to_data_operation.cpp new file mode 100644 index 00000000..11ec2587 --- /dev/null +++ b/examples/ADM_link_transfer_to_data_operation.cpp @@ -0,0 +1,79 @@ +#include +#include + +bool +string_to_convert(std::string s) { + if(s == "true" || s == "TRUE" || s == "True") { + return true; + } else if(s == "false" || s == "FALSE" || s == "False") { + return false; + } else { + throw std::invalid_argument( + "ERROR: Incorrect input value. Please try again.\n"); + } +} + +int +main(int argc, char* argv[]) { + + if(argc != 7) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_link_transfer_to_data_operation \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_link_transfer_to_data_operation remote procedure on {} with operation id {}, transfer id {}, stream {}, arguments {} and job id {} ...\n", + argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); + ADM_link_transfer_to_data_operation_in_t in; + try { + in.operation_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.transfer_id = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.stream = string_to_convert(argv[4]); + } catch(const std::invalid_argument& ia) { + fmt::print( + stderr, + "ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n"); + exit(EXIT_FAILURE); + } + in.arguments = argv[5]; + try { + in.job_id = std::stoi(argv[6]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_link_transfer_to_data_operation_out_t out; + + endp.call("ADM_link_transfer_to_data_operation", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_link_transfer_to_data_operation remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_link_transfer_to_data_operation remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e36512ba..49756705 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND examples 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_push ADM_define_data_operation ADM_connect_data_operation - ADM_finalize_data_operation) + ADM_finalize_data_operation ADM_link_transfer_to_data_operation) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index 7b9136f0..e63939c2 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -221,6 +221,12 @@ struct engine { 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); } void diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 8feb7cae..33f1ebfe 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1248,3 +1248,70 @@ ADM_finalize_data_operation(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_finalize_data_operation) + +/** + * Links the data operation defined with operation_id with the pending transfer + * identified by transf er_id using the values provided as arguments. If the + * operation can be executed in a streaming fashion (i.e., it can start even if + * the input data is not entirely available), the stream parameter must be set + * to true. + * + * @param in.operation_id The operation_id of the operation to be connected. + * @param in.transfer_id The transfer_id of the pending transfer the operation + * should be linked to. + * @param in.stream A stream boolean indicating if the operation should be + * executed in a streaming fashion. + * @param in.arguments The values for the arguments required by the operation. + * @param in.job_id A job_id identifying the originating job. + * @return out.operation_handle An operation_handle for the operation that + * allows clients to further interact with the operation (e.g query its status, + * cancel it, etc.). + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_link_transfer_to_data_operation(hg_handle_t h) { + hg_return_t ret; + + ADM_link_transfer_to_data_operation_in_t in; + ADM_link_transfer_to_data_operation_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.operation_handle = nullptr; + + if(in.operation_id < 0) { + LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid operation_id (< 0)"); + } else if(in.transfer_id < 0) { + LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid transfer_id (< 0)"); + } else if(in.arguments == nullptr) { + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid arguments (nullptr)"); + }else if(in.stream != true && in.stream != false) { + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid stream (not true/false)"); + }else if(in.job_id < 0) { + LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid job_id (< 0)"); + } else { + LOGGER_INFO("ADM_link_transfer_to_data_operation ({}, {}, {}, {}, {})", + in.operation_id, in.transfer_id, in.stream, in.arguments, + in.job_id); + out.ret = 0; + out.operation_handle = "operation_handle"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 79d7288d..5d098316 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -268,6 +268,17 @@ MERCURY_GEN_PROC(ADM_finalize_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_finalize_data_operation); +/// ADM_link_transfer_to_data_operation + +MERCURY_GEN_PROC(ADM_link_transfer_to_data_operation_in_t, + ((int32_t) (operation_id))((int32_t) (transfer_id))( + (hg_bool_t) (stream))((hg_const_string_t) (arguments))( + (int32_t) (job_id))) + +MERCURY_GEN_PROC(ADM_link_transfer_to_data_operation_out_t, + ((int32_t) (ret))((hg_const_string_t) (operation_handle))) + +DECLARE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation); //} // namespace scord::network::rpc -- GitLab From 4332816e4bbef128cedce80a27a9e945db93ad61 Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 16 May 2022 12:36:02 +0200 Subject: [PATCH 71/76] ADM_get_statistics implemented and tested successfully --- examples/ADM_get_statistics.cpp | 52 +++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- src/network/engine.hpp | 4 ++ src/network/rpcs.cpp | 67 +++++++++++++++++++++++++++++---- src/network/rpcs.hpp | 11 ++++++ 5 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 examples/ADM_get_statistics.cpp diff --git a/examples/ADM_get_statistics.cpp b/examples/ADM_get_statistics.cpp new file mode 100644 index 00000000..d15e4471 --- /dev/null +++ b/examples/ADM_get_statistics.cpp @@ -0,0 +1,52 @@ +#include +#include + +int +main(int argc, char* argv[]) { + + if(argc != 4) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print( + stderr, + "Usage: ADM_get_statistics \n"); + exit(EXIT_FAILURE); + } + + scord::network::rpc_client rpc_client{"tcp"}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(argv[1]); + + fmt::print( + stdout, + "Calling ADM_get_statistics remote procedure on {} with job id {} and job step {} ...\n", + argv[1], argv[2], argv[3]); + ADM_get_statistics_in_t in; + try { + in.job_id = std::stoi(argv[2]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + try { + in.job_step = std::stoi(argv[3]); + } catch(const std::exception& e) { + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); + exit(EXIT_FAILURE); + } + + ADM_get_statistics_out_t out; + + endp.call("ADM_get_statistics", &in, &out); + + + if(out.ret < 0) { + fmt::print( + stdout, + "ADM_get_statistics remote procedure not completed successfully\n"); + } else { + fmt::print( + stdout, + "ADM_get_statistics remote procedure completed successfully\n"); + } +} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 49756705..88453845 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND examples 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_push ADM_define_data_operation ADM_connect_data_operation - ADM_finalize_data_operation ADM_link_transfer_to_data_operation) + ADM_finalize_data_operation ADM_link_transfer_to_data_operation ADM_get_statistics) foreach (example IN LISTS examples) add_executable(${example}) diff --git a/src/network/engine.hpp b/src/network/engine.hpp index e63939c2..dc8a15d3 100644 --- a/src/network/engine.hpp +++ b/src/network/engine.hpp @@ -227,6 +227,10 @@ struct engine { 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 diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index 33f1ebfe..e9c90b75 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1285,21 +1285,24 @@ ADM_link_transfer_to_data_operation(hg_handle_t h) { out.operation_handle = nullptr; if(in.operation_id < 0) { - LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid operation_id (< 0)"); + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid operation_id (< 0)"); } else if(in.transfer_id < 0) { - LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid transfer_id (< 0)"); + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid transfer_id (< 0)"); } else if(in.arguments == nullptr) { LOGGER_ERROR( "ADM_link_transfer_to_data_operation(): invalid arguments (nullptr)"); - }else if(in.stream != true && in.stream != false) { + } else if(in.stream != true && in.stream != false) { LOGGER_ERROR( "ADM_link_transfer_to_data_operation(): invalid stream (not true/false)"); - }else if(in.job_id < 0) { - LOGGER_ERROR("ADM_link_transfer_to_data_operation(): invalid job_id (< 0)"); + } else if(in.job_id < 0) { + LOGGER_ERROR( + "ADM_link_transfer_to_data_operation(): invalid job_id (< 0)"); } else { LOGGER_INFO("ADM_link_transfer_to_data_operation ({}, {}, {}, {}, {})", - in.operation_id, in.transfer_id, in.stream, in.arguments, - in.job_id); + in.operation_id, in.transfer_id, in.stream, in.arguments, + in.job_id); out.ret = 0; out.operation_handle = "operation_handle"; } @@ -1315,3 +1318,53 @@ ADM_link_transfer_to_data_operation(hg_handle_t h) { } DEFINE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation) + + +/** + * Returns the current I/O statistics for a specified job_id and an optional + * corresponding job_step. The information will be returned in an + * easy-to-process format, e.g., JSON (see Listing 3.1). + * + * @param in.job_id + * @param in.job_step + * @return out.job_statistics + * @return out.ret Returns if the remote procedure has been completed + * successfully or not. + */ +static void +ADM_get_statistics(hg_handle_t h) { + hg_return_t ret; + + ADM_get_statistics_in_t in; + ADM_get_statistics_out_t out; + + margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + out.job_statistics = nullptr; + + if(in.job_id < 0) { + LOGGER_ERROR("ADM_get_statistics(): invalid job_id (< 0)"); + } else if(in.job_step < 0) { + LOGGER_ERROR("ADM_get_statistics(): invalid job_step (< 0)"); + } else { + LOGGER_INFO("ADM_get_statistics ({}, {})", + in.job_id, in.job_step); + out.ret = 0; + out.job_statistics = "job_statistics"; + } + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_get_statistics) diff --git a/src/network/rpcs.hpp b/src/network/rpcs.hpp index 5d098316..170fb249 100644 --- a/src/network/rpcs.hpp +++ b/src/network/rpcs.hpp @@ -280,6 +280,17 @@ MERCURY_GEN_PROC(ADM_link_transfer_to_data_operation_out_t, DECLARE_MARGO_RPC_HANDLER(ADM_link_transfer_to_data_operation); +/// ADM_get_statistics + +MERCURY_GEN_PROC(ADM_get_statistics_in_t, + ((int32_t) (job_id))((int32_t) (job_step))) + +MERCURY_GEN_PROC(ADM_get_statistics_out_t, + ((int32_t) (ret))((hg_const_string_t) (job_statistics))) + +DECLARE_MARGO_RPC_HANDLER(ADM_get_statistics); + + //} // namespace scord::network::rpc -- GitLab From a43b9945080f3c893e32000542a2a421f95c15bc Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 17 May 2022 11:11:08 +0200 Subject: [PATCH 72/76] ADM_adhoc_access exit failure added --- examples/ADM_adhoc_access.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/ADM_adhoc_access.cpp b/examples/ADM_adhoc_access.cpp index df18e95d..2d28cf3a 100644 --- a/examples/ADM_adhoc_access.cpp +++ b/examples/ADM_adhoc_access.cpp @@ -31,6 +31,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_access remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, -- GitLab From 31333318f821b9a5bfb7167181528eebb27919b9 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 17 May 2022 11:23:46 +0200 Subject: [PATCH 73/76] Exit failure added to RPCs --- examples/ADM_adhoc_background_flush.cpp | 1 + examples/ADM_adhoc_context.cpp | 1 + examples/ADM_adhoc_context_id.cpp | 1 + examples/ADM_adhoc_distribution.cpp | 1 + examples/ADM_adhoc_nodes.cpp | 1 + examples/ADM_adhoc_walltime.cpp | 1 + examples/ADM_cancel_transfer.cpp | 1 + examples/ADM_connect_data_operation.cpp | 1 + examples/ADM_define_data_operation.cpp | 1 + examples/ADM_finalize_data_operation.cpp | 1 + examples/ADM_get_pending_transfers.cpp | 1 + examples/ADM_get_statistics.cpp | 1 + examples/ADM_get_transfer_priority.cpp | 1 + examples/ADM_in_situ_ops.cpp | 1 + examples/ADM_in_transit_ops.cpp | 1 + examples/ADM_inout.cpp | 1 + examples/ADM_input.cpp | 1 + examples/ADM_link_transfer_to_data_operation.cpp | 1 + examples/ADM_output.cpp | 1 + examples/ADM_set_dataset_information.cpp | 1 + examples/ADM_set_io_resources.cpp | 1 + examples/ADM_set_qos_constraints_pull.cpp | 1 + examples/ADM_set_qos_constraints_push.cpp | 1 + examples/ADM_set_transfer_priority.cpp | 1 + examples/ADM_transfer_dataset.cpp | 1 + 25 files changed, 25 insertions(+) diff --git a/examples/ADM_adhoc_background_flush.cpp b/examples/ADM_adhoc_background_flush.cpp index 074f4fc5..e8b52071 100644 --- a/examples/ADM_adhoc_background_flush.cpp +++ b/examples/ADM_adhoc_background_flush.cpp @@ -51,6 +51,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_background_flush remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_context.cpp b/examples/ADM_adhoc_context.cpp index d98d21af..527d8747 100644 --- a/examples/ADM_adhoc_context.cpp +++ b/examples/ADM_adhoc_context.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_context remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_context_id.cpp b/examples/ADM_adhoc_context_id.cpp index 4cc255b9..cf6705b0 100644 --- a/examples/ADM_adhoc_context_id.cpp +++ b/examples/ADM_adhoc_context_id.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_context_id remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_distribution.cpp b/examples/ADM_adhoc_distribution.cpp index aacb4911..4379b735 100644 --- a/examples/ADM_adhoc_distribution.cpp +++ b/examples/ADM_adhoc_distribution.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_distribution remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_adhoc_nodes.cpp b/examples/ADM_adhoc_nodes.cpp index 220f2972..91b36cf5 100644 --- a/examples/ADM_adhoc_nodes.cpp +++ b/examples/ADM_adhoc_nodes.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_nodes remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_adhoc_nodes remote procedure completed successfully\n"); diff --git a/examples/ADM_adhoc_walltime.cpp b/examples/ADM_adhoc_walltime.cpp index 28df9b48..49a38071 100644 --- a/examples/ADM_adhoc_walltime.cpp +++ b/examples/ADM_adhoc_walltime.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_adhoc_walltime remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_cancel_transfer.cpp b/examples/ADM_cancel_transfer.cpp index 52dfd5d2..f8cee99f 100644 --- a/examples/ADM_cancel_transfer.cpp +++ b/examples/ADM_cancel_transfer.cpp @@ -37,6 +37,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_cancel_transfer remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_connect_data_operation.cpp b/examples/ADM_connect_data_operation.cpp index 5643fb97..26c5118e 100644 --- a/examples/ADM_connect_data_operation.cpp +++ b/examples/ADM_connect_data_operation.cpp @@ -66,6 +66,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_connect_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_define_data_operation.cpp b/examples/ADM_define_data_operation.cpp index a484c1d8..a5b737d7 100644 --- a/examples/ADM_define_data_operation.cpp +++ b/examples/ADM_define_data_operation.cpp @@ -42,6 +42,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_define_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_finalize_data_operation.cpp b/examples/ADM_finalize_data_operation.cpp index e1e75f2e..7ad3f084 100644 --- a/examples/ADM_finalize_data_operation.cpp +++ b/examples/ADM_finalize_data_operation.cpp @@ -37,6 +37,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_finalize_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_get_pending_transfers.cpp b/examples/ADM_get_pending_transfers.cpp index 479e2efb..99fdb848 100644 --- a/examples/ADM_get_pending_transfers.cpp +++ b/examples/ADM_get_pending_transfers.cpp @@ -30,6 +30,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_get_pending_transfers remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_get_statistics.cpp b/examples/ADM_get_statistics.cpp index d15e4471..6d08b25d 100644 --- a/examples/ADM_get_statistics.cpp +++ b/examples/ADM_get_statistics.cpp @@ -44,6 +44,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_get_statistics remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_get_transfer_priority.cpp b/examples/ADM_get_transfer_priority.cpp index 8edf6ba8..a09663a3 100644 --- a/examples/ADM_get_transfer_priority.cpp +++ b/examples/ADM_get_transfer_priority.cpp @@ -38,6 +38,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_get_transfer_priority remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_in_situ_ops.cpp b/examples/ADM_in_situ_ops.cpp index f258a48e..b870e6ec 100644 --- a/examples/ADM_in_situ_ops.cpp +++ b/examples/ADM_in_situ_ops.cpp @@ -31,6 +31,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_in_situ_ops remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_in_situ_ops remote procedure completed successfully\n"); diff --git a/examples/ADM_in_transit_ops.cpp b/examples/ADM_in_transit_ops.cpp index 06bd3ec2..4eef3e94 100644 --- a/examples/ADM_in_transit_ops.cpp +++ b/examples/ADM_in_transit_ops.cpp @@ -31,6 +31,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_in_transit_ops remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_inout.cpp b/examples/ADM_inout.cpp index 9dbfa118..4b88dcdb 100644 --- a/examples/ADM_inout.cpp +++ b/examples/ADM_inout.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { if(out.ret < 0) { fmt::print(stdout, "ADM_inout remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_inout remote procedure completed successfully\n"); diff --git a/examples/ADM_input.cpp b/examples/ADM_input.cpp index 5be2f5f8..6a319980 100644 --- a/examples/ADM_input.cpp +++ b/examples/ADM_input.cpp @@ -33,6 +33,7 @@ main(int argc, char* argv[]) { if(out.ret < 0) { fmt::print(stdout, "ADM_input remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_input remote procedure completed successfully\n"); diff --git a/examples/ADM_link_transfer_to_data_operation.cpp b/examples/ADM_link_transfer_to_data_operation.cpp index 11ec2587..e939a981 100644 --- a/examples/ADM_link_transfer_to_data_operation.cpp +++ b/examples/ADM_link_transfer_to_data_operation.cpp @@ -71,6 +71,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_link_transfer_to_data_operation remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_output.cpp b/examples/ADM_output.cpp index f63a2726..b1b3c94a 100644 --- a/examples/ADM_output.cpp +++ b/examples/ADM_output.cpp @@ -32,6 +32,7 @@ main(int argc, char* argv[]) { if(out.ret < 0) { fmt::print(stdout, "ADM_output remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print(stdout, "ADM_output remote procedure completed successfully\n"); diff --git a/examples/ADM_set_dataset_information.cpp b/examples/ADM_set_dataset_information.cpp index b621f076..78d5dd5f 100644 --- a/examples/ADM_set_dataset_information.cpp +++ b/examples/ADM_set_dataset_information.cpp @@ -47,6 +47,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_dataset_information remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_io_resources.cpp b/examples/ADM_set_io_resources.cpp index 6b8bb7bd..8cbebb1a 100644 --- a/examples/ADM_set_io_resources.cpp +++ b/examples/ADM_set_io_resources.cpp @@ -46,6 +46,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_io_resources remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_qos_constraints_pull.cpp b/examples/ADM_set_qos_constraints_pull.cpp index 60c174b2..eb18fdb0 100644 --- a/examples/ADM_set_qos_constraints_pull.cpp +++ b/examples/ADM_set_qos_constraints_pull.cpp @@ -40,6 +40,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_qos_constraints_pull remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_qos_constraints_push.cpp b/examples/ADM_set_qos_constraints_push.cpp index d9612eaa..e5c2b1f5 100644 --- a/examples/ADM_set_qos_constraints_push.cpp +++ b/examples/ADM_set_qos_constraints_push.cpp @@ -42,6 +42,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_qos_constraints_push remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_set_transfer_priority.cpp b/examples/ADM_set_transfer_priority.cpp index 2dbfffcc..a82e3c09 100644 --- a/examples/ADM_set_transfer_priority.cpp +++ b/examples/ADM_set_transfer_priority.cpp @@ -44,6 +44,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_set_transfer_priority remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, diff --git a/examples/ADM_transfer_dataset.cpp b/examples/ADM_transfer_dataset.cpp index 0a2064bd..b1dd75f5 100644 --- a/examples/ADM_transfer_dataset.cpp +++ b/examples/ADM_transfer_dataset.cpp @@ -45,6 +45,7 @@ main(int argc, char* argv[]) { fmt::print( stdout, "ADM_transfer_dataset remote procedure not completed successfully\n"); + exit(EXIT_FAILURE); } else { fmt::print( stdout, -- GitLab From 91f201e2268613e04479c144a413f6c00c04eb19 Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 18 May 2022 12:58:04 +0200 Subject: [PATCH 74/76] Type error in ADM_set_qos_constraints_pull fixed --- examples/ADM_set_qos_constraints_pull.cpp | 5 ++--- src/network/rpcs.cpp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/ADM_set_qos_constraints_pull.cpp b/examples/ADM_set_qos_constraints_pull.cpp index eb18fdb0..ee57c9fb 100644 --- a/examples/ADM_set_qos_constraints_pull.cpp +++ b/examples/ADM_set_qos_constraints_pull.cpp @@ -27,7 +27,7 @@ main(int argc, char* argv[]) { try { in.element_id = std::stoi(argv[3]); } catch(const std::exception& e) { - fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n"); + fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n"); exit(EXIT_FAILURE); } @@ -35,10 +35,9 @@ main(int argc, char* argv[]) { endp.call("ADM_set_qos_constraints_pull", &in, &out); - if(out.ret < 0) { fmt::print( - stdout, + stderr, "ADM_set_qos_constraints_pull remote procedure not completed successfully\n"); exit(EXIT_FAILURE); } else { diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index e9c90b75..d7d0755d 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -1048,11 +1048,11 @@ ADM_set_qos_constraints_pull(hg_handle_t h) { out.list = nullptr; if(in.scope == nullptr) { - LOGGER_ERROR("ADM_input(): invalid scope (nullptr)"); + LOGGER_ERROR("ADM_set_qos_constraints_pull(): invalid scope (nullptr)"); } else if(in.element_id < 0) { - LOGGER_ERROR("ADM_input(): invalid element_id (< 0)"); + LOGGER_ERROR("ADM_set_qos_constraints_pull(): invalid element_id (< 0)"); } else { - LOGGER_INFO("ADM_input({}, {})", in.scope, in.element_id); + LOGGER_INFO("ADM_set_qos_constraints_pull({}, {})", in.scope, in.element_id); if((scp == "dataset") || (scp == "node") || (scp == "job")) { LOGGER_INFO( "ADM_set_qos_constraints_pull scope value is acceptable ({})", -- GitLab From 0f1ac16b35efac489265cc51d8bcc81cb437127a Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 24 May 2022 10:25:32 +0200 Subject: [PATCH 75/76] ADM_adhoc_background_flush modified --- src/network/rpcs.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index d7d0755d..7fb34105 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -491,15 +491,8 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - out.ret = -1; - - if(in.b_flush != true && in.b_flush != false) { - LOGGER_ERROR( - "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); - } else { - LOGGER_INFO("ADM_adhoc_background_flush({})", in.b_flush); - out.ret = 0; - } + LOGGER_INFO("ADM_adhoc_background_flush({})", in.b_flush); + out.ret = 0; ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab From f5e2608574a60466a2ed79989ba16a0b60bd4e63 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 24 May 2022 11:15:26 +0200 Subject: [PATCH 76/76] ADM_adhoc_background_flush modified --- src/network/rpcs.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/network/rpcs.cpp b/src/network/rpcs.cpp index ea310fed..7fb34105 100644 --- a/src/network/rpcs.cpp +++ b/src/network/rpcs.cpp @@ -491,20 +491,8 @@ ADM_adhoc_background_flush(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); -<<<<<<< HEAD LOGGER_INFO("ADM_adhoc_background_flush({})", in.b_flush); out.ret = 0; -======= - out.ret = -1; - - if(in.b_flush != true && in.b_flush != false) { - LOGGER_ERROR( - "ADM_adhoc_background_flush(): invalid background_flush (not true/false)"); - } else { - LOGGER_INFO("ADM_adhoc_background_flush({})", in.b_flush); - out.ret = 0; - } ->>>>>>> 91f201e2268613e04479c144a413f6c00c04eb19 ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab