From f6afefcb0a5934e0535ba566c96a831a81bc9adc Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Fri, 7 Oct 2022 19:35:10 +0200 Subject: [PATCH 1/6] job_requirements: Refactor away std::unique_ptr arg --- src/common/api/admire_types.hpp | 24 +++++++++++++---- src/common/api/convert.cpp | 21 +++++++++++++-- src/common/api/convert.hpp | 8 ++++++ src/common/api/types.cpp | 47 +++++++++++---------------------- 4 files changed, 61 insertions(+), 39 deletions(-) diff --git a/src/common/api/admire_types.hpp b/src/common/api/admire_types.hpp index b6ad7136..9ce2f8aa 100644 --- a/src/common/api/admire_types.hpp +++ b/src/common/api/admire_types.hpp @@ -389,7 +389,7 @@ struct job_requirements { job_requirements(std::vector inputs, std::vector outputs, - std::unique_ptr storage); + admire::adhoc_storage adhoc_storage); explicit job_requirements(ADM_job_requirements_t reqs); @@ -406,8 +406,8 @@ struct job_requirements { inputs() const; std::vector outputs() const; - std::shared_ptr - storage() const; + std::optional + adhoc_storage() const; private: class impl; @@ -632,6 +632,20 @@ struct fmt::formatter> } }; +template <> +struct fmt::formatter> + : formatter { + + // parse is inherited from formatter. + template + auto + format(const std::optional& v, + FormatContext& ctx) const { + return formatter::format( + v ? fmt::format("{}", v.value()) : "none", ctx); + } +}; + template <> struct fmt::formatter : formatter { // parse is inherited from formatter. @@ -729,8 +743,8 @@ struct fmt::formatter : formatter { auto format(const admire::job_requirements& r, FormatContext& ctx) const { return formatter::format( - fmt::format("{{inputs: {}, outputs: {}, storage: {}}}", - r.inputs(), r.outputs(), r.storage()), + fmt::format("{{inputs: {}, outputs: {}, adhoc_storage: {}}}", + r.inputs(), r.outputs(), r.adhoc_storage()), ctx); } }; diff --git a/src/common/api/convert.cpp b/src/common/api/convert.cpp index 8f6e5f80..b0c84ad1 100644 --- a/src/common/api/convert.cpp +++ b/src/common/api/convert.cpp @@ -96,6 +96,24 @@ convert(const adhoc_storage::ctx& ctx) { std::move(managed_adhoc_resources)}; } +managed_ctype +convert(const std::optional& adhoc_storage) { + + if(!adhoc_storage) { + return managed_ctype{}; + } + + auto managed_ctx = + convert(*std::static_pointer_cast( + adhoc_storage->context())); + ADM_storage_t c_st = ADM_storage_create( + adhoc_storage->user_id().c_str(), + static_cast(adhoc_storage->type()), + managed_ctx.get()); + + return managed_ctype{c_st, std::move(managed_ctx)}; +} + managed_ctype convert(const admire::adhoc_storage& st) { @@ -174,8 +192,7 @@ convert(const job::resources& res) { managed_ctype convert(const admire::job_requirements& reqs) { - const auto& adhoc_storage = - *std::dynamic_pointer_cast(reqs.storage()); + const auto& adhoc_storage = reqs.adhoc_storage(); auto managed_storage = convert(adhoc_storage); auto managed_inputs = as_ctype_array(reqs.inputs()); diff --git a/src/common/api/convert.hpp b/src/common/api/convert.hpp index 7d1e84a7..7cd8f19a 100644 --- a/src/common/api/convert.hpp +++ b/src/common/api/convert.hpp @@ -118,6 +118,8 @@ struct admire::api::managed_ctype { template <> struct admire::api::managed_ctype_array { + managed_ctype_array() = default; + explicit managed_ctype_array(ADM_node_t* data, size_t size) : m_nodes(data, size) {} @@ -150,6 +152,8 @@ struct admire::api::managed_ctype_array { template <> struct admire::api::managed_ctype { + managed_ctype() = default; + explicit managed_ctype(ADM_adhoc_resources_t res, managed_ctype_array&& nodes) : m_adhoc_resources(res), m_nodes(std::move(nodes)) {} @@ -172,6 +176,8 @@ struct admire::api::managed_ctype { template <> struct admire::api::managed_ctype { + managed_ctype() = default; + explicit managed_ctype(ADM_adhoc_context_t ctx, managed_ctype&& resources) : m_adhoc_context(ctx), m_adhoc_resources(std::move(resources)) {} @@ -194,6 +200,8 @@ struct admire::api::managed_ctype { template <> struct admire::api::managed_ctype { + managed_ctype() = default; + explicit managed_ctype(ADM_storage_t st, managed_ctype&& ctx) : m_storage(st), m_ctx(std::move(ctx)) {} diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index 3319471a..400d3802 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -1469,9 +1469,10 @@ public: impl(std::vector inputs, std::vector outputs, - std::unique_ptr storage) + admire::adhoc_storage adhoc_storage) : m_inputs(std::move(inputs)), m_outputs(std::move(outputs)), - m_storage(std::move(storage)) {} + m_adhoc_storage(std::move(adhoc_storage)) {} + explicit impl(ADM_job_requirements_t reqs) { m_inputs.reserve(reqs->r_inputs->l_length); @@ -1487,27 +1488,9 @@ public: } if(reqs->r_storage) { - - switch(reqs->r_storage->s_type) { - - case ADM_STORAGE_GEKKOFS: - case ADM_STORAGE_DATACLAY: - case ADM_STORAGE_EXPAND: - case ADM_STORAGE_HERCULES: - m_storage = std::make_unique( - static_cast( - reqs->r_storage->s_type), - reqs->r_storage->s_id, - reqs->r_storage->s_adhoc_ctx); - break; - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - m_storage = std::make_unique( - static_cast( - reqs->r_storage->s_type), - reqs->r_storage->s_id, reqs->r_storage->s_pfs_ctx); - break; - } + m_adhoc_storage = admire::adhoc_storage( + static_cast(reqs->r_storage->s_type), + reqs->r_storage->s_id, reqs->r_storage->s_adhoc_ctx); } } @@ -1528,15 +1511,15 @@ public: return m_outputs; } - std::shared_ptr - storage() const { - return m_storage; + std::optional + adhoc_storage() const { + return m_adhoc_storage; } private: std::vector m_inputs; std::vector m_outputs; - std::shared_ptr m_storage; + std::optional m_adhoc_storage; }; @@ -1546,9 +1529,9 @@ job_requirements::job_requirements(std::vector inputs, job_requirements::job_requirements(std::vector inputs, std::vector outputs, - std::unique_ptr storage) + admire::adhoc_storage adhoc_storage) : m_pimpl(std::make_unique(std::move(inputs), std::move(outputs), - std::move(storage))) {} + std::move(adhoc_storage))) {} job_requirements::job_requirements(ADM_job_requirements_t reqs) : m_pimpl(std::make_unique(reqs)) {} @@ -1579,9 +1562,9 @@ job_requirements::outputs() const { return m_pimpl->outputs(); } -std::shared_ptr -job_requirements::storage() const { - return m_pimpl->storage(); +std::optional +job_requirements::adhoc_storage() const { + return m_pimpl->adhoc_storage(); } namespace qos { -- GitLab From 4d6a60e916129b01cbde6123982c80a2b003a867 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Fri, 7 Oct 2022 20:48:06 +0200 Subject: [PATCH 2/6] examples: Remove calls to ADM_storage_create() --- examples/c/ADM_cancel_transfer.c | 20 ++++++++++++---- examples/c/ADM_connect_data_operation.c | 21 +++++++++++++---- examples/c/ADM_define_data_operation.c | 21 +++++++++++++---- examples/c/ADM_deploy_adhoc_storage.c | 7 ------ examples/c/ADM_finalize_data_operation.c | 21 +++++++++++++---- examples/c/ADM_get_pending_transfers.c | 21 +++++++++++++---- examples/c/ADM_get_qos_constraints.c | 21 +++++++++++++---- examples/c/ADM_get_statistics.c | 21 +++++++++++++---- examples/c/ADM_get_transfer_priority.c | 21 +++++++++++++---- .../c/ADM_link_transfer_to_data_operation.c | 21 +++++++++++++---- examples/c/ADM_register_adhoc_storage.c | 7 ------ examples/c/ADM_register_job.c | 23 ++++++++++++++----- examples/c/ADM_register_pfs_storage.c | 3 --- examples/c/ADM_remove_adhoc_storage.c | 7 ------ examples/c/ADM_remove_job.c | 21 +++++++++++++---- examples/c/ADM_remove_pfs_storage.c | 3 --- examples/c/ADM_set_dataset_information.c | 21 +++++++++++++---- examples/c/ADM_set_io_resources.c | 21 +++++++++++++---- examples/c/ADM_set_qos_constraints.c | 21 +++++++++++++---- examples/c/ADM_set_transfer_priority.c | 21 +++++++++++++---- examples/c/ADM_transfer_datasets.c | 21 +++++++++++++---- examples/c/ADM_update_adhoc_storage.c | 7 ------ examples/c/ADM_update_job.c | 23 ++++++++++++++----- examples/c/ADM_update_pfs_storage.c | 3 --- examples/cxx/ADM_register_adhoc_storage.cpp | 11 --------- examples/cxx/ADM_register_job.cpp | 14 +++++++---- examples/cxx/ADM_transfer_datasets.cpp | 13 +++++++---- examples/cxx/ADM_update_job.cpp | 20 +++++++--------- 28 files changed, 298 insertions(+), 157 deletions(-) diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 14831a40..193279f8 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -68,14 +68,24 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, "ADM_register_adhoc_storage() remote procedure not " + "completed successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_connect_data_operation.c b/examples/c/ADM_connect_data_operation.c index 38cc1daa..cf205bdf 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -64,18 +64,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_define_data_operation.c b/examples/c/ADM_define_data_operation.c index ac952793..894f0593 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -69,14 +69,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_deploy_adhoc_storage.c b/examples/c/ADM_deploy_adhoc_storage.c index 37fb1e4e..d5533ddf 100644 --- a/examples/c/ADM_deploy_adhoc_storage.c +++ b/examples/c/ADM_deploy_adhoc_storage.c @@ -60,13 +60,6 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); - - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); - assert(reqs); - const char* user_id = "adhoc_storage_42"; ADM_storage_t adhoc_storage; diff --git a/examples/c/ADM_finalize_data_operation.c b/examples/c/ADM_finalize_data_operation.c index cc6bb5a1..226ddb03 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -65,18 +65,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_pending_transfers.c b/examples/c/ADM_get_pending_transfers.c index fe320b25..90329761 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_qos_constraints.c b/examples/c/ADM_get_qos_constraints.c index 36679095..339afe5d 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -64,18 +64,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_statistics.c b/examples/c/ADM_get_statistics.c index 294cc6c2..0d9a5603 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -64,18 +64,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_transfer_priority.c b/examples/c/ADM_get_transfer_priority.c index c243fea9..7c33200e 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_link_transfer_to_data_operation.c b/examples/c/ADM_link_transfer_to_data_operation.c index 12f9024d..c333e7e3 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -65,18 +65,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_register_adhoc_storage.c b/examples/c/ADM_register_adhoc_storage.c index 9b859d4e..0302f307 100644 --- a/examples/c/ADM_register_adhoc_storage.c +++ b/examples/c/ADM_register_adhoc_storage.c @@ -60,13 +60,6 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); - - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); - assert(reqs); - const char* user_id = "adhoc_storage_42"; ADM_storage_t adhoc_storage; diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 6b4b02ca..8e7c7c1b 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " @@ -96,7 +107,7 @@ cleanup: ADM_dataset_destroy(outputs[i]); } - ADM_storage_destroy(st); + ADM_storage_destroy(adhoc_storage); ADM_adhoc_context_destroy(ctx); diff --git a/examples/c/ADM_register_pfs_storage.c b/examples/c/ADM_register_pfs_storage.c index 9d09281f..149631a4 100644 --- a/examples/c/ADM_register_pfs_storage.c +++ b/examples/c/ADM_register_pfs_storage.c @@ -57,9 +57,6 @@ main(int argc, char* argv[]) { ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); assert(ctx); - ADM_storage_t st = ADM_storage_create("barbaz", ADM_STORAGE_GPFS, ctx); - assert(st); - ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); if(ret != ADM_SUCCESS) { diff --git a/examples/c/ADM_remove_adhoc_storage.c b/examples/c/ADM_remove_adhoc_storage.c index 45422b93..f8b5eaba 100644 --- a/examples/c/ADM_remove_adhoc_storage.c +++ b/examples/c/ADM_remove_adhoc_storage.c @@ -60,13 +60,6 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); - - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); - assert(reqs); - const char* user_id = "adhoc_storage_42"; ADM_storage_t adhoc_storage; diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index 979acc06..73dedbe4 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_remove_pfs_storage.c b/examples/c/ADM_remove_pfs_storage.c index a1a240d1..b24b4178 100644 --- a/examples/c/ADM_remove_pfs_storage.c +++ b/examples/c/ADM_remove_pfs_storage.c @@ -42,9 +42,6 @@ main(int argc, char* argv[]) { ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); assert(ctx); - ADM_storage_t st = ADM_storage_create("barbaz", ADM_STORAGE_GPFS, ctx); - assert(st); - ADM_storage_t pfs_storage; ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index c43169f6..5e342f72 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -65,18 +65,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_set_io_resources.c b/examples/c/ADM_set_io_resources.c index 9baed9a5..eabe6fa9 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -64,18 +64,29 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; + + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } ADM_job_resources_t job_resources = ADM_job_resources_create(job_nodes, NJOB_NODES); assert(job_resources); - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index 20cc389c..6353f92e 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_set_transfer_priority.c b/examples/c/ADM_set_transfer_priority.c index 77875968..018b2943 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_transfer_datasets.c b/examples/c/ADM_transfer_datasets.c index f157c2ba..bd918ec2 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -71,14 +71,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index e02a8033..7080e772 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -60,13 +60,6 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); - - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); - assert(reqs); - const char* user_id = "adhoc_storage_42"; ADM_storage_t adhoc_storage; diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index be0b22b6..35deba4b 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -68,14 +68,25 @@ main(int argc, char* argv[]) { 100, false); assert(ctx); - ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); - assert(st); + const char* user_id = "adhoc_storage_42"; - ADM_job_requirements_t reqs = - ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); + ADM_storage_t adhoc_storage; + ADM_return_t ret = + ADM_register_adhoc_storage(server, user_id, ctx, &adhoc_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_adhoc_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); + ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " @@ -104,7 +115,7 @@ main(int argc, char* argv[]) { } ADM_job_requirements_t new_reqs = ADM_job_requirements_create( - new_inputs, NINPUTS, new_outputs, NOUTPUTS, st); + new_inputs, NINPUTS, new_outputs, NOUTPUTS, adhoc_storage); ret = ADM_update_job(server, job, job_resources, new_reqs); diff --git a/examples/c/ADM_update_pfs_storage.c b/examples/c/ADM_update_pfs_storage.c index 6acc1127..96a95afa 100644 --- a/examples/c/ADM_update_pfs_storage.c +++ b/examples/c/ADM_update_pfs_storage.c @@ -42,9 +42,6 @@ main(int argc, char* argv[]) { ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); assert(ctx); - ADM_storage_t st = ADM_storage_create("barbaz", ADM_STORAGE_GPFS, ctx); - assert(st); - ADM_storage_t pfs_storage; ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index 8e91fb73..8a74085a 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -43,19 +43,10 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - 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); - auto p = std::make_unique( - admire::storage::type::gekkofs, "foobar", - admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, - admire::adhoc_storage::resources{adhoc_nodes}, 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, @@ -63,8 +54,6 @@ main(int argc, char* argv[]) { admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; try { - const auto job = admire::register_job( - server, admire::job::resources{job_nodes}, reqs); const auto adhoc_storage = admire::register_adhoc_storage( server, user_id, adhoc_storage_ctx); diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index c75c06b0..9eda2df1 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -47,15 +47,19 @@ main(int argc, char* argv[]) { 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", + 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, - admire::adhoc_storage::resources{adhoc_nodes}, 100, false); - - admire::job_requirements reqs(inputs, outputs, std::move(p)); + admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; try { + + const auto adhoc_storage = admire::register_adhoc_storage( + server, user_id, 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); diff --git a/examples/cxx/ADM_transfer_datasets.cpp b/examples/cxx/ADM_transfer_datasets.cpp index c48ac934..381b0777 100644 --- a/examples/cxx/ADM_transfer_datasets.cpp +++ b/examples/cxx/ADM_transfer_datasets.cpp @@ -55,15 +55,18 @@ main(int argc, char* argv[]) { const auto qos_limits = prepare_qos_limits(NLIMITS); const auto mapping = admire::transfer::mapping::n_to_n; - auto p = std::make_unique( - admire::storage::type::gekkofs, "foobar", + 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, - admire::adhoc_storage::resources{adhoc_nodes}, 100, false); - - admire::job_requirements reqs(inputs, outputs, std::move(p)); + admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; try { + const auto adhoc_storage = admire::register_adhoc_storage( + server, user_id, adhoc_storage_ctx); + + admire::job_requirements reqs(inputs, outputs, adhoc_storage); + const auto job = admire::register_job( server, admire::job::resources{job_nodes}, reqs); const auto transfer = admire::transfer_datasets( diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index 70bc1c8a..84b92008 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -47,26 +47,22 @@ main(int argc, char* argv[]) { 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", + const auto gkfs_storage = admire::adhoc_storage{ + admire::storage::type::gekkofs, + "foobar", admire::adhoc_storage::execution_mode::separate_new, admire::adhoc_storage::access_type::read_write, - admire::adhoc_storage::resources{adhoc_nodes}, 100, false); - - admire::job_requirements reqs{inputs, outputs, std::move(p)}; + admire::adhoc_storage::resources{adhoc_nodes}, + 100, + false}; + admire::job_requirements reqs{inputs, outputs, gkfs_storage}; const auto new_inputs = prepare_datasets("input-new-dataset-{}", NINPUTS); const auto new_outputs = prepare_datasets("output-new-dataset-{}", NOUTPUTS); - auto p2 = std::make_unique( - admire::storage::type::gekkofs, "foobar", - admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, - admire::adhoc_storage::resources{adhoc_nodes}, 100, false); - - admire::job_requirements new_reqs{new_inputs, new_outputs, std::move(p2)}; + admire::job_requirements new_reqs{new_inputs, new_outputs, gkfs_storage}; try { [[maybe_unused]] const auto job = admire::register_job( -- GitLab From 7b72f1138ee939b5fa745750f0ee79d7be0cdf40 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 10 Oct 2022 17:41:28 +0200 Subject: [PATCH 3/6] convert: Update conversions for adhoc_storage --- src/common/api/convert.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/common/api/convert.cpp b/src/common/api/convert.cpp index b0c84ad1..2d256784 100644 --- a/src/common/api/convert.cpp +++ b/src/common/api/convert.cpp @@ -103,15 +103,7 @@ convert(const std::optional& adhoc_storage) { return managed_ctype{}; } - auto managed_ctx = - convert(*std::static_pointer_cast( - adhoc_storage->context())); - ADM_storage_t c_st = ADM_storage_create( - adhoc_storage->user_id().c_str(), - static_cast(adhoc_storage->type()), - managed_ctx.get()); - - return managed_ctype{c_st, std::move(managed_ctx)}; + return convert(adhoc_storage.value()); } managed_ctype @@ -124,6 +116,10 @@ convert(const admire::adhoc_storage& st) { st.user_id().c_str(), static_cast(st.type()), managed_ctx.get()); + if(st.id()) { + c_st->s_server_id = static_cast(st.id().value()); + } + return managed_ctype{c_st, std::move(managed_ctx)}; } -- GitLab From c59bd35c14eb0650a18c208bd7848d923e917dec Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 10 Oct 2022 18:10:39 +0200 Subject: [PATCH 4/6] adm_storage: add missing server_id field and update hg_proc_ADM_storage_t: encode/decode server_id --- src/common/api/types.cpp | 8 ++++++++ src/common/net/proto/rpc_types.c | 18 ++++++++++++++++-- src/common/net/proto/rpc_types.h | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index 400d3802..39375b36 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -463,6 +463,7 @@ ADM_storage_create(const char* id, ADM_storage_type_t type, void* ctx) { adm_storage->s_id = (const char*) calloc(strlen(id) + 1, sizeof(char)); strcpy((char*) adm_storage->s_id, id); adm_storage->s_type = type; + adm_storage->s_server_id = -1; switch(adm_storage->s_type) { case ADM_STORAGE_GEKKOFS: @@ -799,6 +800,7 @@ ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, adm_job_reqs->r_storage = ADM_storage_create(storage->s_id, storage->s_type, storage->s_adhoc_ctx); + adm_job_reqs->r_storage->s_server_id = storage->s_server_id; return adm_job_reqs; @@ -1488,9 +1490,15 @@ public: } if(reqs->r_storage) { + // TODO add a conversion constructor m_adhoc_storage = admire::adhoc_storage( static_cast(reqs->r_storage->s_type), reqs->r_storage->s_id, reqs->r_storage->s_adhoc_ctx); + + if(const auto server_id = reqs->r_storage->s_server_id; + server_id != -1) { + m_adhoc_storage->id() = server_id; + } } } diff --git a/src/common/net/proto/rpc_types.c b/src/common/net/proto/rpc_types.c index 8a2aa664..2f837984 100644 --- a/src/common/net/proto/rpc_types.c +++ b/src/common/net/proto/rpc_types.c @@ -427,7 +427,14 @@ hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { break; } - // 3. the appropriate storage context + // 3. the server_id + ret = hg_proc_hg_int64_t(proc, &tmp->s_server_id); + + if(ret != HG_SUCCESS) { + break; + } + + // 4. the appropriate storage context switch(tmp->s_type) { case ADM_STORAGE_GEKKOFS: case ADM_STORAGE_DATACLAY: @@ -474,7 +481,14 @@ hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { break; } - // 3. the appropriate storage context + // 3. the server_id + ret = hg_proc_hg_int64_t(proc, &tmp->s_server_id); + + if(ret != HG_SUCCESS) { + break; + } + + // 4. the appropriate storage context switch(tmp->s_type) { case ADM_STORAGE_GEKKOFS: case ADM_STORAGE_DATACLAY: diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index c11bc37f..94ffe7ed 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -182,7 +182,7 @@ MERCURY_GEN_STRUCT_PROC( typedef struct adm_storage { const char* s_id; ADM_storage_type_t s_type; - uint64_t s_server_id; + int64_t s_server_id; union { ADM_adhoc_context_t s_adhoc_ctx; ADM_pfs_context_t s_pfs_ctx; -- GitLab From e8302771a5bf7818a94e0261952cb04c41d50a08 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 13 Oct 2022 13:20:38 +0200 Subject: [PATCH 5/6] convert: Avoid use-after-free by leaking --- src/common/api/convert.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/api/convert.hpp b/src/common/api/convert.hpp index 7cd8f19a..e8ed9bbc 100644 --- a/src/common/api/convert.hpp +++ b/src/common/api/convert.hpp @@ -165,6 +165,7 @@ struct admire::api::managed_ctype { ADM_adhoc_resources_t release() { + std::ignore = m_nodes.release(); return m_adhoc_resources.release(); } @@ -189,6 +190,7 @@ struct admire::api::managed_ctype { ADM_adhoc_context_t release() { + std::ignore = m_adhoc_resources.release(); return m_adhoc_context.release(); } @@ -213,6 +215,7 @@ struct admire::api::managed_ctype { ADM_storage_t release() { + std::ignore = m_ctx.release(); return m_storage.release(); } -- GitLab From 644f6d59cd4b5e35dfb0622b65a82e0f9d7084d1 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 13 Oct 2022 14:44:01 +0200 Subject: [PATCH 6/6] CI: disable leak detection until #73 is fixed --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c3aba83..b9e68ad1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,7 +47,7 @@ rpc: stage: test needs: [build] script: - - export ASAN_OPTIONS=detect_odr_violation=0 + - export ASAN_OPTIONS=detect_odr_violation=0:detect_leaks=0 - export LSAN_OPTIONS=verbosity=1:log_threads=1:suppressions=${CI_PROJECT_DIR}/tests/LSanSuppress.supp - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${CI_PROJECT_DIR}/compiled/lib - cd build/examples/ -- GitLab