From b2f6ed63803a2bac25f1c036a0b85583f68103f3 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 17 Nov 2022 11:33:24 +0100 Subject: [PATCH 1/4] Fix return for ADM_update_job() --- examples/cxx/ADM_update_job.cpp | 3 +-- src/lib/admire.cpp | 10 ++++++++-- src/lib/admire.hpp | 2 +- src/lib/c_wrapper.cpp | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index 223bd33a..c3359421 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -65,8 +65,7 @@ main(int argc, char* argv[]) { [[maybe_unused]] const auto job = admire::register_job( server, admire::job::resources{job_nodes}, reqs, 0); - [[maybe_unused]] ADM_return_t ret = admire::update_job( - server, job, admire::job::resources{new_job_nodes}); + admire::update_job(server, job, admire::job::resources{new_job_nodes}); fmt::print( stdout, diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 5bb0dae0..e99153fa 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -221,10 +221,16 @@ register_job(const server& srv, const job::resources& resources, return rv.value(); } -admire::error_code +void update_job(const server& srv, const job& job, const job::resources& job_resources) { - return detail::update_job(srv, job, job_resources); + + const auto ec = detail::update_job(srv, job, job_resources); + + if(!ec) { + throw std::runtime_error( + fmt::format("ADM_update_job() error: {}", ec.message())); + } } admire::error_code diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 13ed1b3b..013b6638 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -51,7 +51,7 @@ admire::job register_job(const server& srv, const job::resources& job_resources, const job_requirements& reqs, admire::slurm_job_id slurm_id); -admire::error_code +void update_job(const server& srv, const job&, const job::resources& job_resources); admire::error_code diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index e9a2e142..7853dea3 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -68,8 +68,8 @@ ADM_update_job(ADM_server_t server, ADM_job_t job, const admire::server srv{server}; - return admire::update_job(srv, admire::job{job}, - admire::job::resources{job_resources}); + return admire::detail::update_job(srv, admire::job{job}, + admire::job::resources{job_resources}); } ADM_return_t -- GitLab From ccebb6b055967fbe394aefa52690d0d3fa894574 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 17 Nov 2022 11:36:11 +0100 Subject: [PATCH 2/4] Fix return for ADM_remove_job() --- examples/cxx/ADM_remove_job.cpp | 37 +++++++++++++++++++++++++++++---- src/lib/admire.cpp | 10 +++++++-- src/lib/admire.hpp | 2 +- src/lib/c_wrapper.cpp | 2 +- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/examples/cxx/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp index 0bd8fb87..0f320fae 100644 --- a/examples/cxx/ADM_remove_job.cpp +++ b/examples/cxx/ADM_remove_job.cpp @@ -24,7 +24,12 @@ #include #include +#include "common.hpp" +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -37,16 +42,40 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - admire::job job{42, 42}; + const auto job_nodes = prepare_nodes(NJOB_NODES); + const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); + const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); + const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); + + 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, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; try { - [[maybe_unused]] const auto ret = admire::remove_job(server, job); + + const auto adhoc_storage = admire::register_adhoc_storage( + server, name, admire::storage::type::gekkofs, + adhoc_storage_ctx); + + admire::job_requirements reqs(inputs, outputs, adhoc_storage); + + [[maybe_unused]] const auto job = admire::register_job( + server, admire::job::resources{job_nodes}, reqs, 0); + + // do something with job + + fmt::print(stdout, "ADM_register_job() remote procedure completed " + "successfully\n"); + + admire::remove_job(server, job); + fmt::print(stdout, "ADM_remove_job() remote procedure completed " "successfully\n"); exit(EXIT_SUCCESS); } catch(const std::exception& e) { - fmt::print(stdout, "ADM_remove_job() remote procedure not completed " - "successfully\n"); + fmt::print(stderr, "FATAL: example failed: {}\n", e.what()); exit(EXIT_FAILURE); } } diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index e99153fa..a4a06c39 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -233,9 +233,15 @@ update_job(const server& srv, const job& job, } } -admire::error_code +void remove_job(const server& srv, const job& job) { - return detail::remove_job(srv, job); + + const auto ec = detail::remove_job(srv, job); + + if(!ec) { + throw std::runtime_error( + fmt::format("ADM_remove_job() error: {}", ec.message())); + } } admire::adhoc_storage diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 013b6638..2b7f1ce1 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -54,7 +54,7 @@ register_job(const server& srv, const job::resources& job_resources, void update_job(const server& srv, const job&, const job::resources& job_resources); -admire::error_code +void remove_job(const server& srv, const job& job); admire::adhoc_storage diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 7853dea3..5cfd5eca 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -77,7 +77,7 @@ ADM_remove_job(ADM_server_t server, ADM_job_t job) { const admire::server srv{server}; - return admire::remove_job(srv, admire::job{job}); + return admire::detail::remove_job(srv, admire::job{job}); } ADM_return_t -- GitLab From 31e771090c6f89db6d2b382c964cc536e21f4923 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 17 Nov 2022 11:40:00 +0100 Subject: [PATCH 3/4] Fix return for ADM_update_adhoc_storage() --- examples/cxx/ADM_update_adhoc_storage.cpp | 13 +++---------- src/lib/admire.cpp | 10 ++++++++-- src/lib/admire.hpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index a2905446..cf1116da 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -63,22 +63,15 @@ main(int argc, char* argv[]) { server, name, admire::storage::type::gekkofs, adhoc_storage_ctx); - const auto ret = admire::update_adhoc_storage(server, adhoc_storage, - new_adhoc_storage_ctx); - - if(!ret) { - fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", - ret.message()); - exit(EXIT_FAILURE); - } + admire::update_adhoc_storage(server, adhoc_storage, + new_adhoc_storage_ctx); 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_register_adhoc_storage() failed: {}\n", - e.what()); + fmt::print(stderr, "FATAL: example failed: {}\n", e.what()); exit(EXIT_FAILURE); } } diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index a4a06c39..7dc46bba 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -260,10 +260,16 @@ register_adhoc_storage(const server& srv, const std::string& name, return rv.value(); } -admire::error_code +void update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, const adhoc_storage::ctx& adhoc_storage_ctx) { - return detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); + const auto ec = + detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); + + if(!ec) { + throw std::runtime_error(fmt::format( + "ADM_update_adhoc_storage() error: {}", ec.message())); + } } admire::error_code diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 2b7f1ce1..9f78f994 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::error_code +void update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, const adhoc_storage::ctx& adhoc_storage_ctx); -- GitLab From a711330564eaff397f383582b19e72649bf4a8d7 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 17 Nov 2022 11:45:28 +0100 Subject: [PATCH 4/4] Fix return for ADM_remove_adhoc_storage() --- src/lib/admire.cpp | 10 ++++++++-- src/lib/admire.hpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 7dc46bba..98bc455a 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -272,9 +272,15 @@ update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, } } -admire::error_code +void remove_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) { - return detail::remove_adhoc_storage(srv, adhoc_storage); + + const auto ec = detail::remove_adhoc_storage(srv, adhoc_storage); + + if(!ec) { + throw std::runtime_error(fmt::format( + "ADM_remove_adhoc_storage() error: {}", ec.message())); + } } ADM_return_t diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 9f78f994..4e690b18 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -66,7 +66,7 @@ void update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, const adhoc_storage::ctx& adhoc_storage_ctx); -admire::error_code +void remove_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage); ADM_return_t -- GitLab