From 38f9aad4645fcc58cab651f9f991f33de2d57484 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Fri, 18 Nov 2022 14:38:20 +0100 Subject: [PATCH 1/2] API: Split ADM_storage_t into ADM_adhoc_storage_t and ADM_pfs_storage_t --- examples/c/ADM_cancel_transfer.c | 4 +- examples/c/ADM_connect_data_operation.c | 4 +- examples/c/ADM_define_data_operation.c | 4 +- examples/c/ADM_deploy_adhoc_storage.c | 12 +- examples/c/ADM_finalize_data_operation.c | 4 +- examples/c/ADM_get_pending_transfers.c | 4 +- examples/c/ADM_get_qos_constraints.c | 4 +- examples/c/ADM_get_statistics.c | 4 +- examples/c/ADM_get_transfer_priority.c | 4 +- .../c/ADM_link_transfer_to_data_operation.c | 4 +- examples/c/ADM_register_adhoc_storage.c | 4 +- examples/c/ADM_register_job.c | 4 +- examples/c/ADM_register_pfs_storage.c | 2 +- examples/c/ADM_remove_adhoc_storage.c | 4 +- examples/c/ADM_remove_job.c | 4 +- examples/c/ADM_remove_pfs_storage.c | 2 +- examples/c/ADM_set_dataset_information.c | 4 +- examples/c/ADM_set_io_resources.c | 6 +- examples/c/ADM_set_qos_constraints.c | 4 +- examples/c/ADM_set_transfer_priority.c | 4 +- examples/c/ADM_transfer_datasets.c | 4 +- examples/c/ADM_update_adhoc_storage.c | 4 +- examples/c/ADM_update_job.c | 4 +- examples/c/ADM_update_pfs_storage.c | 2 +- examples/cxx/ADM_deploy_adhoc_storage.cpp | 10 +- examples/cxx/ADM_register_adhoc_storage.cpp | 2 +- examples/cxx/ADM_register_job.cpp | 2 +- examples/cxx/ADM_register_pfs_storage.cpp | 2 +- examples/cxx/ADM_remove_adhoc_storage.cpp | 2 +- examples/cxx/ADM_remove_job.cpp | 2 +- examples/cxx/ADM_remove_pfs_storage.cpp | 2 +- examples/cxx/ADM_set_io_resources.cpp | 2 +- examples/cxx/ADM_transfer_datasets.cpp | 2 +- examples/cxx/ADM_update_adhoc_storage.cpp | 2 +- examples/cxx/ADM_update_job.cpp | 2 +- examples/cxx/ADM_update_pfs_storage.cpp | 2 +- src/common/api/admire_types.h | 81 ++-- src/common/api/admire_types.hpp | 199 ++++------ src/common/api/convert.cpp | 16 +- src/common/api/convert.hpp | 20 +- src/common/api/types.cpp | 358 ++++++++++-------- src/common/net/proto/rpc_types.c | 169 +++++++-- src/common/net/proto/rpc_types.h | 40 +- src/lib/admire.cpp | 9 +- src/lib/admire.h | 23 +- src/lib/admire.hpp | 8 +- src/lib/c_wrapper.cpp | 22 +- src/lib/detail/impl.cpp | 2 +- 48 files changed, 622 insertions(+), 457 deletions(-) diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 478f3ed3..fb921ded 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 8b6bf16f..d47ffa0a 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -66,9 +66,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 0c9520ab..cc63b091 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -71,9 +71,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 04ad737a..ef77fb0b 100644 --- a/examples/c/ADM_deploy_adhoc_storage.c +++ b/examples/c/ADM_deploy_adhoc_storage.c @@ -25,9 +25,7 @@ #include #include #include -#include #include "common.h" -#include #define NADHOC_NODES 25 #define NINPUTS 10 @@ -53,7 +51,7 @@ main(int argc, char* argv[]) { ADM_adhoc_resources_t adhoc_resources = NULL; ADM_adhoc_context_t adhoc_ctx = NULL; ADM_adhoc_context_t new_adhoc_ctx = NULL; - ADM_storage_t adhoc_storage = NULL; + ADM_adhoc_storage_t adhoc_storage = NULL; // Let's prepare all the information required by the API calls. @@ -98,8 +96,9 @@ main(int argc, char* argv[]) { } // 2. Register the adhoc storage - if(ADM_register_adhoc_storage(server, adhoc_name, ADM_STORAGE_DATACLAY, - adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { + if(ADM_register_adhoc_storage(server, adhoc_name, + ADM_ADHOC_STORAGE_DATACLAY, adhoc_ctx, + &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); goto cleanup; @@ -120,8 +119,7 @@ main(int argc, char* argv[]) { } // We can now request the deployment to the server - if((ret = ADM_deploy_adhoc_storage(server, adhoc_storage)) != - ADM_SUCCESS) { + if((ret = ADM_deploy_adhoc_storage(server, adhoc_storage)) != ADM_SUCCESS) { fprintf(stderr, "ADM_deploy_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 9b125281..62dd9c34 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -67,9 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 d0c49c43..26ea286a 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 bd9ba065..f1b15b83 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -66,9 +66,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 17f93842..fcec8a87 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -66,9 +66,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 30593254..3ed3b1ae 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 7765f5cf..348d54ff 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -67,9 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 25abdc2d..756f2f7c 100644 --- a/examples/c/ADM_register_adhoc_storage.c +++ b/examples/c/ADM_register_adhoc_storage.c @@ -49,7 +49,7 @@ main(int argc, char* argv[]) { ADM_node_t* adhoc_nodes = NULL; ADM_adhoc_resources_t adhoc_resources = NULL; ADM_adhoc_context_t adhoc_ctx = NULL; - ADM_storage_t adhoc_storage = NULL; + ADM_adhoc_storage_t adhoc_storage = NULL; // Let's prepare all the information required by the API calls. // ADM_register_adhoc_storage() requires a set of nodes for the adhoc @@ -92,7 +92,7 @@ main(int argc, char* argv[]) { } // 2. Register the adhoc storage - if(ADM_register_adhoc_storage(server, adhoc_name, ADM_STORAGE_GEKKOFS, + if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 3e44467e..2ee75d15 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -50,7 +50,7 @@ main(int argc, char* argv[]) { ADM_node_t* adhoc_nodes = NULL; ADM_adhoc_resources_t adhoc_resources = NULL; ADM_adhoc_context_t adhoc_ctx = NULL; - ADM_storage_t adhoc_storage = NULL; + ADM_adhoc_storage_t adhoc_storage = NULL; // job information ADM_node_t* job_nodes = NULL; @@ -103,7 +103,7 @@ main(int argc, char* argv[]) { } // 2. Register the adhoc storage - if(ADM_register_adhoc_storage(server, adhoc_name, ADM_STORAGE_GEKKOFS, + if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); diff --git a/examples/c/ADM_register_pfs_storage.c b/examples/c/ADM_register_pfs_storage.c index 413f22e1..7b9a806f 100644 --- a/examples/c/ADM_register_pfs_storage.c +++ b/examples/c/ADM_register_pfs_storage.c @@ -43,7 +43,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_storage_t pfs_storage; + ADM_pfs_storage_t pfs_storage; ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); assert(ctx); diff --git a/examples/c/ADM_remove_adhoc_storage.c b/examples/c/ADM_remove_adhoc_storage.c index 34a0dca6..d8c1bbce 100644 --- a/examples/c/ADM_remove_adhoc_storage.c +++ b/examples/c/ADM_remove_adhoc_storage.c @@ -50,7 +50,7 @@ main(int argc, char* argv[]) { ADM_node_t* adhoc_nodes = NULL; ADM_adhoc_resources_t adhoc_resources = NULL; ADM_adhoc_context_t adhoc_ctx = NULL; - ADM_storage_t adhoc_storage = NULL; + ADM_adhoc_storage_t adhoc_storage = NULL; // Let's prepare all the information required by the API calls. @@ -95,7 +95,7 @@ main(int argc, char* argv[]) { } // 2. Register the adhoc storage - if(ADM_register_adhoc_storage(server, adhoc_name, ADM_STORAGE_GEKKOFS, + if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index 219cff71..826e950f 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_remove_pfs_storage.c b/examples/c/ADM_remove_pfs_storage.c index ee2638b9..e5a81c1a 100644 --- a/examples/c/ADM_remove_pfs_storage.c +++ b/examples/c/ADM_remove_pfs_storage.c @@ -42,7 +42,7 @@ main(int argc, char* argv[]) { ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); assert(ctx); - ADM_storage_t pfs_storage; + ADM_pfs_storage_t pfs_storage; ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); if(ret != ADM_SUCCESS) { diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index 4dd160da..a04735a7 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -67,9 +67,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 21d0c5bd..6b6c6f48 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -66,9 +66,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, @@ -99,7 +99,7 @@ main(int argc, char* argv[]) { goto cleanup; } - ADM_storage_t tier = NULL; + ADM_adhoc_storage_t tier = NULL; ADM_adhoc_resources_t resources = NULL; ret = ADM_set_io_resources(server, job, tier, resources); diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index 0cfed1bf..b82941e2 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 62ce6241..dc13d14d 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 d7b2ce66..d0be9ed4 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -73,9 +73,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &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 383afbc1..89bd4738 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -51,7 +51,7 @@ main(int argc, char* argv[]) { ADM_adhoc_resources_t adhoc_resources = NULL; ADM_adhoc_context_t adhoc_ctx = NULL; ADM_adhoc_context_t new_adhoc_ctx = NULL; - ADM_storage_t adhoc_storage = NULL; + ADM_adhoc_storage_t adhoc_storage = NULL; // Let's prepare all the information required by the API calls. @@ -96,7 +96,7 @@ main(int argc, char* argv[]) { } // 2. Register the adhoc storage - if(ADM_register_adhoc_storage(server, adhoc_name, ADM_STORAGE_GEKKOFS, + if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS, adhoc_ctx, &adhoc_storage) != ADM_SUCCESS) { fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n", ADM_strerror(ret)); diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index d3a876fe..18fdb7d6 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -70,9 +70,9 @@ main(int argc, char* argv[]) { const char* name = "adhoc_storage_42"; - ADM_storage_t adhoc_storage; + ADM_adhoc_storage_t adhoc_storage; ADM_return_t ret = ADM_register_adhoc_storage( - server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); + server, name, ADM_ADHOC_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { fprintf(stderr, diff --git a/examples/c/ADM_update_pfs_storage.c b/examples/c/ADM_update_pfs_storage.c index 90d0cf75..eb159575 100644 --- a/examples/c/ADM_update_pfs_storage.c +++ b/examples/c/ADM_update_pfs_storage.c @@ -42,7 +42,7 @@ main(int argc, char* argv[]) { ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); assert(ctx); - ADM_storage_t pfs_storage; + ADM_pfs_storage_t pfs_storage; ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); if(ret != ADM_SUCCESS) { diff --git a/examples/cxx/ADM_deploy_adhoc_storage.cpp b/examples/cxx/ADM_deploy_adhoc_storage.cpp index cc4ae7a2..ccfc76c1 100644 --- a/examples/cxx/ADM_deploy_adhoc_storage.cpp +++ b/examples/cxx/ADM_deploy_adhoc_storage.cpp @@ -55,7 +55,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::dataclay, + server, name, admire::adhoc_storage::type::dataclay, adhoc_storage_ctx); fmt::print(stdout, @@ -65,10 +65,10 @@ main(int argc, char* argv[]) { admire::deploy_adhoc_storage(server, adhoc_storage); } catch(const std::exception& e) { - fmt::print( - stderr, - "FATAL: ADM_register_adhoc_storage() or ADM_deploy_adhoc_storage() failed: {}\n", - e.what()); + fmt::print(stderr, + "FATAL: ADM_register_adhoc_storage() or " + "ADM_deploy_adhoc_storage() failed: {}\n", + e.what()); exit(EXIT_FAILURE); } diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index b18c19b6..4b00c3d4 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -55,7 +55,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::dataclay, + server, name, admire::adhoc_storage::type::gekkofs, adhoc_storage_ctx); fmt::print(stdout, diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index 463e319d..a016ea2f 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -56,7 +56,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::gekkofs, + server, name, admire::adhoc_storage::type::gekkofs, adhoc_storage_ctx); admire::job_requirements reqs(inputs, outputs, adhoc_storage); diff --git a/examples/cxx/ADM_register_pfs_storage.cpp b/examples/cxx/ADM_register_pfs_storage.cpp index 5c6e2356..4ff9c553 100644 --- a/examples/cxx/ADM_register_pfs_storage.cpp +++ b/examples/cxx/ADM_register_pfs_storage.cpp @@ -39,7 +39,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_pfs_context_t ctx{}; - ADM_storage_t pfs_storage{}; + ADM_pfs_storage_t pfs_storage{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_remove_adhoc_storage.cpp b/examples/cxx/ADM_remove_adhoc_storage.cpp index 3c1336ed..a9714cc3 100644 --- a/examples/cxx/ADM_remove_adhoc_storage.cpp +++ b/examples/cxx/ADM_remove_adhoc_storage.cpp @@ -55,7 +55,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::gekkofs, + server, name, admire::adhoc_storage::type::gekkofs, adhoc_storage_ctx); admire::remove_adhoc_storage(server, adhoc_storage); fmt::print(stdout, diff --git a/examples/cxx/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp index 0f320fae..1320946f 100644 --- a/examples/cxx/ADM_remove_job.cpp +++ b/examples/cxx/ADM_remove_job.cpp @@ -56,7 +56,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::gekkofs, + server, name, admire::adhoc_storage::type::gekkofs, adhoc_storage_ctx); admire::job_requirements reqs(inputs, outputs, adhoc_storage); diff --git a/examples/cxx/ADM_remove_pfs_storage.cpp b/examples/cxx/ADM_remove_pfs_storage.cpp index b4e88de1..11e887df 100644 --- a/examples/cxx/ADM_remove_pfs_storage.cpp +++ b/examples/cxx/ADM_remove_pfs_storage.cpp @@ -37,7 +37,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_storage_t pfs_storage{}; + ADM_pfs_storage_t pfs_storage{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_set_io_resources.cpp b/examples/cxx/ADM_set_io_resources.cpp index bad2726d..ab9108a4 100644 --- a/examples/cxx/ADM_set_io_resources.cpp +++ b/examples/cxx/ADM_set_io_resources.cpp @@ -38,7 +38,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_storage_t tier{}; + ADM_adhoc_storage_t tier{}; ADM_adhoc_resources_t resources{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_transfer_datasets.cpp b/examples/cxx/ADM_transfer_datasets.cpp index 88842c19..efd62144 100644 --- a/examples/cxx/ADM_transfer_datasets.cpp +++ b/examples/cxx/ADM_transfer_datasets.cpp @@ -63,7 +63,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::gekkofs, + server, name, admire::adhoc_storage::type::gekkofs, adhoc_storage_ctx); admire::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 cf1116da..54b6033b 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -60,7 +60,7 @@ main(int argc, char* argv[]) { try { const auto adhoc_storage = admire::register_adhoc_storage( - server, name, admire::storage::type::gekkofs, + server, name, admire::adhoc_storage::type::gekkofs, adhoc_storage_ctx); admire::update_adhoc_storage(server, adhoc_storage, diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index c3359421..1d8152f6 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -49,7 +49,7 @@ main(int argc, char* argv[]) { const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); const auto gkfs_storage = admire::register_adhoc_storage( - server, "foobar", admire::storage::type::gekkofs, + server, "foobar", admire::adhoc_storage::type::gekkofs, admire::adhoc_storage::ctx{ admire::adhoc_storage::execution_mode::separate_new, admire::adhoc_storage::access_type::read_write, diff --git a/examples/cxx/ADM_update_pfs_storage.cpp b/examples/cxx/ADM_update_pfs_storage.cpp index 90451902..fa2b6de6 100644 --- a/examples/cxx/ADM_update_pfs_storage.cpp +++ b/examples/cxx/ADM_update_pfs_storage.cpp @@ -38,7 +38,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_pfs_context_t ctx{}; - ADM_storage_t pfs_storage{}; + ADM_pfs_storage_t pfs_storage{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/src/common/api/admire_types.h b/src/common/api/admire_types.h index 40de25e7..727fc841 100644 --- a/src/common/api/admire_types.h +++ b/src/common/api/admire_types.h @@ -108,18 +108,25 @@ typedef struct adm_qos_limit_list* ADM_qos_limit_list_t; /* Storage tiers */ /* ----------------------------------------------------- */ -/** Storage tier types */ +/** Adhoc storage tier types */ typedef enum { - ADM_STORAGE_GEKKOFS, - ADM_STORAGE_DATACLAY, - ADM_STORAGE_EXPAND, - ADM_STORAGE_HERCULES, - ADM_STORAGE_LUSTRE, - ADM_STORAGE_GPFS, -} ADM_storage_type_t; + ADM_ADHOC_STORAGE_GEKKOFS, + ADM_ADHOC_STORAGE_DATACLAY, + ADM_ADHOC_STORAGE_EXPAND, + ADM_ADHOC_STORAGE_HERCULES, +} ADM_adhoc_storage_type_t; -/** A storage tier */ -typedef struct adm_storage* ADM_storage_t; +/** Adhoc storage tier types */ +typedef enum { + ADM_PFS_STORAGE_LUSTRE, + ADM_PFS_STORAGE_GPFS, +} ADM_pfs_storage_type_t; + +/** An adhoc storage tier */ +typedef struct adm_adhoc_storage* ADM_adhoc_storage_t; + +/** A PFS storage tier */ +typedef struct adm_pfs_storage* ADM_pfs_storage_t; /** Information about resources assigned to a storage tier */ typedef struct adm_adhoc_resources* ADM_adhoc_resources_t; @@ -314,7 +321,7 @@ ADM_job_resources_destroy(ADM_job_resources_t res); * @param[in] outputs An array of DATASET_DESCRIPTORS describing the output * information generated by the job. * @param[in] outputs_len The number of DATASET_DESCRIPTORS stored in outputs. - * @param[in] storage An optional ADHOC_DESCRIPTOR describing the adhoc + * @param[in] adhoc_storage An optional ADHOC_DESCRIPTOR describing the adhoc * storage system required by the job (can be set to NULL if no adhoc storage * system is required). * @return A valid ADM_job_requirements_t if sucessfull or NULL in case of @@ -323,7 +330,7 @@ ADM_job_resources_destroy(ADM_job_resources_t res); ADM_job_requirements_t ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, ADM_dataset_t outputs[], size_t outputs_len, - ADM_storage_t storage); + ADM_adhoc_storage_t adhoc_storage); /** * Destroy a ADM_job_requirements_t created by ADM_job_requirements_create(). @@ -411,30 +418,31 @@ ADM_dataset_list_destroy(ADM_dataset_list_t list); /* ----------------------------------------------------- */ /** - * Create a ADM_STORAGE to represent a storage tier. + * Create a ADM_ADHOC_STORAGE to represent an adhoc storage tier. * - * @remark ADM_STORAGEs need to be freed by calling ADM_storage_destroy(). + * @remark ADM_ADHOC_STORAGEs need to be freed by calling + * ADM_adhoc_storage_destroy(). * * @param[in] name A name for the storage tier * @param[in] type The type for the storage tier being created. * @param[in] id The assigned id for the storage tier being created. - * @param[in] 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. - * @return A valid ADM_STORAGE if successful, or NULL in case of failure. + * @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. + * @return A valid ADM_ADHOC_STORAGE if successful, or NULL in case of failure. */ -ADM_storage_t -ADM_storage_create(const char* name, ADM_storage_type_t type, uint64_t id, - void* ctx); +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); /** - * Destroy a ADM_STORAGE created by ADM_storage_destroy(). + * Destroy an ADM_ADHOC_STORAGE created by ADM_adhoc_storage_destroy(). * * @param[in] storage A valid ADM_STORAGE * @return ADM_SUCCESS or corresponding ADM error code */ ADM_return_t -ADM_storage_destroy(ADM_storage_t storage); +ADM_adhoc_storage_destroy(ADM_adhoc_storage_t adhoc_storage); /** * Create an ADM_ADHOC_RESOURCES from information about storage resources. @@ -490,6 +498,33 @@ ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, ADM_return_t ADM_adhoc_context_destroy(ADM_adhoc_context_t ctx); +/** + * Create a ADM_PFS_STORAGE to represent a PFS storage tier. + * + * @remark ADM_PFS_STORAGEs need to be freed by calling + * ADM_pfs_storage_destroy(). + * + * @param[in] name A name for the storage tier + * @param[in] type The type for the storage tier being created. + * @param[in] id The assigned id for the storage tier being created. + * @param[in] pfs_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. + * @return A valid ADM_ADHOC_STORAGE if successful, or NULL in case of failure. + */ +ADM_adhoc_storage_t +ADM_pfs_storage_create(const char* name, ADM_adhoc_storage_type_t type, + uint64_t id, ADM_adhoc_context_t adhoc_ctx); + +/** + * Destroy an ADM_ADHOC_STORAGE created by ADM_adhoc_storage_destroy(). + * + * @param[in] storage A valid ADM_STORAGE + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_pfs_storage_destroy(ADM_pfs_storage_t pfs_storage); + /** * Create an ADM_PFS_CONTEXT from information about how a PFS is configured. * diff --git a/src/common/api/admire_types.hpp b/src/common/api/admire_types.hpp index cfaf9c79..a6613afa 100644 --- a/src/common/api/admire_types.hpp +++ b/src/common/api/admire_types.hpp @@ -310,43 +310,15 @@ private: std::unique_ptr m_pimpl; }; -struct storage { - - enum class type : std::underlying_type::type { - gekkofs = ADM_STORAGE_GEKKOFS, - dataclay = ADM_STORAGE_DATACLAY, - expand = ADM_STORAGE_EXPAND, - hercules = ADM_STORAGE_HERCULES, - lustre = ADM_STORAGE_LUSTRE, - gpfs = ADM_STORAGE_GPFS - }; +struct adhoc_storage { - struct ctx { - virtual ~ctx() = default; + enum class type : std::underlying_type::type { + gekkofs = ADM_ADHOC_STORAGE_GEKKOFS, + dataclay = ADM_ADHOC_STORAGE_DATACLAY, + expand = ADM_ADHOC_STORAGE_EXPAND, + hercules = ADM_ADHOC_STORAGE_HERCULES, }; - storage(storage::type type, std::string name, std::uint64_t id); - - virtual ~storage() = default; - - std::string - name() const; - type - type() const; - std::uint64_t - id() const; - - virtual std::shared_ptr - context() const = 0; - -protected: - std::string m_name; - enum type m_type; - std::uint64_t m_id; -}; - -struct adhoc_storage : public storage { - enum class execution_mode : std::underlying_type::type { in_job_shared = ADM_ADHOC_MODE_IN_JOB_SHARED, in_job_dedicated = ADM_ADHOC_MODE_IN_JOB_DEDICATED, @@ -371,7 +343,7 @@ struct adhoc_storage : public storage { std::vector m_nodes; }; - struct ctx : storage::ctx { + struct ctx { ctx(execution_mode exec_mode, access_type access_type, adhoc_storage::resources resources, std::uint32_t walltime, @@ -398,15 +370,13 @@ struct adhoc_storage : public storage { bool m_should_flush; }; - adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, - execution_mode exec_mode, access_type access_type, - adhoc_storage::resources res, std::uint32_t walltime, - bool should_flush); - explicit adhoc_storage(ADM_storage_t storage); - adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, - ADM_adhoc_context_t ctx); - adhoc_storage(enum storage::type type, std::string name, std::uint64_t id, - const admire::adhoc_storage::ctx& ctx); + 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, + std::uint32_t walltime, bool should_flush); + explicit adhoc_storage(ADM_adhoc_storage_t storage); + adhoc_storage(enum adhoc_storage::type type, std::string name, + std::uint64_t id, const admire::adhoc_storage::ctx& ctx); adhoc_storage(const adhoc_storage& other) noexcept; adhoc_storage(adhoc_storage&&) noexcept; @@ -414,10 +384,16 @@ struct adhoc_storage : public storage { operator=(const adhoc_storage&) noexcept; adhoc_storage& operator=(adhoc_storage&&) noexcept; - ~adhoc_storage() override; + ~adhoc_storage(); - std::shared_ptr - context() const final; + std::string + name() const; + type + type() const; + std::uint64_t + id() const; + adhoc_storage::ctx + context() const; void update(admire::adhoc_storage::ctx new_ctx); @@ -427,9 +403,14 @@ private: std::unique_ptr m_pimpl; }; -struct pfs_storage : public storage { +struct pfs_storage { - struct ctx : storage::ctx { + enum class type : std::underlying_type::type { + lustre = ADM_PFS_STORAGE_LUSTRE, + gpfs = ADM_PFS_STORAGE_GPFS + }; + + struct ctx { explicit ctx(std::filesystem::path mount_point); @@ -442,20 +423,24 @@ struct pfs_storage : public storage { std::filesystem::path m_mount_point; }; - pfs_storage(enum storage::type type, std::string name, std::uint64_t id, + pfs_storage(enum pfs_storage::type type, std::string name, std::uint64_t id, std::filesystem::path mount_point); - pfs_storage(enum storage::type type, std::string name, std::uint64_t id, - ADM_pfs_context_t ctx); pfs_storage(const pfs_storage& other) noexcept; pfs_storage(pfs_storage&&) noexcept = default; pfs_storage& operator=(const pfs_storage& other) noexcept; pfs_storage& operator=(pfs_storage&&) noexcept = default; - ~pfs_storage() override; + ~pfs_storage(); - std::shared_ptr - context() const final; + std::string + name() const; + type + type() const; + std::uint64_t + id() const; + pfs_storage::ctx + context() const; private: class impl; @@ -547,34 +532,29 @@ struct fmt::formatter : formatter { }; template <> -struct fmt::formatter +struct fmt::formatter : formatter { // parse is inherited from formatter. template auto - format(const enum admire::storage::type& t, FormatContext& ctx) const { + format(const enum admire::adhoc_storage::type& t, + FormatContext& ctx) const { - using admire::storage; + using admire::adhoc_storage; std::string_view name = "unknown"; switch(t) { - case storage::type::gekkofs: - name = "ADM_STORAGE_GEKKOFS"; - break; - case storage::type::dataclay: - name = "ADM_STORAGE_DATACLAY"; + case adhoc_storage::type::gekkofs: + name = "ADM_ADHOC_STORAGE_GEKKOFS"; break; - case storage::type::expand: - name = "ADM_STORAGE_EXPAND"; + case adhoc_storage::type::dataclay: + name = "ADM_ADHOC_STORAGE_DATACLAY"; break; - case storage::type::hercules: - name = "ADM_STORAGE_HERCULES"; + case adhoc_storage::type::expand: + name = "ADM_ADHOC_STORAGE_EXPAND"; break; - case storage::type::lustre: - name = "ADM_STORAGE_LUSTRE"; - break; - case storage::type::gpfs: - name = "ADM_STORAGE_GPFS"; + case adhoc_storage::type::hercules: + name = "ADM_ADHOC_STORAGE_HERCULES"; break; } @@ -643,41 +623,6 @@ struct fmt::formatter } }; -template <> -struct fmt::formatter> - : formatter { - // parse is inherited from formatter. - template - auto - format(const std::shared_ptr& s, - FormatContext& ctx) const { - - if(!s) { - return formatter::format("NULL", ctx); - } - - switch(s->type()) { - case admire::storage::type::gekkofs: - case admire::storage::type::dataclay: - case admire::storage::type::expand: - case admire::storage::type::hercules: - return formatter::format( - fmt::format("{}", - *(dynamic_cast( - s.get()))), - ctx); - case admire::storage::type::lustre: - case admire::storage::type::gpfs: - return formatter::format( - fmt::format("{}", *(dynamic_cast( - s.get()))), - ctx); - default: - return formatter::format("unknown", ctx); - } - } -}; - template struct fmt::formatter> : formatter { @@ -696,14 +641,9 @@ struct fmt::formatter : formatter { template auto format(const admire::adhoc_storage& s, FormatContext& ctx) const { - - const auto pctx = std::dynamic_pointer_cast( - s.context()); - - const auto str = - fmt::format("{{type: {}, id: {}, name: {}, context: {}}}", - s.type(), s.id(), std::quoted(s.name()), - (pctx ? fmt::format("{}", *pctx) : "NULL")); + const auto str = fmt::format( + "{{type: {}, id: {}, name: {}, context: {}}}", s.type(), s.id(), + std::quoted(s.name()), s.context()); return formatter::format(str, ctx); } }; @@ -742,6 +682,29 @@ struct fmt::formatter } }; +template <> +struct fmt::formatter + : formatter { + // parse is inherited from formatter. + template + auto + format(const enum admire::pfs_storage::type& t, FormatContext& ctx) const { + + using admire::pfs_storage; + std::string_view name = "unknown"; + + switch(t) { + case pfs_storage::type::lustre: + name = "ADM_PFS_STORAGE_LUSTRE"; + break; + case pfs_storage::type::gpfs: + name = "ADM_PFS_STORAGE_GPFS"; + break; + } + + return formatter::format(name, ctx); + } +}; template <> struct fmt::formatter : formatter { @@ -749,11 +712,7 @@ struct fmt::formatter : formatter { template auto format(const admire::pfs_storage& s, FormatContext& ctx) const { - - const auto pctx = std::dynamic_pointer_cast( - s.context()); - const auto str = fmt::format( - "{{context: {}}}", (pctx ? fmt::format("{}", *pctx) : "NULL")); + const auto str = fmt::format("{{context: {}}}", s.context()); return formatter::format(str, ctx); } }; diff --git a/src/common/api/convert.cpp b/src/common/api/convert.cpp index 6f1e131a..3dc82ce3 100644 --- a/src/common/api/convert.cpp +++ b/src/common/api/convert.cpp @@ -96,27 +96,25 @@ convert(const adhoc_storage::ctx& ctx) { std::move(managed_adhoc_resources)}; } -managed_ctype +managed_ctype convert(const std::optional& adhoc_storage) { if(!adhoc_storage) { - return managed_ctype{}; + return managed_ctype{}; } return convert(adhoc_storage.value()); } -managed_ctype +managed_ctype convert(const admire::adhoc_storage& st) { - auto managed_ctx = - convert(*std::static_pointer_cast( - st.context())); - ADM_storage_t c_st = ADM_storage_create( - st.name().c_str(), static_cast(st.type()), + auto managed_ctx = convert(st.context()); + ADM_adhoc_storage_t c_st = ADM_adhoc_storage_create( + st.name().c_str(), static_cast(st.type()), st.id(), managed_ctx.get()); - return managed_ctype{c_st, std::move(managed_ctx)}; + return managed_ctype{c_st, std::move(managed_ctx)}; } managed_ctype diff --git a/src/common/api/convert.hpp b/src/common/api/convert.hpp index e8ed9bbc..1104baba 100644 --- a/src/common/api/convert.hpp +++ b/src/common/api/convert.hpp @@ -48,7 +48,7 @@ convert(const adhoc_storage::resources& res); managed_ctype convert(const adhoc_storage::ctx& ctx); -managed_ctype +managed_ctype convert(const admire::adhoc_storage& st); managed_ctype @@ -200,26 +200,27 @@ struct admire::api::managed_ctype { }; template <> -struct admire::api::managed_ctype { +struct admire::api::managed_ctype { managed_ctype() = default; - explicit managed_ctype(ADM_storage_t st, + explicit managed_ctype(ADM_adhoc_storage_t st, managed_ctype&& ctx) : m_storage(st), m_ctx(std::move(ctx)) {} - ADM_storage_t + ADM_adhoc_storage_t get() const { return m_storage.get(); } - ADM_storage_t + ADM_adhoc_storage_t release() { std::ignore = m_ctx.release(); return m_storage.release(); } - scord::utils::ctype_ptr m_storage; + scord::utils::ctype_ptr + m_storage; managed_ctype m_ctx; }; @@ -321,9 +322,10 @@ struct admire::api::managed_ctype { explicit managed_ctype(ADM_job_requirements_t reqs, managed_ctype_array&& inputs, managed_ctype_array&& outputs, - managed_ctype&& storage) + managed_ctype&& adhoc_storage) : m_reqs(reqs), m_inputs(std::move(inputs)), - m_outputs(std::move(outputs)), m_storage(std::move(storage)) {} + m_outputs(std::move(outputs)), + m_adhoc_storage(std::move(adhoc_storage)) {} ADM_job_requirements_t get() const { @@ -341,7 +343,7 @@ struct admire::api::managed_ctype { m_reqs; managed_ctype_array m_inputs; managed_ctype_array m_outputs; - managed_ctype m_storage; + managed_ctype m_adhoc_storage; }; diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index 2a337e98..56a41359 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -439,16 +439,16 @@ ADM_dataset_list_destroy(ADM_dataset_list_t list) { return ret; } -ADM_storage_t -ADM_storage_create(const char* name, ADM_storage_type_t type, uint64_t id, - void* ctx) { +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) { - struct adm_storage* adm_storage = - (struct adm_storage*) malloc(sizeof(*adm_storage)); + struct adm_adhoc_storage* adm_adhoc_storage = + (struct adm_adhoc_storage*) malloc(sizeof(*adm_adhoc_storage)); const char* error_msg = NULL; - if(!adm_storage) { - LOGGER_ERROR("Could not allocate ADM_storage_t"); + if(!adm_adhoc_storage) { + LOGGER_ERROR("Could not allocate ADM_adhoc_storage_t"); return NULL; } @@ -457,92 +457,59 @@ ADM_storage_create(const char* name, ADM_storage_type_t type, uint64_t id, return NULL; } - if(!ctx) { + if(!adhoc_ctx) { LOGGER_ERROR("Null storage context") return NULL; } - adm_storage->s_name = (const char*) calloc(strlen(name) + 1, sizeof(char)); - strcpy((char*) adm_storage->s_name, name); - adm_storage->s_type = type; - adm_storage->s_id = id; - - switch(adm_storage->s_type) { - case ADM_STORAGE_GEKKOFS: - case ADM_STORAGE_DATACLAY: - case ADM_STORAGE_EXPAND: - case ADM_STORAGE_HERCULES: - adm_storage->s_adhoc_ctx = - (ADM_adhoc_context_t) calloc(1, sizeof(adm_adhoc_context)); - if(!adm_storage->s_adhoc_ctx) { - error_msg = "Could not allocate ADM_adhoc_context_t"; - goto cleanup_on_error; - } - - memcpy(adm_storage->s_adhoc_ctx, (ADM_adhoc_context_t) ctx, - sizeof(*(ADM_adhoc_context_t) ctx)); - break; - - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - adm_storage->s_pfs_ctx = - (ADM_pfs_context_t) calloc(1, sizeof(adm_pfs_context)); - if(!adm_storage->s_pfs_ctx) { - error_msg = "Could not allocate ADM_pfs_context_t"; - goto cleanup_on_error; - } + adm_adhoc_storage->s_name = + (const char*) calloc(strlen(name) + 1, sizeof(char)); + strcpy((char*) adm_adhoc_storage->s_name, name); + adm_adhoc_storage->s_type = type; + adm_adhoc_storage->s_id = id; - memcpy(adm_storage->s_pfs_ctx, (ADM_pfs_context_t) ctx, - sizeof(*(ADM_pfs_context_t) ctx)); - break; + adm_adhoc_storage->s_adhoc_ctx = + (ADM_adhoc_context_t) calloc(1, sizeof(adm_adhoc_context)); + if(!adm_adhoc_storage->s_adhoc_ctx) { + error_msg = "Could not allocate ADM_adhoc_context_t"; + goto cleanup_on_error; } - return adm_storage; + memcpy(adm_adhoc_storage->s_adhoc_ctx, adhoc_ctx, sizeof(*adhoc_ctx)); + + return adm_adhoc_storage; cleanup_on_error: if(error_msg) { LOGGER_ERROR(error_msg); } - [[maybe_unused]] ADM_return_t ret = ADM_storage_destroy(adm_storage); + [[maybe_unused]] ADM_return_t ret = + ADM_adhoc_storage_destroy(adm_adhoc_storage); assert(ret); return NULL; } ADM_return_t -ADM_storage_destroy(ADM_storage_t storage) { +ADM_adhoc_storage_destroy(ADM_adhoc_storage_t adhoc_storage) { ADM_return_t ret = ADM_SUCCESS; - if(!storage) { - LOGGER_ERROR("Invalid ADM_storage_t") + if(!adhoc_storage) { + LOGGER_ERROR("Invalid ADM_adhoc_storage_t") return ADM_EBADARGS; } - if(storage->s_name) { - free((void*) storage->s_name); + if(adhoc_storage->s_name) { + free((void*) adhoc_storage->s_name); } - switch(storage->s_type) { - case ADM_STORAGE_GEKKOFS: - case ADM_STORAGE_DATACLAY: - case ADM_STORAGE_EXPAND: - case ADM_STORAGE_HERCULES: - if(storage->s_adhoc_ctx) { - free(storage->s_adhoc_ctx); - } - break; - - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - if(storage->s_pfs_ctx) { - free(storage->s_pfs_ctx); - } - break; + if(adhoc_storage->s_adhoc_ctx) { + free(adhoc_storage->s_adhoc_ctx); } - free(storage); + free(adhoc_storage); return ret; } @@ -601,6 +568,80 @@ ADM_adhoc_resources_destroy(ADM_adhoc_resources_t res) { return ret; } +ADM_pfs_storage_t +ADM_pfs_storage_create(const char* name, ADM_pfs_storage_type_t type, + uint64_t id, ADM_pfs_context_t pfs_ctx) { + + struct adm_pfs_storage* adm_pfs_storage = + (struct adm_pfs_storage*) malloc(sizeof(*adm_pfs_storage)); + const char* error_msg = NULL; + + if(!adm_pfs_storage) { + LOGGER_ERROR("Could not allocate ADM_pfs_storage_t"); + return NULL; + } + + if(!name) { + LOGGER_ERROR("Null storage name") + return NULL; + } + + if(!pfs_ctx) { + LOGGER_ERROR("Null storage context") + return NULL; + } + + adm_pfs_storage->s_name = + (const char*) calloc(strlen(name) + 1, sizeof(char)); + strcpy((char*) adm_pfs_storage->s_name, name); + adm_pfs_storage->s_type = type; + adm_pfs_storage->s_id = id; + + adm_pfs_storage->s_pfs_ctx = + (ADM_pfs_context_t) calloc(1, sizeof(adm_pfs_context)); + if(!adm_pfs_storage->s_pfs_ctx) { + error_msg = "Could not allocate ADM_pfs_context_t"; + goto cleanup_on_error; + } + + memcpy(adm_pfs_storage->s_pfs_ctx, pfs_ctx, sizeof(*pfs_ctx)); + + return adm_pfs_storage; + +cleanup_on_error: + if(error_msg) { + LOGGER_ERROR(error_msg); + } + + [[maybe_unused]] ADM_return_t ret = + ADM_pfs_storage_destroy(adm_pfs_storage); + assert(ret); + + return NULL; +} + +ADM_return_t +ADM_pfs_storage_destroy(ADM_pfs_storage_t pfs_storage) { + + ADM_return_t ret = ADM_SUCCESS; + + if(!pfs_storage) { + LOGGER_ERROR("Invalid ADM_pfs_storage_t") + return ADM_EBADARGS; + } + + if(pfs_storage->s_name) { + free((void*) pfs_storage->s_name); + } + + if(pfs_storage->s_pfs_ctx) { + free(pfs_storage->s_pfs_ctx); + } + + free(pfs_storage); + return ret; +} + ADM_data_operation_t ADM_data_operation_create() { @@ -755,7 +796,7 @@ ADM_job_resources_destroy(ADM_job_resources_t res) { ADM_job_requirements_t ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, ADM_dataset_t outputs[], size_t outputs_len, - ADM_storage_t storage) { + ADM_adhoc_storage_t adhoc_storage) { struct adm_job_requirements* adm_job_reqs = (struct adm_job_requirements*) calloc( @@ -787,21 +828,21 @@ ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, adm_job_reqs->r_inputs = inputs_list; adm_job_reqs->r_outputs = outputs_list; - if(!storage) { + if(!adhoc_storage) { return adm_job_reqs; } - if(storage->s_type != ADM_STORAGE_GEKKOFS && - storage->s_type != ADM_STORAGE_DATACLAY && - storage->s_type != ADM_STORAGE_EXPAND && - storage->s_type != ADM_STORAGE_HERCULES) { + if(adhoc_storage->s_type != ADM_ADHOC_STORAGE_GEKKOFS && + adhoc_storage->s_type != ADM_ADHOC_STORAGE_DATACLAY && + adhoc_storage->s_type != ADM_ADHOC_STORAGE_EXPAND && + adhoc_storage->s_type != ADM_ADHOC_STORAGE_HERCULES) { error_msg = "Invalid adhoc_storage type"; goto cleanup_on_error; } - adm_job_reqs->r_storage = - ADM_storage_create(storage->s_name, storage->s_type, storage->s_id, - storage->s_adhoc_ctx); + 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); return adm_job_reqs; @@ -835,8 +876,8 @@ ADM_job_requirements_destroy(ADM_job_requirements_t reqs) { ADM_dataset_list_destroy(reqs->r_outputs); } - if(reqs->r_storage) { - ADM_storage_destroy(reqs->r_storage); + if(reqs->r_adhoc_storage) { + ADM_adhoc_storage_destroy(reqs->r_adhoc_storage); } free(reqs); @@ -1279,24 +1320,6 @@ dataset::id() const { return m_pimpl->id(); } -storage::storage(enum storage::type type, std::string name, std::uint64_t id) - : m_name(std::move(name)), m_type(type), m_id(id) {} - -std::string -storage::name() const { - return m_name; -} - -enum storage::type -storage::type() const { - return m_type; -} - -std::uint64_t -storage::id() const { - return m_id; -} - adhoc_storage::resources::resources(std::vector nodes) : m_nodes(std::move(nodes)) {} @@ -1356,7 +1379,10 @@ adhoc_storage::ctx::should_flush() const { class adhoc_storage::impl { public: - explicit impl(adhoc_storage::ctx ctx) : m_ctx(std::move(ctx)) {} + explicit impl(enum adhoc_storage::type type, std::string name, + std::uint64_t id, adhoc_storage::ctx ctx) + : m_type(type), m_name(std::move(name)), m_id(id), + m_ctx(std::move(ctx)) {} impl(const impl& rhs) = default; impl(impl&& rhs) = default; impl& @@ -1365,6 +1391,21 @@ public: operator=(impl&&) noexcept = default; ~impl() = default; + std::string + name() const { + return m_name; + } + + enum type + type() const { + return m_type; + } + + std::uint64_t + id() const { + return m_id; + } + adhoc_storage::ctx context() const { return m_ctx; @@ -1376,50 +1417,33 @@ public: } private: + enum type m_type; + std::string m_name; + std::uint64_t m_id; adhoc_storage::ctx m_ctx; }; -adhoc_storage::adhoc_storage(enum storage::type type, std::string name, +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, std::uint32_t walltime, bool should_flush) - : storage(type, std::move(name), id), - m_pimpl(std::make_unique( + : m_pimpl(std::make_unique( + type, std::move(name), id, adhoc_storage::ctx{exec_mode, access_type, std::move(res), walltime, should_flush})) {} -adhoc_storage::adhoc_storage(ADM_storage_t st) - : storage(static_cast(st->s_type), st->s_name, - st->s_id) { - - switch(st->s_type) { - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - throw std::runtime_error( - fmt::format("Invalid type {} for adhoc_storage", - static_cast(st->s_type))); - break; - - default: - break; - } - m_pimpl = std::make_unique(adhoc_storage::ctx{st->s_adhoc_ctx}); -} - -adhoc_storage::adhoc_storage(enum storage::type type, std::string name, - std::uint64_t id, ADM_adhoc_context_t ctx) - : storage(type, std::move(name), id), - m_pimpl(std::make_unique(adhoc_storage::ctx{ctx})) {} +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})) {} -adhoc_storage::adhoc_storage(enum storage::type type, std::string name, +adhoc_storage::adhoc_storage(enum adhoc_storage::type type, std::string name, std::uint64_t id, const adhoc_storage::ctx& ctx) - : storage(type, std::move(name), id), m_pimpl(std::make_unique(ctx)) { -} + : m_pimpl(std::make_unique(type, std::move(name), id, ctx)) {} adhoc_storage::adhoc_storage(const adhoc_storage& other) noexcept - : storage(other.m_type, other.m_name, other.m_id), - m_pimpl(std::make_unique(*other.m_pimpl)) {} + : m_pimpl(std::make_unique(*other.m_pimpl)) {} adhoc_storage::adhoc_storage(adhoc_storage&&) noexcept = default; @@ -1432,9 +1456,24 @@ adhoc_storage::operator=(const adhoc_storage& other) noexcept { adhoc_storage& adhoc_storage::operator=(adhoc_storage&&) noexcept = default; -std::shared_ptr +std::string +adhoc_storage::name() const { + return m_pimpl->name(); +} + +enum adhoc_storage::type +adhoc_storage::type() const { + return m_pimpl->type(); +} + +std::uint64_t +adhoc_storage::id() const { + return m_pimpl->id(); +} + +adhoc_storage::ctx adhoc_storage::context() const { - return std::make_shared(m_pimpl->context()); + return m_pimpl->context(); } void @@ -1450,8 +1489,7 @@ pfs_storage::ctx::ctx(std::filesystem::path mount_point) pfs_storage::ctx::ctx(ADM_pfs_context_t ctx) : pfs_storage::ctx(ctx->c_mount) {} pfs_storage::pfs_storage(const pfs_storage& other) noexcept - : storage(other.m_type, other.m_name, other.m_id), - m_pimpl(std::make_unique(*other.m_pimpl)) {} + : m_pimpl(std::make_unique(*other.m_pimpl)) {} pfs_storage& pfs_storage::operator=(const pfs_storage& other) noexcept { @@ -1465,9 +1503,11 @@ pfs_storage::ctx::mount_point() const { } class pfs_storage::impl { - public: - explicit impl(pfs_storage::ctx ctx) : m_ctx(std::move(ctx)) {} + explicit impl(enum pfs_storage::type type, std::string name, + std::uint64_t id, pfs_storage::ctx ctx) + : m_type(type), m_name(std::move(name)), m_id(id), + m_ctx(std::move(ctx)) {} impl(const impl& rhs) = default; impl(impl&& rhs) = default; impl& @@ -1475,35 +1515,62 @@ public: impl& operator=(impl&&) noexcept = default; + enum type + type() const { + return m_type; + }; + + std::string + name() const { + return m_name; + } + + std::uint64_t + id() const { + return m_id; + }; + pfs_storage::ctx context() const { return m_ctx; } private: + enum type m_type; + std::string m_name; + std::uint64_t m_id; pfs_storage::ctx m_ctx; }; -pfs_storage::pfs_storage(enum storage::type type, std::string name, +pfs_storage::pfs_storage(enum pfs_storage::type type, std::string name, std::uint64_t id, std::filesystem::path mount_point) - : storage(type, std::move(name), id), - m_pimpl(std::make_unique( + : m_pimpl(std::make_unique( + type, std::move(name), id, pfs_storage::ctx{std::move(mount_point)})) {} -pfs_storage::pfs_storage(enum storage::type type, std::string name, - std::uint64_t id, ADM_pfs_context_t ctx) - : storage(type, std::move(name), id), - m_pimpl(std::make_unique(pfs_storage::ctx{ctx})) {} - pfs_storage::~pfs_storage() = default; -std::shared_ptr +std::string +pfs_storage::name() const { + return m_pimpl->name(); +} + +enum pfs_storage::type +pfs_storage::type() const { + return m_pimpl->type(); +} + +std::uint64_t +pfs_storage::id() const { + return m_pimpl->id(); +} + +pfs_storage::ctx pfs_storage::context() const { - return std::make_shared(m_pimpl->context()); + return m_pimpl->context(); } class job_requirements::impl { - public: impl(std::vector inputs, std::vector outputs) @@ -1529,12 +1596,8 @@ public: m_outputs.emplace_back(reqs->r_outputs->l_datasets[i].d_id); } - 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_name, reqs->r_storage->s_id, - reqs->r_storage->s_adhoc_ctx); + if(reqs->r_adhoc_storage) { + m_adhoc_storage = admire::adhoc_storage(reqs->r_adhoc_storage); } } @@ -1612,7 +1675,6 @@ job_requirements::adhoc_storage() const { } namespace qos { - class entity::impl { public: template diff --git a/src/common/net/proto/rpc_types.c b/src/common/net/proto/rpc_types.c index c2df5d57..623d9803 100644 --- a/src/common/net/proto/rpc_types.c +++ b/src/common/net/proto/rpc_types.c @@ -24,8 +24,10 @@ #include "rpc_types.h" -hg_return_t (*hg_proc_ADM_storage_type_t)(hg_proc_t, - void*) = hg_proc_hg_uint32_t; +hg_return_t (*hg_proc_ADM_adhoc_storage_type_t)(hg_proc_t, + void*) = hg_proc_hg_uint32_t; +hg_return_t (*hg_proc_ADM_pfs_storage_type_t)(hg_proc_t, + void*) = hg_proc_hg_uint32_t; hg_return_t (*hg_proc_ADM_qos_scope_t)(hg_proc_t, void*) = hg_proc_hg_uint32_t; hg_return_t (*hg_proc_ADM_qos_class_t)(hg_proc_t, void*) = hg_proc_hg_uint32_t; @@ -387,20 +389,19 @@ hg_proc_ADM_dataset_list_t(hg_proc_t proc, void* data) { hg_return_t -hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { - (void) proc; - (void) data; +hg_proc_ADM_adhoc_storage_t(hg_proc_t proc, void* data) { hg_return_t ret = HG_SUCCESS; - ADM_storage_t* storage = (ADM_storage_t*) data; - ADM_storage_t tmp = NULL; + ADM_adhoc_storage_t* storage = (ADM_adhoc_storage_t*) data; + ADM_adhoc_storage_t tmp = NULL; hg_size_t storage_length = 0; switch(hg_proc_get_op(proc)) { case HG_ENCODE: - // find out the length of the adm_storage object we need to send - storage_length = *storage ? sizeof(adm_storage) : 0; + // find out the length of the adm_adhoc_storage object we need to + // send + storage_length = *storage ? sizeof(adm_adhoc_storage) : 0; ret = hg_proc_hg_size_t(proc, &storage_length); if(ret != HG_SUCCESS) { @@ -411,7 +412,7 @@ hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { return HG_SUCCESS; } - // if we actually need to send an adm_storage object, + // if we actually need to send an adm_adhoc_storage object, // write each of its fields to the mercury buffer tmp = *storage; @@ -437,23 +438,16 @@ hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { } // 4. the appropriate storage context - switch(tmp->s_type) { - case ADM_STORAGE_GEKKOFS: - case ADM_STORAGE_DATACLAY: - case ADM_STORAGE_EXPAND: - case ADM_STORAGE_HERCULES: - ret = hg_proc_ADM_adhoc_context_t(proc, &tmp->s_adhoc_ctx); - break; - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - ret = hg_proc_ADM_pfs_context_t(proc, &tmp->s_pfs_ctx); - break; + ret = hg_proc_ADM_adhoc_context_t(proc, &tmp->s_adhoc_ctx); + + if(ret != HG_SUCCESS) { + break; } break; case HG_DECODE: - // find out the length of the adm_storage object + // find out the length of the adm_adhoc_storage object ret = hg_proc_hg_size_t(proc, &storage_length); if(ret != HG_SUCCESS) { @@ -465,9 +459,9 @@ hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { break; } - // if the received adm_storage object was not NULL, read each of - // its fields from the mercury buffer - tmp = (adm_storage*) calloc(1, sizeof(adm_storage)); + // if the received adm_adhoc_storage object was not NULL, read each + // of its fields from the mercury buffer + tmp = (adm_adhoc_storage*) calloc(1, sizeof(adm_adhoc_storage)); // 1. the storage type ret = hg_proc_uint32_t(proc, &tmp->s_type); @@ -491,17 +485,10 @@ hg_proc_ADM_storage_t(hg_proc_t proc, void* data) { } // 4. the appropriate storage context - switch(tmp->s_type) { - case ADM_STORAGE_GEKKOFS: - case ADM_STORAGE_DATACLAY: - case ADM_STORAGE_EXPAND: - case ADM_STORAGE_HERCULES: - ret = hg_proc_ADM_adhoc_context_t(proc, &tmp->s_adhoc_ctx); - break; - case ADM_STORAGE_LUSTRE: - case ADM_STORAGE_GPFS: - ret = hg_proc_ADM_pfs_context_t(proc, &tmp->s_adhoc_ctx); - break; + ret = hg_proc_ADM_adhoc_context_t(proc, &tmp->s_adhoc_ctx); + + if(ret != HG_SUCCESS) { + break; } // return the newly-created ctx @@ -588,6 +575,116 @@ hg_proc_ADM_adhoc_context_t(hg_proc_t proc, void* data) { return ret; } +hg_return_t +hg_proc_ADM_pfs_storage_t(hg_proc_t proc, void* data) { + + hg_return_t ret = HG_SUCCESS; + ADM_pfs_storage_t* storage = (ADM_pfs_storage_t*) data; + ADM_pfs_storage_t tmp = NULL; + hg_size_t storage_length = 0; + + switch(hg_proc_get_op(proc)) { + + case HG_ENCODE: + // find out the length of the adm_pfs_storage object we need to send + storage_length = *storage ? sizeof(adm_pfs_storage) : 0; + ret = hg_proc_hg_size_t(proc, &storage_length); + + if(ret != HG_SUCCESS) { + break; + } + + if(!storage_length) { + return HG_SUCCESS; + } + + // if we actually need to send an adm_pfs_storage object, + // write each of its fields to the mercury buffer + tmp = *storage; + + // 1. the storage type + ret = hg_proc_hg_uint32_t(proc, &tmp->s_type); + + if(ret != HG_SUCCESS) { + break; + } + + // 2. the storage id + ret = hg_proc_hg_const_string_t(proc, &tmp->s_name); + + if(ret != HG_SUCCESS) { + break; + } + + // 3. the server-assigned id + ret = hg_proc_hg_int64_t(proc, &tmp->s_id); + + if(ret != HG_SUCCESS) { + break; + } + + // 4. the appropriate storage context + ret = hg_proc_ADM_pfs_context_t(proc, &tmp->s_pfs_ctx); + break; + + case HG_DECODE: + // find out the length of the adm_pfs_storage object + ret = hg_proc_hg_size_t(proc, &storage_length); + + if(ret != HG_SUCCESS) { + break; + } + + if(!storage_length) { + *storage = NULL; + break; + } + + // if the received adm_pfs_storage object was not NULL, read each of + // its fields from the mercury buffer + tmp = (adm_pfs_storage*) calloc(1, sizeof(adm_pfs_storage)); + + // 1. the storage type + ret = hg_proc_uint32_t(proc, &tmp->s_type); + + if(ret != HG_SUCCESS) { + break; + } + + // 2. the storage id + ret = hg_proc_hg_const_string_t(proc, &tmp->s_name); + + if(ret != HG_SUCCESS) { + break; + } + + // 3. the server-assigned id + ret = hg_proc_hg_int64_t(proc, &tmp->s_id); + + if(ret != HG_SUCCESS) { + break; + } + + // 4. the appropriate storage context + ret = hg_proc_ADM_pfs_context_t(proc, &tmp->s_pfs_ctx); + + if(ret != HG_SUCCESS) { + break; + } + + // return the newly-created ctx + *storage = tmp; + break; + + case HG_FREE: + tmp = *storage; + free(tmp); + break; + } + + return ret; +} + hg_return_t hg_proc_ADM_pfs_context_t(hg_proc_t proc, void* data) { diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index b624c828..07a8c029 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -182,21 +182,29 @@ MERCURY_GEN_STRUCT_PROC( ); // clang-format on -extern hg_return_t (*hg_proc_ADM_storage_type_t)(hg_proc_t, void*); +extern hg_return_t (*hg_proc_ADM_adhoc_storage_type_t)(hg_proc_t, void*); -typedef struct adm_storage { +typedef struct adm_adhoc_storage { const char* s_name; - ADM_storage_type_t s_type; + ADM_adhoc_storage_type_t s_type; uint64_t s_id; - union { - ADM_adhoc_context_t s_adhoc_ctx; - ADM_pfs_context_t s_pfs_ctx; - }; -} adm_storage; + ADM_adhoc_context_t s_adhoc_ctx; +} adm_adhoc_storage; hg_return_t -hg_proc_ADM_storage_t(hg_proc_t proc, void* data); +hg_proc_ADM_adhoc_storage_t(hg_proc_t proc, void* data); +extern hg_return_t (*hg_proc_ADM_pfs_storage_type_t)(hg_proc_t, void*); + +typedef struct adm_pfs_storage { + const char* s_name; + ADM_pfs_storage_type_t s_type; + uint64_t s_id; + ADM_pfs_context_t s_pfs_ctx; +} adm_pfs_storage; + +hg_return_t +hg_proc_ADM_pfs_storage_t(hg_proc_t proc, void* data); struct adm_node_list { /** An array of nodes */ @@ -256,15 +264,15 @@ typedef struct adm_job_requirements { /** An array of output datasets */ ADM_dataset_list_t r_outputs; /** An optional definition for a specific storage instance */ - ADM_storage_t r_storage; + ADM_adhoc_storage_t r_adhoc_storage; } adm_job_requirements; // clang-format off MERCURY_GEN_STRUCT_PROC( adm_job_requirements, // NOLINT - ((ADM_dataset_list_t) (r_inputs)) - ((ADM_dataset_list_t) (r_outputs)) - ((ADM_storage_t) (r_storage)) + ((ADM_dataset_list_t) (r_inputs)) + ((ADM_dataset_list_t) (r_outputs)) + ((ADM_adhoc_storage_t) (r_adhoc_storage)) ); // clang-format on @@ -334,9 +342,9 @@ MERCURY_GEN_PROC( /// ADM_register_adhoc_storage MERCURY_GEN_PROC( ADM_register_adhoc_storage_in_t, - ((hg_const_string_t) (name)) - ((ADM_storage_type_t) (type)) - ((ADM_adhoc_context_t) (ctx)) + ((hg_const_string_t) (name)) + ((ADM_adhoc_storage_type_t) (type)) + ((ADM_adhoc_context_t) (ctx)) ); MERCURY_GEN_PROC( diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index e3e74f11..3e0a9648 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -292,12 +292,11 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) { throw std::runtime_error(fmt::format( "ADM_deploy_adhoc_storage() error: {}", ec.message())); } - } ADM_return_t register_pfs_storage(const server& srv, ADM_pfs_context_t ctx, - ADM_storage_t* pfs_storage) { + ADM_pfs_storage_t* pfs_storage) { (void) srv; (void) ctx; (void) pfs_storage; @@ -324,7 +323,7 @@ register_pfs_storage(const server& srv, ADM_pfs_context_t ctx, ADM_return_t update_pfs_storage(const server& srv, ADM_pfs_context_t ctx, - ADM_storage_t pfs_storage) { + ADM_pfs_storage_t pfs_storage) { (void) srv; (void) ctx; (void) pfs_storage; @@ -350,7 +349,7 @@ update_pfs_storage(const server& srv, ADM_pfs_context_t ctx, } ADM_return_t -remove_pfs_storage(const server& srv, ADM_storage_t pfs_storage) { +remove_pfs_storage(const server& srv, ADM_pfs_storage_t pfs_storage) { (void) srv; (void) pfs_storage; @@ -423,7 +422,7 @@ set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, } ADM_return_t -set_io_resources(const server& srv, ADM_job_t job, ADM_storage_t tier, +set_io_resources(const server& srv, ADM_job_t job, ADM_adhoc_storage_t tier, ADM_adhoc_resources_t resources) { (void) srv; (void) job; diff --git a/src/lib/admire.h b/src/lib/admire.h index 2545d6c4..87b62349 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -113,8 +113,9 @@ ADM_remove_job(ADM_server_t server, ADM_job_t job); */ ADM_return_t ADM_register_adhoc_storage(ADM_server_t server, const char* name, - ADM_storage_type_t type, ADM_adhoc_context_t ctx, - ADM_storage_t* adhoc_storage); + ADM_adhoc_storage_type_t type, + ADM_adhoc_context_t ctx, + ADM_adhoc_storage_t* adhoc_storage); /** * Update an already-registered adhoc storage system. @@ -127,7 +128,7 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, * successfully. */ ADM_return_t -ADM_update_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage, +ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_storage_t adhoc_storage, ADM_adhoc_context_t ctx); /** @@ -141,7 +142,8 @@ ADM_update_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage, * successfully. */ ADM_return_t -ADM_remove_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage); +ADM_remove_adhoc_storage(ADM_server_t server, + ADM_adhoc_storage_t adhoc_storage); /** * Initiate the deployment of an adhoc storage system instance. @@ -153,7 +155,8 @@ ADM_remove_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage); * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_deploy_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage); +ADM_deploy_adhoc_storage(ADM_server_t server, + ADM_adhoc_storage_t adhoc_storage); /** * Register a PFS storage tier. @@ -167,7 +170,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage); */ ADM_return_t ADM_register_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, - ADM_storage_t* pfs_storage); + ADM_pfs_storage_t* pfs_storage); /** * Update an already-registered PFS storage tier. @@ -181,7 +184,7 @@ ADM_register_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, */ ADM_return_t ADM_update_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, - ADM_storage_t adhoc_storage); + ADM_pfs_storage_t adhoc_storage); /** * Remove an already-registered PFS storage tier. @@ -194,7 +197,7 @@ ADM_update_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, * successfully. */ ADM_return_t -ADM_remove_pfs_storage(ADM_server_t server, ADM_storage_t adhoc_storage); +ADM_remove_pfs_storage(ADM_server_t server, ADM_pfs_storage_t adhoc_storage); /** * Transfers the dataset identified by the source_name to the storage tier @@ -258,8 +261,8 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, * successfully. */ ADM_return_t -ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_storage_t tier, - ADM_adhoc_resources_t resources); +ADM_set_io_resources(ADM_server_t server, ADM_job_t job, + ADM_adhoc_storage_t tier, ADM_adhoc_resources_t resources); /** diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 980fcb27..2980244f 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -74,14 +74,14 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage); ADM_return_t register_pfs_storage(const server& srv, ADM_pfs_context_t ctx, - ADM_storage_t* pfs_storage); + ADM_pfs_storage_t* pfs_storage); ADM_return_t update_pfs_storage(const server& srv, ADM_pfs_context_t ctx, - ADM_storage_t pfs_storage); + ADM_pfs_storage_t pfs_storage); ADM_return_t -remove_pfs_storage(const server& srv, ADM_storage_t pfs_storage); +remove_pfs_storage(const server& srv, ADM_pfs_storage_t pfs_storage); admire::transfer transfer_datasets(const server& srv, const job& job, @@ -95,7 +95,7 @@ set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, ADM_dataset_info_t info); ADM_return_t -set_io_resources(const server& srv, ADM_job_t job, ADM_storage_t tier, +set_io_resources(const server& srv, ADM_job_t job, ADM_adhoc_storage_t tier, ADM_adhoc_resources_t resources); ADM_return_t diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index fd5744e5..be03a197 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -82,8 +82,9 @@ ADM_remove_job(ADM_server_t server, ADM_job_t job) { ADM_return_t ADM_register_adhoc_storage(ADM_server_t server, const char* name, - ADM_storage_type_t type, ADM_adhoc_context_t ctx, - ADM_storage_t* adhoc_storage) { + ADM_adhoc_storage_type_t type, + ADM_adhoc_context_t ctx, + ADM_adhoc_storage_t* adhoc_storage) { const admire::server srv{server}; @@ -101,7 +102,7 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name, } ADM_return_t -ADM_update_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage, +ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_storage_t adhoc_storage, ADM_adhoc_context_t ctx) { const admire::server srv{server}; @@ -112,7 +113,8 @@ ADM_update_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage, } ADM_return_t -ADM_remove_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage) { +ADM_remove_adhoc_storage(ADM_server_t server, + ADM_adhoc_storage_t adhoc_storage) { const admire::server srv{server}; @@ -121,7 +123,8 @@ ADM_remove_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage) { } ADM_return_t -ADM_deploy_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage) { +ADM_deploy_adhoc_storage(ADM_server_t server, + ADM_adhoc_storage_t adhoc_storage) { const admire::server srv{server}; @@ -131,7 +134,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_storage_t adhoc_storage) { ADM_return_t ADM_register_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, - ADM_storage_t* pfs_storage) { + ADM_pfs_storage_t* pfs_storage) { const admire::server srv{server}; @@ -140,7 +143,7 @@ ADM_register_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, ADM_return_t ADM_update_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, - ADM_storage_t pfs_storage) { + ADM_pfs_storage_t pfs_storage) { const admire::server srv{server}; @@ -148,7 +151,7 @@ ADM_update_pfs_storage(ADM_server_t server, ADM_pfs_context_t ctx, } ADM_return_t -ADM_remove_pfs_storage(ADM_server_t server, ADM_storage_t pfs_storage) { +ADM_remove_pfs_storage(ADM_server_t server, ADM_pfs_storage_t pfs_storage) { const admire::server srv{server}; @@ -189,7 +192,8 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, } ADM_return_t -ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_storage_t tier, +ADM_set_io_resources(ADM_server_t server, ADM_job_t job, + ADM_adhoc_storage_t tier, ADM_adhoc_resources_t resources) { const admire::server srv{server}; diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index e2d84d41..40f80930 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -330,7 +330,7 @@ register_adhoc_storage(const server& srv, const std::string& name, std::quoted(rpc_client.self_address()), name, type, ctx); const auto rpc_name = name.c_str(); - const auto rpc_type = static_cast(type); + const auto rpc_type = static_cast(type); const auto rpc_ctx = api::convert(ctx); ADM_register_adhoc_storage_in_t in{rpc_name, rpc_type, rpc_ctx.get()}; -- GitLab From eaeafd0992efdc012a1486eaba51e609cd40ef01 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 23 Nov 2022 12:27:29 +0100 Subject: [PATCH 2/2] ADM_deploy_adhoc_storage: Update RPC handler --- src/scord/rpc_handlers.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 8bc7ef81..515caed7 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -457,16 +457,15 @@ ADM_deploy_adhoc_storage(hg_handle_t h) { am_result.has_value()) { const auto& storage_info = am_result.value(); const auto adhoc_storage = storage_info->adhoc_storage(); - ec = admire::error_code::success; - if(adhoc_storage.type() == admire::storage::type::gekkofs) { - const auto adhoc_ctx = - (admire::adhoc_storage::ctx*) adhoc_storage.context().get(); + + if(adhoc_storage.type() == admire::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()); + std::to_string(adhoc_ctx.resources().nodes().size()); /* Walltime */ - const std::string walltime = std::to_string(adhoc_ctx->walltime()); + const std::string walltime = std::to_string(adhoc_ctx.walltime()); /* Launch script */ switch(const auto pid = fork()) { -- GitLab