From 97c7c5cd3a2a2be8e3635bd05dc63fe0abe7f059 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 23 Jun 2022 19:42:52 +0200 Subject: [PATCH 1/7] Add C examples --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 21 ++-------- examples/c/ADM_register_job.c | 31 ++++++++++++++ examples/c/CMakeLists.txt | 32 ++++++++++++++ examples/{ => cxx}/ADM_cancel_transfer.cpp | 0 .../{ => cxx}/ADM_connect_data_operation.cpp | 0 .../{ => cxx}/ADM_define_data_operation.cpp | 0 .../{ => cxx}/ADM_deploy_adhoc_storage.cpp | 0 .../{ => cxx}/ADM_finalize_data_operation.cpp | 0 .../{ => cxx}/ADM_get_pending_transfers.cpp | 0 .../{ => cxx}/ADM_get_qos_constraints.cpp | 0 examples/{ => cxx}/ADM_get_statistics.cpp | 0 .../{ => cxx}/ADM_get_transfer_priority.cpp | 0 examples/{ => cxx}/ADM_in_situ_ops.cpp | 0 examples/{ => cxx}/ADM_in_transit_ops.cpp | 0 .../ADM_link_transfer_to_data_operation.cpp | 0 .../{ => cxx}/ADM_register_adhoc_storage.cpp | 0 examples/{ => cxx}/ADM_register_job.cpp | 0 .../{ => cxx}/ADM_remove_adhoc_storage.cpp | 4 +- examples/{ => cxx}/ADM_remove_job.cpp | 0 .../{ => cxx}/ADM_set_dataset_information.cpp | 0 examples/{ => cxx}/ADM_set_io_resources.cpp | 0 .../{ => cxx}/ADM_set_qos_constraints.cpp | 0 .../{ => cxx}/ADM_set_transfer_priority.cpp | 0 examples/{ => cxx}/ADM_transfer_dataset.cpp | 0 .../{ => cxx}/ADM_update_adhoc_storage.cpp | 12 +++--- examples/{ => cxx}/ADM_update_job.cpp | 0 examples/cxx/CMakeLists.txt | 42 +++++++++++++++++++ examples/{ => cxx}/ping.cpp | 0 29 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 examples/c/ADM_register_job.c create mode 100644 examples/c/CMakeLists.txt rename examples/{ => cxx}/ADM_cancel_transfer.cpp (100%) rename examples/{ => cxx}/ADM_connect_data_operation.cpp (100%) rename examples/{ => cxx}/ADM_define_data_operation.cpp (100%) rename examples/{ => cxx}/ADM_deploy_adhoc_storage.cpp (100%) rename examples/{ => cxx}/ADM_finalize_data_operation.cpp (100%) rename examples/{ => cxx}/ADM_get_pending_transfers.cpp (100%) rename examples/{ => cxx}/ADM_get_qos_constraints.cpp (100%) rename examples/{ => cxx}/ADM_get_statistics.cpp (100%) rename examples/{ => cxx}/ADM_get_transfer_priority.cpp (100%) rename examples/{ => cxx}/ADM_in_situ_ops.cpp (100%) rename examples/{ => cxx}/ADM_in_transit_ops.cpp (100%) rename examples/{ => cxx}/ADM_link_transfer_to_data_operation.cpp (100%) rename examples/{ => cxx}/ADM_register_adhoc_storage.cpp (100%) rename examples/{ => cxx}/ADM_register_job.cpp (100%) rename examples/{ => cxx}/ADM_remove_adhoc_storage.cpp (95%) rename examples/{ => cxx}/ADM_remove_job.cpp (100%) rename examples/{ => cxx}/ADM_set_dataset_information.cpp (100%) rename examples/{ => cxx}/ADM_set_io_resources.cpp (100%) rename examples/{ => cxx}/ADM_set_qos_constraints.cpp (100%) rename examples/{ => cxx}/ADM_set_transfer_priority.cpp (100%) rename examples/{ => cxx}/ADM_transfer_dataset.cpp (100%) rename examples/{ => cxx}/ADM_update_adhoc_storage.cpp (74%) rename examples/{ => cxx}/ADM_update_job.cpp (100%) create mode 100644 examples/cxx/CMakeLists.txt rename examples/{ => cxx}/ping.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3199c66c..53101b97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ cmake_minimum_required(VERSION 3.14) project( scord VERSION 0.1.0 - LANGUAGES CXX + LANGUAGES C CXX ) # Set default build type and also populate a list of available options diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e7620f25..91d8ee9b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright 2021, Barcelona Supercomputing Center (BSC), Spain # +# Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain # # # # This software was partially supported by the EuroHPC-funded project ADMIRE # # (Project ID: 956748, https://www.admire-eurohpc.eu). # @@ -22,20 +22,5 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -list(APPEND examples - ping - ADM_register_job ADM_update_job ADM_remove_job - ADM_register_adhoc_storage ADM_update_adhoc_storage - ADM_remove_adhoc_storage ADM_deploy_adhoc_storage - ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset - ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority - ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers - ADM_set_qos_constraints ADM_get_qos_constraints ADM_define_data_operation ADM_connect_data_operation - ADM_finalize_data_operation ADM_link_transfer_to_data_operation ADM_get_statistics) - -foreach (example IN LISTS examples) - add_executable(${example}) - target_sources(${example} PRIVATE ${example}.cpp) - target_link_libraries(${example} - PUBLIC network_engine fmt::fmt adm_iosched) -endforeach() +add_subdirectory(c) +add_subdirectory(cxx) diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c new file mode 100644 index 00000000..55b71e86 --- /dev/null +++ b/examples/c/ADM_register_job.c @@ -0,0 +1,31 @@ +#include +#include +#include + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fprintf(stderr, "ERROR: no location provided\n"); + fprintf(stderr, "Usage: ADM_register_job \n"); + exit(EXIT_FAILURE); + } + +#if 0 + ADM_server_t* server = ADM_server_create("tcp", argv[1]); + + ADM_job_handle_t job = ADM_job_handle_init(); + ADM_job_requirements_t reqs = ADM_job_requirements_init(); + ADM_dataset_info_t info = ADM_dataset_info_init(); + ADM_return_t ret = ADM_register_job(server, reqs, &job); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, "ADM_register_job() remote procedure not completed " + "successfully\n"); + exit(EXIT_FAILURE); + } +#endif + + fprintf(stdout, "ADM_register_job() remote procedure completed " + "successfully\n"); +} diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt new file mode 100644 index 00000000..ff36f94a --- /dev/null +++ b/examples/c/CMakeLists.txt @@ -0,0 +1,32 @@ +################################################################################ +# Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain # +# # +# This software was partially supported by the EuroHPC-funded project ADMIRE # +# (Project ID: 956748, https://www.admire-eurohpc.eu). # +# # +# This file is part of scord. # +# # +# scord is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# scord is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with scord. If not, see . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +list(APPEND examples_c ADM_register_job) + +foreach(example IN LISTS examples_c) + add_executable(${example}_c) + target_sources(${example}_c PRIVATE ${example}.c) + target_link_libraries(${example}_c PUBLIC adm_iosched) + set_target_properties(${example}_c PROPERTIES OUTPUT_NAME ${example}) +endforeach() diff --git a/examples/ADM_cancel_transfer.cpp b/examples/cxx/ADM_cancel_transfer.cpp similarity index 100% rename from examples/ADM_cancel_transfer.cpp rename to examples/cxx/ADM_cancel_transfer.cpp diff --git a/examples/ADM_connect_data_operation.cpp b/examples/cxx/ADM_connect_data_operation.cpp similarity index 100% rename from examples/ADM_connect_data_operation.cpp rename to examples/cxx/ADM_connect_data_operation.cpp diff --git a/examples/ADM_define_data_operation.cpp b/examples/cxx/ADM_define_data_operation.cpp similarity index 100% rename from examples/ADM_define_data_operation.cpp rename to examples/cxx/ADM_define_data_operation.cpp diff --git a/examples/ADM_deploy_adhoc_storage.cpp b/examples/cxx/ADM_deploy_adhoc_storage.cpp similarity index 100% rename from examples/ADM_deploy_adhoc_storage.cpp rename to examples/cxx/ADM_deploy_adhoc_storage.cpp diff --git a/examples/ADM_finalize_data_operation.cpp b/examples/cxx/ADM_finalize_data_operation.cpp similarity index 100% rename from examples/ADM_finalize_data_operation.cpp rename to examples/cxx/ADM_finalize_data_operation.cpp diff --git a/examples/ADM_get_pending_transfers.cpp b/examples/cxx/ADM_get_pending_transfers.cpp similarity index 100% rename from examples/ADM_get_pending_transfers.cpp rename to examples/cxx/ADM_get_pending_transfers.cpp diff --git a/examples/ADM_get_qos_constraints.cpp b/examples/cxx/ADM_get_qos_constraints.cpp similarity index 100% rename from examples/ADM_get_qos_constraints.cpp rename to examples/cxx/ADM_get_qos_constraints.cpp diff --git a/examples/ADM_get_statistics.cpp b/examples/cxx/ADM_get_statistics.cpp similarity index 100% rename from examples/ADM_get_statistics.cpp rename to examples/cxx/ADM_get_statistics.cpp diff --git a/examples/ADM_get_transfer_priority.cpp b/examples/cxx/ADM_get_transfer_priority.cpp similarity index 100% rename from examples/ADM_get_transfer_priority.cpp rename to examples/cxx/ADM_get_transfer_priority.cpp diff --git a/examples/ADM_in_situ_ops.cpp b/examples/cxx/ADM_in_situ_ops.cpp similarity index 100% rename from examples/ADM_in_situ_ops.cpp rename to examples/cxx/ADM_in_situ_ops.cpp diff --git a/examples/ADM_in_transit_ops.cpp b/examples/cxx/ADM_in_transit_ops.cpp similarity index 100% rename from examples/ADM_in_transit_ops.cpp rename to examples/cxx/ADM_in_transit_ops.cpp diff --git a/examples/ADM_link_transfer_to_data_operation.cpp b/examples/cxx/ADM_link_transfer_to_data_operation.cpp similarity index 100% rename from examples/ADM_link_transfer_to_data_operation.cpp rename to examples/cxx/ADM_link_transfer_to_data_operation.cpp diff --git a/examples/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp similarity index 100% rename from examples/ADM_register_adhoc_storage.cpp rename to examples/cxx/ADM_register_adhoc_storage.cpp diff --git a/examples/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp similarity index 100% rename from examples/ADM_register_job.cpp rename to examples/cxx/ADM_register_job.cpp diff --git a/examples/ADM_remove_adhoc_storage.cpp b/examples/cxx/ADM_remove_adhoc_storage.cpp similarity index 95% rename from examples/ADM_remove_adhoc_storage.cpp rename to examples/cxx/ADM_remove_adhoc_storage.cpp index 9cfd194d..ce5e7da8 100644 --- a/examples/ADM_remove_adhoc_storage.cpp +++ b/examples/cxx/ADM_remove_adhoc_storage.cpp @@ -1,5 +1,5 @@ -#include -#include +#include "fmt/format.h" +#include "admire.hpp" int diff --git a/examples/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp similarity index 100% rename from examples/ADM_remove_job.cpp rename to examples/cxx/ADM_remove_job.cpp diff --git a/examples/ADM_set_dataset_information.cpp b/examples/cxx/ADM_set_dataset_information.cpp similarity index 100% rename from examples/ADM_set_dataset_information.cpp rename to examples/cxx/ADM_set_dataset_information.cpp diff --git a/examples/ADM_set_io_resources.cpp b/examples/cxx/ADM_set_io_resources.cpp similarity index 100% rename from examples/ADM_set_io_resources.cpp rename to examples/cxx/ADM_set_io_resources.cpp diff --git a/examples/ADM_set_qos_constraints.cpp b/examples/cxx/ADM_set_qos_constraints.cpp similarity index 100% rename from examples/ADM_set_qos_constraints.cpp rename to examples/cxx/ADM_set_qos_constraints.cpp diff --git a/examples/ADM_set_transfer_priority.cpp b/examples/cxx/ADM_set_transfer_priority.cpp similarity index 100% rename from examples/ADM_set_transfer_priority.cpp rename to examples/cxx/ADM_set_transfer_priority.cpp diff --git a/examples/ADM_transfer_dataset.cpp b/examples/cxx/ADM_transfer_dataset.cpp similarity index 100% rename from examples/ADM_transfer_dataset.cpp rename to examples/cxx/ADM_transfer_dataset.cpp diff --git a/examples/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp similarity index 74% rename from examples/ADM_update_adhoc_storage.cpp rename to examples/cxx/ADM_update_adhoc_storage.cpp index fc435527..385fe002 100644 --- a/examples/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -28,14 +28,12 @@ main(int argc, char* argv[]) { } if(ret != ADM_SUCCESS) { - fmt::print( - stdout, - "ADM_update_adhoc_storage() remote procedure not completed " - "successfully\n"); + fmt::print(stdout, + "ADM_update_adhoc_storage() remote procedure not completed " + "successfully\n"); exit(EXIT_FAILURE); } - fmt::print(stdout, - "ADM_update_adhoc_storage() remote procedure completed " - "successfully\n"); + fmt::print(stdout, "ADM_update_adhoc_storage() remote procedure completed " + "successfully\n"); } diff --git a/examples/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp similarity index 100% rename from examples/ADM_update_job.cpp rename to examples/cxx/ADM_update_job.cpp diff --git a/examples/cxx/CMakeLists.txt b/examples/cxx/CMakeLists.txt new file mode 100644 index 00000000..a884f425 --- /dev/null +++ b/examples/cxx/CMakeLists.txt @@ -0,0 +1,42 @@ +################################################################################ +# Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain # +# # +# This software was partially supported by the EuroHPC-funded project ADMIRE # +# (Project ID: 956748, https://www.admire-eurohpc.eu). # +# # +# This file is part of scord. # +# # +# scord is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# scord is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with scord. If not, see . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +list(APPEND examples_cxx + ping + ADM_register_job ADM_update_job ADM_remove_job + ADM_register_adhoc_storage ADM_update_adhoc_storage + ADM_remove_adhoc_storage ADM_deploy_adhoc_storage + ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset + ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority + ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers + ADM_set_qos_constraints ADM_get_qos_constraints ADM_define_data_operation ADM_connect_data_operation + ADM_finalize_data_operation ADM_link_transfer_to_data_operation ADM_get_statistics) + +foreach (example IN LISTS examples_cxx) + add_executable(${example}_cxx) + target_sources(${example}_cxx PRIVATE ${example}.cpp) + target_link_libraries(${example}_cxx + PUBLIC network_engine fmt::fmt adm_iosched) + set_target_properties(${example}_cxx PROPERTIES OUTPUT_NAME ${example}) +endforeach() diff --git a/examples/ping.cpp b/examples/cxx/ping.cpp similarity index 100% rename from examples/ping.cpp rename to examples/cxx/ping.cpp -- GitLab From 84992b52cd4f9d78734d62a4cce05d203d17668f Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 23 Jun 2022 19:44:03 +0200 Subject: [PATCH 2/7] Fix extraneous C++ definitions in C API header --- src/api/admire.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/admire.h b/src/api/admire.h index 73c9e190..178296a5 100644 --- a/src/api/admire.h +++ b/src/api/admire.h @@ -26,6 +26,7 @@ #define SCORD_ADMIRE_H #include +#include #ifdef __cplusplus extern "C" { @@ -41,17 +42,17 @@ extern "C" { */ /* Error return codes */ -enum ADM_return_t { +typedef enum { ADM_SUCCESS = 0, // FIXME: generic error only for now ADM_OTHER_ERROR -}; +} ADM_return_t; /* A server */ typedef struct adm_server ADM_server_t; /* A node */ -typedef const char* ADM_node_t; +typedef char* ADM_node_t; /* A dataset handle */ @@ -61,21 +62,21 @@ typedef struct adm_dataset* ADM_dataset_handle_t; typedef struct adm_job* ADM_job_handle_t; /* The scope affected by a QoS limit */ -enum ADM_qos_scope_t { +typedef enum { ADM_QOS_SCOPE_DATASET, ADM_QOS_SCOPE_NODE, ADM_QOS_SCOPE_JOB -}; +} ADM_qos_scope_t; /** The class of QoS limit applied to a scope */ -enum ADM_qos_class_t { ADM_QOS_CLASS_BANDWIDTH, ADM_QOS_CLASS_IOPS }; +typedef enum { ADM_QOS_CLASS_BANDWIDTH, ADM_QOS_CLASS_IOPS } ADM_qos_class_t; /** An ADMIRE entity upon which QoS can be defined */ -union ADM_qos_entity_t { +typedef union { ADM_node_t l_node; ADM_job_handle_t l_job; ADM_dataset_handle_t l_dataset; -}; +} ADM_qos_entity_t; /** A QoS limit */ typedef struct { -- GitLab From 77bfe429e4a911a3d8ea03d1e2f1efbebf7580b4 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 23 Jun 2022 20:18:44 +0200 Subject: [PATCH 3/7] Add ADM_server_[create|destroy]() --- examples/c/ADM_register_job.c | 14 +++++-- src/api/admire.h | 26 ++++++++++++- src/api/c_wrapper.cpp | 73 +++++++++++++++++++++++++---------- 3 files changed, 86 insertions(+), 27 deletions(-) diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 55b71e86..e533b728 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -11,10 +11,11 @@ main(int argc, char* argv[]) { exit(EXIT_FAILURE); } -#if 0 - ADM_server_t* server = ADM_server_create("tcp", argv[1]); + int exit_status = EXIT_SUCCESS; + ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_handle_t job = ADM_job_handle_init(); + ADM_job_handle_t job; +#if 0 ADM_job_requirements_t reqs = ADM_job_requirements_init(); ADM_dataset_info_t info = ADM_dataset_info_init(); ADM_return_t ret = ADM_register_job(server, reqs, &job); @@ -22,10 +23,15 @@ main(int argc, char* argv[]) { if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " "successfully\n"); - exit(EXIT_FAILURE); + exit_status = EXIT_FAILURE; + goto cleanup; } #endif fprintf(stdout, "ADM_register_job() remote procedure completed " "successfully\n"); + +cleanup: + ADM_server_destroy(server); + exit(exit_status); } diff --git a/src/api/admire.h b/src/api/admire.h index 178296a5..ffb3e4f4 100644 --- a/src/api/admire.h +++ b/src/api/admire.h @@ -44,12 +44,34 @@ extern "C" { /* Error return codes */ typedef enum { ADM_SUCCESS = 0, - // FIXME: generic error only for now + ADM_EINVAL, + // generic error code ADM_OTHER_ERROR } ADM_return_t; /* A server */ -typedef struct adm_server ADM_server_t; +typedef struct adm_server* ADM_server_t; + +/** + * Initialize a server from a user-provided name/address. + * + * @remark Servers need to be freed by calling ADM_server_destroy(). + * + * @param[in] protocol The protocol that will be used to access the server. + * @param[in] address The address of server. + * @return A valid ADM_server_t if successful or NULL in case of failure. + */ +ADM_server_t +ADM_server_create(const char* protocol, const char* address); + +/** + * Destroy a server created by ADM_server_create(). + * + * @param[in] server A pointer to a ADM_server_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_server_destroy(ADM_server_t server); /* A node */ typedef char* ADM_node_t; diff --git a/src/api/c_wrapper.cpp b/src/api/c_wrapper.cpp index 9c454795..6d036ff5 100644 --- a/src/api/c_wrapper.cpp +++ b/src/api/c_wrapper.cpp @@ -24,17 +24,48 @@ #include #include +#include struct adm_server { const char* s_protocol; const char* s_address; }; +ADM_server_t +ADM_server_create(const char* protocol, const char* address) { + + struct adm_server* adm_server = + (struct adm_server*) malloc(sizeof(struct adm_server)); + + if(!adm_server) { + LOGGER_ERROR("Could not allocate ADM_server_t") + return NULL; + } + + adm_server->s_protocol = protocol; + adm_server->s_address = address; + + return adm_server; +} + +ADM_return_t +ADM_server_destroy(ADM_server_t server) { + ADM_return_t ret = ADM_SUCCESS; + + if(!server) { + LOGGER_ERROR("Invalid ADM_server_t") + return ADM_EINVAL; + } + + free(server); + return ret; +} + ADM_return_t ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, ADM_job_handle_t* job) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::register_job(srv, reqs, job); } @@ -43,7 +74,7 @@ ADM_return_t ADM_update_job(ADM_server_t server, ADM_job_handle_t job, ADM_job_requirements_t reqs) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::update_job(srv, job, reqs); } @@ -51,7 +82,7 @@ ADM_update_job(ADM_server_t server, ADM_job_handle_t job, ADM_return_t ADM_remove_job(ADM_server_t server, ADM_job_handle_t job) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::remove_job(srv, job); } @@ -61,7 +92,7 @@ ADM_register_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t* adhoc_handle) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::register_adhoc_storage(srv, job, ctx, adhoc_handle); } @@ -71,7 +102,7 @@ ADM_update_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t adhoc_handle) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::update_adhoc_storage(srv, job, ctx, adhoc_handle); } @@ -80,7 +111,7 @@ ADM_return_t ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, ADM_adhoc_storage_handle_t adhoc_handle) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::remove_adhoc_storage(srv, job, adhoc_handle); } @@ -89,7 +120,7 @@ ADM_return_t ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, ADM_adhoc_storage_handle_t adhoc_handle) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::deploy_adhoc_storage(srv, job, adhoc_handle); } @@ -101,7 +132,7 @@ ADM_transfer_dataset(ADM_server_t server, ADM_job_handle_t job, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::transfer_dataset(srv, job, sources, targets, limits, mapping, tx_handle); @@ -112,7 +143,7 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_handle_t job, ADM_dataset_handle_t target, ADM_dataset_info_t info) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::set_dataset_information(srv, job, target, info); } @@ -122,7 +153,7 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_handle_t job, ADM_storage_handle_t tier, ADM_storage_resources_t resources) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::set_io_resources(srv, job, tier, resources); } @@ -132,7 +163,7 @@ ADM_get_transfer_priority(ADM_server_t server, ADM_job_handle_t job, ADM_transfer_handle_t tx_handle, ADM_transfer_priority_t* priority) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::get_transfer_priority(srv, job, tx_handle, priority); } @@ -141,7 +172,7 @@ ADM_return_t ADM_set_transfer_priority(ADM_server_t server, ADM_job_handle_t job, ADM_transfer_handle_t tx_handle, int incr) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::set_transfer_priority(srv, job, tx_handle, incr); } @@ -150,7 +181,7 @@ ADM_return_t ADM_cancel_transfer(ADM_server_t server, ADM_job_handle_t job, ADM_transfer_handle_t tx_handle) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::cancel_transfer(srv, job, tx_handle); } @@ -159,7 +190,7 @@ ADM_return_t ADM_get_pending_transfers(ADM_server_t server, ADM_job_handle_t job, ADM_transfer_handle_t** pending_transfers) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::get_pending_transfers(srv, job, pending_transfers); } @@ -168,7 +199,7 @@ ADM_return_t ADM_set_qos_constraints(ADM_server_t server, ADM_job_handle_t job, ADM_limit_t limit) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::set_qos_constraints(srv, job, limit); } @@ -178,7 +209,7 @@ ADM_get_qos_constraints(ADM_server_t server, ADM_job_handle_t job, ADM_qos_scope_t scope, ADM_qos_entity_t entity, ADM_limit_t** limits) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::get_qos_constraints(srv, job, scope, entity, limits); } @@ -188,7 +219,7 @@ ADM_define_data_operation(ADM_server_t server, ADM_job_handle_t job, const char* path, ADM_data_operation_handle_t* op, ...) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; va_list args; va_start(args, op); @@ -204,7 +235,7 @@ ADM_connect_data_operation(ADM_server_t server, ADM_job_handle_t job, ADM_dataset_handle_t output, bool should_stream, ...) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; va_list args; va_start(args, should_stream); @@ -220,7 +251,7 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_handle_t job, ADM_data_operation_handle_t op, ADM_data_operation_status_t* status) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::finalize_data_operation(srv, job, op, status); } @@ -230,7 +261,7 @@ ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_handle_t job, ADM_data_operation_handle_t op, bool should_stream, ...) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; va_list args; va_start(args, should_stream); @@ -244,6 +275,6 @@ ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_handle_t job, ADM_return_t ADM_get_statistics(ADM_server_t server, ADM_job_handle_t job, ADM_job_stats_t** stats) { - const admire::server srv{server.s_protocol, server.s_address}; + const admire::server srv{server->s_protocol, server->s_address}; return admire::get_statistics(srv, job, stats); } -- GitLab From 697dd0841d403da0edb8f1c3860c4493c998ed9b Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Sat, 25 Jun 2022 19:41:41 +0200 Subject: [PATCH 4/7] Refactor ADM_register_job() implementation --- CMakeLists.txt | 15 ++++++++ examples/cxx/ADM_register_job.cpp | 21 +++++------ src/api/CMakeLists.txt | 8 ++--- src/api/admire.cpp | 31 +++++------------ src/api/admire.h | 5 ++- src/api/admire.hpp | 13 +++++-- src/api/c_wrapper.cpp | 47 +++++++++++++++++++++++-- src/api/detail/impl.cpp | 58 +++++++++++++++++++++++++++++++ src/api/detail/impl.hpp | 42 ++++++++++++++++++++++ 9 files changed, 193 insertions(+), 47 deletions(-) create mode 100644 src/api/detail/impl.cpp create mode 100644 src/api/detail/impl.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 53101b97..21909d93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,6 +209,21 @@ FetchContent_Declare( FetchContent_MakeAvailable(genopts) +### expected: required for using tl::expected in the C++ library implementation +### until std::expected makes it to C++ + +message(STATUS "[${PROJECT_NAME}] Downloading and building tl::expected") +set(EXPECTED_BUILD_PACKAGE OFF) +set(EXPECTED_BUILD_TESTS OFF) +FetchContent_Declare( + expected + GIT_REPOSITORY https://github.com/TartanLlama/expected + GIT_TAG 96d547c03d2feab8db64c53c3744a9b4a7c8f2c5 # latest + GIT_SHALLOW ON + GIT_PROGRESS ON +) + +FetchContent_MakeAvailable(expected) ### Mark any CMake variables imported from {fmt} and spdlog as advanced, so ### that they don't appear in cmake-gui or ccmake. Similarly for FETCHCONTENT diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index 56672509..5001058b 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -13,24 +13,19 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; ADM_job_requirements_t reqs{}; - ADM_dataset_info_t info{}; - ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::register_job(server, reqs, &job); - } catch(const std::exception& e) { - fmt::print(stderr, "FATAL: ADM_register_job() failed: {}\n", e.what()); - exit(EXIT_FAILURE); - } - if(ret != ADM_SUCCESS) { - fmt::print(stdout, "ADM_register_job() remote procedure not completed " + [[maybe_unused]] const auto job = admire::register_job(server, reqs); + + // do something with job + + fmt::print(stdout, "ADM_register_job() remote procedure completed " "successfully\n"); + exit(EXIT_SUCCESS); + } catch(const std::exception& e) { + fmt::print(stderr, "FATAL: ADM_register_job() failed: {}\n", e.what()); exit(EXIT_FAILURE); } - - fmt::print(stdout, "ADM_register_job() remote procedure completed " - "successfully\n"); } diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index ae30d58f..77cb0bd8 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -22,15 +22,15 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_library(adm_iosched SHARED c_wrapper.cpp admire.hpp) +add_library(adm_iosched SHARED) target_sources(adm_iosched - PUBLIC admire.h - PRIVATE admire.cpp) + PUBLIC admire.h admire.hpp + PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp) target_include_directories(adm_iosched PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(adm_iosched PRIVATE network_engine) +target_link_libraries(adm_iosched PRIVATE network_engine PUBLIC tl::expected) install( TARGETS adm_iosched diff --git a/src/api/admire.cpp b/src/api/admire.cpp index c9ab9e7b..14ad6331 100644 --- a/src/api/admire.cpp +++ b/src/api/admire.cpp @@ -25,6 +25,7 @@ #include #include #include +#include "detail/impl.hpp" namespace { @@ -47,37 +48,23 @@ init_logger() { scord::logger::create_global_logger("libadm_iosched", "console color"); } + } // namespace namespace admire { -ADM_return_t -register_job(const server& srv, ADM_job_requirements_t reqs, - ADM_job_handle_t* job) { - (void) srv; - (void) reqs; - (void) job; +admire::job +register_job(const server& srv, ADM_job_requirements_t reqs) { - scord::network::rpc_client rpc_client{srv.m_protocol}; - rpc_client.register_rpcs(); + const auto rv = detail::register_job(srv, reqs); - auto endp = rpc_client.lookup(srv.m_address); - - LOGGER_INFO("ADM_register_job(...)"); - - ADM_register_job_in_t in{}; - ADM_register_job_out_t out; - - endp.call("ADM_register_job", &in, &out); - - if(out.ret < 0) { - LOGGER_ERROR("ADM_register_job() = {}", out.ret); - return static_cast(out.ret); + if(!rv) { + /* TODO ADM_strerror(rv.error()) */ + throw std::runtime_error("ADM_register_job() error"); } - LOGGER_INFO("ADM_register_job() = {}", ADM_SUCCESS); - return ADM_SUCCESS; + return rv.value(); } ADM_return_t diff --git a/src/api/admire.h b/src/api/admire.h index ffb3e4f4..93b2cc87 100644 --- a/src/api/admire.h +++ b/src/api/admire.h @@ -203,14 +203,13 @@ typedef struct { * * @param[in] server The server to which the request is directed * @param[in] reqs The requirements for the job. - * @param[out] job An ADHOC_HANDLE referring to the newly-created - * adhoc storage instance. + * @param[out] job_handle A JOB_HANDLE referring to the newly-registered job. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, - ADM_job_handle_t* job); + ADM_job_handle_t* job_handle); ADM_return_t ADM_update_job(ADM_server_t server, ADM_job_handle_t job, diff --git a/src/api/admire.hpp b/src/api/admire.hpp index e340c1e6..73ac3780 100644 --- a/src/api/admire.hpp +++ b/src/api/admire.hpp @@ -23,6 +23,7 @@ *****************************************************************************/ #include +#include #include #include @@ -31,14 +32,20 @@ namespace admire { +using job_id = int64_t; + struct server { std::string m_protocol; std::string m_address; }; -ADM_return_t -register_job(const server& srv, ADM_job_requirements_t reqs, - ADM_job_handle_t* job); +struct job { + job_id m_id; +}; + + +admire::job +register_job(const server& srv, ADM_job_requirements_t reqs); ADM_return_t update_job(const server& srv, ADM_job_handle_t job, diff --git a/src/api/c_wrapper.cpp b/src/api/c_wrapper.cpp index 6d036ff5..29fc0439 100644 --- a/src/api/c_wrapper.cpp +++ b/src/api/c_wrapper.cpp @@ -25,12 +25,17 @@ #include #include #include +#include "detail/impl.hpp" struct adm_server { const char* s_protocol; const char* s_address; }; +struct adm_job { + uint64_t j_id; +}; + ADM_server_t ADM_server_create(const char* protocol, const char* address) { @@ -61,13 +66,51 @@ ADM_server_destroy(ADM_server_t server) { return ret; } +/** + * Initialize a job handle that can be used by clients to refer to a job. + * + * @remark This function is not actually part of the public API, but it is + * useful to have for internal purposes + * + * @param [in] id The identifier for this job + * @return A valid job_handle or NULL in case of failure. + */ +static ADM_job_handle_t +ADM_job_handle_create(uint64_t id) { + + struct adm_job* adm_job = (struct adm_job*) malloc(sizeof(struct adm_job)); + + if(!adm_job) { + LOGGER_ERROR("Could not allocate ADM_job_handle_t") + return NULL; + } + + adm_job->j_id = id; + + return adm_job; +} + ADM_return_t ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, - ADM_job_handle_t* job) { + ADM_job_handle_t* job_handle) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::register_job(srv, reqs, job); + const auto rv = admire::detail::register_job(srv, reqs); + + if(!rv) { + return rv.error(); + } + + const auto jh = ADM_job_handle_create(rv->m_id); + + if(!jh) { + return ADM_OTHER_ERROR; + } + + *job_handle = jh; + + return ADM_SUCCESS; } ADM_return_t diff --git a/src/api/detail/impl.cpp b/src/api/detail/impl.cpp new file mode 100644 index 00000000..962444de --- /dev/null +++ b/src/api/detail/impl.cpp @@ -0,0 +1,58 @@ +/****************************************************************************** + * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain + * + * This software was partially supported by the EuroHPC-funded project ADMIRE + * (Project ID: 956748, https://www.admire-eurohpc.eu). + * + * This file is part of scord. + * + * scord is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * scord is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with scord. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include +#include "impl.hpp" + +namespace admire::detail { + +tl::expected +register_job(const admire::server& srv, ADM_job_requirements_t reqs) { + (void) srv; + (void) reqs; + + scord::network::rpc_client rpc_client{srv.m_protocol}; + rpc_client.register_rpcs(); + + auto endp = rpc_client.lookup(srv.m_address); + + LOGGER_INFO("ADM_register_job(...)"); + + ADM_register_job_in_t in{}; + ADM_register_job_out_t out; + + endp.call("ADM_register_job", &in, &out); + + if(out.ret < 0) { + LOGGER_ERROR("ADM_register_job() = {}", out.ret); + /* TODO ADM_strerror(out.ret) */ + throw std::runtime_error("ADM_register_job() error"); + } + + LOGGER_INFO("ADM_register_job() = {}", ADM_SUCCESS); + return admire::job{42}; +} + +} // namespace admire::detail diff --git a/src/api/detail/impl.hpp b/src/api/detail/impl.hpp new file mode 100644 index 00000000..501489c3 --- /dev/null +++ b/src/api/detail/impl.hpp @@ -0,0 +1,42 @@ +/****************************************************************************** + * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain + * + * This software was partially supported by the EuroHPC-funded project ADMIRE + * (Project ID: 956748, https://www.admire-eurohpc.eu). + * + * This file is part of scord. + * + * scord is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * scord is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with scord. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + + +#ifndef SCORD_ADMIRE_IMPL_HPP +#define SCORD_ADMIRE_IMPL_HPP + +#include + +namespace admire { +using error_code = ADM_return_t; +} // namespace admire + +namespace admire::detail { + +tl::expected +register_job(const server& srv, ADM_job_requirements_t reqs); + +} // namespace admire::detail + +#endif // SCORD_ADMIRE_IMPL_HPP -- GitLab From 0fa44316b9e3e9be59509630ebb9d824b6aa49c6 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 27 Jun 2022 09:48:18 +0200 Subject: [PATCH 5/7] Rename ADM_job_handle_t to ADM_job_t --- examples/c/ADM_register_job.c | 2 +- examples/cxx/ADM_cancel_transfer.cpp | 2 +- examples/cxx/ADM_connect_data_operation.cpp | 2 +- examples/cxx/ADM_define_data_operation.cpp | 2 +- examples/cxx/ADM_deploy_adhoc_storage.cpp | 2 +- examples/cxx/ADM_finalize_data_operation.cpp | 2 +- examples/cxx/ADM_get_pending_transfers.cpp | 2 +- examples/cxx/ADM_get_qos_constraints.cpp | 2 +- examples/cxx/ADM_get_statistics.cpp | 2 +- examples/cxx/ADM_get_transfer_priority.cpp | 2 +- .../ADM_link_transfer_to_data_operation.cpp | 2 +- examples/cxx/ADM_register_adhoc_storage.cpp | 2 +- examples/cxx/ADM_remove_adhoc_storage.cpp | 2 +- examples/cxx/ADM_remove_job.cpp | 2 +- examples/cxx/ADM_set_dataset_information.cpp | 2 +- examples/cxx/ADM_set_io_resources.cpp | 2 +- examples/cxx/ADM_set_qos_constraints.cpp | 2 +- examples/cxx/ADM_set_transfer_priority.cpp | 2 +- examples/cxx/ADM_transfer_dataset.cpp | 2 +- examples/cxx/ADM_update_adhoc_storage.cpp | 2 +- examples/cxx/ADM_update_job.cpp | 2 +- src/api/admire.cpp | 40 ++++---- src/api/admire.h | 97 +++++++++---------- src/api/admire.hpp | 40 ++++---- src/api/c_wrapper.cpp | 58 ++++++----- 25 files changed, 137 insertions(+), 140 deletions(-) diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index e533b728..7eb9d71f 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_handle_t job; + ADM_job_t job; #if 0 ADM_job_requirements_t reqs = ADM_job_requirements_init(); ADM_dataset_info_t info = ADM_dataset_info_init(); diff --git a/examples/cxx/ADM_cancel_transfer.cpp b/examples/cxx/ADM_cancel_transfer.cpp index 3a0137fd..04c9eacb 100644 --- a/examples/cxx/ADM_cancel_transfer.cpp +++ b/examples/cxx/ADM_cancel_transfer.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_transfer_handle_t tx_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_connect_data_operation.cpp b/examples/cxx/ADM_connect_data_operation.cpp index a8cf7b12..98e046f0 100644 --- a/examples/cxx/ADM_connect_data_operation.cpp +++ b/examples/cxx/ADM_connect_data_operation.cpp @@ -26,7 +26,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_dataset_handle_t input{}; ADM_dataset_handle_t output{}; bool should_stream = false; diff --git a/examples/cxx/ADM_define_data_operation.cpp b/examples/cxx/ADM_define_data_operation.cpp index 571a19f7..36c90205 100644 --- a/examples/cxx/ADM_define_data_operation.cpp +++ b/examples/cxx/ADM_define_data_operation.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; const char* path = ""; ADM_data_operation_handle_t op_handle; va_list args; // FIXME: placeholder diff --git a/examples/cxx/ADM_deploy_adhoc_storage.cpp b/examples/cxx/ADM_deploy_adhoc_storage.cpp index 0bf4fd9c..207ebaa2 100644 --- a/examples/cxx/ADM_deploy_adhoc_storage.cpp +++ b/examples/cxx/ADM_deploy_adhoc_storage.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_adhoc_storage_handle_t adhoc_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_finalize_data_operation.cpp b/examples/cxx/ADM_finalize_data_operation.cpp index 8227ac34..e396577b 100644 --- a/examples/cxx/ADM_finalize_data_operation.cpp +++ b/examples/cxx/ADM_finalize_data_operation.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_data_operation_handle_t op_handle{}; ADM_data_operation_status_t status; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_get_pending_transfers.cpp b/examples/cxx/ADM_get_pending_transfers.cpp index 1729e7b4..75e64d7d 100644 --- a/examples/cxx/ADM_get_pending_transfers.cpp +++ b/examples/cxx/ADM_get_pending_transfers.cpp @@ -13,7 +13,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_transfer_handle_t** tx_handles = nullptr; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_get_qos_constraints.cpp b/examples/cxx/ADM_get_qos_constraints.cpp index 3b52fd69..b0bf6156 100644 --- a/examples/cxx/ADM_get_qos_constraints.cpp +++ b/examples/cxx/ADM_get_qos_constraints.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_qos_scope_t scope{}; ADM_qos_entity_t entity{}; ADM_limit_t* limits; diff --git a/examples/cxx/ADM_get_statistics.cpp b/examples/cxx/ADM_get_statistics.cpp index c9e03dc3..eccb9f89 100644 --- a/examples/cxx/ADM_get_statistics.cpp +++ b/examples/cxx/ADM_get_statistics.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_job_stats_t* stats = nullptr; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_get_transfer_priority.cpp b/examples/cxx/ADM_get_transfer_priority.cpp index a8ef68a2..3637e658 100644 --- a/examples/cxx/ADM_get_transfer_priority.cpp +++ b/examples/cxx/ADM_get_transfer_priority.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_transfer_handle_t tx_handle{}; ADM_transfer_priority_t priority; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_link_transfer_to_data_operation.cpp b/examples/cxx/ADM_link_transfer_to_data_operation.cpp index db1a4f09..df0e7268 100644 --- a/examples/cxx/ADM_link_transfer_to_data_operation.cpp +++ b/examples/cxx/ADM_link_transfer_to_data_operation.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_data_operation_handle_t op_handle; bool should_stream = false; va_list args; diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index 60dd044a..e7971aa1 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_adhoc_context_t ctx{}; ADM_adhoc_storage_handle_t adhoc_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_remove_adhoc_storage.cpp b/examples/cxx/ADM_remove_adhoc_storage.cpp index ce5e7da8..bee61143 100644 --- a/examples/cxx/ADM_remove_adhoc_storage.cpp +++ b/examples/cxx/ADM_remove_adhoc_storage.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_adhoc_storage_handle_t adhoc_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp index f489c2c1..fc037a10 100644 --- a/examples/cxx/ADM_remove_job.cpp +++ b/examples/cxx/ADM_remove_job.cpp @@ -13,7 +13,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_set_dataset_information.cpp b/examples/cxx/ADM_set_dataset_information.cpp index 0ac0e2e7..57f19c9c 100644 --- a/examples/cxx/ADM_set_dataset_information.cpp +++ b/examples/cxx/ADM_set_dataset_information.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_dataset_handle_t target{}; ADM_dataset_info_t info{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_set_io_resources.cpp b/examples/cxx/ADM_set_io_resources.cpp index d2a3be64..b7c8e050 100644 --- a/examples/cxx/ADM_set_io_resources.cpp +++ b/examples/cxx/ADM_set_io_resources.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_storage_handle_t tier{}; ADM_storage_resources_t resources{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_set_qos_constraints.cpp b/examples/cxx/ADM_set_qos_constraints.cpp index ed2b0e05..6662602e 100644 --- a/examples/cxx/ADM_set_qos_constraints.cpp +++ b/examples/cxx/ADM_set_qos_constraints.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_limit_t limit{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_set_transfer_priority.cpp b/examples/cxx/ADM_set_transfer_priority.cpp index b00e7283..3a280f25 100644 --- a/examples/cxx/ADM_set_transfer_priority.cpp +++ b/examples/cxx/ADM_set_transfer_priority.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_transfer_handle_t tx_handle{}; int incr = 42; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_transfer_dataset.cpp b/examples/cxx/ADM_transfer_dataset.cpp index 96312a7e..986d7ad4 100644 --- a/examples/cxx/ADM_transfer_dataset.cpp +++ b/examples/cxx/ADM_transfer_dataset.cpp @@ -16,7 +16,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_dataset_handle_t** sources = nullptr; ADM_dataset_handle_t** targets = nullptr; ADM_limit_t** limits = nullptr; diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index 385fe002..46219a17 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_adhoc_context_t ctx{}; ADM_adhoc_storage_handle_t adhoc_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index ab82690f..8d1cfcb5 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -13,7 +13,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - ADM_job_handle_t job{}; + ADM_job_t job{}; ADM_job_requirements_t reqs{}; ADM_dataset_info_t info{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/src/api/admire.cpp b/src/api/admire.cpp index 14ad6331..b3586426 100644 --- a/src/api/admire.cpp +++ b/src/api/admire.cpp @@ -68,7 +68,7 @@ register_job(const server& srv, ADM_job_requirements_t reqs) { } ADM_return_t -update_job(const server& srv, ADM_job_handle_t job, +update_job(const server& srv, ADM_job_t job, ADM_job_requirements_t reqs) { (void) srv; (void) job; @@ -96,7 +96,7 @@ update_job(const server& srv, ADM_job_handle_t job, } ADM_return_t -remove_job(const server& srv, ADM_job_handle_t job) { +remove_job(const server& srv, ADM_job_t job) { (void) srv; (void) job; @@ -122,7 +122,7 @@ remove_job(const server& srv, ADM_job_handle_t job) { } ADM_return_t -register_adhoc_storage(const server& srv, ADM_job_handle_t job, +register_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t* adhoc_handle) { (void) srv; @@ -152,7 +152,7 @@ register_adhoc_storage(const server& srv, ADM_job_handle_t job, } ADM_return_t -update_adhoc_storage(const server& srv, ADM_job_handle_t job, +update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t adhoc_handle) { (void) srv; @@ -182,7 +182,7 @@ update_adhoc_storage(const server& srv, ADM_job_handle_t job, } ADM_return_t -remove_adhoc_storage(const server& srv, ADM_job_handle_t job, +remove_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle) { (void) srv; (void) job; @@ -210,7 +210,7 @@ remove_adhoc_storage(const server& srv, ADM_job_handle_t job, } ADM_return_t -deploy_adhoc_storage(const server& srv, ADM_job_handle_t job, +deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle) { (void) srv; (void) job; @@ -238,7 +238,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_handle_t job, } ADM_return_t -transfer_dataset(const server& srv, ADM_job_handle_t job, +transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_handle_t** sources, ADM_dataset_handle_t** targets, ADM_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { @@ -272,7 +272,7 @@ transfer_dataset(const server& srv, ADM_job_handle_t job, } ADM_return_t -set_dataset_information(const server& srv, ADM_job_handle_t job, +set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_handle_t target, ADM_dataset_info_t info) { (void) srv; (void) job; @@ -301,7 +301,7 @@ set_dataset_information(const server& srv, ADM_job_handle_t job, } ADM_return_t -set_io_resources(const server& srv, ADM_job_handle_t job, +set_io_resources(const server& srv, ADM_job_t job, ADM_storage_handle_t tier, ADM_storage_resources_t resources) { (void) srv; (void) job; @@ -330,7 +330,7 @@ set_io_resources(const server& srv, ADM_job_handle_t job, } ADM_return_t -get_transfer_priority(const server& srv, ADM_job_handle_t job, +get_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_handle_t tx_handle, ADM_transfer_priority_t* priority) { (void) srv; @@ -360,7 +360,7 @@ get_transfer_priority(const server& srv, ADM_job_handle_t job, } ADM_return_t -set_transfer_priority(const server& srv, ADM_job_handle_t job, +set_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_handle_t tx_handle, int incr) { (void) srv; (void) job; @@ -389,7 +389,7 @@ set_transfer_priority(const server& srv, ADM_job_handle_t job, } ADM_return_t -cancel_transfer(const server& srv, ADM_job_handle_t job, +cancel_transfer(const server& srv, ADM_job_t job, ADM_transfer_handle_t tx_handle) { (void) job; @@ -418,7 +418,7 @@ cancel_transfer(const server& srv, ADM_job_handle_t job, } ADM_return_t -get_pending_transfers(const server& srv, ADM_job_handle_t job, +get_pending_transfers(const server& srv, ADM_job_t job, ADM_transfer_handle_t** pending_transfers) { (void) srv; (void) job; @@ -447,7 +447,7 @@ get_pending_transfers(const server& srv, ADM_job_handle_t job, } ADM_return_t -set_qos_constraints(const server& srv, ADM_job_handle_t job, +set_qos_constraints(const server& srv, ADM_job_t job, ADM_limit_t limit) { (void) srv; (void) job; @@ -477,7 +477,7 @@ set_qos_constraints(const server& srv, ADM_job_handle_t job, } ADM_return_t -get_qos_constraints(const server& srv, ADM_job_handle_t job, +get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_scope_t scope, ADM_qos_entity_t entity, ADM_limit_t** limits) { (void) srv; @@ -510,7 +510,7 @@ get_qos_constraints(const server& srv, ADM_job_handle_t job, } ADM_return_t -define_data_operation(const server& srv, ADM_job_handle_t job, const char* path, +define_data_operation(const server& srv, ADM_job_t job, const char* path, ADM_data_operation_handle_t* op, va_list args) { (void) srv; (void) job; @@ -542,7 +542,7 @@ define_data_operation(const server& srv, ADM_job_handle_t job, const char* path, } ADM_return_t -connect_data_operation(const server& srv, ADM_job_handle_t job, +connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_handle_t input, ADM_dataset_handle_t output, bool should_stream, va_list args) { (void) srv; @@ -576,7 +576,7 @@ connect_data_operation(const server& srv, ADM_job_handle_t job, } ADM_return_t -finalize_data_operation(const server& srv, ADM_job_handle_t job, +finalize_data_operation(const server& srv, ADM_job_t job, ADM_data_operation_handle_t op, ADM_data_operation_status_t* status) { (void) srv; @@ -608,7 +608,7 @@ finalize_data_operation(const server& srv, ADM_job_handle_t job, } ADM_return_t -link_transfer_to_data_operation(const server& srv, ADM_job_handle_t job, +link_transfer_to_data_operation(const server& srv, ADM_job_t job, ADM_data_operation_handle_t op, bool should_stream, va_list args) { (void) srv; @@ -641,7 +641,7 @@ link_transfer_to_data_operation(const server& srv, ADM_job_handle_t job, } ADM_return_t -get_statistics(const server& srv, ADM_job_handle_t job, +get_statistics(const server& srv, ADM_job_t job, ADM_job_stats_t** stats) { (void) srv; (void) job; diff --git a/src/api/admire.h b/src/api/admire.h index 93b2cc87..b6b4c754 100644 --- a/src/api/admire.h +++ b/src/api/admire.h @@ -81,7 +81,7 @@ typedef char* ADM_node_t; typedef struct adm_dataset* ADM_dataset_handle_t; /* A job handle */ -typedef struct adm_job* ADM_job_handle_t; +typedef struct adm_job* ADM_job_t; /* The scope affected by a QoS limit */ typedef enum { @@ -96,7 +96,7 @@ typedef enum { ADM_QOS_CLASS_BANDWIDTH, ADM_QOS_CLASS_IOPS } ADM_qos_class_t; /** An ADMIRE entity upon which QoS can be defined */ typedef union { ADM_node_t l_node; - ADM_job_handle_t l_job; + ADM_job_t l_job; ADM_dataset_handle_t l_dataset; } ADM_qos_entity_t; @@ -201,28 +201,30 @@ typedef struct { /** * Register a job and its requirements. * + * @remark The returned ADM_JOB will be freed when passed to + * ADM_remove_job(). + * * @param[in] server The server to which the request is directed * @param[in] reqs The requirements for the job. - * @param[out] job_handle A JOB_HANDLE referring to the newly-registered job. + * @param[out] job An ADM_JOB referring to the newly-registered job. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, - ADM_job_handle_t* job_handle); + ADM_job_t* job); ADM_return_t -ADM_update_job(ADM_server_t server, ADM_job_handle_t job, - ADM_job_requirements_t reqs); +ADM_update_job(ADM_server_t server, ADM_job_t job, ADM_job_requirements_t reqs); ADM_return_t -ADM_remove_job(ADM_server_t server, ADM_job_handle_t job); +ADM_remove_job(ADM_server_t server, ADM_job_t job); /** * Register an adhoc storage system. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] ctx The EXECUTION_CONTEXT for the adhoc storage system. * @param[out] adhoc_handle An ADHOC_HANDLE referring to the newly-created * adhoc storage instance. @@ -230,7 +232,7 @@ ADM_remove_job(ADM_server_t server, ADM_job_handle_t job); * successfully. */ ADM_return_t -ADM_register_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_register_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t* adhoc_handle); @@ -238,7 +240,7 @@ ADM_register_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, * Update an already-registered adhoc storage system. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] ctx The updated EXECUTION_CONTEXT for the adhoc storage system. * @param[in] adhoc_handle An ADHOC_HANDLE referring to the adhoc storage * instance of interest. @@ -246,7 +248,7 @@ ADM_register_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, * successfully. */ ADM_return_t -ADM_update_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_update_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t adhoc_handle); @@ -254,27 +256,27 @@ ADM_update_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, * Remove an already-registered adhoc storage system. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] adhoc_handle An ADHOC_HANDLE referring to the adhoc storage * instance of interest. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t -ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle); /** * Initiate the deployment of an adhoc storage system instance. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] adhoc_handle An ADHOC_HANDLE referring to the adhoc storage * instance of interest. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle); /** @@ -284,7 +286,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, * operation (i.e., get statistics, or status). * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] sources A list of DATASETs identifying the source dataset/s * to be transferred. * @param[in] targets A list of DATASETs identifying the destination @@ -301,7 +303,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, * successfully or not. */ ADM_return_t -ADM_transfer_dataset(ADM_server_t server, ADM_job_handle_t job, +ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_handle_t** sources, ADM_dataset_handle_t** targets, ADM_limit_t** limits, ADM_tx_mapping_t mapping, @@ -312,7 +314,7 @@ ADM_transfer_dataset(ADM_server_t server, ADM_job_handle_t job, * Sets information for the dataset identified by resource_id. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] target A DATASET_HANDLE referring to the dataset of interest. * @param[in] info A DATASET_INFO with information about the * dataset (e.g. its lifespan, access methods, intended usage, etc.). @@ -320,7 +322,7 @@ ADM_transfer_dataset(ADM_server_t server, ADM_job_handle_t job, * successfully. */ ADM_return_t -ADM_set_dataset_information(ADM_server_t server, ADM_job_handle_t job, +ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, ADM_dataset_handle_t target, ADM_dataset_info_t info); @@ -329,7 +331,7 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_handle_t job, * System. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] tier A STORAGE_HANDLE referring to the target storage tier. * @param[in] resources A RESOURCES argument containing information * about the I/O resources to set (e.g. number of I/O nodes.). @@ -337,7 +339,7 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_handle_t job, * successfully. */ ADM_return_t -ADM_set_io_resources(ADM_server_t server, ADM_job_handle_t job, +ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_storage_handle_t tier, ADM_storage_resources_t resources); @@ -346,7 +348,7 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_handle_t job, * Returns the priority of the pending transfer identified by transfer_id. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] tx_handle A TRANSFER_HANDLE referring to a pending transfer * @param[out] priority The priority of the pending transfer or an error code if * it didn’t exist or is no longer pending. @@ -354,7 +356,7 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_handle_t job, * successfully. */ ADM_return_t -ADM_get_transfer_priority(ADM_server_t server, ADM_job_handle_t job, +ADM_get_transfer_priority(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t tx_handle, ADM_transfer_priority_t* priority); @@ -364,14 +366,14 @@ ADM_get_transfer_priority(ADM_server_t server, ADM_job_handle_t job, * its scheduling queue. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] tx_handle A TRANSFER_HANDLE referring to a pending transfer * @param[in] incr A positive or negative number for the number of * positions the transfer should go up or down in its scheduling queue. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_set_transfer_priority(ADM_server_t server, ADM_job_handle_t job, +ADM_set_transfer_priority(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t tx_handle, int incr); @@ -379,12 +381,12 @@ ADM_set_transfer_priority(ADM_server_t server, ADM_job_handle_t job, * Cancels the pending transfer identified by transfer_id. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] tx_handle A TRANSFER_HANDLE referring to a pending transfer. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_cancel_transfer(ADM_server_t server, ADM_job_handle_t job, +ADM_cancel_transfer(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t tx_handle); @@ -392,12 +394,12 @@ ADM_cancel_transfer(ADM_server_t server, ADM_job_handle_t job, * Returns a list of pending transfers. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[out] pending_transfers A list of pending_transfers. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_get_pending_transfers(ADM_server_t server, ADM_job_handle_t job, +ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t** pending_transfers); @@ -406,7 +408,7 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_handle_t job, * identified by id. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] limit A QOS_LIMIT specifying at least: * - The QOS_SCOPE the limit should be applied to: e.g. * dataset, node, or job. @@ -417,24 +419,23 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_handle_t job, * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_set_qos_constraints(ADM_server_t server, ADM_job_handle_t job, - ADM_limit_t limit); +ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_limit_t limit); /** * Returns a list of QoS constraints defined for an element identified for id. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] scope The scope being queried: dataset, node, or job. * @param[in] entity An QOS_ENTITY referring to the target of the query, i.e. a - * RESOURCE_HANDLE, a NODE hostname, or a JOB_HANDLE. + * RESOURCE_HANDLE, a NODE hostname, or a ADM_JOB. * @param[in] limits A list of QOS_LIMITS that includes all the classes * currently defined for the element as well as the values set for them. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_get_qos_constraints(ADM_server_t server, ADM_job_handle_t job, +ADM_get_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_qos_scope_t scope, ADM_qos_entity_t entity, ADM_limit_t** limits); @@ -445,16 +446,15 @@ ADM_get_qos_constraints(ADM_server_t server, ADM_job_handle_t job, * defined, using the next format "arg0, arg1, arg2, ... ". * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] path A valid path for the operation executable. * @param[in] ... A list of ARGUMENTS for the operation. * @param[out] op An OPERATION_HANDLE for the newly-defined operation. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_define_data_operation(ADM_server_t server, ADM_job_handle_t job, - const char* path, ADM_data_operation_handle_t* op, - ...); +ADM_define_data_operation(ADM_server_t server, ADM_job_t job, const char* path, + ADM_data_operation_handle_t* op, ...); /** @@ -465,7 +465,7 @@ ADM_define_data_operation(ADM_server_t server, ADM_job_handle_t job, * set to true. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] op The OPERATION_HANDLE of the operation to be connected. * @param[in] input An input DATASET_HANDLE for the operation. * @param[in] output An output DATASET_HANDLE where the result of @@ -476,7 +476,7 @@ ADM_define_data_operation(ADM_server_t server, ADM_job_handle_t job, * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_connect_data_operation(ADM_server_t server, ADM_job_handle_t job, +ADM_connect_data_operation(ADM_server_t server, ADM_job_t job, ADM_dataset_handle_t input, ADM_dataset_handle_t output, bool should_stream, ...); @@ -486,14 +486,14 @@ ADM_connect_data_operation(ADM_server_t server, ADM_job_handle_t job, * Finalises the operation defined with operation_id. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] op The OPERATION_HANDLE of the operation to be connected. * @return[out] status An OPERATION_STATUS type indicating whether the * operation was successful. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_finalize_data_operation(ADM_server_t server, ADM_job_handle_t job, +ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, ADM_data_operation_handle_t op, ADM_data_operation_status_t* status); @@ -506,18 +506,18 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_handle_t job, * to true. * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] op The OPERATION_HANDLE of the operation to be connected. * @param[in] tx_handle The TRANSFER_HANDLE referring to the pending transfer * the operation should be linked to. - * @param[in] job A JOB_HANDLE identifying the originating job. + * @param[in] job An ADM_JOB identifying the originating job. * @param[in] should_stream A boolean indicating whether the operation * should be executed in a streaming fashion. * @param[in] ... The VALUES for the arguments required by the operation. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_handle_t job, +ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_t job, ADM_data_operation_handle_t op, bool should_stream, ...); @@ -528,14 +528,13 @@ ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_handle_t job, * easy-to-process format, e.g., JSON (see Listing 3.1). * * @param[in] server The server to which the request is directed - * @param[in] job A JOB_HANDLE identifying the originating job and, + * @param[in] job An ADM_JOB identifying the originating job and, * optionally, its JOB_STEP. * @return[out] stats A list of JOB_STATS. * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t -ADM_get_statistics(ADM_server_t server, ADM_job_handle_t job, - ADM_job_stats_t** stats); +ADM_get_statistics(ADM_server_t server, ADM_job_t job, ADM_job_stats_t** stats); #ifdef __cplusplus } // extern "C" diff --git a/src/api/admire.hpp b/src/api/admire.hpp index 73ac3780..5ab69028 100644 --- a/src/api/admire.hpp +++ b/src/api/admire.hpp @@ -48,90 +48,90 @@ admire::job register_job(const server& srv, ADM_job_requirements_t reqs); ADM_return_t -update_job(const server& srv, ADM_job_handle_t job, +update_job(const server& srv, ADM_job_t job, ADM_job_requirements_t reqs); ADM_return_t -remove_job(const server& srv, ADM_job_handle_t job); +remove_job(const server& srv, ADM_job_t job); ADM_return_t -register_adhoc_storage(const server& srv, ADM_job_handle_t job, +register_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t* adhoc_handle); ADM_return_t -update_adhoc_storage(const server& srv, ADM_job_handle_t job, +update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t adhoc_handle); ADM_return_t -remove_adhoc_storage(const server& srv, ADM_job_handle_t job, +remove_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle); ADM_return_t -deploy_adhoc_storage(const server& srv, ADM_job_handle_t job, +deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle); ADM_return_t -transfer_dataset(const server& srv, ADM_job_handle_t job, +transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_handle_t** sources, ADM_dataset_handle_t** targets, ADM_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle); ADM_return_t -set_dataset_information(const server& srv, ADM_job_handle_t job, +set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_handle_t target, ADM_dataset_info_t info); ADM_return_t -set_io_resources(const server& srv, ADM_job_handle_t job, +set_io_resources(const server& srv, ADM_job_t job, ADM_storage_handle_t tier, ADM_storage_resources_t resources); ADM_return_t -get_transfer_priority(const server& srv, ADM_job_handle_t job, +get_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_handle_t tx_handle, ADM_transfer_priority_t* priority); ADM_return_t -set_transfer_priority(const server& srv, ADM_job_handle_t job, +set_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_handle_t tx_handle, int incr); ADM_return_t -cancel_transfer(const server& srv, ADM_job_handle_t job, +cancel_transfer(const server& srv, ADM_job_t job, ADM_transfer_handle_t tx_handle); ADM_return_t -get_pending_transfers(const server& srv, ADM_job_handle_t job, +get_pending_transfers(const server& srv, ADM_job_t job, ADM_transfer_handle_t** pending_transfers); ADM_return_t -set_qos_constraints(const server& srv, ADM_job_handle_t job, ADM_limit_t limit); +set_qos_constraints(const server& srv, ADM_job_t job, ADM_limit_t limit); ADM_return_t -get_qos_constraints(const server& srv, ADM_job_handle_t job, +get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_scope_t scope, ADM_qos_entity_t entity, ADM_limit_t** limits); ADM_return_t -define_data_operation(const server& srv, ADM_job_handle_t job, const char* path, +define_data_operation(const server& srv, ADM_job_t job, const char* path, ADM_data_operation_handle_t* op, va_list args); ADM_return_t -connect_data_operation(const server& srv, ADM_job_handle_t job, +connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_handle_t input, ADM_dataset_handle_t output, bool should_stream, va_list args); ADM_return_t -finalize_data_operation(const server& srv, ADM_job_handle_t job, +finalize_data_operation(const server& srv, ADM_job_t job, ADM_data_operation_handle_t op, ADM_data_operation_status_t* status); ADM_return_t -link_transfer_to_data_operation(const server& srv, ADM_job_handle_t job, +link_transfer_to_data_operation(const server& srv, ADM_job_t job, ADM_data_operation_handle_t op, bool should_stream, va_list args); ADM_return_t -get_statistics(const server& srv, ADM_job_handle_t job, +get_statistics(const server& srv, ADM_job_t job, ADM_job_stats_t** stats); } // namespace admire diff --git a/src/api/c_wrapper.cpp b/src/api/c_wrapper.cpp index 29fc0439..12228005 100644 --- a/src/api/c_wrapper.cpp +++ b/src/api/c_wrapper.cpp @@ -73,15 +73,15 @@ ADM_server_destroy(ADM_server_t server) { * useful to have for internal purposes * * @param [in] id The identifier for this job - * @return A valid job_handle or NULL in case of failure. + * @return A valid JOB HANDLE or NULL in case of failure. */ -static ADM_job_handle_t -ADM_job_handle_create(uint64_t id) { +static ADM_job_t +ADM_job_create(uint64_t id) { struct adm_job* adm_job = (struct adm_job*) malloc(sizeof(struct adm_job)); if(!adm_job) { - LOGGER_ERROR("Could not allocate ADM_job_handle_t") + LOGGER_ERROR("Could not allocate ADM_job_t") return NULL; } @@ -92,7 +92,7 @@ ADM_job_handle_create(uint64_t id) { ADM_return_t ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, - ADM_job_handle_t* job_handle) { + ADM_job_t* job) { const admire::server srv{server->s_protocol, server->s_address}; @@ -102,19 +102,19 @@ ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, return rv.error(); } - const auto jh = ADM_job_handle_create(rv->m_id); + const auto jh = ADM_job_create(rv->m_id); if(!jh) { return ADM_OTHER_ERROR; } - *job_handle = jh; + *job = jh; return ADM_SUCCESS; } ADM_return_t -ADM_update_job(ADM_server_t server, ADM_job_handle_t job, +ADM_update_job(ADM_server_t server, ADM_job_t job, ADM_job_requirements_t reqs) { const admire::server srv{server->s_protocol, server->s_address}; @@ -123,7 +123,7 @@ ADM_update_job(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_remove_job(ADM_server_t server, ADM_job_handle_t job) { +ADM_remove_job(ADM_server_t server, ADM_job_t job) { const admire::server srv{server->s_protocol, server->s_address}; @@ -131,7 +131,7 @@ ADM_remove_job(ADM_server_t server, ADM_job_handle_t job) { } ADM_return_t -ADM_register_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_register_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t* adhoc_handle) { @@ -141,7 +141,7 @@ ADM_register_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_update_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_update_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_adhoc_storage_handle_t adhoc_handle) { @@ -151,7 +151,7 @@ ADM_update_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle) { const admire::server srv{server->s_protocol, server->s_address}; @@ -160,7 +160,7 @@ ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, +ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_storage_handle_t adhoc_handle) { const admire::server srv{server->s_protocol, server->s_address}; @@ -169,7 +169,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_transfer_dataset(ADM_server_t server, ADM_job_handle_t job, +ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_handle_t** sources, ADM_dataset_handle_t** targets, ADM_limit_t** limits, ADM_tx_mapping_t mapping, @@ -182,7 +182,7 @@ ADM_transfer_dataset(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_set_dataset_information(ADM_server_t server, ADM_job_handle_t job, +ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, ADM_dataset_handle_t target, ADM_dataset_info_t info) { @@ -192,7 +192,7 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_set_io_resources(ADM_server_t server, ADM_job_handle_t job, +ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_storage_handle_t tier, ADM_storage_resources_t resources) { @@ -202,7 +202,7 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_get_transfer_priority(ADM_server_t server, ADM_job_handle_t job, +ADM_get_transfer_priority(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t tx_handle, ADM_transfer_priority_t* priority) { @@ -212,7 +212,7 @@ ADM_get_transfer_priority(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_set_transfer_priority(ADM_server_t server, ADM_job_handle_t job, +ADM_set_transfer_priority(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t tx_handle, int incr) { const admire::server srv{server->s_protocol, server->s_address}; @@ -221,7 +221,7 @@ ADM_set_transfer_priority(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_cancel_transfer(ADM_server_t server, ADM_job_handle_t job, +ADM_cancel_transfer(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t tx_handle) { const admire::server srv{server->s_protocol, server->s_address}; @@ -230,7 +230,7 @@ ADM_cancel_transfer(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_get_pending_transfers(ADM_server_t server, ADM_job_handle_t job, +ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, ADM_transfer_handle_t** pending_transfers) { const admire::server srv{server->s_protocol, server->s_address}; @@ -239,8 +239,7 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_set_qos_constraints(ADM_server_t server, ADM_job_handle_t job, - ADM_limit_t limit) { +ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_limit_t limit) { const admire::server srv{server->s_protocol, server->s_address}; @@ -248,7 +247,7 @@ ADM_set_qos_constraints(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_get_qos_constraints(ADM_server_t server, ADM_job_handle_t job, +ADM_get_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_qos_scope_t scope, ADM_qos_entity_t entity, ADM_limit_t** limits) { @@ -258,9 +257,8 @@ ADM_get_qos_constraints(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_define_data_operation(ADM_server_t server, ADM_job_handle_t job, - const char* path, ADM_data_operation_handle_t* op, - ...) { +ADM_define_data_operation(ADM_server_t server, ADM_job_t job, const char* path, + ADM_data_operation_handle_t* op, ...) { const admire::server srv{server->s_protocol, server->s_address}; @@ -273,7 +271,7 @@ ADM_define_data_operation(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_connect_data_operation(ADM_server_t server, ADM_job_handle_t job, +ADM_connect_data_operation(ADM_server_t server, ADM_job_t job, ADM_dataset_handle_t input, ADM_dataset_handle_t output, bool should_stream, ...) { @@ -290,7 +288,7 @@ ADM_connect_data_operation(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_finalize_data_operation(ADM_server_t server, ADM_job_handle_t job, +ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, ADM_data_operation_handle_t op, ADM_data_operation_status_t* status) { @@ -300,7 +298,7 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_handle_t job, +ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_t job, ADM_data_operation_handle_t op, bool should_stream, ...) { @@ -316,7 +314,7 @@ ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_handle_t job, } ADM_return_t -ADM_get_statistics(ADM_server_t server, ADM_job_handle_t job, +ADM_get_statistics(ADM_server_t server, ADM_job_t job, ADM_job_stats_t** stats) { const admire::server srv{server->s_protocol, server->s_address}; return admire::get_statistics(srv, job, stats); -- GitLab From ab585f224b1fdc4a151d0c8ba871daae27041a46 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 27 Jun 2022 09:48:48 +0200 Subject: [PATCH 6/7] Add ADM_dataset_[create|destroy]() --- src/api/admire.h | 16 ++++++++++++++++ src/api/c_wrapper.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/api/admire.h b/src/api/admire.h index b6b4c754..84576dee 100644 --- a/src/api/admire.h +++ b/src/api/admire.h @@ -80,6 +80,22 @@ typedef char* ADM_node_t; /* A dataset handle */ typedef struct adm_dataset* ADM_dataset_handle_t; +/** + * Create a dataset from a user-provided id (e.g. a path for POSIX-like file + * systems or key for key-value stores). + * + * @remark Datasets need to be freed by calling ADM_dataset_destroy(). + * + * @param[in] id The id for the dataset. + * @return A valid ADM_dataset_handle_t if successful or NULL in case of + * failure. + */ +ADM_dataset_handle_t +ADM_dataset_create(const char* id); + +ADM_return_t +ADM_dataset_destroy(ADM_dataset_handle_t dataset); + /* A job handle */ typedef struct adm_job* ADM_job_t; diff --git a/src/api/c_wrapper.cpp b/src/api/c_wrapper.cpp index 12228005..c5822a22 100644 --- a/src/api/c_wrapper.cpp +++ b/src/api/c_wrapper.cpp @@ -36,6 +36,10 @@ struct adm_job { uint64_t j_id; }; +struct adm_dataset { + const char* d_id; +}; + ADM_server_t ADM_server_create(const char* protocol, const char* address) { @@ -66,6 +70,35 @@ ADM_server_destroy(ADM_server_t server) { return ret; } +ADM_dataset_handle_t +ADM_dataset_create(const char* id) { + + struct adm_dataset* adm_dataset = + (struct adm_dataset*) malloc(sizeof(struct adm_dataset)); + + if(!adm_dataset) { + LOGGER_ERROR("Could not allocate ADM_dataset_t") + return NULL; + } + + adm_dataset->d_id = id; + + return adm_dataset; +} + +ADM_return_t +ADM_dataset_destroy(ADM_dataset_handle_t dataset) { + ADM_return_t ret = ADM_SUCCESS; + + if(!dataset) { + LOGGER_ERROR("Invalid ADM_dataset_t") + return ADM_EINVAL; + } + + free(dataset); + return ret; +} + /** * Initialize a job handle that can be used by clients to refer to a job. * -- GitLab From 0d3aa87541b2a51dd11f3647ad49e58b3e617a0f Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 27 Jun 2022 13:49:11 +0200 Subject: [PATCH 7/7] Add ADM_job_requirements_[create|destroy]. Also make the implementation of ADM_job_requirements_t private to the library. --- examples/c/ADM_register_job.c | 39 ++++++++++++++++++++++++--- src/api/admire.h | 49 ++++++++++++++++++++++++++-------- src/api/c_wrapper.cpp | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 15 deletions(-) diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 7eb9d71f..d9df64f3 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -2,6 +2,9 @@ #include #include +#define NINPUTS 10 +#define NOUTPUTS 5 + int main(int argc, char* argv[]) { @@ -14,10 +17,30 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); + ADM_job_t job; -#if 0 - ADM_job_requirements_t reqs = ADM_job_requirements_init(); - ADM_dataset_info_t info = ADM_dataset_info_init(); + ADM_dataset_handle_t inputs[NINPUTS]; + + for(int i = 0; i < NINPUTS; ++i) { + const char* pattern = "input-dataset-%d"; + size_t n = snprintf(NULL, 0, pattern, i); + char* id = (char*) malloc(n + 1); + snprintf(id, n, pattern, i); + inputs[i] = ADM_dataset_create(id); + } + + ADM_dataset_handle_t outputs[NOUTPUTS]; + + for(int i = 0; i < NOUTPUTS; ++i) { + const char* pattern = "output-dataset-%d"; + size_t n = snprintf(NULL, 0, pattern, i); + char* id = (char*) malloc(n + 1); + snprintf(id, n, pattern, i); + outputs[i] = ADM_dataset_create(id); + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, NULL); ADM_return_t ret = ADM_register_job(server, reqs, &job); if(ret != ADM_SUCCESS) { @@ -26,12 +49,20 @@ main(int argc, char* argv[]) { exit_status = EXIT_FAILURE; goto cleanup; } -#endif fprintf(stdout, "ADM_register_job() remote procedure completed " "successfully\n"); cleanup: + + for(int i = 0; i < NINPUTS; ++i) { + ADM_dataset_destroy(inputs[i]); + } + + for(int i = 0; i < NOUTPUTS; ++i) { + ADM_dataset_destroy(outputs[i]); + } + ADM_server_destroy(server); exit(exit_status); } diff --git a/src/api/admire.h b/src/api/admire.h index 84576dee..33d19e6a 100644 --- a/src/api/admire.h +++ b/src/api/admire.h @@ -25,6 +25,7 @@ #ifndef SCORD_ADMIRE_H #define SCORD_ADMIRE_H +#include #include #include @@ -37,9 +38,10 @@ extern "C" { #define ADM_IOSCHED_API_VERSION_MINOR 1 #define ADM_IOSCHED_API_VERSION_PATCH 0 -/** - * Public type and struct definitions - */ + +/******************************************************************************/ +/* Public type definitions and type-related functions */ +/******************************************************************************/ /* Error return codes */ typedef enum { @@ -200,14 +202,39 @@ typedef struct { typedef ADM_adhoc_context_t* ADM_adhoc_storage_handle_t; /** The I/O requirements for a job */ -typedef struct { - /** A list of input datasets */ - ADM_dataset_handle_t** r_inputs; - /** A list of output datasets */ - ADM_dataset_handle_t** r_outputs; - /** A definition for a specific adhoc storage instance */ - ADM_adhoc_storage_handle_t r_adhoc_storage; -} ADM_job_requirements_t; +typedef struct adm_job_requirements* ADM_job_requirements_t; + +/** + * Create a JOB_REQUIREMENTS from user-provided information. + * + * @remark JOB_REQUIREMENTS created by this function need to be freed by calling + * ADM_job_requirements_destroy(). + * + * @param[in] inputs An array of DATASET_DESCRIPTORS describing the input + * information required by the job. + * @param[in] inputs_len The number of DATASET_DESCRIPTORS stored in inputs. + * @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] 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 + * failure. + */ +ADM_job_requirements_t +ADM_job_requirements_create(ADM_dataset_handle_t inputs[], size_t inputs_len, + ADM_dataset_handle_t outputs[], size_t outputs_len, + ADM_adhoc_storage_handle_t adhoc_storage); + +/** + * Destroy a ADM_job_requirements_t created by ADM_job_requirements_create(). + * + * @param[in] reqs The ADM_job_requirements_t to destroy. + * @return ADM_SUCCESS or corresponding error code. + */ +ADM_return_t +ADM_job_requirements_destroy(ADM_job_requirements_t reqs); /******************************************************************************/ diff --git a/src/api/c_wrapper.cpp b/src/api/c_wrapper.cpp index c5822a22..2496c43b 100644 --- a/src/api/c_wrapper.cpp +++ b/src/api/c_wrapper.cpp @@ -40,6 +40,20 @@ struct adm_dataset { const char* d_id; }; +/** The I/O requirements for a job */ +struct adm_job_requirements { + /** An array of input datasets */ + ADM_dataset_handle_t* r_inputs; + /** The number of datasets in r_inputs */ + size_t r_num_inputs; + /** A list of output datasets */ + ADM_dataset_handle_t* r_outputs; + /** The number of datasets in r_outputs */ + size_t r_num_outputs; + /** An optional definition for a specific adhoc storage instance */ + ADM_adhoc_storage_handle_t r_adhoc_storage; +}; + ADM_server_t ADM_server_create(const char* protocol, const char* address) { @@ -99,6 +113,42 @@ ADM_dataset_destroy(ADM_dataset_handle_t dataset) { return ret; } +ADM_job_requirements_t +ADM_job_requirements_create(ADM_dataset_handle_t inputs[], size_t inputs_len, + ADM_dataset_handle_t outputs[], size_t outputs_len, + ADM_adhoc_storage_handle_t adhoc_storage) { + + struct adm_job_requirements* adm_job_reqs = + (struct adm_job_requirements*) malloc( + sizeof(struct adm_job_requirements)); + + if(!adm_job_reqs) { + LOGGER_ERROR("Could not allocate ADM_job_requirements_t") + return NULL; + } + + adm_job_reqs->r_inputs = inputs; + adm_job_reqs->r_num_inputs = inputs_len; + adm_job_reqs->r_outputs = outputs; + adm_job_reqs->r_num_outputs = outputs_len; + adm_job_reqs->r_adhoc_storage = adhoc_storage; + + return adm_job_reqs; +} + +ADM_return_t +ADM_job_requirements_destroy(ADM_job_requirements_t reqs) { + ADM_return_t ret = ADM_SUCCESS; + + if(!reqs) { + LOGGER_ERROR("Invalid ADM_job_requirements_t") + return ADM_EINVAL; + } + + free(reqs); + return ret; +} + /** * Initialize a job handle that can be used by clients to refer to a job. * -- GitLab