From 3d4fc97d299b6b99c50e37b2da4452d237c3a5fd Mon Sep 17 00:00:00 2001 From: amanzano Date: Wed, 5 Oct 2022 12:55:17 +0200 Subject: [PATCH 1/9] First attempt to recover adhoc_storage --- examples/c/ADM_update_adhoc_storage.c | 6 ++- examples/cxx/ADM_update_adhoc_storage.cpp | 31 ++++++++++++-- src/common/net/proto/rpc_types.h | 13 +++++- src/lib/admire.cpp | 33 +++++---------- src/lib/admire.hpp | 7 ++-- src/lib/c_wrapper.cpp | 17 ++++++-- src/lib/detail/impl.cpp | 51 +++++++++++++++++++++++ src/lib/detail/impl.hpp | 5 +++ src/scord/rpc_handlers.cpp | 26 ++++++++++-- 9 files changed, 152 insertions(+), 37 deletions(-) diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index b20bf515..5ad3d0f1 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -78,7 +78,11 @@ main(int argc, char* argv[]) { fprintf(stdout, "ADM_register_adhoc_storage() remote procedure completed " "successfully\n"); - ret = ADM_update_adhoc_storage(server, ctx, adhoc_storage); + ADM_adhoc_context_t ctx_updated = ADM_adhoc_context_create( + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 200, false); + assert(ctx_updated); + + ret = ADM_update_adhoc_storage(server, ctx_updated, adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index fec1c4b5..caabd25e 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -25,6 +25,8 @@ #include #include +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -38,12 +40,35 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_adhoc_context_t ctx{}; - ADM_storage_t adhoc_storage{}; + const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); + const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); + + auto p = std::make_unique( + admire::storage::type::gekkofs, "foobar", + admire::adhoc_storage::execution_mode::separate_new, + admire::adhoc_storage::access_type::read_write, 42, 100, false); + + admire::job_requirements reqs(inputs, outputs, std::move(p)); + + std::string user_id = "adhoc_storage_42"; + + const auto adhoc_storage_ctx = admire::adhoc_storage::ctx{ + admire::adhoc_storage::execution_mode::separate_new, + admire::adhoc_storage::access_type::read_write, 42, 100, false}; + + const auto adhoc_storage_ctx_updated = admire::adhoc_storage::ctx{ + admire::adhoc_storage::execution_mode::separate_new, + admire::adhoc_storage::access_type::read_write, 42, 200, false}; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::update_adhoc_storage(server, ctx, adhoc_storage); + const auto job = admire::register_job(server, reqs); + + const auto adhoc_storage = admire::register_adhoc_storage( + server, job, user_id, adhoc_storage_ctx); + + const auto adhoc_storage_updated = admire::update_adhoc_storage( + server, adhoc_storage_ctx_updated, adhoc_storage); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", e.what()); diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index 4161ef5d..f18ae4aa 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -346,9 +346,18 @@ MERCURY_GEN_PROC( ); /// ADM_update_adhoc_storage -MERCURY_GEN_PROC(ADM_update_adhoc_storage_in_t, ((int32_t) (reqs))) +MERCURY_GEN_PROC( + ADM_update_adhoc_storage_in_t, + ((ADM_adhoc_context_t)(adhoc_storage_ctx)) + ((ADM_storage_t)(adhoc_storage)) +); -MERCURY_GEN_PROC(ADM_update_adhoc_storage_out_t, ((int32_t) (ret))) +MERCURY_GEN_PROC( + ADM_update_adhoc_storage_out_t, + ((hg_uint64_t) (op_id)) + ((int32_t) (retval)) + ((uint64_t)(server_id)) +); /// ADM_remove_adhoc_storage MERCURY_GEN_PROC(ADM_remove_adhoc_storage_in_t, ((int32_t) (reqs))) diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 54a51124..f32592da 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -248,32 +248,21 @@ register_adhoc_storage(const server& srv, const std::string& name, return rv.value(); } -ADM_return_t -update_adhoc_storage(const server& srv, ADM_adhoc_context_t ctx, - ADM_storage_t adhoc_storage) { - - (void) srv; - (void) ctx; - (void) adhoc_storage; - - scord::network::rpc_client rpc_client{srv.protocol(), rpc_registration_cb}; - - auto endp = rpc_client.lookup(srv.address()); - - LOGGER_INFO("ADM_update_adhoc_storage(...)"); - - ADM_update_adhoc_storage_in_t in{}; - ADM_update_adhoc_storage_out_t out; +admire::adhoc_storage +update_adhoc_storage(const server& srv, + const adhoc_storage::ctx& adhoc_storage_ctx, + const adhoc_storage& adhoc_storage) { - const auto rpc = endp.call("ADM_update_adhoc_storage", &in, &out); + const auto rv = + detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); - if(out.ret < 0) { - LOGGER_ERROR("ADM_update_adhoc_storage() = {}", out.ret); - return static_cast(out.ret); + if(!rv) { + throw std::runtime_error( + fmt::format("ADM_update_adhoc_storage() error: {}", + ADM_strerror(rv.error()))); } - LOGGER_INFO("ADM_update_adhoc_storage() = {}", ADM_SUCCESS); - return ADM_SUCCESS; + return rv.value(); } ADM_return_t diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 00e44943..f237727a 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -62,9 +62,10 @@ register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, const adhoc_storage::ctx& ctx); -ADM_return_t -update_adhoc_storage(const server& srv, ADM_adhoc_context_t ctx, - ADM_storage_t adhoc_storage); +admire::adhoc_storage +update_adhoc_storage(const server& srv, + const adhoc_storage::ctx& adhoc_storage_ctx, + const adhoc_storage& adhoc_storage); ADM_return_t remove_adhoc_storage(const server& srv, ADM_storage_t adhoc_storage); diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 05faa3f7..75e029dd 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -101,12 +101,23 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, } ADM_return_t -ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_context_t ctx, - ADM_storage_t adhoc_storage) { +ADM_update_adhoc_storage(ADM_server_t server, + ADM_adhoc_context_t adhoc_storage_ctx, + ADM_storage_t* adhoc_storage) { const admire::server srv{server}; - return admire::update_adhoc_storage(srv, ctx, adhoc_storage); + const auto rv = admire::detail::update_adhoc_storage( + srv, admire::adhoc_storage::ctx{adhoc_storage_ctx}, + admire::adhoc_storage{adhoc_storage}); + + if(!rv) { + return rv.error(); + } + + *adhoc_storage = admire::api::convert(*rv).release(); + + return ADM_SUCCESS; } ADM_return_t diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 91451d9e..437341a9 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -407,4 +407,55 @@ transfer_datasets(const server& srv, const job& job, return tx; } +tl::expected +update_adhoc_storage(const server& srv, + const adhoc_storage::ctx& adhoc_storage_ctx, + const adhoc_storage& adhoc_storage) { + + scord::network::rpc_client rpc_client{srv.protocol(), rpc_registration_cb}; + + const auto rpc_id = ::api::remote_procedure::new_id(); + auto endp = rpc_client.lookup(srv.address()); + + LOGGER_INFO("rpc id: name: {} from: {} => " + "body: {{job: {}}}", + rpc_id, std::quoted("ADM_"s + __FUNCTION__), + std::quoted(rpc_client.self_address()), job); + + // const auto rpc_job = api::convert(job); + // const auto rpc_user_id = user_id.c_str(); + const auto rpc_ctx = api::convert(adhoc_storage_ctx); + const auto rpc_adhoc_storage = api::convert(adhoc_storage); + // const auto rpc_adhoc_storage = adhoc_storage; + + + ADM_update_adhoc_storage_in_t in{ + rpc_ctx.get(), + rpc_adhoc_storage.get()}; // rpc_job.get(), rpc_user_id, + ADM_update_adhoc_storage_out_t out; + + const auto rpc = endp.call("ADM_update_adhoc_storage", &in, &out); + + if(out.retval < 0) { + const auto retval = static_cast(out.retval); + LOGGER_ERROR("rpc id: {} name: {} from: {} <= " + "body: {{retval: {}}} [op_id: {}]", + rpc_id, std::quoted("ADM_"s + __FUNCTION__), retval, + out.op_id); + return tl::make_unexpected(retval); + } + + // auto rpc_adhoc_storage = + // admire::adhoc_storage{admire::storage::type::gekkofs, user_id, ctx}; + + rpc_adhoc_storage.id() = out.server_id; + + LOGGER_INFO("rpc id: {} name: {} from: {} <= " + "body: {{retval: {}}} [op_id: {}]", + rpc_id, std::quoted("ADM_"s + __FUNCTION__), ADM_SUCCESS, + out.op_id); + + return rpc_adhoc_storage; +} + } // namespace admire::detail diff --git a/src/lib/detail/impl.hpp b/src/lib/detail/impl.hpp index 613b960e..8fbd689f 100644 --- a/src/lib/detail/impl.hpp +++ b/src/lib/detail/impl.hpp @@ -57,6 +57,11 @@ register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, const adhoc_storage::ctx& ctx); +tl::expected +update_adhoc_storage(const server& srv, + const adhoc_storage::ctx& adhoc_storage_ctx, + const adhoc_storage& adhoc_storage); + } // namespace admire::detail #endif // SCORD_ADMIRE_IMPL_HPP diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index b172e67e..5a88bb63 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -336,11 +336,31 @@ ADM_update_adhoc_storage(hg_handle_t h) { ret = margo_get_input(h, &in); assert(ret == HG_SUCCESS); - out.ret = -1; + const admire::adhoc_storage::ctx adhoc_storage_ctx(in.adhoc_storage_ctx); + // const admire::adhoc_storage adhoc_storage(in.adhoc_storage); + const auto adhoc_storage = adhoc_storage_manager::create( + admire::adhoc_storage::type::gekkofs, adhoc_storage.id(), + adhoc_storage_ctx); + + const auto rpc_id = remote_procedure::new_id(); + LOGGER_INFO("rpc id: {} name: {} from: {} => " + "body: {{adhoc_storage: {}}}", + rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), + adhoc_storage); - LOGGER_INFO("ADM_update_adhoc_storage()"); + // const auto adhoc_storage = adhoc_storage_manager::create( + // admire::adhoc_storage::type::gekkofs, id, ctx); - out.ret = 0; + admire::error_code rv = ADM_SUCCESS; + + out.op_id = rpc_id; + out.retval = rv; + out.server_id = *adhoc_storage.id(); + + LOGGER_INFO("rpc id: {} name: {} to: {} => " + "body: {{retval: {}, server_id: {}}}", + rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), + rv, out.server_id); ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab From 71b2a5578813b46fe5bd8253cf3a21d667951350 Mon Sep 17 00:00:00 2001 From: amanzano Date: Thu, 13 Oct 2022 16:52:35 +0200 Subject: [PATCH 2/9] Rebase of main done --- examples/c/ADM_update_adhoc_storage.c | 4 +++- examples/cxx/ADM_update_adhoc_storage.cpp | 4 ++-- src/common/api/admire_types.hpp | 1 + src/common/api/types.cpp | 16 ++++++++++++++++ src/common/net/proto/rpc_types.h | 2 +- src/lib/admire.cpp | 8 ++++---- src/lib/admire.h | 2 +- src/lib/admire.hpp | 2 +- src/lib/c_wrapper.cpp | 7 ++++--- src/lib/detail/impl.cpp | 20 ++++++++++---------- src/lib/detail/impl.hpp | 2 +- src/scord/rpc_handlers.cpp | 12 ++++++------ 12 files changed, 50 insertions(+), 30 deletions(-) diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index 5ad3d0f1..a489a9ca 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -82,7 +82,9 @@ main(int argc, char* argv[]) { ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 200, false); assert(ctx_updated); - ret = ADM_update_adhoc_storage(server, ctx_updated, adhoc_storage); + const auto adhoc_storage_id = "id"; + + ret = ADM_update_adhoc_storage(server, ctx_updated, adhoc_storage_id); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index caabd25e..e739cc9c 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -67,8 +67,8 @@ main(int argc, char* argv[]) { const auto adhoc_storage = admire::register_adhoc_storage( server, job, user_id, adhoc_storage_ctx); - const auto adhoc_storage_updated = admire::update_adhoc_storage( - server, adhoc_storage_ctx_updated, adhoc_storage); + /*const auto adhoc_storage_updated = admire::update_adhoc_storage( + server, adhoc_storage_ctx_updated, adhoc_storage);*/ } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", e.what()); diff --git a/src/common/api/admire_types.hpp b/src/common/api/admire_types.hpp index 8d13791b..cfaf9c79 100644 --- a/src/common/api/admire_types.hpp +++ b/src/common/api/admire_types.hpp @@ -402,6 +402,7 @@ struct adhoc_storage : public storage { execution_mode exec_mode, access_type access_type, adhoc_storage::resources res, std::uint32_t walltime, bool should_flush); + explicit adhoc_storage(ADM_storage_t storage); adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, ADM_adhoc_context_t ctx); adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index 0f1a05d7..e5bcdb59 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -1380,6 +1380,21 @@ private: adhoc_storage::ctx m_ctx; }; +void +foo(ADM_storage_t storage) { // donde se coloca? como ayuda eso a c_wrapper? + switch(storage->s_type) { + case ADM_STORAGE_GEKKOFS: + case ADM_STORAGE_DATACLAY: + case ADM_STORAGE_EXPAND: + case ADM_STORAGE_HERCULES: + break; + + case ADM_STORAGE_LUSTRE: + case ADM_STORAGE_GPFS: + // lanzar excepcion + break; + } +} adhoc_storage::adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, execution_mode exec_mode, @@ -1390,6 +1405,7 @@ adhoc_storage::adhoc_storage(enum storage::type type, std::string name, m_pimpl(std::make_unique( adhoc_storage::ctx{exec_mode, access_type, std::move(res), walltime, should_flush})) {} +adhoc_storage::adhoc_storage(ADM_storage_t storage) : m_pimpl(storage) {} adhoc_storage::adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, ADM_adhoc_context_t ctx) diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index f18ae4aa..c057ec45 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -349,7 +349,7 @@ MERCURY_GEN_PROC( MERCURY_GEN_PROC( ADM_update_adhoc_storage_in_t, ((ADM_adhoc_context_t)(adhoc_storage_ctx)) - ((ADM_storage_t)(adhoc_storage)) + ((hg_string_t)(adhoc_storage_id)) ); MERCURY_GEN_PROC( diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index f32592da..c58aa68d 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -248,21 +248,21 @@ register_adhoc_storage(const server& srv, const std::string& name, return rv.value(); } -admire::adhoc_storage +ADM_return_t update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage) { - const auto rv = - detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); + return detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); + /* if(!rv) { throw std::runtime_error( fmt::format("ADM_update_adhoc_storage() error: {}", ADM_strerror(rv.error()))); } - return rv.value(); + return rv.value(); */ } ADM_return_t diff --git a/src/lib/admire.h b/src/lib/admire.h index d0bf7cbb..57abe4ed 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -128,7 +128,7 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, */ ADM_return_t ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_context_t ctx, - ADM_storage_t adhoc_storage); + const char* adhoc_storage_id); /** * Remove an already-registered adhoc storage system. diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index f237727a..42ea040c 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -62,7 +62,7 @@ register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, const adhoc_storage::ctx& ctx); -admire::adhoc_storage +ADM_return_t update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage); diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 75e029dd..a872dbfa 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -107,17 +107,18 @@ ADM_update_adhoc_storage(ADM_server_t server, const admire::server srv{server}; - const auto rv = admire::detail::update_adhoc_storage( + return admire::detail::update_adhoc_storage( srv, admire::adhoc_storage::ctx{adhoc_storage_ctx}, admire::adhoc_storage{adhoc_storage}); + /* if(!rv) { return rv.error(); } - *adhoc_storage = admire::api::convert(*rv).release(); + *adhoc_storage = admire::api::convert(*rv).release(); */ - return ADM_SUCCESS; + // return ADM_SUCCESS; } ADM_return_t diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 437341a9..e8558374 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -407,7 +407,7 @@ transfer_datasets(const server& srv, const job& job, return tx; } -tl::expected +admire::error_code update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage) { @@ -418,20 +418,20 @@ update_adhoc_storage(const server& srv, auto endp = rpc_client.lookup(srv.address()); LOGGER_INFO("rpc id: name: {} from: {} => " - "body: {{job: {}}}", + "body: {{adhoc_storage_id: {}, adhoc_storage_ctx{}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), job); + std::quoted(rpc_client.self_address()), adhoc_storage_id, + adhoc_storage_ctx); // const auto rpc_job = api::convert(job); // const auto rpc_user_id = user_id.c_str(); const auto rpc_ctx = api::convert(adhoc_storage_ctx); - const auto rpc_adhoc_storage = api::convert(adhoc_storage); + // const auto rpc_adhoc_storage = api::convert(adhoc_storage); // const auto rpc_adhoc_storage = adhoc_storage; - ADM_update_adhoc_storage_in_t in{ - rpc_ctx.get(), - rpc_adhoc_storage.get()}; // rpc_job.get(), rpc_user_id, + ADM_update_adhoc_storage_in_t in{rpc_ctx.get(), adhoc_storage_id}; + // rpc_adhoc_storage.get()}; // rpc_job.get(), rpc_user_id, ADM_update_adhoc_storage_out_t out; const auto rpc = endp.call("ADM_update_adhoc_storage", &in, &out); @@ -442,20 +442,20 @@ update_adhoc_storage(const server& srv, "body: {{retval: {}}} [op_id: {}]", rpc_id, std::quoted("ADM_"s + __FUNCTION__), retval, out.op_id); - return tl::make_unexpected(retval); + return retval; } // auto rpc_adhoc_storage = // admire::adhoc_storage{admire::storage::type::gekkofs, user_id, ctx}; - rpc_adhoc_storage.id() = out.server_id; + // rpc_adhoc_storage.id() = out.server_id; LOGGER_INFO("rpc id: {} name: {} from: {} <= " "body: {{retval: {}}} [op_id: {}]", rpc_id, std::quoted("ADM_"s + __FUNCTION__), ADM_SUCCESS, out.op_id); - return rpc_adhoc_storage; + return ADM_SUCCESS; } } // namespace admire::detail diff --git a/src/lib/detail/impl.hpp b/src/lib/detail/impl.hpp index 8fbd689f..f80a1cfb 100644 --- a/src/lib/detail/impl.hpp +++ b/src/lib/detail/impl.hpp @@ -57,7 +57,7 @@ register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, const adhoc_storage::ctx& ctx); -tl::expected +admire::error_code update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage); diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 5a88bb63..bcdfdbfa 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -338,15 +338,15 @@ ADM_update_adhoc_storage(hg_handle_t h) { const admire::adhoc_storage::ctx adhoc_storage_ctx(in.adhoc_storage_ctx); // const admire::adhoc_storage adhoc_storage(in.adhoc_storage); - const auto adhoc_storage = adhoc_storage_manager::create( - admire::adhoc_storage::type::gekkofs, adhoc_storage.id(), - adhoc_storage_ctx); + /* const auto adhoc_storage = adhoc_storage_manager::create( + admire::adhoc_storage::type::gekkofs, adhoc_storage_id, + adhoc_storage_ctx); */ const auto rpc_id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{adhoc_storage: {}}}", + "body: {{adhoc_storage_id: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - adhoc_storage); + in.adhoc_storage_id); // const auto adhoc_storage = adhoc_storage_manager::create( // admire::adhoc_storage::type::gekkofs, id, ctx); @@ -355,7 +355,7 @@ ADM_update_adhoc_storage(hg_handle_t h) { out.op_id = rpc_id; out.retval = rv; - out.server_id = *adhoc_storage.id(); + // out.server_id = *adhoc_storage.id(); LOGGER_INFO("rpc id: {} name: {} to: {} => " "body: {{retval: {}, server_id: {}}}", -- GitLab From e81cbdaa811ac3f0c9172fab1e8a3dea1a353176 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 18 Oct 2022 12:05:33 +0200 Subject: [PATCH 3/9] ADM_update_adhoc_storage examples updated --- examples/c/ADM_update_adhoc_storage.c | 7 ++-- examples/cxx/ADM_update_adhoc_storage.cpp | 40 ++++++++++------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index a489a9ca..41f2c1ab 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -79,12 +79,11 @@ main(int argc, char* argv[]) { "successfully\n"); ADM_adhoc_context_t ctx_updated = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 200, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 200, false); assert(ctx_updated); - const auto adhoc_storage_id = "id"; - - ret = ADM_update_adhoc_storage(server, ctx_updated, adhoc_storage_id); + ret = ADM_update_adhoc_storage(server, ctx_updated, adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index e739cc9c..079c0cec 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -24,9 +24,11 @@ #include #include +#include "common.hpp" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -40,35 +42,32 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; + const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); - auto p = std::make_unique( - admire::storage::type::gekkofs, "foobar", - admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false); - - admire::job_requirements reqs(inputs, outputs, std::move(p)); - - std::string user_id = "adhoc_storage_42"; - + std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = admire::adhoc_storage::ctx{ admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false}; + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; const auto adhoc_storage_ctx_updated = admire::adhoc_storage::ctx{ admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 200, false}; + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 200, false}; + ADM_return_t ret = ADM_SUCCESS; try { - const auto job = admire::register_job(server, reqs); - const auto adhoc_storage = admire::register_adhoc_storage( - server, job, user_id, adhoc_storage_ctx); - - /*const auto adhoc_storage_updated = admire::update_adhoc_storage( - server, adhoc_storage_ctx_updated, adhoc_storage);*/ + server, name, admire::storage::type::gekkofs, + adhoc_storage_ctx); + ret = admire::update_adhoc_storage(server, adhoc_storage_ctx_updated, + adhoc_storage); + fmt::print(stdout, + "ADM_update_adhoc_storage() remote procedure completed " + "successfully\n"); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", e.what()); @@ -81,7 +80,4 @@ main(int argc, char* argv[]) { "successfully\n"); exit(EXIT_FAILURE); } - - fmt::print(stdout, "ADM_update_adhoc_storage() remote procedure completed " - "successfully\n"); } -- GitLab From f47ac5b472f34b405ee29761d79080fca87464b9 Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 18 Oct 2022 12:09:14 +0200 Subject: [PATCH 4/9] Code fixed and building successfully --- src/common/api/types.cpp | 36 ++++++++++++++++---------------- src/common/net/proto/rpc_types.h | 2 +- src/lib/admire.cpp | 10 --------- src/lib/admire.h | 2 +- src/lib/c_wrapper.cpp | 11 +--------- src/lib/detail/impl.cpp | 16 +++----------- src/scord/rpc_handlers.cpp | 10 +-------- src/scord/scord.cpp | 1 - 8 files changed, 25 insertions(+), 63 deletions(-) diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index e5bcdb59..2a337e98 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -629,7 +629,6 @@ ADM_data_operation_destroy(ADM_data_operation_t op) { return ret; } - ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, ADM_adhoc_access_t access_type, @@ -1380,22 +1379,6 @@ private: adhoc_storage::ctx m_ctx; }; -void -foo(ADM_storage_t storage) { // donde se coloca? como ayuda eso a c_wrapper? - switch(storage->s_type) { - case ADM_STORAGE_GEKKOFS: - case ADM_STORAGE_DATACLAY: - case ADM_STORAGE_EXPAND: - case ADM_STORAGE_HERCULES: - break; - - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - // lanzar excepcion - break; - } -} - adhoc_storage::adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, execution_mode exec_mode, access_type access_type, @@ -1405,7 +1388,24 @@ adhoc_storage::adhoc_storage(enum storage::type type, std::string name, m_pimpl(std::make_unique( adhoc_storage::ctx{exec_mode, access_type, std::move(res), walltime, should_flush})) {} -adhoc_storage::adhoc_storage(ADM_storage_t storage) : m_pimpl(storage) {} + +adhoc_storage::adhoc_storage(ADM_storage_t st) + : storage(static_cast(st->s_type), st->s_name, + st->s_id) { + + switch(st->s_type) { + case ADM_STORAGE_LUSTRE: + case ADM_STORAGE_GPFS: + throw std::runtime_error( + fmt::format("Invalid type {} for adhoc_storage", + static_cast(st->s_type))); + break; + + default: + break; + } + m_pimpl = std::make_unique(adhoc_storage::ctx{st->s_adhoc_ctx}); +} adhoc_storage::adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, ADM_adhoc_context_t ctx) diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index c057ec45..f18ae4aa 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -349,7 +349,7 @@ MERCURY_GEN_PROC( MERCURY_GEN_PROC( ADM_update_adhoc_storage_in_t, ((ADM_adhoc_context_t)(adhoc_storage_ctx)) - ((hg_string_t)(adhoc_storage_id)) + ((ADM_storage_t)(adhoc_storage)) ); MERCURY_GEN_PROC( diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index c58aa68d..a5749b00 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -252,17 +252,7 @@ ADM_return_t update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage) { - return detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); - - /* - if(!rv) { - throw std::runtime_error( - fmt::format("ADM_update_adhoc_storage() error: {}", - ADM_strerror(rv.error()))); - } - - return rv.value(); */ } ADM_return_t diff --git a/src/lib/admire.h b/src/lib/admire.h index 57abe4ed..d0bf7cbb 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -128,7 +128,7 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, */ ADM_return_t ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_context_t ctx, - const char* adhoc_storage_id); + ADM_storage_t adhoc_storage); /** * Remove an already-registered adhoc storage system. diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index a872dbfa..0f7bda5e 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -103,22 +103,13 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, ADM_return_t ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_context_t adhoc_storage_ctx, - ADM_storage_t* adhoc_storage) { + ADM_storage_t adhoc_storage) { const admire::server srv{server}; return admire::detail::update_adhoc_storage( srv, admire::adhoc_storage::ctx{adhoc_storage_ctx}, admire::adhoc_storage{adhoc_storage}); - - /* - if(!rv) { - return rv.error(); - } - - *adhoc_storage = admire::api::convert(*rv).release(); */ - - // return ADM_SUCCESS; } ADM_return_t diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index e8558374..5c3a1cad 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -420,18 +420,13 @@ update_adhoc_storage(const server& srv, LOGGER_INFO("rpc id: name: {} from: {} => " "body: {{adhoc_storage_id: {}, adhoc_storage_ctx{}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), adhoc_storage_id, + std::quoted(rpc_client.self_address()), adhoc_storage.id(), adhoc_storage_ctx); - // const auto rpc_job = api::convert(job); - // const auto rpc_user_id = user_id.c_str(); const auto rpc_ctx = api::convert(adhoc_storage_ctx); - // const auto rpc_adhoc_storage = api::convert(adhoc_storage); - // const auto rpc_adhoc_storage = adhoc_storage; + const auto rpc_adhoc_storage = api::convert(adhoc_storage); - - ADM_update_adhoc_storage_in_t in{rpc_ctx.get(), adhoc_storage_id}; - // rpc_adhoc_storage.get()}; // rpc_job.get(), rpc_user_id, + ADM_update_adhoc_storage_in_t in{rpc_ctx.get(), rpc_adhoc_storage.get()}; ADM_update_adhoc_storage_out_t out; const auto rpc = endp.call("ADM_update_adhoc_storage", &in, &out); @@ -445,11 +440,6 @@ update_adhoc_storage(const server& srv, return retval; } - // auto rpc_adhoc_storage = - // admire::adhoc_storage{admire::storage::type::gekkofs, user_id, ctx}; - - // rpc_adhoc_storage.id() = out.server_id; - LOGGER_INFO("rpc id: {} name: {} from: {} <= " "body: {{retval: {}}} [op_id: {}]", rpc_id, std::quoted("ADM_"s + __FUNCTION__), ADM_SUCCESS, diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index bcdfdbfa..08d71876 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -337,25 +337,17 @@ ADM_update_adhoc_storage(hg_handle_t h) { assert(ret == HG_SUCCESS); const admire::adhoc_storage::ctx adhoc_storage_ctx(in.adhoc_storage_ctx); - // const admire::adhoc_storage adhoc_storage(in.adhoc_storage); - /* const auto adhoc_storage = adhoc_storage_manager::create( - admire::adhoc_storage::type::gekkofs, adhoc_storage_id, - adhoc_storage_ctx); */ const auto rpc_id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " "body: {{adhoc_storage_id: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - in.adhoc_storage_id); - - // const auto adhoc_storage = adhoc_storage_manager::create( - // admire::adhoc_storage::type::gekkofs, id, ctx); + in.adhoc_storage->s_id); admire::error_code rv = ADM_SUCCESS; out.op_id = rpc_id; out.retval = rv; - // out.server_id = *adhoc_storage.id(); LOGGER_INFO("rpc id: {} name: {} to: {} => " "body: {{retval: {}, server_id: {}}}", diff --git a/src/scord/scord.cpp b/src/scord/scord.cpp index 64afe54d..77b09e57 100644 --- a/src/scord/scord.cpp +++ b/src/scord/scord.cpp @@ -224,7 +224,6 @@ main(int argc, char* argv[]) { REGISTER_RPC(ctx, "ADM_input", ADM_input_in_t, ADM_input_out_t, ADM_input, true); - REGISTER_RPC(ctx, "ADM_output", ADM_output_in_t, ADM_output_out_t, ADM_output, true); -- GitLab From 0370b97a24d821c2be5a91227c803e261d21a480 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 21 Oct 2022 16:15:18 +0200 Subject: [PATCH 5/9] Update code to new error_code semantics --- src/lib/admire.cpp | 2 +- src/lib/admire.hpp | 2 +- src/lib/detail/impl.cpp | 13 ++++++------- src/scord/rpc_handlers.cpp | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index a5749b00..debc4b8e 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -248,7 +248,7 @@ register_adhoc_storage(const server& srv, const std::string& name, return rv.value(); } -ADM_return_t +admire::error_code update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage) { diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 42ea040c..ceab7c6d 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -62,7 +62,7 @@ register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, const adhoc_storage::ctx& ctx); -ADM_return_t +admire::error_code update_adhoc_storage(const server& srv, const adhoc_storage::ctx& adhoc_storage_ctx, const adhoc_storage& adhoc_storage); diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 5c3a1cad..66df5760 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -431,21 +431,20 @@ update_adhoc_storage(const server& srv, const auto rpc = endp.call("ADM_update_adhoc_storage", &in, &out); - if(out.retval < 0) { - const auto retval = static_cast(out.retval); + if(const auto rv = admire::error_code{out.retval}; !rv) { LOGGER_ERROR("rpc id: {} name: {} from: {} <= " "body: {{retval: {}}} [op_id: {}]", - rpc_id, std::quoted("ADM_"s + __FUNCTION__), retval, + rpc_id, std::quoted("ADM_"s + __FUNCTION__), rv, out.op_id); - return retval; + return rv; } LOGGER_INFO("rpc id: {} name: {} from: {} <= " "body: {{retval: {}}} [op_id: {}]", - rpc_id, std::quoted("ADM_"s + __FUNCTION__), ADM_SUCCESS, - out.op_id); + rpc_id, std::quoted("ADM_"s + __FUNCTION__), + admire::error_code::success, out.op_id); - return ADM_SUCCESS; + return admire::error_code::success; } } // namespace admire::detail diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 08d71876..8e352159 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -344,15 +344,15 @@ ADM_update_adhoc_storage(hg_handle_t h) { rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), in.adhoc_storage->s_id); - admire::error_code rv = ADM_SUCCESS; + admire::error_code ec; out.op_id = rpc_id; - out.retval = rv; + out.retval = ec; LOGGER_INFO("rpc id: {} name: {} to: {} => " "body: {{retval: {}, server_id: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - rv, out.server_id); + ec, out.server_id); ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab From 6a5d54ac6a9f4f66b6a83aff763f546c6641a30d Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 24 Oct 2022 12:06:52 +0200 Subject: [PATCH 6/9] Logger info renamed --- src/lib/detail/impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 66df5760..93d89819 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -418,7 +418,7 @@ update_adhoc_storage(const server& srv, auto endp = rpc_client.lookup(srv.address()); LOGGER_INFO("rpc id: name: {} from: {} => " - "body: {{adhoc_storage_id: {}, adhoc_storage_ctx{}}}", + "body: {{id: {}, adhoc_ctx{}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), std::quoted(rpc_client.self_address()), adhoc_storage.id(), adhoc_storage_ctx); -- GitLab From bffc01fe9e963b9efc221ddeb83f2a2339fdaab2 Mon Sep 17 00:00:00 2001 From: amanzano Date: Fri, 21 Oct 2022 13:22:22 +0200 Subject: [PATCH 7/9] Update examples --- examples/c/ADM_update_adhoc_storage.c | 20 +++++++++++++--- examples/cxx/ADM_update_adhoc_storage.cpp | 29 ++++++++++++----------- src/lib/c_wrapper.cpp | 5 ++-- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index 41f2c1ab..3024bdb9 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -78,12 +78,12 @@ main(int argc, char* argv[]) { fprintf(stdout, "ADM_register_adhoc_storage() remote procedure completed " "successfully\n"); - ADM_adhoc_context_t ctx_updated = ADM_adhoc_context_create( + ADM_adhoc_context_t new_ctx = ADM_adhoc_context_create( ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, 200, false); - assert(ctx_updated); + assert(new_ctx); - ret = ADM_update_adhoc_storage(server, ctx_updated, adhoc_storage); + ret = ADM_update_adhoc_storage(server, new_ctx, adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, @@ -98,6 +98,20 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: + for(int i = 0; i < NINPUTS; ++i) { + ADM_dataset_destroy(inputs[i]); + } + + for(int i = 0; i < NOUTPUTS; ++i) { + ADM_dataset_destroy(outputs[i]); + } + + ADM_storage_destroy(adhoc_storage); + + ADM_adhoc_context_destroy(ctx); + + ADM_adhoc_context_destroy(new_ctx); + ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index 079c0cec..a353d457 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -43,6 +43,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); + const auto new_adhoc_nodes = prepare_nodes(NADHOC_NODES * 2); const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); @@ -52,32 +53,32 @@ main(int argc, char* argv[]) { admire::adhoc_storage::access_type::read_write, admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; - const auto adhoc_storage_ctx_updated = admire::adhoc_storage::ctx{ + const auto new_adhoc_storage_ctx = admire::adhoc_storage::ctx{ admire::adhoc_storage::execution_mode::separate_new, admire::adhoc_storage::access_type::read_write, - admire::adhoc_storage::resources{adhoc_nodes}, 200, false}; - - ADM_return_t ret = ADM_SUCCESS; + admire::adhoc_storage::resources{new_adhoc_nodes}, 200, false}; try { const auto adhoc_storage = admire::register_adhoc_storage( server, name, admire::storage::type::gekkofs, adhoc_storage_ctx); - ret = admire::update_adhoc_storage(server, adhoc_storage_ctx_updated, - adhoc_storage); + + const auto ret = admire::update_adhoc_storage( + server, new_adhoc_storage_ctx, adhoc_storage); + + if(!ret) { + fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", + ret.message()); + exit(EXIT_FAILURE); + } + fmt::print(stdout, "ADM_update_adhoc_storage() remote procedure completed " "successfully\n"); + exit(EXIT_SUCCESS); } catch(const std::exception& e) { - fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", + fmt::print(stderr, "FATAL: ADM_register_adhoc_storage() failed: {}\n", e.what()); exit(EXIT_FAILURE); } - - if(ret != ADM_SUCCESS) { - fmt::print(stdout, - "ADM_update_adhoc_storage() remote procedure not completed " - "successfully\n"); - exit(EXIT_FAILURE); - } } diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 0f7bda5e..a841b31c 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -101,14 +101,13 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, } ADM_return_t -ADM_update_adhoc_storage(ADM_server_t server, - ADM_adhoc_context_t adhoc_storage_ctx, +ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_context_t ctx, ADM_storage_t adhoc_storage) { const admire::server srv{server}; return admire::detail::update_adhoc_storage( - srv, admire::adhoc_storage::ctx{adhoc_storage_ctx}, + srv, admire::adhoc_storage::ctx{ctx}, admire::adhoc_storage{adhoc_storage}); } -- GitLab From ede837b912ae7b76911aaa1e38bc6660fc28958c Mon Sep 17 00:00:00 2001 From: amanzano Date: Mon, 24 Oct 2022 17:31:37 +0200 Subject: [PATCH 8/9] send server_id instead of full context --- src/common/net/proto/rpc_types.h | 5 ++--- src/lib/detail/impl.cpp | 3 +-- src/scord/rpc_handlers.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index f18ae4aa..dc828276 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -349,14 +349,13 @@ MERCURY_GEN_PROC( MERCURY_GEN_PROC( ADM_update_adhoc_storage_in_t, ((ADM_adhoc_context_t)(adhoc_storage_ctx)) - ((ADM_storage_t)(adhoc_storage)) + ((hg_uint64_t)(server_id)) ); MERCURY_GEN_PROC( ADM_update_adhoc_storage_out_t, ((hg_uint64_t) (op_id)) - ((int32_t) (retval)) - ((uint64_t)(server_id)) + ((hg_int32_t) (retval)) ); /// ADM_remove_adhoc_storage diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 93d89819..5d7c34c1 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -424,9 +424,8 @@ update_adhoc_storage(const server& srv, adhoc_storage_ctx); const auto rpc_ctx = api::convert(adhoc_storage_ctx); - const auto rpc_adhoc_storage = api::convert(adhoc_storage); - ADM_update_adhoc_storage_in_t in{rpc_ctx.get(), rpc_adhoc_storage.get()}; + ADM_update_adhoc_storage_in_t in{rpc_ctx.get(), adhoc_storage.id()}; ADM_update_adhoc_storage_out_t out; const auto rpc = endp.call("ADM_update_adhoc_storage", &in, &out); diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 8e352159..ca84ac7f 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -337,12 +337,13 @@ ADM_update_adhoc_storage(hg_handle_t h) { assert(ret == HG_SUCCESS); const admire::adhoc_storage::ctx adhoc_storage_ctx(in.adhoc_storage_ctx); + const std::uint64_t server_id(in.server_id); const auto rpc_id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " "body: {{adhoc_storage_id: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - in.adhoc_storage->s_id); + server_id); admire::error_code ec; @@ -350,9 +351,9 @@ ADM_update_adhoc_storage(hg_handle_t h) { out.retval = ec; LOGGER_INFO("rpc id: {} name: {} to: {} => " - "body: {{retval: {}, server_id: {}}}", + "body: {{retval: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - ec, out.server_id); + ec); ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); -- GitLab From ee7a9c03622bd5c9d440b4cab05004989bca1ebf Mon Sep 17 00:00:00 2001 From: amanzano Date: Tue, 25 Oct 2022 12:25:50 +0200 Subject: [PATCH 9/9] Registered adhoc_storages can now be updated --- src/scord/rpc_handlers.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index ca84ac7f..3c32c84e 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -345,7 +345,14 @@ ADM_update_adhoc_storage(hg_handle_t h) { rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), server_id); - admire::error_code ec; + auto& adhoc_manager = scord::adhoc_storage_manager::instance(); + const auto ec = adhoc_manager.update(server_id, adhoc_storage_ctx); + + if(!ec) { + LOGGER_ERROR( + "rpc id: {} error_msg: \"Error updating adhoc_storage: {}\"", + rpc_id, ec); + } out.op_id = rpc_id; out.retval = ec; -- GitLab