From cf772c650b59a0e768cbaa86557e89a60eb27b37 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 20 Feb 2023 10:15:23 +0100 Subject: [PATCH 1/4] API: Add `adhoc_resources` argument to ADM_register_adhoc_storage() --- examples/c/ADM_cancel_transfer.c | 5 +++-- examples/c/ADM_connect_data_operation.c | 5 +++-- examples/c/ADM_define_data_operation.c | 5 +++-- examples/c/ADM_deploy_adhoc_storage.c | 6 +++--- examples/c/ADM_finalize_data_operation.c | 5 +++-- examples/c/ADM_get_pending_transfers.c | 5 +++-- examples/c/ADM_get_qos_constraints.c | 5 +++-- examples/c/ADM_get_statistics.c | 5 +++-- examples/c/ADM_get_transfer_priority.c | 5 +++-- examples/c/ADM_link_transfer_to_data_operation.c | 5 +++-- examples/c/ADM_register_adhoc_storage.c | 3 ++- examples/c/ADM_register_job.c | 3 ++- examples/c/ADM_remove_adhoc_storage.c | 3 ++- examples/c/ADM_remove_job.c | 5 +++-- examples/c/ADM_set_dataset_information.c | 5 +++-- examples/c/ADM_set_io_resources.c | 5 +++-- examples/c/ADM_set_qos_constraints.c | 5 +++-- examples/c/ADM_set_transfer_priority.c | 5 +++-- examples/c/ADM_transfer_datasets.c | 5 +++-- examples/c/ADM_update_adhoc_storage.c | 3 ++- examples/c/ADM_update_job.c | 5 +++-- examples/cxx/ADM_deploy_adhoc_storage.cpp | 3 ++- examples/cxx/ADM_register_adhoc_storage.cpp | 3 ++- examples/cxx/ADM_register_job.cpp | 3 ++- examples/cxx/ADM_remove_adhoc_storage.cpp | 3 ++- examples/cxx/ADM_remove_job.cpp | 4 +++- examples/cxx/ADM_transfer_datasets.cpp | 3 ++- examples/cxx/ADM_update_adhoc_storage.cpp | 5 ++++- examples/cxx/ADM_update_job.cpp | 3 ++- src/lib/c_wrapper.cpp | 9 +++++---- src/lib/detail/impl.cpp | 13 ++++++++----- src/lib/detail/impl.hpp | 3 ++- src/lib/libscord.cpp | 6 ++++-- src/lib/scord/scord.h | 1 + src/lib/scord/scord.hpp | 3 ++- src/scord/rpc_handlers.cpp | 8 +++++--- src/scord/rpc_handlers.hpp | 3 ++- 37 files changed, 107 insertions(+), 64 deletions(-) diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 80603311..849eb708 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_connect_data_operation.c b/examples/c/ADM_connect_data_operation.c index f9bf1eb3..b4656472 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -67,8 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_define_data_operation.c b/examples/c/ADM_define_data_operation.c index 19d2939e..2946d073 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -72,8 +72,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_deploy_adhoc_storage.c b/examples/c/ADM_deploy_adhoc_storage.c index 1cfd70b9..73fe414c 100644 --- a/examples/c/ADM_deploy_adhoc_storage.c +++ b/examples/c/ADM_deploy_adhoc_storage.c @@ -96,9 +96,9 @@ main(int argc, char* argv[]) { } // 2. Register the adhoc storage - if(ADM_register_adhoc_storage(server, adhoc_name, - ADM_ADHOC_STORAGE_DATACLAY, adhoc_ctx, - &adhoc_storage) != ADM_SUCCESS) { + if(ADM_register_adhoc_storage( + server, adhoc_name, ADM_ADHOC_STORAGE_DATACLAY, adhoc_ctx, + adhoc_resources, &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; diff --git a/examples/c/ADM_finalize_data_operation.c b/examples/c/ADM_finalize_data_operation.c index 39b31155..1e32ffe5 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -68,8 +68,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_get_pending_transfers.c b/examples/c/ADM_get_pending_transfers.c index 7d4ba51c..d8be0e76 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_get_qos_constraints.c b/examples/c/ADM_get_qos_constraints.c index 9bcb3abc..9707f697 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -67,8 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_get_statistics.c b/examples/c/ADM_get_statistics.c index 47b29968..21dd9a85 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -67,8 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_get_transfer_priority.c b/examples/c/ADM_get_transfer_priority.c index adad6483..a1cb8bea 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_link_transfer_to_data_operation.c b/examples/c/ADM_link_transfer_to_data_operation.c index 7595b926..0922a684 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -68,8 +68,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_register_adhoc_storage.c b/examples/c/ADM_register_adhoc_storage.c index 9ffef223..fb086f0d 100644 --- a/examples/c/ADM_register_adhoc_storage.c +++ b/examples/c/ADM_register_adhoc_storage.c @@ -93,7 +93,8 @@ main(int argc, char* argv[]) { // 2. Register the adhoc storage if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, - adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { + adhoc_ctx, adhoc_resources, + &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 7105607a..393cb450 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -104,7 +104,8 @@ main(int argc, char* argv[]) { // 2. Register the adhoc storage if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, - adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { + adhoc_ctx, adhoc_resources, + &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; diff --git a/examples/c/ADM_remove_adhoc_storage.c b/examples/c/ADM_remove_adhoc_storage.c index 5d083441..5a8f9b85 100644 --- a/examples/c/ADM_remove_adhoc_storage.c +++ b/examples/c/ADM_remove_adhoc_storage.c @@ -96,7 +96,8 @@ main(int argc, char* argv[]) { // 2. Register the adhoc storage if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, - adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { + adhoc_ctx, adhoc_resources, + &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index e95aeb55..0d3d28da 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index 21aa11c5..f314821b 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -68,8 +68,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_set_io_resources.c b/examples/c/ADM_set_io_resources.c index 8161aa0b..eb6b712c 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -67,8 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index f3b6a40f..6e74af4e 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_set_transfer_priority.c b/examples/c/ADM_set_transfer_priority.c index fbb71729..436614eb 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_transfer_datasets.c b/examples/c/ADM_transfer_datasets.c index 6f080302..7b5ce6ce 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -74,8 +74,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index ee74f499..eee79f24 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -97,7 +97,8 @@ main(int argc, char* argv[]) { // 2. Register the adhoc storage if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, - adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { + adhoc_ctx, adhoc_resources, + &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index 5e7377be..1e4f46f7 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -71,8 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; ADM_adhoc_storage_t adhoc_storage; - ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); + ADM_return_t ret = + ADM_register_adhoc_storage(server, name, ADM_ADHOC_STORAGE_GEKKOFS, + ctx, adhoc_resources, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/cxx/ADM_deploy_adhoc_storage.cpp b/examples/cxx/ADM_deploy_adhoc_storage.cpp index d7a34f30..7cfc53ef 100644 --- a/examples/cxx/ADM_deploy_adhoc_storage.cpp +++ b/examples/cxx/ADM_deploy_adhoc_storage.cpp @@ -52,11 +52,12 @@ main(int argc, char* argv[]) { scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::dataclay, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); fmt::print(stdout, "ADM_register_adhoc_storage() remote procedure completed " diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index 894ccd92..5a21d106 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -52,11 +52,12 @@ main(int argc, char* argv[]) { scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::gekkofs, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); fmt::print(stdout, "ADM_register_adhoc_storage() remote procedure completed " diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index 634ed2ba..5ac731c4 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -52,12 +52,13 @@ main(int argc, char* argv[]) { scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::gekkofs, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); scord::job::requirements reqs(inputs, outputs, adhoc_storage); diff --git a/examples/cxx/ADM_remove_adhoc_storage.cpp b/examples/cxx/ADM_remove_adhoc_storage.cpp index a804e418..b0c70def 100644 --- a/examples/cxx/ADM_remove_adhoc_storage.cpp +++ b/examples/cxx/ADM_remove_adhoc_storage.cpp @@ -52,11 +52,12 @@ main(int argc, char* argv[]) { scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::gekkofs, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); scord::remove_adhoc_storage(server, adhoc_storage); fmt::print(stdout, "ADM_remove_adhoc_storage() remote procedure completed " diff --git a/examples/cxx/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp index ca3975f6..ecdbe165 100644 --- a/examples/cxx/ADM_remove_job.cpp +++ b/examples/cxx/ADM_remove_job.cpp @@ -53,11 +53,13 @@ main(int argc, char* argv[]) { scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; + try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::gekkofs, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); scord::job::requirements reqs(inputs, outputs, adhoc_storage); diff --git a/examples/cxx/ADM_transfer_datasets.cpp b/examples/cxx/ADM_transfer_datasets.cpp index 56b5a24c..dcecdf22 100644 --- a/examples/cxx/ADM_transfer_datasets.cpp +++ b/examples/cxx/ADM_transfer_datasets.cpp @@ -60,11 +60,12 @@ main(int argc, char* argv[]) { scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::gekkofs, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); scord::job::requirements reqs(inputs, outputs, adhoc_storage); diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index 62c3a93a..5ecea6e3 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -52,16 +52,19 @@ main(int argc, char* argv[]) { scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; const auto new_adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, scord::adhoc_storage::resources{new_adhoc_nodes}, 200, false}; + const auto new_adhoc_resources = + scord::adhoc_storage::resources{new_adhoc_nodes}; try { const auto adhoc_storage = scord::register_adhoc_storage( server, name, scord::adhoc_storage::type::gekkofs, - adhoc_storage_ctx); + adhoc_storage_ctx, adhoc_resources); scord::update_adhoc_storage(server, adhoc_storage, new_adhoc_storage_ctx); diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index 581029cc..da68dc30 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -53,7 +53,8 @@ main(int argc, char* argv[]) { scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}); + scord::adhoc_storage::resources{adhoc_nodes}, 100, false}, + scord::adhoc_storage::resources{adhoc_nodes}); scord::job::requirements reqs{inputs, outputs, gkfs_storage}; diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index c00d09f3..fec3516f 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -112,13 +112,14 @@ ADM_return_t ADM_register_adhoc_storage(ADM_server_t server, const char* name, ADM_adhoc_storage_type_t type, ADM_adhoc_context_t ctx, + ADM_adhoc_resources_t resources, ADM_adhoc_storage_t* adhoc_storage) { - const scord::server srv{server}; - - const auto cxx_type = static_cast(type); const auto rv = scord::detail::register_adhoc_storage( - srv, name, cxx_type, scord::adhoc_storage::ctx{ctx}); + scord::server{server}, name, + static_cast(type), + scord::adhoc_storage::ctx{ctx}, + scord::adhoc_storage::resources{resources}); if(!rv) { return rv.error(); diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index d197fb41..db85beac 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -204,7 +204,8 @@ remove_job(const server& srv, const job& job) { tl::expected register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, - const adhoc_storage::ctx& ctx) { + const adhoc_storage::ctx& ctx, + const adhoc_storage::resources& resources) { scord::network::client rpc_client{srv.protocol()}; @@ -215,12 +216,14 @@ register_adhoc_storage(const server& srv, const std::string& name, const auto& endp = lookup_rv.value(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{name: {}, type: {}, adhoc_ctx: {}}}", + "body: {{name: {}, type: {}, adhoc_ctx: {}, " + "adhoc_resources: {}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), name, type, ctx); + std::quoted(rpc_client.self_address()), name, type, ctx, + resources); - if(const auto& call_rv = - endp.call("ADM_"s + __FUNCTION__, name, type, ctx); + if(const auto& call_rv = endp.call("ADM_"s + __FUNCTION__, name, type, + ctx, resources); call_rv.has_value()) { const scord::network::response_with_id resp{call_rv.value()}; diff --git a/src/lib/detail/impl.hpp b/src/lib/detail/impl.hpp index d437b944..309d376c 100644 --- a/src/lib/detail/impl.hpp +++ b/src/lib/detail/impl.hpp @@ -49,7 +49,8 @@ remove_job(const server& srv, const job& job); tl::expected register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, - const adhoc_storage::ctx& ctx); + const adhoc_storage::ctx& ctx, + const adhoc_storage::resources& resources); scord::error_code update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx, diff --git a/src/lib/libscord.cpp b/src/lib/libscord.cpp index 39e00510..7b517491 100644 --- a/src/lib/libscord.cpp +++ b/src/lib/libscord.cpp @@ -250,9 +250,11 @@ remove_job(const server& srv, const job& job) { scord::adhoc_storage register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, - const adhoc_storage::ctx& ctx) { + const adhoc_storage::ctx& ctx, + const adhoc_storage::resources& resources) { - const auto rv = detail::register_adhoc_storage(srv, name, type, ctx); + const auto rv = + detail::register_adhoc_storage(srv, name, type, ctx, resources); if(!rv) { throw std::runtime_error( diff --git a/src/lib/scord/scord.h b/src/lib/scord/scord.h index fcfe8815..585582b4 100644 --- a/src/lib/scord/scord.h +++ b/src/lib/scord/scord.h @@ -115,6 +115,7 @@ ADM_return_t ADM_register_adhoc_storage(ADM_server_t server, const char* name, ADM_adhoc_storage_type_t type, ADM_adhoc_context_t ctx, + ADM_adhoc_resources_t resources, ADM_adhoc_storage_t* adhoc_storage); /** diff --git a/src/lib/scord/scord.hpp b/src/lib/scord/scord.hpp index d3642e28..f4fdab60 100644 --- a/src/lib/scord/scord.hpp +++ b/src/lib/scord/scord.hpp @@ -60,7 +60,8 @@ remove_job(const server& srv, const job& job); scord::adhoc_storage register_adhoc_storage(const server& srv, const std::string& name, enum adhoc_storage::type type, - const adhoc_storage::ctx& ctx); + const adhoc_storage::ctx& ctx, + const adhoc_storage::resources& resources); void update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 0f4909fa..ac0b2f7c 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -198,7 +198,8 @@ remove_job(const request& req, scord::job_id job_id) { void register_adhoc_storage(const request& req, const std::string& name, enum scord::adhoc_storage::type type, - const scord::adhoc_storage::ctx& ctx) { + const scord::adhoc_storage::ctx& ctx, + const scord::adhoc_storage::resources& resources) { using scord::network::get_address; @@ -206,9 +207,10 @@ register_adhoc_storage(const request& req, const std::string& name, const auto rpc_id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{name: {}, type: {}, adhoc_ctx: {}}}", + "body: {{name: {}, type: {}, adhoc_ctx: {}, " + "adhoc_resources: {}}}", rpc_id, std::quoted(rpc_name), std::quoted(get_address(req)), - name, type, ctx); + name, type, ctx, resources); scord::error_code ec; std::optional adhoc_id; diff --git a/src/scord/rpc_handlers.hpp b/src/scord/rpc_handlers.hpp index 94d84aeb..279929a5 100644 --- a/src/scord/rpc_handlers.hpp +++ b/src/scord/rpc_handlers.hpp @@ -50,7 +50,8 @@ remove_job(const request& req, scord::job_id job_id); void register_adhoc_storage(const request& req, const std::string& name, enum scord::adhoc_storage::type type, - const scord::adhoc_storage::ctx& ctx); + const scord::adhoc_storage::ctx& ctx, + const scord::adhoc_storage::resources& resources); void update_adhoc_storage(const request& req, std::uint64_t adhoc_id, const scord::adhoc_storage::ctx& new_ctx); -- GitLab From b6574c68059f38ff918427c4932c2e5e4f072c97 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 20 Feb 2023 16:43:19 +0100 Subject: [PATCH 2/4] API: Remove adhoc_resources from ADM_adhoc_context_t --- examples/c/ADM_cancel_transfer.c | 3 +-- examples/c/ADM_connect_data_operation.c | 3 +-- examples/c/ADM_define_data_operation.c | 3 +-- examples/c/ADM_deploy_adhoc_storage.c | 6 ++---- examples/c/ADM_finalize_data_operation.c | 3 +-- examples/c/ADM_get_pending_transfers.c | 3 +-- examples/c/ADM_get_qos_constraints.c | 3 +-- examples/c/ADM_get_statistics.c | 3 +-- examples/c/ADM_get_transfer_priority.c | 3 +-- examples/c/ADM_link_transfer_to_data_operation.c | 3 +-- examples/c/ADM_register_adhoc_storage.c | 3 +-- examples/c/ADM_register_job.c | 3 +-- examples/c/ADM_remove_adhoc_storage.c | 3 +-- examples/c/ADM_remove_job.c | 3 +-- examples/c/ADM_set_dataset_information.c | 3 +-- examples/c/ADM_set_io_resources.c | 3 +-- examples/c/ADM_set_qos_constraints.c | 3 +-- examples/c/ADM_set_transfer_priority.c | 3 +-- examples/c/ADM_transfer_datasets.c | 3 +-- examples/c/ADM_update_adhoc_storage.c | 6 ++---- examples/c/ADM_update_job.c | 3 +-- examples/cxx/ADM_deploy_adhoc_storage.cpp | 3 +-- examples/cxx/ADM_register_adhoc_storage.cpp | 3 +-- examples/cxx/ADM_register_job.cpp | 3 +-- examples/cxx/ADM_remove_adhoc_storage.cpp | 3 +-- examples/cxx/ADM_remove_job.cpp | 3 +-- examples/cxx/ADM_transfer_datasets.cpp | 3 +-- examples/cxx/ADM_update_adhoc_storage.cpp | 6 ++---- examples/cxx/ADM_update_job.cpp | 3 +-- src/lib/scord/types.h | 6 ++---- src/lib/scord/types.hpp | 14 +++++--------- src/lib/types.c | 6 ++---- src/lib/types.cpp | 13 ++----------- src/lib/types_private.h | 2 -- 34 files changed, 43 insertions(+), 94 deletions(-) diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 849eb708..8a3bc88d 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_connect_data_operation.c b/examples/c/ADM_connect_data_operation.c index b4656472..10398544 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -60,8 +60,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_define_data_operation.c b/examples/c/ADM_define_data_operation.c index 2946d073..8b4fa0ca 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -65,8 +65,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_deploy_adhoc_storage.c b/examples/c/ADM_deploy_adhoc_storage.c index 73fe414c..1dc7c035 100644 --- a/examples/c/ADM_deploy_adhoc_storage.c +++ b/examples/c/ADM_deploy_adhoc_storage.c @@ -77,8 +77,7 @@ main(int argc, char* argv[]) { // 3. the adhoc storage execution context adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_ACCESS_RDWR, 100, false); if(adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing adhoc context\n"); @@ -110,8 +109,7 @@ main(int argc, char* argv[]) { // storage system new_adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, - adhoc_resources, 200, false); + ADM_ADHOC_ACCESS_RDWR, 200, false); if(new_adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing new adhoc context\n"); diff --git a/examples/c/ADM_finalize_data_operation.c b/examples/c/ADM_finalize_data_operation.c index 1e32ffe5..9851326e 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -61,8 +61,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_get_pending_transfers.c b/examples/c/ADM_get_pending_transfers.c index d8be0e76..e2c109bf 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_get_qos_constraints.c b/examples/c/ADM_get_qos_constraints.c index 9707f697..6644c99b 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -60,8 +60,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_get_statistics.c b/examples/c/ADM_get_statistics.c index 21dd9a85..9686246b 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -60,8 +60,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_get_transfer_priority.c b/examples/c/ADM_get_transfer_priority.c index a1cb8bea..2be2ac0f 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_link_transfer_to_data_operation.c b/examples/c/ADM_link_transfer_to_data_operation.c index 0922a684..66bd656b 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -61,8 +61,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_register_adhoc_storage.c b/examples/c/ADM_register_adhoc_storage.c index fb086f0d..5f2a86dc 100644 --- a/examples/c/ADM_register_adhoc_storage.c +++ b/examples/c/ADM_register_adhoc_storage.c @@ -74,8 +74,7 @@ main(int argc, char* argv[]) { // 3. define the adhoc execution context adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_ACCESS_RDWR, 100, false); if(adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing adhoc context\n"); diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 393cb450..36bc1dbb 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -84,8 +84,7 @@ main(int argc, char* argv[]) { // 3. the adhoc storage execution context adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_ACCESS_RDWR, 100, false); if(adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing adhoc context\n"); diff --git a/examples/c/ADM_remove_adhoc_storage.c b/examples/c/ADM_remove_adhoc_storage.c index 5a8f9b85..23e404bb 100644 --- a/examples/c/ADM_remove_adhoc_storage.c +++ b/examples/c/ADM_remove_adhoc_storage.c @@ -76,8 +76,7 @@ main(int argc, char* argv[]) { // 3. the adhoc storage execution context adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_ACCESS_RDWR, 100, false); if(adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing adhoc context\n"); diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index 0d3d28da..c4d0a7c8 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index f314821b..ddeefe0c 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -61,8 +61,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_set_io_resources.c b/examples/c/ADM_set_io_resources.c index eb6b712c..37989fa5 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -60,8 +60,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index 6e74af4e..dec01f69 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_set_transfer_priority.c b/examples/c/ADM_set_transfer_priority.c index 436614eb..60e33761 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_transfer_datasets.c b/examples/c/ADM_transfer_datasets.c index 7b5ce6ce..73af36c5 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -67,8 +67,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index eee79f24..7dd22dd2 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -77,8 +77,7 @@ main(int argc, char* argv[]) { // 3. the adhoc storage execution context adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_ACCESS_RDWR, 100, false); if(adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing adhoc context\n"); @@ -110,8 +109,7 @@ main(int argc, char* argv[]) { // storage system new_adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_ACCESS_RDWR, - adhoc_resources, 200, false); + ADM_ADHOC_ACCESS_RDWR, 200, false); if(new_adhoc_ctx == NULL) { fprintf(stderr, "Fatal error preparing new adhoc context\n"); diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index 1e4f46f7..2e94dded 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -64,8 +64,7 @@ main(int argc, char* argv[]) { assert(adhoc_resources); ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, - 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 100, false); assert(ctx); const char* name = "adhoc_storage_42"; diff --git a/examples/cxx/ADM_deploy_adhoc_storage.cpp b/examples/cxx/ADM_deploy_adhoc_storage.cpp index 7cfc53ef..38077cca 100644 --- a/examples/cxx/ADM_deploy_adhoc_storage.cpp +++ b/examples/cxx/ADM_deploy_adhoc_storage.cpp @@ -50,8 +50,7 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index 5a21d106..98b00c56 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -50,8 +50,7 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index 5ac731c4..267f56ad 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -50,8 +50,7 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { diff --git a/examples/cxx/ADM_remove_adhoc_storage.cpp b/examples/cxx/ADM_remove_adhoc_storage.cpp index b0c70def..9459663b 100644 --- a/examples/cxx/ADM_remove_adhoc_storage.cpp +++ b/examples/cxx/ADM_remove_adhoc_storage.cpp @@ -50,8 +50,7 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { diff --git a/examples/cxx/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp index ecdbe165..37498e12 100644 --- a/examples/cxx/ADM_remove_job.cpp +++ b/examples/cxx/ADM_remove_job.cpp @@ -50,8 +50,7 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; diff --git a/examples/cxx/ADM_transfer_datasets.cpp b/examples/cxx/ADM_transfer_datasets.cpp index dcecdf22..d13cc8ad 100644 --- a/examples/cxx/ADM_transfer_datasets.cpp +++ b/examples/cxx/ADM_transfer_datasets.cpp @@ -58,8 +58,7 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; try { diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index 5ecea6e3..943a08d6 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -50,14 +50,12 @@ main(int argc, char* argv[]) { std::string name = "adhoc_storage_42"; const auto adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}; + scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; const auto new_adhoc_storage_ctx = scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{new_adhoc_nodes}, 200, false}; + scord::adhoc_storage::access_type::read_write, 200, false}; const auto new_adhoc_resources = scord::adhoc_storage::resources{new_adhoc_nodes}; diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index da68dc30..72c82031 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -52,8 +52,7 @@ main(int argc, char* argv[]) { server, "foobar", scord::adhoc_storage::type::gekkofs, scord::adhoc_storage::ctx{ scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, - scord::adhoc_storage::resources{adhoc_nodes}, 100, false}, + scord::adhoc_storage::access_type::read_write, 100, false}, scord::adhoc_storage::resources{adhoc_nodes}); scord::job::requirements reqs{inputs, outputs, gkfs_storage}; diff --git a/src/lib/scord/types.h b/src/lib/scord/types.h index f369cc90..8b2d939d 100644 --- a/src/lib/scord/types.h +++ b/src/lib/scord/types.h @@ -477,7 +477,6 @@ ADM_adhoc_resources_destroy(ADM_adhoc_resources_t res); * * @param[in] exec_mode The adhoc storage system execution mode * @param[in] access_type The adhoc storage system execution type - * @param[in] adhoc_resources The resources assigned for the storage system * @param[in] walltime The adhoc storage system walltime * @param[in] should_flush Whether the adhoc storage system should flush data in * the background @@ -485,9 +484,8 @@ ADM_adhoc_resources_destroy(ADM_adhoc_resources_t res); */ ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, - ADM_adhoc_access_t access_type, - ADM_adhoc_resources_t adhoc_resources, - uint32_t walltime, bool should_flush); + ADM_adhoc_access_t access_type, uint32_t walltime, + bool should_flush); /** * Destroy an ADM_ADHOC_CONTEXT created by ADM_adhoc_context_create(). diff --git a/src/lib/scord/types.hpp b/src/lib/scord/types.hpp index 7978a1cd..775d2ad2 100644 --- a/src/lib/scord/types.hpp +++ b/src/lib/scord/types.hpp @@ -215,8 +215,7 @@ struct adhoc_storage { ctx() = default; ctx(execution_mode exec_mode, access_type access_type, - adhoc_storage::resources resources, std::uint32_t walltime, - bool should_flush); + std::uint32_t walltime, bool should_flush); explicit ctx(ADM_adhoc_context_t ctx); explicit operator ADM_adhoc_context_t() const; @@ -237,7 +236,6 @@ struct adhoc_storage { serialize(Archive&& ar) { ar& m_exec_mode; ar& m_access_type; - ar& m_resources; ar& m_walltime; ar& m_should_flush; } @@ -245,7 +243,6 @@ struct adhoc_storage { private: execution_mode m_exec_mode; enum access_type m_access_type; - adhoc_storage::resources m_resources; std::uint32_t m_walltime; bool m_should_flush; }; @@ -783,11 +780,10 @@ struct fmt::formatter : formatter { auto format(const scord::adhoc_storage::ctx& c, FormatContext& ctx) const { - const auto str = - fmt::format("{{execution_mode: {}, access_type: {}, " - "resources: {}, walltime: {}, should_flush: {}}}", - c.exec_mode(), c.access_type(), c.resources(), - c.walltime(), c.should_flush()); + const auto str = fmt::format("{{execution_mode: {}, access_type: {}, " + "walltime: {}, should_flush: {}}}", + c.exec_mode(), c.access_type(), + c.walltime(), c.should_flush()); return formatter::format(str, ctx); } diff --git a/src/lib/types.c b/src/lib/types.c index 763e1b21..a3f560ea 100644 --- a/src/lib/types.c +++ b/src/lib/types.c @@ -654,9 +654,8 @@ ADM_data_operation_destroy(ADM_data_operation_t op) { ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, - ADM_adhoc_access_t access_type, - ADM_adhoc_resources_t adhoc_resources, - uint32_t walltime, bool should_flush) { + ADM_adhoc_access_t access_type, uint32_t walltime, + bool should_flush) { struct adm_adhoc_context* adm_adhoc_context = (struct adm_adhoc_context*) malloc(sizeof(*adm_adhoc_context)); @@ -668,7 +667,6 @@ ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, adm_adhoc_context->c_mode = exec_mode; adm_adhoc_context->c_access = access_type; - adm_adhoc_context->c_resources = adhoc_resources; adm_adhoc_context->c_walltime = walltime; adm_adhoc_context->c_should_bg_flush = should_flush; diff --git a/src/lib/types.cpp b/src/lib/types.cpp index ca343013..4b7c2b0c 100644 --- a/src/lib/types.cpp +++ b/src/lib/types.cpp @@ -544,23 +544,19 @@ adhoc_storage::resources::nodes() const { adhoc_storage::ctx::ctx(adhoc_storage::execution_mode exec_mode, adhoc_storage::access_type access_type, - adhoc_storage::resources resources, std::uint32_t walltime, bool should_flush) - : m_exec_mode(exec_mode), m_access_type(access_type), - m_resources(std::move(resources)), m_walltime(walltime), + : m_exec_mode(exec_mode), m_access_type(access_type), m_walltime(walltime), m_should_flush(should_flush) {} adhoc_storage::ctx::ctx(ADM_adhoc_context_t ctx) : adhoc_storage::ctx(static_cast(ctx->c_mode), static_cast(ctx->c_access), - adhoc_storage::resources{ctx->c_resources}, ctx->c_walltime, ctx->c_should_bg_flush) {} adhoc_storage::ctx::operator ADM_adhoc_context_t() const { return ADM_adhoc_context_create( static_cast(m_exec_mode), - static_cast(m_access_type), - static_cast(m_resources), m_walltime, + static_cast(m_access_type), m_walltime, m_should_flush); } @@ -574,11 +570,6 @@ adhoc_storage::ctx::access_type() const { return m_access_type; } -adhoc_storage::resources -adhoc_storage::ctx::resources() const { - return m_resources; -} - std::uint32_t adhoc_storage::ctx::walltime() const { return m_walltime; diff --git a/src/lib/types_private.h b/src/lib/types_private.h index 2c59eefd..b90a7fc1 100644 --- a/src/lib/types_private.h +++ b/src/lib/types_private.h @@ -79,8 +79,6 @@ struct adm_adhoc_context { ADM_adhoc_mode_t c_mode; /** The adhoc storage system access type */ ADM_adhoc_access_t c_access; - /** The resources assigned for the adhoc storage system */ - ADM_adhoc_resources_t c_resources; /** The adhoc storage system walltime */ uint32_t c_walltime; /** Whether the adhoc storage system should flush data in the background */ -- GitLab From 457608b9f77a2a4ee3df582ffedc1fc252de3213 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 20 Feb 2023 16:47:15 +0100 Subject: [PATCH 3/4] API: Add adhoc_resources to ADM_adhoc_storage_t --- src/lib/detail/impl.cpp | 3 ++- src/lib/scord/types.h | 4 ++- src/lib/scord/types.hpp | 6 ++++- src/lib/types.c | 7 ++++-- src/lib/types.cpp | 39 ++++++++++++++++++++--------- src/lib/types_private.h | 2 ++ src/scord/adhoc_storage_manager.hpp | 6 +++-- src/scord/rpc_handlers.cpp | 6 ++--- 8 files changed, 51 insertions(+), 22 deletions(-) diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index db85beac..1da6b6a0 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -239,7 +239,8 @@ register_adhoc_storage(const server& srv, const std::string& name, return tl::make_unexpected(ec); } - return scord::adhoc_storage{type, name, resp.value(), ctx}; + return scord::adhoc_storage{type, name, resp.value(), ctx, + resources}; } } diff --git a/src/lib/scord/types.h b/src/lib/scord/types.h index 8b2d939d..f1f24923 100644 --- a/src/lib/scord/types.h +++ b/src/lib/scord/types.h @@ -429,11 +429,13 @@ ADM_dataset_list_destroy(ADM_dataset_list_t list); * @param[in] adhoc_ctx Some specific context information for the storage * tier or NULL if none is required. For instance, an adhoc storage system may * find it useful to provide an ADM_adhoc_context_t describing the instance. + * @param[in] adhoc_resources The adhoc resources for this instance. * @return A valid ADM_ADHOC_STORAGE if successful, or NULL in case of failure. */ ADM_adhoc_storage_t ADM_adhoc_storage_create(const char* name, ADM_adhoc_storage_type_t type, - uint64_t id, ADM_adhoc_context_t adhoc_ctx); + uint64_t id, ADM_adhoc_context_t adhoc_ctx, + ADM_adhoc_resources_t adhoc_resources); /** * Destroy an ADM_ADHOC_STORAGE created by ADM_adhoc_storage_destroy(). diff --git a/src/lib/scord/types.hpp b/src/lib/scord/types.hpp index 775d2ad2..12722a39 100644 --- a/src/lib/scord/types.hpp +++ b/src/lib/scord/types.hpp @@ -255,7 +255,8 @@ struct adhoc_storage { explicit adhoc_storage(ADM_adhoc_storage_t storage); explicit operator ADM_adhoc_storage_t() const; adhoc_storage(enum adhoc_storage::type type, std::string name, - std::uint64_t id, const scord::adhoc_storage::ctx& ctx); + std::uint64_t id, const scord::adhoc_storage::ctx& ctx, + adhoc_storage::resources resources); adhoc_storage(const adhoc_storage& other) noexcept; adhoc_storage(adhoc_storage&&) noexcept; @@ -274,6 +275,9 @@ struct adhoc_storage { adhoc_storage::ctx context() const; + adhoc_storage::resources + get_resources() const; + void update(scord::adhoc_storage::ctx new_ctx); diff --git a/src/lib/types.c b/src/lib/types.c index a3f560ea..0a44d15f 100644 --- a/src/lib/types.c +++ b/src/lib/types.c @@ -430,7 +430,8 @@ ADM_dataset_list_destroy(ADM_dataset_list_t list) { ADM_adhoc_storage_t ADM_adhoc_storage_create(const char* name, ADM_adhoc_storage_type_t type, - uint64_t id, ADM_adhoc_context_t adhoc_ctx) { + uint64_t id, ADM_adhoc_context_t adhoc_ctx, + ADM_adhoc_resources_t adhoc_resources) { struct adm_adhoc_storage* adm_adhoc_storage = (struct adm_adhoc_storage*) malloc(sizeof(*adm_adhoc_storage)); @@ -466,6 +467,8 @@ ADM_adhoc_storage_create(const char* name, ADM_adhoc_storage_type_t type, memcpy(adm_adhoc_storage->s_adhoc_ctx, adhoc_ctx, sizeof(*adhoc_ctx)); + adm_adhoc_storage->s_resources = adhoc_resources; + return adm_adhoc_storage; cleanup_on_error: @@ -824,7 +827,7 @@ ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, adm_job_reqs->r_adhoc_storage = ADM_adhoc_storage_create( adhoc_storage->s_name, adhoc_storage->s_type, adhoc_storage->s_id, - adhoc_storage->s_adhoc_ctx); + adhoc_storage->s_adhoc_ctx, adhoc_storage->s_resources); return adm_job_reqs; diff --git a/src/lib/types.cpp b/src/lib/types.cpp index 4b7c2b0c..023ff075 100644 --- a/src/lib/types.cpp +++ b/src/lib/types.cpp @@ -585,9 +585,10 @@ class adhoc_storage::impl { public: impl() = default; explicit impl(enum adhoc_storage::type type, std::string name, - std::uint64_t id, adhoc_storage::ctx ctx) + std::uint64_t id, adhoc_storage::ctx ctx, + struct adhoc_storage::resources resources) : m_type(type), m_name(std::move(name)), m_id(id), - m_ctx(std::move(ctx)) {} + m_ctx(std::move(ctx)), m_resources(std::move(resources)) {} impl(const impl& rhs) = default; impl(impl&& rhs) = default; impl& @@ -616,6 +617,11 @@ public: return m_ctx; } + struct adhoc_storage::resources + resources() const { + return m_resources; + }; + void update(adhoc_storage::ctx new_ctx) { m_ctx = std::move(new_ctx); @@ -645,6 +651,7 @@ private: std::string m_name; std::uint64_t m_id; adhoc_storage::ctx m_ctx; + struct adhoc_storage::resources m_resources; }; adhoc_storage::adhoc_storage() = default; @@ -652,29 +659,32 @@ adhoc_storage::adhoc_storage() = default; adhoc_storage::adhoc_storage(enum adhoc_storage::type type, std::string name, std::uint64_t id, execution_mode exec_mode, access_type access_type, - adhoc_storage::resources res, + struct adhoc_storage::resources res, std::uint32_t walltime, bool should_flush) - : m_pimpl(std::make_unique( - type, std::move(name), id, - adhoc_storage::ctx{exec_mode, access_type, std::move(res), - walltime, should_flush})) {} + : m_pimpl(std::make_unique(type, std::move(name), id, + adhoc_storage::ctx{exec_mode, access_type, + walltime, should_flush}, + std::move(res))) {} adhoc_storage::adhoc_storage(ADM_adhoc_storage_t st) : m_pimpl(std::make_unique( static_cast(st->s_type), st->s_name, - st->s_id, adhoc_storage::ctx{st->s_adhoc_ctx})) {} + st->s_id, adhoc_storage::ctx{st->s_adhoc_ctx}, + adhoc_storage::resources{st->s_resources})) {} adhoc_storage::operator ADM_adhoc_storage_t() const { return ADM_adhoc_storage_create( m_pimpl->name().c_str(), static_cast(m_pimpl->type()), - m_pimpl->id(), - static_cast(m_pimpl->context())); + m_pimpl->id(), static_cast(m_pimpl->context()), + static_cast(m_pimpl->resources())); } adhoc_storage::adhoc_storage(enum adhoc_storage::type type, std::string name, - std::uint64_t id, const adhoc_storage::ctx& ctx) - : m_pimpl(std::make_unique(type, std::move(name), id, ctx)) {} + std::uint64_t id, const adhoc_storage::ctx& ctx, + adhoc_storage::resources resources) + : m_pimpl(std::make_unique(type, std::move(name), id, ctx, + std::move(resources))) {} adhoc_storage::adhoc_storage(const adhoc_storage& other) noexcept : m_pimpl(std::make_unique(*other.m_pimpl)) {} @@ -710,6 +720,11 @@ adhoc_storage::context() const { return m_pimpl->context(); } +adhoc_storage::resources +adhoc_storage::get_resources() const { + return m_pimpl->resources(); +} + void adhoc_storage::update(scord::adhoc_storage::ctx new_ctx) { return m_pimpl->update(std::move(new_ctx)); diff --git a/src/lib/types_private.h b/src/lib/types_private.h index b90a7fc1..db44caf5 100644 --- a/src/lib/types_private.h +++ b/src/lib/types_private.h @@ -95,6 +95,8 @@ struct adm_adhoc_storage { ADM_adhoc_storage_type_t s_type; uint64_t s_id; ADM_adhoc_context_t s_adhoc_ctx; + /** The resources assigned for the adhoc storage system */ + ADM_adhoc_resources_t s_resources; }; struct adm_pfs_storage { diff --git a/src/scord/adhoc_storage_manager.hpp b/src/scord/adhoc_storage_manager.hpp index c0d6d051..eeb7b88a 100644 --- a/src/scord/adhoc_storage_manager.hpp +++ b/src/scord/adhoc_storage_manager.hpp @@ -43,7 +43,8 @@ struct adhoc_storage_manager : scord::utils::singleton { tl::expected, scord::error_code> create(enum scord::adhoc_storage::type type, const std::string& name, - const scord::adhoc_storage::ctx& ctx) { + const scord::adhoc_storage::ctx& ctx, + const scord::adhoc_storage::resources& resources) { static std::atomic_uint64_t current_id; std::uint64_t id = current_id++; @@ -54,7 +55,8 @@ struct adhoc_storage_manager : scord::utils::singleton { it == m_adhoc_storages.end()) { const auto& [it_adhoc, inserted] = m_adhoc_storages.emplace( id, std::make_shared( - scord::adhoc_storage{type, name, id, ctx})); + scord::adhoc_storage{type, name, id, ctx, + resources})); if(!inserted) { LOGGER_ERROR("{}: Emplace failed", __FUNCTION__); diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index ac0b2f7c..999d4ff0 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -216,7 +216,7 @@ register_adhoc_storage(const request& req, const std::string& name, std::optional adhoc_id; auto& adhoc_manager = scord::adhoc_storage_manager::instance(); - if(const auto am_result = adhoc_manager.create(type, name, ctx); + if(const auto am_result = adhoc_manager.create(type, name, ctx, resources); am_result.has_value()) { const auto& adhoc_storage_info = am_result.value(); adhoc_id = adhoc_storage_info->adhoc_storage().id(); @@ -325,8 +325,8 @@ deploy_adhoc_storage(const request& req, std::uint64_t adhoc_id) { if(adhoc_storage.type() == scord::adhoc_storage::type::gekkofs) { const auto adhoc_ctx = adhoc_storage.context(); /* Number of nodes */ - const std::string nodes = - std::to_string(adhoc_ctx.resources().nodes().size()); + const std::string nodes = std::to_string( + adhoc_storage.get_resources().nodes().size()); /* Walltime */ const std::string walltime = std::to_string(adhoc_ctx.walltime()); -- GitLab From 1b55c62312fb7a141ed6f0b27e9e11e0746d38fc Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 20 Feb 2023 19:03:12 +0100 Subject: [PATCH 4/4] API: Update resources instead of execution context in ADM_update_adhoc_storage() --- examples/c/ADM_update_adhoc_storage.c | 31 ++++++++++++++++++----- examples/cxx/ADM_update_adhoc_storage.cpp | 6 +---- src/lib/c_wrapper.cpp | 6 ++--- src/lib/detail/impl.cpp | 10 ++++---- src/lib/detail/impl.hpp | 4 +-- src/lib/libscord.cpp | 4 +-- src/lib/scord/scord.h | 5 ++-- src/lib/scord/scord.hpp | 2 +- src/lib/scord/types.hpp | 3 +++ src/lib/types.cpp | 10 ++++++++ src/scord/adhoc_storage_manager.hpp | 4 +-- src/scord/internal_types.hpp | 4 +-- src/scord/rpc_handlers.cpp | 8 +++--- src/scord/rpc_handlers.hpp | 2 +- 14 files changed, 63 insertions(+), 36 deletions(-) diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index 7dd22dd2..f8f06397 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -27,9 +27,10 @@ #include #include "common.h" -#define NADHOC_NODES 25 -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NADHOC_NODES 25 +#define N_NEW_ADHOC_NODES 10 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -48,9 +49,11 @@ main(int argc, char* argv[]) { const char* adhoc_name = "adhoc_storage_42"; ADM_node_t* adhoc_nodes = NULL; + ADM_node_t* new_adhoc_nodes = NULL; ADM_adhoc_resources_t adhoc_resources = NULL; ADM_adhoc_context_t adhoc_ctx = NULL; ADM_adhoc_context_t new_adhoc_ctx = NULL; + ADM_adhoc_resources_t new_adhoc_resources = NULL; ADM_adhoc_storage_t adhoc_storage = NULL; @@ -105,9 +108,16 @@ main(int argc, char* argv[]) { // Now that we have an existing adhoc storage registered into the - // system, let's prepare a new execution context for the adhoc + // system, let's prepare a new set of resources for the adhoc // storage system + new_adhoc_nodes = prepare_nodes(N_NEW_ADHOC_NODES); + + if(new_adhoc_nodes == NULL) { + fprintf(stderr, "Fatal error preparing adhoc nodes\n"); + goto cleanup; + } + new_adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 200, false); @@ -116,9 +126,17 @@ main(int argc, char* argv[]) { goto cleanup; } + new_adhoc_resources = + ADM_adhoc_resources_create(new_adhoc_nodes, N_NEW_ADHOC_NODES); + + if(new_adhoc_resources == NULL) { + fprintf(stderr, "Fatal error preparing new adhoc resources\n"); + goto cleanup; + } + // We can now request the update to the server - if((ret = ADM_update_adhoc_storage(server, adhoc_storage, new_adhoc_ctx)) != - ADM_SUCCESS) { + if((ret = ADM_update_adhoc_storage(server, adhoc_storage, + new_adhoc_resources)) != ADM_SUCCESS) { fprintf(stderr, "ADM_update_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; @@ -142,6 +160,7 @@ cleanup: ADM_adhoc_context_destroy(new_adhoc_ctx); ADM_adhoc_context_destroy(adhoc_ctx); ADM_adhoc_resources_destroy(adhoc_resources); + destroy_nodes(new_adhoc_nodes, N_NEW_ADHOC_NODES); destroy_nodes(adhoc_nodes, NADHOC_NODES); exit(exit_status); } diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index 943a08d6..36cdaf55 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -53,9 +53,6 @@ main(int argc, char* argv[]) { scord::adhoc_storage::access_type::read_write, 100, false}; const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes}; - const auto new_adhoc_storage_ctx = scord::adhoc_storage::ctx{ - scord::adhoc_storage::execution_mode::separate_new, - scord::adhoc_storage::access_type::read_write, 200, false}; const auto new_adhoc_resources = scord::adhoc_storage::resources{new_adhoc_nodes}; @@ -64,8 +61,7 @@ main(int argc, char* argv[]) { server, name, scord::adhoc_storage::type::gekkofs, adhoc_storage_ctx, adhoc_resources); - scord::update_adhoc_storage(server, adhoc_storage, - new_adhoc_storage_ctx); + scord::update_adhoc_storage(server, adhoc_storage, new_adhoc_resources); fmt::print(stdout, "ADM_update_adhoc_storage() remote procedure completed " diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index fec3516f..f4be0262 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -132,13 +132,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_storage_t adhoc_storage, - ADM_adhoc_context_t ctx) { + ADM_adhoc_resources_t new_resources) { const scord::server srv{server}; return scord::detail::update_adhoc_storage( - srv, scord::adhoc_storage::ctx{ctx}, - scord::adhoc_storage{adhoc_storage}); + srv, scord::adhoc_storage{adhoc_storage}, + scord::adhoc_storage::resources{new_resources}); } ADM_return_t diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 1da6b6a0..6f3bc40d 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -249,8 +249,8 @@ register_adhoc_storage(const server& srv, const std::string& name, } scord::error_code -update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx, - const adhoc_storage& adhoc_storage) { +update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, + const adhoc_storage::resources& new_resources) { scord::network::client rpc_client{srv.protocol()}; @@ -261,13 +261,13 @@ update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx, const auto& endp = lookup_rv.value(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{adhoc_id: {}, new_ctx: {}}}", + "body: {{adhoc_id: {}, new_resources: {}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), std::quoted(rpc_client.self_address()), adhoc_storage.id(), - new_ctx); + new_resources); if(const auto& call_rv = endp.call("ADM_"s + __FUNCTION__, - adhoc_storage.id(), new_ctx); + adhoc_storage.id(), new_resources); call_rv.has_value()) { const scord::network::generic_response resp{call_rv.value()}; diff --git a/src/lib/detail/impl.hpp b/src/lib/detail/impl.hpp index 309d376c..40bb30c9 100644 --- a/src/lib/detail/impl.hpp +++ b/src/lib/detail/impl.hpp @@ -53,8 +53,8 @@ register_adhoc_storage(const server& srv, const std::string& name, const adhoc_storage::resources& resources); scord::error_code -update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx, - const adhoc_storage& adhoc_storage); +update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, + const adhoc_storage::resources& new_resources); scord::error_code remove_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage); diff --git a/src/lib/libscord.cpp b/src/lib/libscord.cpp index 7b517491..cbe3b47c 100644 --- a/src/lib/libscord.cpp +++ b/src/lib/libscord.cpp @@ -267,9 +267,9 @@ register_adhoc_storage(const server& srv, const std::string& name, void update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, - const adhoc_storage::ctx& adhoc_storage_ctx) { + const adhoc_storage::resources& new_resources) { const auto ec = - detail::update_adhoc_storage(srv, adhoc_storage_ctx, adhoc_storage); + detail::update_adhoc_storage(srv, adhoc_storage, new_resources); if(!ec) { throw std::runtime_error(fmt::format( diff --git a/src/lib/scord/scord.h b/src/lib/scord/scord.h index 585582b4..fa481557 100644 --- a/src/lib/scord/scord.h +++ b/src/lib/scord/scord.h @@ -122,15 +122,14 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, * Update an already-registered adhoc storage system. * * @param[in] server The server to which the request is directed - * @param[in] ctx The updated EXECUTION_CONTEXT for the adhoc storage system. * @param[in] adhoc_storage An ADM_STORAGE referring to the adhoc storage - * instance of interest. + * @param[in] new_resources The new resources for teh adhoc storage instance. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_storage_t adhoc_storage, - ADM_adhoc_context_t ctx); + ADM_adhoc_resources_t new_resources); /** * Remove an already-registered adhoc storage system. diff --git a/src/lib/scord/scord.hpp b/src/lib/scord/scord.hpp index f4fdab60..1a9a5c56 100644 --- a/src/lib/scord/scord.hpp +++ b/src/lib/scord/scord.hpp @@ -65,7 +65,7 @@ register_adhoc_storage(const server& srv, const std::string& name, void update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage, - const adhoc_storage::ctx& adhoc_storage_ctx); + const adhoc_storage::resources& new_resources); void remove_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage); diff --git a/src/lib/scord/types.hpp b/src/lib/scord/types.hpp index 12722a39..e017f2fb 100644 --- a/src/lib/scord/types.hpp +++ b/src/lib/scord/types.hpp @@ -281,6 +281,9 @@ struct adhoc_storage { void update(scord::adhoc_storage::ctx new_ctx); + void + update(scord::adhoc_storage::resources new_resources); + // The implementation for this must be deferred until // after the declaration of the PIMPL class template diff --git a/src/lib/types.cpp b/src/lib/types.cpp index 023ff075..2b23bd73 100644 --- a/src/lib/types.cpp +++ b/src/lib/types.cpp @@ -627,6 +627,11 @@ public: m_ctx = std::move(new_ctx); } + void + update(scord::adhoc_storage::resources new_resources) { + m_resources = std::move(new_resources); + } + template void load(Archive& ar) { @@ -730,6 +735,11 @@ adhoc_storage::update(scord::adhoc_storage::ctx new_ctx) { return m_pimpl->update(std::move(new_ctx)); } +void +adhoc_storage::update(scord::adhoc_storage::resources new_resources) { + return m_pimpl->update(std::move(new_resources)); +} + // since the PIMPL class is fully defined at this point, we can now // define the serialization function template diff --git a/src/scord/adhoc_storage_manager.hpp b/src/scord/adhoc_storage_manager.hpp index eeb7b88a..381991a6 100644 --- a/src/scord/adhoc_storage_manager.hpp +++ b/src/scord/adhoc_storage_manager.hpp @@ -71,14 +71,14 @@ struct adhoc_storage_manager : scord::utils::singleton { } scord::error_code - update(std::uint64_t id, scord::adhoc_storage::ctx new_ctx) { + update(std::uint64_t id, scord::adhoc_storage::resources new_resources) { abt::unique_lock lock(m_adhoc_storages_mutex); if(const auto it = m_adhoc_storages.find(id); it != m_adhoc_storages.end()) { const auto current_adhoc_info = it->second; - current_adhoc_info->update(std::move(new_ctx)); + current_adhoc_info->update(std::move(new_resources)); return scord::error_code::success; } diff --git a/src/scord/internal_types.hpp b/src/scord/internal_types.hpp index f8064945..72d34e4d 100644 --- a/src/scord/internal_types.hpp +++ b/src/scord/internal_types.hpp @@ -74,8 +74,8 @@ struct adhoc_storage_info { } void - update(scord::adhoc_storage::ctx adhoc_context) { - m_adhoc_storage.update(std::move(adhoc_context)); + update(scord::adhoc_storage::resources new_resources) { + m_adhoc_storage.update(std::move(new_resources)); } scord::error_code diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 999d4ff0..9c4045bc 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -239,7 +239,7 @@ register_adhoc_storage(const request& req, const std::string& name, void update_adhoc_storage(const request& req, std::uint64_t adhoc_id, - const scord::adhoc_storage::ctx& new_ctx) { + const scord::adhoc_storage::resources& new_resources) { using scord::network::get_address; @@ -247,12 +247,12 @@ update_adhoc_storage(const request& req, std::uint64_t adhoc_id, const auto rpc_id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{adhoc_id: {}, new_ctx: {}}}", + "body: {{adhoc_id: {}, new_resources: {}}}", rpc_id, std::quoted(rpc_name), std::quoted(get_address(req)), - adhoc_id, new_ctx); + adhoc_id, new_resources); auto& adhoc_manager = scord::adhoc_storage_manager::instance(); - const auto ec = adhoc_manager.update(adhoc_id, new_ctx); + const auto ec = adhoc_manager.update(adhoc_id, new_resources); if(!ec) { LOGGER_ERROR( diff --git a/src/scord/rpc_handlers.hpp b/src/scord/rpc_handlers.hpp index 279929a5..c0bc3963 100644 --- a/src/scord/rpc_handlers.hpp +++ b/src/scord/rpc_handlers.hpp @@ -54,7 +54,7 @@ register_adhoc_storage(const request& req, const std::string& name, const scord::adhoc_storage::resources& resources); void update_adhoc_storage(const request& req, std::uint64_t adhoc_id, - const scord::adhoc_storage::ctx& new_ctx); + const scord::adhoc_storage::resources& new_resources); void remove_adhoc_storage(const request& req, std::uint64_t adhoc_id); -- GitLab