From 94f7b3122e441c01f2f10f46c554fbca454e28cf Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 10:24:00 +0200 Subject: [PATCH 01/19] Refactor ADM_node_t type --- src/lib/admire.h | 22 +++++++++++++++++++- src/lib/c_wrapper.cpp | 48 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index ea992ed9..fb978bd5 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -78,7 +78,27 @@ ADM_return_t ADM_server_destroy(ADM_server_t server); /* A node */ -typedef char* ADM_node_t; +typedef struct adm_node* ADM_node_t; + +/** + * Initialize a node from a user-provided hostname/address. + * + * @remark Nodes need to be freed by calling ADM_server_destroy(). + * + * @param[in] hostname The hostname of the node. + * @return A valid ADM_server_t if successful or NULL in case of failure. + */ +ADM_node_t +ADM_node_create(const char* hostname); + +/** + * Destroy a node created by ADM_node_create(). + * + * @param[in] node A valid ADM_node_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_node_destroy(ADM_node_t node); /* A dataset handle */ diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 1ffffe06..3d6b464d 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -27,19 +27,28 @@ #include #include "detail/impl.hpp" + +/******************************************************************************/ +/* Type definitions and related functions */ +/******************************************************************************/ + struct adm_server { const char* s_protocol; const char* s_address; }; -struct adm_job { - uint64_t j_id; +struct adm_node { + const char* n_hostname; }; struct adm_dataset { const char* d_id; }; +struct adm_job { + uint64_t j_id; +}; + /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ @@ -84,6 +93,37 @@ ADM_server_destroy(ADM_server_t server) { return ret; } + +ADM_node_t +ADM_node_create(const char* hostname) { + + struct adm_node* adm_node = + (struct adm_node*) malloc(sizeof(struct adm_node)); + + if(!adm_node) { + LOGGER_ERROR("Could not allocate ADM_node_t") + return NULL; + } + + adm_node->n_hostname = hostname; + + return adm_node; +} + +ADM_return_t +ADM_node_destroy(ADM_node_t node) { + ADM_return_t ret = ADM_SUCCESS; + + if(!node) { + LOGGER_ERROR("Invalid ADM_node_t") + return ADM_EBADARGS; + } + + free(node); + return ret; +} + + ADM_dataset_handle_t ADM_dataset_create(const char* id) { @@ -173,6 +213,10 @@ ADM_job_create(uint64_t id) { return adm_job; } + +/******************************************************************************/ +/* C API implementation */ +/******************************************************************************/ ADM_return_t ADM_ping(ADM_server_t server) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From 746cceb8d225896309ef33695146aee7f3688fd5 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 11:02:42 +0200 Subject: [PATCH 02/19] Refactor ADM_qos_entity_t --- src/lib/admire.h | 31 ++++++++++++++++++++---- src/lib/c_wrapper.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index fb978bd5..1ad665cf 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -134,11 +134,32 @@ typedef enum { 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_t l_job; - ADM_dataset_handle_t l_dataset; -} ADM_qos_entity_t; +typedef struct adm_qos_entity* ADM_qos_entity_t; + +/** + * Create a QoS entity given a scope, a node, a dataset, or a job. + * + * @remark QoS entities need to be freed by calling ADM_qos_entity_destroy(). + * + * @param scope The scope of the entity, i.e. ADM_QOS_SCOPE_DATASET, + * ADM_QOS_SCOPE_NODE, or ADM_QOS_SCOPE_JOB. + * @param ... A single argument with data from either a ADM_dataset_t, + * ADM_node_t, or ADM_job_t variable. The argument must correspond properly + * to the scope provided. + * @return A valid ADM_qos_entity_t if successful or NULL in case of failure. + */ +ADM_qos_entity_t +ADM_qos_entity_create(ADM_qos_scope_t scope, ...); + +/** + * Destroy a QoS entity created by ADM_qos_entity_create(). + * + * @param[in] entity A valid ADM_qos_entity_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_qos_entity_destroy(ADM_qos_entity_t entity); + /** A QoS limit */ typedef struct { diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 3d6b464d..dfe05388 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -49,6 +49,15 @@ struct adm_job { uint64_t j_id; }; +struct adm_qos_entity { + ADM_qos_scope_t e_scope; + union { + ADM_node_t e_node; + ADM_job_t e_job; + ADM_dataset_handle_t e_dataset; + }; +}; + /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ @@ -153,6 +162,52 @@ ADM_dataset_destroy(ADM_dataset_handle_t dataset) { return ret; } +ADM_qos_entity_t +ADM_qos_entity_create(ADM_qos_scope_t scope, ...) { + + struct adm_qos_entity* adm_qos_entity = + (struct adm_qos_entity*) malloc(sizeof(struct adm_qos_entity)); + + if(!adm_qos_entity) { + LOGGER_ERROR("Could not allocate ADM_qos_entity_t") + return NULL; + } + + adm_qos_entity->e_scope = scope; + + va_list ap; + va_start(ap, scope); + + switch(scope) { + case ADM_QOS_SCOPE_NODE: + adm_qos_entity->e_node = va_arg(ap, ADM_node_t); + break; + case ADM_QOS_SCOPE_JOB: + adm_qos_entity->e_job = va_arg(ap, ADM_job_t); + break; + case ADM_QOS_SCOPE_DATASET: + adm_qos_entity->e_dataset = va_arg(ap, ADM_dataset_handle_t); + break; + } + va_end(ap); + + return adm_qos_entity; +} + +ADM_return_t +ADM_qos_entity_destroy(ADM_qos_entity_t entity) { + + ADM_return_t ret = ADM_SUCCESS; + + if(!entity) { + LOGGER_ERROR("Invalid ADM_qos_entity_t") + return ADM_EBADARGS; + } + + free(entity); + 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, -- GitLab From 79e61a83cc83af8fc94da15fcef2cd2d8c2d5697 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 11:24:34 +0200 Subject: [PATCH 03/19] Rename ADM_dataset_handle_t to ADM_dataset_t --- examples/c/ADM_register_job.c | 4 +-- examples/cxx/ADM_connect_data_operation.cpp | 4 +-- examples/cxx/ADM_set_dataset_information.cpp | 2 +- examples/cxx/ADM_transfer_dataset.cpp | 4 +-- src/lib/admire.cpp | 16 +++++------ src/lib/admire.h | 25 ++++++++--------- src/lib/admire.hpp | 16 +++++------ src/lib/c_wrapper.cpp | 29 +++++++++----------- 8 files changed, 45 insertions(+), 55 deletions(-) diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index d9df64f3..17bf064f 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -19,7 +19,7 @@ main(int argc, char* argv[]) { ADM_job_t job; - ADM_dataset_handle_t inputs[NINPUTS]; + ADM_dataset_t inputs[NINPUTS]; for(int i = 0; i < NINPUTS; ++i) { const char* pattern = "input-dataset-%d"; @@ -29,7 +29,7 @@ main(int argc, char* argv[]) { inputs[i] = ADM_dataset_create(id); } - ADM_dataset_handle_t outputs[NOUTPUTS]; + ADM_dataset_t outputs[NOUTPUTS]; for(int i = 0; i < NOUTPUTS; ++i) { const char* pattern = "output-dataset-%d"; diff --git a/examples/cxx/ADM_connect_data_operation.cpp b/examples/cxx/ADM_connect_data_operation.cpp index 98e046f0..b16c6c52 100644 --- a/examples/cxx/ADM_connect_data_operation.cpp +++ b/examples/cxx/ADM_connect_data_operation.cpp @@ -27,8 +27,8 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_dataset_handle_t input{}; - ADM_dataset_handle_t output{}; + ADM_dataset_t input{}; + ADM_dataset_t output{}; bool should_stream = false; va_list args; // FIXME placeholder ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_set_dataset_information.cpp b/examples/cxx/ADM_set_dataset_information.cpp index 57f19c9c..eeff1f01 100644 --- a/examples/cxx/ADM_set_dataset_information.cpp +++ b/examples/cxx/ADM_set_dataset_information.cpp @@ -16,7 +16,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_dataset_handle_t target{}; + ADM_dataset_t target{}; ADM_dataset_info_t info{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/examples/cxx/ADM_transfer_dataset.cpp b/examples/cxx/ADM_transfer_dataset.cpp index 986d7ad4..d85ca2eb 100644 --- a/examples/cxx/ADM_transfer_dataset.cpp +++ b/examples/cxx/ADM_transfer_dataset.cpp @@ -17,8 +17,8 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_dataset_handle_t** sources = nullptr; - ADM_dataset_handle_t** targets = nullptr; + ADM_dataset_t** sources = nullptr; + ADM_dataset_t** targets = nullptr; ADM_limit_t** limits = nullptr; ADM_tx_mapping_t mapping = ADM_MAPPING_ONE_TO_ONE; ADM_transfer_handle_t tx_handle{}; diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 5ed6f1fc..da8b7c5b 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -363,10 +363,9 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, } ADM_return_t -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) { +transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, + ADM_dataset_t** targets, ADM_limit_t** limits, + ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { (void) srv; (void) job; (void) sources; @@ -396,8 +395,8 @@ transfer_dataset(const server& srv, ADM_job_t job, } ADM_return_t -set_dataset_information(const server& srv, ADM_job_t job, - ADM_dataset_handle_t target, ADM_dataset_info_t info) { +set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, + ADM_dataset_info_t info) { (void) srv; (void) job; (void) target; @@ -652,9 +651,8 @@ define_data_operation(const server& srv, ADM_job_t job, const char* path, } ADM_return_t -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) { +connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_t input, + ADM_dataset_t output, bool should_stream, va_list args) { (void) srv; (void) job; (void) input; diff --git a/src/lib/admire.h b/src/lib/admire.h index 1ad665cf..66b92f30 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -101,8 +101,8 @@ ADM_return_t ADM_node_destroy(ADM_node_t node); -/* A dataset handle */ -typedef struct adm_dataset* ADM_dataset_handle_t; +/** A dataset */ +typedef struct adm_dataset* ADM_dataset_t; /** * Create a dataset from a user-provided id (e.g. a path for POSIX-like file @@ -114,11 +114,11 @@ typedef struct adm_dataset* ADM_dataset_handle_t; * @return A valid ADM_dataset_handle_t if successful or NULL in case of * failure. */ -ADM_dataset_handle_t +ADM_dataset_t ADM_dataset_create(const char* id); ADM_return_t -ADM_dataset_destroy(ADM_dataset_handle_t dataset); +ADM_dataset_destroy(ADM_dataset_t dataset); /* A job handle */ typedef struct adm_job* ADM_job_t; @@ -266,8 +266,8 @@ typedef struct adm_job_requirements* ADM_job_requirements_t; * 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_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, + ADM_dataset_t outputs[], size_t outputs_len, ADM_adhoc_storage_handle_t adhoc_storage); /** @@ -400,9 +400,8 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, */ ADM_return_t 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, + ADM_dataset_t** sources, ADM_dataset_t** targets, + ADM_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle); @@ -419,8 +418,7 @@ ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, */ ADM_return_t ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, - ADM_dataset_handle_t target, - ADM_dataset_info_t info); + ADM_dataset_t target, ADM_dataset_info_t info); /** * Changes the I/O resources used by a storage tier, typically an Ad hoc Storage @@ -573,9 +571,8 @@ ADM_define_data_operation(ADM_server_t server, ADM_job_t job, const char* path, */ ADM_return_t 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, - ...); + ADM_dataset_t input, ADM_dataset_t output, + bool should_stream, ...); /** diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 1ab5f55e..86a38d0d 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -73,14 +73,13 @@ 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_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); +transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, + ADM_dataset_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_t job, - ADM_dataset_handle_t target, ADM_dataset_info_t info); +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_handle_t tier, @@ -115,9 +114,8 @@ 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_t job, - ADM_dataset_handle_t input, ADM_dataset_handle_t output, - bool should_stream, va_list args); +connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_t input, + ADM_dataset_t output, bool should_stream, va_list args); ADM_return_t finalize_data_operation(const server& srv, ADM_job_t job, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index dfe05388..41812d61 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -54,18 +54,18 @@ struct adm_qos_entity { union { ADM_node_t e_node; ADM_job_t e_job; - ADM_dataset_handle_t e_dataset; + ADM_dataset_t e_dataset; }; }; /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ - ADM_dataset_handle_t* r_inputs; + ADM_dataset_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; + ADM_dataset_t* r_outputs; /** The number of datasets in r_outputs */ size_t r_num_outputs; /** An optional definition for a specific adhoc storage instance */ @@ -133,7 +133,7 @@ ADM_node_destroy(ADM_node_t node) { } -ADM_dataset_handle_t +ADM_dataset_t ADM_dataset_create(const char* id) { struct adm_dataset* adm_dataset = @@ -150,7 +150,7 @@ ADM_dataset_create(const char* id) { } ADM_return_t -ADM_dataset_destroy(ADM_dataset_handle_t dataset) { +ADM_dataset_destroy(ADM_dataset_t dataset) { ADM_return_t ret = ADM_SUCCESS; if(!dataset) { @@ -186,7 +186,7 @@ ADM_qos_entity_create(ADM_qos_scope_t scope, ...) { adm_qos_entity->e_job = va_arg(ap, ADM_job_t); break; case ADM_QOS_SCOPE_DATASET: - adm_qos_entity->e_dataset = va_arg(ap, ADM_dataset_handle_t); + adm_qos_entity->e_dataset = va_arg(ap, ADM_dataset_t); break; } va_end(ap); @@ -209,8 +209,8 @@ ADM_qos_entity_destroy(ADM_qos_entity_t entity) { } 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_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, + ADM_dataset_t outputs[], size_t outputs_len, ADM_adhoc_storage_handle_t adhoc_storage) { struct adm_job_requirements* adm_job_reqs = @@ -358,9 +358,8 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_return_t 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, + ADM_dataset_t** sources, ADM_dataset_t** targets, + ADM_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { const admire::server srv{server->s_protocol, server->s_address}; @@ -371,8 +370,7 @@ ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, - ADM_dataset_handle_t target, - ADM_dataset_info_t info) { + ADM_dataset_t target, ADM_dataset_info_t info) { const admire::server srv{server->s_protocol, server->s_address}; @@ -460,9 +458,8 @@ ADM_define_data_operation(ADM_server_t server, ADM_job_t job, const char* path, ADM_return_t 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, - ...) { + ADM_dataset_t input, ADM_dataset_t output, + bool should_stream, ...) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From 9a2be760ee0f99bbdd7dad8d8c959892c8261a5c Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 11:25:21 +0200 Subject: [PATCH 04/19] Add missing documentation for ADM_dataset_destroy() --- src/lib/admire.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/admire.h b/src/lib/admire.h index 66b92f30..5ee238d0 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -117,6 +117,12 @@ typedef struct adm_dataset* ADM_dataset_t; ADM_dataset_t ADM_dataset_create(const char* id); +/** + * Destroy a dataset created by ADM_dataset_create(). + * + * @param[in] dataset A valid ADM_dataset_t + * @return ADM_SUCCESS or corresponding ADM error code + */ ADM_return_t ADM_dataset_destroy(ADM_dataset_t dataset); -- GitLab From a39c6d2adf17f4aa73929883d51a256bb64429cf Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 11:26:20 +0200 Subject: [PATCH 05/19] Rename ADM_limit_t to ADM_qos_limit_t --- examples/cxx/ADM_get_qos_constraints.cpp | 2 +- examples/cxx/ADM_set_qos_constraints.cpp | 2 +- examples/cxx/ADM_transfer_dataset.cpp | 2 +- src/lib/admire.cpp | 6 +++--- src/lib/admire.h | 9 +++++---- src/lib/admire.hpp | 6 +++--- src/lib/c_wrapper.cpp | 7 ++++--- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/cxx/ADM_get_qos_constraints.cpp b/examples/cxx/ADM_get_qos_constraints.cpp index b0bf6156..91b55b2b 100644 --- a/examples/cxx/ADM_get_qos_constraints.cpp +++ b/examples/cxx/ADM_get_qos_constraints.cpp @@ -18,7 +18,7 @@ main(int argc, char* argv[]) { ADM_job_t job{}; ADM_qos_scope_t scope{}; ADM_qos_entity_t entity{}; - ADM_limit_t* limits; + ADM_qos_limit_t* limits; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_set_qos_constraints.cpp b/examples/cxx/ADM_set_qos_constraints.cpp index 6662602e..f301845d 100644 --- a/examples/cxx/ADM_set_qos_constraints.cpp +++ b/examples/cxx/ADM_set_qos_constraints.cpp @@ -16,7 +16,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_limit_t limit{}; + ADM_qos_limit_t limit{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_transfer_dataset.cpp b/examples/cxx/ADM_transfer_dataset.cpp index d85ca2eb..ad6ad700 100644 --- a/examples/cxx/ADM_transfer_dataset.cpp +++ b/examples/cxx/ADM_transfer_dataset.cpp @@ -19,7 +19,7 @@ main(int argc, char* argv[]) { ADM_job_t job{}; ADM_dataset_t** sources = nullptr; ADM_dataset_t** targets = nullptr; - ADM_limit_t** limits = nullptr; + ADM_qos_limit_t** limits = nullptr; ADM_tx_mapping_t mapping = ADM_MAPPING_ONE_TO_ONE; ADM_transfer_handle_t tx_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index da8b7c5b..2f1a242b 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -364,7 +364,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, - ADM_dataset_t** targets, ADM_limit_t** limits, + ADM_dataset_t** targets, ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { (void) srv; (void) job; @@ -564,7 +564,7 @@ get_pending_transfers(const server& srv, ADM_job_t job, } ADM_return_t -set_qos_constraints(const server& srv, ADM_job_t job, ADM_limit_t limit) { +set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_limit_t limit) { (void) srv; (void) job; (void) limit; @@ -592,7 +592,7 @@ 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_t job, ADM_qos_scope_t scope, - ADM_qos_entity_t entity, ADM_limit_t** limits) { + ADM_qos_entity_t entity, ADM_qos_limit_t** limits) { (void) srv; (void) job; (void) scope; diff --git a/src/lib/admire.h b/src/lib/admire.h index 5ee238d0..7fe06b0b 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -173,7 +173,7 @@ typedef struct { ADM_qos_scope_t l_scope; ADM_qos_class_t l_class; ADM_qos_entity_t l_element; -} ADM_limit_t; +} ADM_qos_limit_t; /** A transfer mapping */ typedef enum { @@ -407,7 +407,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, - ADM_limit_t** limits, ADM_tx_mapping_t mapping, + ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle); @@ -519,7 +519,8 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_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_t job, ADM_limit_t limit); +ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, + ADM_qos_limit_t limit); /** @@ -537,7 +538,7 @@ ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_limit_t limit); ADM_return_t 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); + ADM_qos_limit_t** limits); /** diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 86a38d0d..e329d0e1 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -74,7 +74,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, - ADM_dataset_t** targets, ADM_limit_t** limits, + ADM_dataset_t** targets, ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle); ADM_return_t @@ -103,11 +103,11 @@ 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_t job, ADM_limit_t limit); +set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_limit_t limit); ADM_return_t 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_qos_entity_t entity, ADM_qos_limit_t** limits); ADM_return_t define_data_operation(const server& srv, ADM_job_t job, const char* path, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 41812d61..31084ae9 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -359,7 +359,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, - ADM_limit_t** limits, ADM_tx_mapping_t mapping, + ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { const admire::server srv{server->s_protocol, server->s_address}; @@ -425,7 +425,8 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, } ADM_return_t -ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_limit_t limit) { +ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, + ADM_qos_limit_t limit) { const admire::server srv{server->s_protocol, server->s_address}; @@ -435,7 +436,7 @@ ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_limit_t limit) { ADM_return_t 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) { + ADM_qos_limit_t** limits) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From a458b5a56874d50e5d8e04d0ed33d2bb37149bc7 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 11:59:12 +0200 Subject: [PATCH 06/19] Refactor ADM_qos_limit_t Update ADM_get_qos_constraints() and ADM_set_qos_constraints() to new definition of ADM_qos_limit_t semantics. --- examples/cxx/ADM_get_qos_constraints.cpp | 3 +- examples/cxx/ADM_set_qos_constraints.cpp | 3 +- src/lib/admire.cpp | 9 ++-- src/lib/admire.h | 52 ++++++++++++++++-------- src/lib/admire.hpp | 7 ++-- src/lib/c_wrapper.cpp | 47 ++++++++++++++++++--- 6 files changed, 88 insertions(+), 33 deletions(-) diff --git a/examples/cxx/ADM_get_qos_constraints.cpp b/examples/cxx/ADM_get_qos_constraints.cpp index 91b55b2b..da64bcbf 100644 --- a/examples/cxx/ADM_get_qos_constraints.cpp +++ b/examples/cxx/ADM_get_qos_constraints.cpp @@ -16,13 +16,12 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_qos_scope_t scope{}; ADM_qos_entity_t entity{}; ADM_qos_limit_t* limits; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::get_qos_constraints(server, job, scope, entity, &limits); + ret = admire::get_qos_constraints(server, job, entity, &limits); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_cancel_transfer() failed: {}\n", e.what()); diff --git a/examples/cxx/ADM_set_qos_constraints.cpp b/examples/cxx/ADM_set_qos_constraints.cpp index f301845d..cdd50a89 100644 --- a/examples/cxx/ADM_set_qos_constraints.cpp +++ b/examples/cxx/ADM_set_qos_constraints.cpp @@ -16,11 +16,12 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; + ADM_qos_entity_t entity{}; ADM_qos_limit_t limit{}; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::set_qos_constraints(server, job, limit); + ret = admire::set_qos_constraints(server, job, entity, limit); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_set_qos_constraints() failed: {}\n", e.what()); diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 2f1a242b..0552ca97 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -564,9 +564,11 @@ get_pending_transfers(const server& srv, ADM_job_t job, } ADM_return_t -set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_limit_t limit) { +set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, + ADM_qos_limit_t limit) { (void) srv; (void) job; + (void) entity; (void) limit; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -591,11 +593,10 @@ set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_limit_t limit) { } ADM_return_t -get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_scope_t scope, - ADM_qos_entity_t entity, ADM_qos_limit_t** limits) { +get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, + ADM_qos_limit_t** limits) { (void) srv; (void) job; - (void) scope; (void) entity; (void) limits; diff --git a/src/lib/admire.h b/src/lib/admire.h index 7fe06b0b..4664894c 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -166,14 +166,32 @@ ADM_qos_entity_create(ADM_qos_scope_t scope, ...); ADM_return_t ADM_qos_entity_destroy(ADM_qos_entity_t entity); - /** A QoS limit */ -typedef struct { - // TODO: empty for now - ADM_qos_scope_t l_scope; - ADM_qos_class_t l_class; - ADM_qos_entity_t l_element; -} ADM_qos_limit_t; +typedef struct adm_qos_limit* ADM_qos_limit_t; + +/** + * Create a QoS limit given an entity and a QoS class. + * + * @remark QoS limits need to be freed by calling ADM_qos_limit_destroy(). + * + * @param[in] entity The entity upon which the QoS limit should be enforced. + * @param[in] cls The QoS restriction class to apply. + * @param[in] value The limit's value. + * @return A valid ADM_qos_limit_t if successful or NULL in case of failure. + */ +ADM_qos_limit_t +ADM_qos_limit_create(ADM_qos_entity_t entity, ADM_qos_class_t cls, + uint64_t value); + +/** + * Destroy a QoS limit created by ADM_qos_limit_create(). + * + * @param[in] limit A valid ADM_qos_limit_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_qos_limit_destroy(ADM_qos_limit_t limit); + /** A transfer mapping */ typedef enum { @@ -509,18 +527,18 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, * * @param[in] server The server to which the request is directed * @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. + * @param[in] entity An QOS_ENTITY referring to the target of the query, i.e. a + * ADM_DATASET, a ADM_NODE, or a ADM_JOB. + * @param[in] limit A QOS_LIMIT specifying: * - The QOS_CLASS of the limit (e.g. "bandwidth", "iops", * etc.). - * - The QOS_ENTITY it should be applied to (e.g. job, node, + * - The VALUE it should be applied to (e.g. job, node, * dataset, etc.) * @return Returns ADM_SUCCESS if the remote procedure has completed */ ADM_return_t ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, - ADM_qos_limit_t limit); + ADM_qos_entity_t entity, ADM_qos_limit_t limit); /** @@ -528,17 +546,15 @@ ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, * * @param[in] server The server to which the request is directed * @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 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. + * ADM_DATASET, a ADM_NODE, or a ADM_JOB. + * @param[in] limits A NULL-terminated array 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_t job, - ADM_qos_scope_t scope, ADM_qos_entity_t entity, - ADM_qos_limit_t** limits); + ADM_qos_entity_t entity, ADM_qos_limit_t** limits); /** diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index e329d0e1..94768dc3 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -103,11 +103,12 @@ 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_t job, ADM_qos_limit_t limit); +set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, + ADM_qos_limit_t limit); ADM_return_t -get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_scope_t scope, - ADM_qos_entity_t entity, ADM_qos_limit_t** limits); +get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, + ADM_qos_limit_t** limits); ADM_return_t define_data_operation(const server& srv, ADM_job_t job, const char* path, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 31084ae9..5614f015 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -58,6 +58,12 @@ struct adm_qos_entity { }; }; +struct adm_qos_limit { + ADM_qos_entity_t l_entity; + ADM_qos_class_t l_class; + uint64_t l_value; +}; + /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ @@ -208,6 +214,38 @@ ADM_qos_entity_destroy(ADM_qos_entity_t entity) { return ret; } +ADM_qos_limit_t +ADM_qos_limit_create(ADM_qos_entity_t entity, ADM_qos_class_t cls, + uint64_t value) { + + struct adm_qos_limit* adm_qos_limit = + (struct adm_qos_limit*) malloc(sizeof(struct adm_qos_limit)); + + if(!adm_qos_limit) { + LOGGER_ERROR("Could not allocate ADM_qos_limit_t") + return NULL; + } + + adm_qos_limit->l_entity = entity; + adm_qos_limit->l_class = cls; + adm_qos_limit->l_value = value; + + return adm_qos_limit; +} + +ADM_return_t +ADM_qos_limit_destroy(ADM_qos_limit_t limit) { + ADM_return_t ret = ADM_SUCCESS; + + if(!limit) { + LOGGER_ERROR("Invalid ADM_qos_limit_t") + return ADM_EBADARGS; + } + + free(limit); + return ret; +} + ADM_job_requirements_t ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, ADM_dataset_t outputs[], size_t outputs_len, @@ -426,21 +464,20 @@ ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_set_qos_constraints(ADM_server_t server, ADM_job_t job, - ADM_qos_limit_t limit) { + ADM_qos_entity_t entity, ADM_qos_limit_t limit) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::set_qos_constraints(srv, job, limit); + return admire::set_qos_constraints(srv, job, entity, limit); } ADM_return_t ADM_get_qos_constraints(ADM_server_t server, ADM_job_t job, - ADM_qos_scope_t scope, ADM_qos_entity_t entity, - ADM_qos_limit_t** limits) { + ADM_qos_entity_t entity, ADM_qos_limit_t** limits) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::get_qos_constraints(srv, job, scope, entity, limits); + return admire::get_qos_constraints(srv, job, entity, limits); } ADM_return_t -- GitLab From 69a340faca287ef9560f7dc6d2a8214fb7215760 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 12:29:19 +0200 Subject: [PATCH 07/19] Rename ADM_transfer_handle_t to ADM_transfer_t --- examples/cxx/ADM_cancel_transfer.cpp | 2 +- examples/cxx/ADM_get_pending_transfers.cpp | 2 +- examples/cxx/ADM_get_transfer_priority.cpp | 2 +- examples/cxx/ADM_set_transfer_priority.cpp | 2 +- examples/cxx/ADM_transfer_dataset.cpp | 2 +- src/lib/admire.cpp | 22 +++++++++---------- src/lib/admire.h | 25 +++++++++++----------- src/lib/admire.hpp | 14 ++++++------ src/lib/c_wrapper.cpp | 19 ++++++++-------- 9 files changed, 44 insertions(+), 46 deletions(-) diff --git a/examples/cxx/ADM_cancel_transfer.cpp b/examples/cxx/ADM_cancel_transfer.cpp index 04c9eacb..966b0c11 100644 --- a/examples/cxx/ADM_cancel_transfer.cpp +++ b/examples/cxx/ADM_cancel_transfer.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_transfer_handle_t tx_handle{}; + ADM_transfer_t tx_handle{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_get_pending_transfers.cpp b/examples/cxx/ADM_get_pending_transfers.cpp index 75e64d7d..3a146dad 100644 --- a/examples/cxx/ADM_get_pending_transfers.cpp +++ b/examples/cxx/ADM_get_pending_transfers.cpp @@ -14,7 +14,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_transfer_handle_t** tx_handles = nullptr; + ADM_transfer_t** tx_handles = nullptr; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_get_transfer_priority.cpp b/examples/cxx/ADM_get_transfer_priority.cpp index 3637e658..f52152d1 100644 --- a/examples/cxx/ADM_get_transfer_priority.cpp +++ b/examples/cxx/ADM_get_transfer_priority.cpp @@ -16,7 +16,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_transfer_handle_t tx_handle{}; + ADM_transfer_t tx_handle{}; ADM_transfer_priority_t priority; 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 3a280f25..516a9159 100644 --- a/examples/cxx/ADM_set_transfer_priority.cpp +++ b/examples/cxx/ADM_set_transfer_priority.cpp @@ -16,7 +16,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_transfer_handle_t tx_handle{}; + ADM_transfer_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 ad6ad700..0f086645 100644 --- a/examples/cxx/ADM_transfer_dataset.cpp +++ b/examples/cxx/ADM_transfer_dataset.cpp @@ -21,7 +21,7 @@ main(int argc, char* argv[]) { ADM_dataset_t** targets = nullptr; ADM_qos_limit_t** limits = nullptr; ADM_tx_mapping_t mapping = ADM_MAPPING_ONE_TO_ONE; - ADM_transfer_handle_t tx_handle{}; + ADM_transfer_t tx_handle{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 0552ca97..309cbe27 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -365,14 +365,14 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, - ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle) { + ADM_tx_mapping_t mapping, ADM_transfer_t* transfer) { (void) srv; (void) job; (void) sources; (void) targets; (void) limits; (void) mapping; - (void) tx_handle; + (void) transfer; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -451,12 +451,11 @@ set_io_resources(const server& srv, ADM_job_t job, ADM_storage_handle_t tier, } ADM_return_t -get_transfer_priority(const server& srv, ADM_job_t job, - ADM_transfer_handle_t tx_handle, +get_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_t transfer, ADM_transfer_priority_t* priority) { (void) srv; (void) job; - (void) tx_handle; + (void) transfer; (void) priority; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -480,11 +479,11 @@ get_transfer_priority(const server& srv, ADM_job_t job, } ADM_return_t -set_transfer_priority(const server& srv, ADM_job_t job, - ADM_transfer_handle_t tx_handle, int incr) { +set_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_t transfer, + int incr) { (void) srv; (void) job; - (void) tx_handle; + (void) transfer; (void) incr; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -508,11 +507,10 @@ set_transfer_priority(const server& srv, ADM_job_t job, } ADM_return_t -cancel_transfer(const server& srv, ADM_job_t job, - ADM_transfer_handle_t tx_handle) { +cancel_transfer(const server& srv, ADM_job_t job, ADM_transfer_t transfer) { (void) job; - (void) tx_handle; + (void) transfer; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -537,7 +535,7 @@ cancel_transfer(const server& srv, ADM_job_t job, ADM_return_t get_pending_transfers(const server& srv, ADM_job_t job, - ADM_transfer_handle_t** pending_transfers) { + ADM_transfer_t** pending_transfers) { (void) srv; (void) job; (void) pending_transfers; diff --git a/src/lib/admire.h b/src/lib/admire.h index 4664894c..a7dbaeed 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -203,7 +203,7 @@ typedef enum { /** A handle to a created transfer */ typedef struct { // TODO: empty for now -} ADM_transfer_handle_t; +} ADM_transfer_t; /** Information about a dataset */ typedef struct { @@ -416,7 +416,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, * or resource level. * @param[in] mapping A distribution strategy for the transfers (e.g. * ONE_TO_ONE, ONE_TO_MANY, MANY_TO_MANY) - * @param[out] transfer_handle A TRANSFER_HANDLE allowing clients to interact + * @param[out] transfer A ADM_TRANSFER allowing clients to interact * with the transfer (e.g. wait for its completion, query its status, cancel it, * etc. * @return Returns if the remote procedure has been completed @@ -426,7 +426,7 @@ ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, - ADM_transfer_handle_t* tx_handle); + ADM_transfer_t* transfer); /** @@ -467,7 +467,7 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_t job, * * @param[in] server The server to which the request is directed * @param[in] job An ADM_JOB identifying the originating job. - * @param[in] tx_handle A TRANSFER_HANDLE referring to a pending transfer + * @param[in] transfer A ADM_TRANSFER 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. * @return Returns ADM_SUCCESS if the remote procedure has completed @@ -475,7 +475,7 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_t job, */ ADM_return_t ADM_get_transfer_priority(ADM_server_t server, ADM_job_t job, - ADM_transfer_handle_t tx_handle, + ADM_transfer_t transfer, ADM_transfer_priority_t* priority); @@ -485,14 +485,14 @@ ADM_get_transfer_priority(ADM_server_t server, ADM_job_t job, * * @param[in] server The server to which the request is directed * @param[in] job An ADM_JOB identifying the originating job. - * @param[in] tx_handle A TRANSFER_HANDLE referring to a pending transfer + * @param[in] transfer A ADM_TRANSFER 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_t job, - ADM_transfer_handle_t tx_handle, int incr); + ADM_transfer_t transfer, int incr); /** @@ -500,12 +500,12 @@ ADM_set_transfer_priority(ADM_server_t server, ADM_job_t job, * * @param[in] server The server to which the request is directed * @param[in] job An ADM_JOB identifying the originating job. - * @param[in] tx_handle A TRANSFER_HANDLE referring to a pending transfer. + * @param[in] transfer A ADM_TRANSFER 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_t job, - ADM_transfer_handle_t tx_handle); + ADM_transfer_t transfer); /** @@ -518,7 +518,7 @@ ADM_cancel_transfer(ADM_server_t server, ADM_job_t job, */ ADM_return_t ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, - ADM_transfer_handle_t** pending_transfers); + ADM_transfer_t** pending_transfers); /** @@ -624,7 +624,7 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, * @param[in] server The server to which the request is directed * @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 + * @param[in] transfer The ADM_TRANSFER referring to the pending transfer * the operation should be linked to. * @param[in] job An ADM_JOB identifying the originating job. * @param[in] should_stream A boolean indicating whether the operation @@ -635,7 +635,8 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_t job, ADM_data_operation_handle_t op, - bool should_stream, ...); + ADM_transfer_t transfer, bool should_stream, + ...); /** diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 94768dc3..270bbaa8 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -75,7 +75,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, - ADM_tx_mapping_t mapping, ADM_transfer_handle_t* tx_handle); + ADM_tx_mapping_t mapping, ADM_transfer_t* transfer); ADM_return_t set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, @@ -86,21 +86,19 @@ 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_t job, - ADM_transfer_handle_t tx_handle, +get_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_t transfer, ADM_transfer_priority_t* priority); ADM_return_t -set_transfer_priority(const server& srv, ADM_job_t job, - ADM_transfer_handle_t tx_handle, int incr); +set_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_t transfer, + int incr); ADM_return_t -cancel_transfer(const server& srv, ADM_job_t job, - ADM_transfer_handle_t tx_handle); +cancel_transfer(const server& srv, ADM_job_t job, ADM_transfer_t transfer); ADM_return_t get_pending_transfers(const server& srv, ADM_job_t job, - ADM_transfer_handle_t** pending_transfers); + ADM_transfer_t** pending_transfers); ADM_return_t set_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 5614f015..d01e8985 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -55,6 +55,7 @@ struct adm_qos_entity { ADM_node_t e_node; ADM_job_t e_job; ADM_dataset_t e_dataset; + ADM_transfer_t e_transfer; }; }; @@ -398,12 +399,12 @@ ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, - ADM_transfer_handle_t* tx_handle) { + ADM_transfer_t* transfer) { const admire::server srv{server->s_protocol, server->s_address}; return admire::transfer_dataset(srv, job, sources, targets, limits, mapping, - tx_handle); + transfer); } ADM_return_t @@ -427,35 +428,35 @@ ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_get_transfer_priority(ADM_server_t server, ADM_job_t job, - ADM_transfer_handle_t tx_handle, + ADM_transfer_t transfer, ADM_transfer_priority_t* priority) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::get_transfer_priority(srv, job, tx_handle, priority); + return admire::get_transfer_priority(srv, job, transfer, priority); } ADM_return_t ADM_set_transfer_priority(ADM_server_t server, ADM_job_t job, - ADM_transfer_handle_t tx_handle, int incr) { + ADM_transfer_t transfer, int incr) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::set_transfer_priority(srv, job, tx_handle, incr); + return admire::set_transfer_priority(srv, job, transfer, incr); } ADM_return_t ADM_cancel_transfer(ADM_server_t server, ADM_job_t job, - ADM_transfer_handle_t tx_handle) { + ADM_transfer_t transfer) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::cancel_transfer(srv, job, tx_handle); + return admire::cancel_transfer(srv, job, transfer); } ADM_return_t ADM_get_pending_transfers(ADM_server_t server, ADM_job_t job, - ADM_transfer_handle_t** pending_transfers) { + ADM_transfer_t** pending_transfers) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From 2d2dd42f59f94a196ac9022130f746626ecceb70 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 12:30:15 +0200 Subject: [PATCH 08/19] Rename ADM_tx_mapping_t to ADM_transfer_mapping_t. --- examples/cxx/ADM_transfer_dataset.cpp | 2 +- src/lib/admire.cpp | 2 +- src/lib/admire.h | 4 ++-- src/lib/admire.hpp | 2 +- src/lib/c_wrapper.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/cxx/ADM_transfer_dataset.cpp b/examples/cxx/ADM_transfer_dataset.cpp index 0f086645..0c736284 100644 --- a/examples/cxx/ADM_transfer_dataset.cpp +++ b/examples/cxx/ADM_transfer_dataset.cpp @@ -20,7 +20,7 @@ main(int argc, char* argv[]) { ADM_dataset_t** sources = nullptr; ADM_dataset_t** targets = nullptr; ADM_qos_limit_t** limits = nullptr; - ADM_tx_mapping_t mapping = ADM_MAPPING_ONE_TO_ONE; + ADM_transfer_mapping_t mapping = ADM_MAPPING_ONE_TO_ONE; ADM_transfer_t tx_handle{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 309cbe27..656cae97 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -365,7 +365,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, - ADM_tx_mapping_t mapping, ADM_transfer_t* transfer) { + ADM_transfer_mapping_t mapping, ADM_transfer_t* transfer) { (void) srv; (void) job; (void) sources; diff --git a/src/lib/admire.h b/src/lib/admire.h index a7dbaeed..8fabf87e 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -198,7 +198,7 @@ typedef enum { ADM_MAPPING_ONE_TO_ONE, ADM_MAPPING_ONE_TO_N, ADM_MAPPING_N_TO_N -} ADM_tx_mapping_t; +} ADM_transfer_mapping_t; /** A handle to a created transfer */ typedef struct { @@ -425,7 +425,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, - ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, + ADM_qos_limit_t** limits, ADM_transfer_mapping_t mapping, ADM_transfer_t* transfer); diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 270bbaa8..2592d01e 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -75,7 +75,7 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, - ADM_tx_mapping_t mapping, ADM_transfer_t* transfer); + ADM_transfer_mapping_t mapping, ADM_transfer_t* transfer); ADM_return_t set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index d01e8985..74057fc0 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -398,7 +398,7 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, - ADM_qos_limit_t** limits, ADM_tx_mapping_t mapping, + ADM_qos_limit_t** limits, ADM_transfer_mapping_t mapping, ADM_transfer_t* transfer) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From 9513d9c42382421072bbc4f8e1769b1e562491a1 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 13:12:13 +0200 Subject: [PATCH 09/19] Refactor ADM_transfer_t --- src/lib/admire.h | 4 +--- src/lib/c_wrapper.cpp | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index 8fabf87e..5486fe04 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -201,9 +201,7 @@ typedef enum { } ADM_transfer_mapping_t; /** A handle to a created transfer */ -typedef struct { - // TODO: empty for now -} ADM_transfer_t; +typedef struct adm_transfer* ADM_transfer_t; /** Information about a dataset */ typedef struct { diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 74057fc0..52ff4b14 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -65,6 +65,10 @@ struct adm_qos_limit { uint64_t l_value; }; +struct adm_transfer { + // TODO: empty for now +}; + /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ -- GitLab From dfe0df64830054158678faa009e4b6e2d3c11335 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 13:24:07 +0200 Subject: [PATCH 10/19] Refactor ADM_dataset_info_t --- src/lib/admire.h | 25 ++++++++++++++++++++++--- src/lib/c_wrapper.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index 5486fe04..744532ed 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -204,9 +204,28 @@ typedef enum { typedef struct adm_transfer* ADM_transfer_t; /** Information about a dataset */ -typedef struct { - // TODO: empty for now -} ADM_dataset_info_t; +typedef struct adm_dataset_info* ADM_dataset_info_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_info_destroy(). + * + * @return A valid ADM_DATASET_INFO if successful or NULL in case of + * failure. + */ +ADM_dataset_info_t +ADM_dataset_info_create(); + +/** + * Destroy a dataset created by ADM_dataset_info_create(). + * + * @param[in] dataset A valid ADM_dataset_info_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info); /** A storage tier handle */ typedef struct { diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 52ff4b14..c1120835 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -69,6 +69,10 @@ struct adm_transfer { // TODO: empty for now }; +struct adm_dataset_info { + // TODO: empty for now +}; + /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ @@ -251,6 +255,33 @@ ADM_qos_limit_destroy(ADM_qos_limit_t limit) { return ret; } +ADM_dataset_info_t +ADM_dataset_info_create() { + + struct adm_dataset_info* adm_dataset_info = + (struct adm_dataset_info*) malloc(sizeof(*adm_dataset_info)); + + if(!adm_dataset_info) { + LOGGER_ERROR("Could not allocate ADM_dataset_info_t"); + return NULL; + } + + return adm_dataset_info; +} + +ADM_return_t +ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info) { + ADM_return_t ret = ADM_SUCCESS; + + if(!dataset_info) { + LOGGER_ERROR("Invalid ADM_dataset_info_t") + return ADM_EBADARGS; + } + + free(dataset_info); + return ret; +} + ADM_job_requirements_t ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, ADM_dataset_t outputs[], size_t outputs_len, -- GitLab From 6368b88f6eb2c41c6b8bd59c76cfe780686f52d6 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 13:27:32 +0200 Subject: [PATCH 11/19] Rename ADM_storage_handle_t to ADM_storage_t --- examples/cxx/ADM_set_io_resources.cpp | 2 +- src/lib/admire.cpp | 2 +- src/lib/admire.h | 7 +++---- src/lib/admire.hpp | 2 +- src/lib/c_wrapper.cpp | 3 +-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/cxx/ADM_set_io_resources.cpp b/examples/cxx/ADM_set_io_resources.cpp index b7c8e050..e4ee70a0 100644 --- a/examples/cxx/ADM_set_io_resources.cpp +++ b/examples/cxx/ADM_set_io_resources.cpp @@ -16,7 +16,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_storage_handle_t tier{}; + ADM_storage_t tier{}; ADM_storage_resources_t resources{}; ADM_return_t ret = ADM_SUCCESS; diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 656cae97..59267848 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -423,7 +423,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_handle_t tier, +set_io_resources(const server& srv, ADM_job_t job, ADM_storage_t tier, ADM_storage_resources_t resources) { (void) srv; (void) job; diff --git a/src/lib/admire.h b/src/lib/admire.h index 744532ed..7f4e6094 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -230,7 +230,7 @@ ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info); /** A storage tier handle */ typedef struct { // TODO: empty for now -} ADM_storage_handle_t; +} ADM_storage_t; /** Information about resources assigned to a storage tier */ typedef struct { @@ -467,15 +467,14 @@ ADM_set_dataset_information(ADM_server_t server, ADM_job_t job, * * @param[in] server The server to which the request is directed * @param[in] job An ADM_JOB identifying the originating job. - * @param[in] tier A STORAGE_HANDLE referring to the target storage tier. + * @param[in] tier A ADM_STORAGE_TIER 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.). * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t -ADM_set_io_resources(ADM_server_t server, ADM_job_t job, - ADM_storage_handle_t tier, +ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_storage_t tier, ADM_storage_resources_t resources); diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 2592d01e..d779baaf 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -82,7 +82,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_handle_t tier, +set_io_resources(const server& srv, ADM_job_t job, ADM_storage_t tier, ADM_storage_resources_t resources); ADM_return_t diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index c1120835..5da3c2f1 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -452,8 +452,7 @@ 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_handle_t tier, +ADM_set_io_resources(ADM_server_t server, ADM_job_t job, ADM_storage_t tier, ADM_storage_resources_t resources) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From 5db5a5985ac32864846c397ad7c6ed02d9ba08eb Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 15:29:57 +0200 Subject: [PATCH 12/19] Refactor ADM_storage_t, ADM_adhoc_context_t, and ADM_pfs_context_t --- src/lib/admire.h | 109 +++++++++++++++++++++++----- src/lib/c_wrapper.cpp | 165 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 253 insertions(+), 21 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index 7f4e6094..01bacc3a 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -227,10 +227,41 @@ ADM_dataset_info_create(); ADM_return_t ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info); -/** A storage tier handle */ -typedef struct { - // TODO: empty for now -} ADM_storage_t; +typedef enum { + ADM_STORAGE_GEKKOFS, + ADM_STORAGE_DATACLAY, + ADM_STORAGE_EXPAND, + ADM_STORAGE_HERCULES, + ADM_STORAGE_LUSTRE, + ADM_STORAGE_GPFS, +} ADM_storage_type_t; + +/** A storage tier */ +typedef struct adm_storage* ADM_storage_t; + +/** + * Create a ADM_STORAGE to represent a storage tier. + * + * @remark ADM_STORAGEs need to be freed by calling ADM_storage_destroy(). + * + * @param[in] id An identifier for the storage tier + * @param[in] type The type 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. + */ +ADM_storage_t +ADM_storage_create(const char* id, ADM_storage_type_t type, void* ctx); + +/** + * Destroy a ADM_STORAGE created by ADM_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); /** Information about resources assigned to a storage tier */ typedef struct { @@ -270,18 +301,60 @@ typedef enum { typedef struct adm_adhoc_data_distribution* ADM_adhoc_data_distribution_t; /** The context for an adhoc storage instance */ -typedef struct { - /** The adhoc storage system execution mode */ - ADM_adhoc_mode_t c_mode; - /** The adhoc storage system access type */ - ADM_adhoc_access_t c_access; - /** The number of nodes for the adhoc storage system */ - uint32_t c_nodes; - /** The adhoc storage system walltime */ - uint32_t c_walltime; - /** Whether the adhoc storage system should flush data in the background */ - bool c_should_bg_flush; -} ADM_adhoc_context_t; +typedef struct adm_adhoc_context* ADM_adhoc_context_t; + +/** + * Create an ADM_ADHOC_CONTEXT from information about how an adhoc storage + * instance should be executed. + * + * @remark ADM_ADHOC_CONTEXTs need to be freed by calling + * ADM_adhoc_context_destroy(). + * + * @param[in] exec_mode The adhoc storage system execution mode + * @param[in] access_type The adhoc storage system execution type + * @param[in] nodes The number of nodes for the adhoc storage system + * @param[in] walltime The adhoc storage system walltime + * @param[in] should_flush Whether the adhoc storage system should flush data in + * the background + * @return A valid ADM_ADHOC_CONTEXT if successful. NULL otherwise. + */ +ADM_adhoc_context_t +ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, + ADM_adhoc_access_t access_type, uint32_t nodes, + uint32_t walltime, bool should_flush); + +/** + * Destroy an ADM_ADHOC_CONTEXT created by ADM_adhoc_context_create(). + * + * @param[in] ctx A valid ADM_ADHOC_CONTEXT + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_adhoc_context_destroy(ADM_adhoc_context_t ctx); + +/** The context for a parallel file system storage */ +typedef struct adm_pfs_context* ADM_pfs_context_t; + +/** + * Create an ADM_PFS_CONTEXT from information about how a PFS is configured. + * + * @remark ADM_PFS_CONTEXTs need to be freed by calling + * ADM_pfs_context_destroy(). + * + * @param[in] mountpoint The PFS mount point + * @return A valid ADM_PFS_CONTEXT if successful. NULL otherwise. + */ +ADM_pfs_context_t +ADM_pfs_context_create(const char* mountpoint); + +/** + * Destroy an ADM_PFS_CONTEXT created by ADM_pfs_context_create(). + * + * @param[in] ctx A valid ADM_PFS_CONTEXT + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_pfs_context_destroy(ADM_pfs_context_t ctx); typedef ADM_adhoc_context_t* ADM_adhoc_storage_handle_t; @@ -300,7 +373,7 @@ typedef struct adm_job_requirements* ADM_job_requirements_t; * @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 + * @param[in] 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 @@ -309,7 +382,7 @@ typedef struct adm_job_requirements* ADM_job_requirements_t; 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_adhoc_storage_handle_t adhoc_storage); + ADM_storage_t storage); /** * Destroy a ADM_job_requirements_t created by ADM_job_requirements_create(). diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 5da3c2f1..c2bdb67d 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -73,6 +73,33 @@ struct adm_dataset_info { // TODO: empty for now }; +struct adm_storage { + const char* s_id; + ADM_storage_type_t s_type; + union { + ADM_adhoc_context_t s_adhoc_ctx; + ADM_pfs_context_t s_pfs_ctx; + }; +}; + +struct adm_adhoc_context { + /** The adhoc storage system execution mode */ + ADM_adhoc_mode_t c_mode; + /** The adhoc storage system access type */ + ADM_adhoc_access_t c_access; + /** The number of nodes for the adhoc storage system */ + uint32_t c_nodes; + /** The adhoc storage system walltime */ + uint32_t c_walltime; + /** Whether the adhoc storage system should flush data in the background */ + bool c_should_bg_flush; +}; + +struct adm_pfs_context { + /** The PFS mount point */ + const char* c_mount; +}; + /** The I/O requirements for a job */ struct adm_job_requirements { /** An array of input datasets */ @@ -84,7 +111,7 @@ struct adm_job_requirements { /** 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_adhoc_context_t r_adhoc_ctx; }; ADM_server_t @@ -282,10 +309,131 @@ ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info) { return ret; } +ADM_storage_t +ADM_storage_create(const char* id, ADM_storage_type_t type, void* ctx) { + + struct adm_storage* adm_storage = + (struct adm_storage*) malloc(sizeof(*adm_storage)); + + if(!adm_storage) { + LOGGER_ERROR("Could not allocate ADM_storage_t"); + return NULL; + } + + if(!id) { + LOGGER_ERROR("Null storage id") + return NULL; + } + + if(!ctx) { + LOGGER_ERROR("Null storage context") + return NULL; + } + + adm_storage->s_id = id; + adm_storage->s_type = type; + + 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*) ctx); + break; + + case ADM_STORAGE_LUSTRE: + case ADM_STORAGE_GPFS: + adm_storage->s_pfs_ctx = *((ADM_pfs_context_t*) ctx); + break; + } + + return adm_storage; +} + +ADM_return_t +ADM_storage_destroy(ADM_storage_t storage) { + + ADM_return_t ret = ADM_SUCCESS; + + if(!storage) { + LOGGER_ERROR("Invalid ADM_storage_t") + return ADM_EBADARGS; + } + + free(storage); + return ret; +} + +ADM_adhoc_context_t +ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, + ADM_adhoc_access_t access_type, uint32_t nodes, + uint32_t walltime, bool should_flush) { + + struct adm_adhoc_context* adm_adhoc_context = + (struct adm_adhoc_context*) malloc(sizeof(*adm_adhoc_context)); + + if(!adm_adhoc_context) { + LOGGER_ERROR("Could not allocate ADM_adhoc_context_t"); + return NULL; + } + + adm_adhoc_context->c_mode = exec_mode; + adm_adhoc_context->c_access = access_type; + adm_adhoc_context->c_nodes = nodes; + adm_adhoc_context->c_walltime = walltime; + adm_adhoc_context->c_should_bg_flush = should_flush; + + return adm_adhoc_context; +} + +ADM_return_t +ADM_adhoc_context_destroy(ADM_adhoc_context_t ctx) { + + + ADM_return_t ret = ADM_SUCCESS; + + if(!ctx) { + LOGGER_ERROR("Invalid ADM_adhoc_context_t") + return ADM_EBADARGS; + } + + free(ctx); + return ret; +} + +ADM_pfs_context_t +ADM_pfs_context_create(const char* mountpoint) { + + struct adm_pfs_context* adm_pfs_context = + (struct adm_pfs_context*) malloc(sizeof(*adm_pfs_context)); + + if(!adm_pfs_context) { + LOGGER_ERROR("Could not allocate ADM_adhoc_context_t"); + return NULL; + } + + adm_pfs_context->c_mount = mountpoint; + + return adm_pfs_context; +} + +ADM_return_t +ADM_pfs_context_destroy(ADM_pfs_context_t ctx) { + ADM_return_t ret = ADM_SUCCESS; + + if(!ctx) { + LOGGER_ERROR("Invalid ADM_pfs_context_t") + return ADM_EBADARGS; + } + + free(ctx); + return ret; +} + 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_adhoc_storage_handle_t adhoc_storage) { + ADM_storage_t storage) { struct adm_job_requirements* adm_job_reqs = (struct adm_job_requirements*) malloc( @@ -300,7 +448,18 @@ ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len, 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; + adm_job_reqs->r_adhoc_ctx = NULL; + + if(storage) { + 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) { + LOGGER_ERROR("Invalid adhoc_storage") + return NULL; + } + adm_job_reqs->r_adhoc_ctx = storage->s_adhoc_ctx; + } return adm_job_reqs; } -- GitLab From 25f8ff723a2d9b47903701845b29283508b69d0a Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 17:16:18 +0200 Subject: [PATCH 13/19] Replace ADM_adhoc_storage_handle_t with ADM_adhoc_storage_t --- examples/cxx/ADM_deploy_adhoc_storage.cpp | 4 ++-- examples/cxx/ADM_register_adhoc_storage.cpp | 4 ++-- examples/cxx/ADM_remove_adhoc_storage.cpp | 4 ++-- examples/cxx/ADM_update_adhoc_storage.cpp | 4 ++-- src/lib/admire.cpp | 17 ++++++++--------- src/lib/admire.h | 19 ++++++++----------- src/lib/admire.hpp | 9 ++++----- src/lib/c_wrapper.cpp | 17 ++++++++--------- 8 files changed, 36 insertions(+), 42 deletions(-) diff --git a/examples/cxx/ADM_deploy_adhoc_storage.cpp b/examples/cxx/ADM_deploy_adhoc_storage.cpp index 207ebaa2..9350fa5a 100644 --- a/examples/cxx/ADM_deploy_adhoc_storage.cpp +++ b/examples/cxx/ADM_deploy_adhoc_storage.cpp @@ -15,11 +15,11 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_adhoc_storage_handle_t adhoc_handle{}; + ADM_storage_t adhoc_storage{}; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::deploy_adhoc_storage(server, job, adhoc_handle); + ret = admire::deploy_adhoc_storage(server, job, adhoc_storage); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_deploy_adhoc_storage() failed: {}\n", e.what()); diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index e7971aa1..f97aa692 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -16,11 +16,11 @@ main(int argc, char* argv[]) { ADM_job_t job{}; ADM_adhoc_context_t ctx{}; - ADM_adhoc_storage_handle_t adhoc_handle{}; + ADM_storage_t adhoc_storage{}; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::register_adhoc_storage(server, job, ctx, &adhoc_handle); + ret = admire::register_adhoc_storage(server, job, ctx, &adhoc_storage); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_register_adhoc_storage() failed: {}\n", e.what()); diff --git a/examples/cxx/ADM_remove_adhoc_storage.cpp b/examples/cxx/ADM_remove_adhoc_storage.cpp index bee61143..d622bf01 100644 --- a/examples/cxx/ADM_remove_adhoc_storage.cpp +++ b/examples/cxx/ADM_remove_adhoc_storage.cpp @@ -15,11 +15,11 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_adhoc_storage_handle_t adhoc_handle{}; + ADM_storage_t adhoc_storage{}; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::remove_adhoc_storage(server, job, adhoc_handle); + ret = admire::remove_adhoc_storage(server, job, adhoc_storage); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_remove_adhoc_storage() failed: {}\n", e.what()); diff --git a/examples/cxx/ADM_update_adhoc_storage.cpp b/examples/cxx/ADM_update_adhoc_storage.cpp index 46219a17..2d43d7df 100644 --- a/examples/cxx/ADM_update_adhoc_storage.cpp +++ b/examples/cxx/ADM_update_adhoc_storage.cpp @@ -16,11 +16,11 @@ main(int argc, char* argv[]) { ADM_job_t job{}; ADM_adhoc_context_t ctx{}; - ADM_adhoc_storage_handle_t adhoc_handle{}; + ADM_storage_t adhoc_storage{}; ADM_return_t ret = ADM_SUCCESS; try { - ret = admire::update_adhoc_storage(server, job, ctx, adhoc_handle); + ret = admire::update_adhoc_storage(server, job, ctx, adhoc_storage); } catch(const std::exception& e) { fmt::print(stderr, "FATAL: ADM_update_adhoc_storage() failed: {}\n", e.what()); diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 59267848..9e12ddaf 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -253,12 +253,11 @@ remove_job(const server& srv, ADM_job_t job) { ADM_return_t register_adhoc_storage(const server& srv, ADM_job_t job, - ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t* adhoc_handle) { + ADM_adhoc_context_t ctx, ADM_storage_t* adhoc_storage) { (void) srv; (void) job; (void) ctx; - (void) adhoc_handle; + (void) adhoc_storage; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -282,11 +281,11 @@ register_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t adhoc_handle) { + ADM_storage_t adhoc_storage) { (void) srv; (void) job; (void) ctx; - (void) adhoc_handle; + (void) adhoc_storage; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -310,10 +309,10 @@ update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, ADM_return_t remove_adhoc_storage(const server& srv, ADM_job_t job, - ADM_adhoc_storage_handle_t adhoc_handle) { + ADM_storage_t adhoc_storage) { (void) srv; (void) job; - (void) adhoc_handle; + (void) adhoc_storage; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; @@ -337,10 +336,10 @@ remove_adhoc_storage(const server& srv, ADM_job_t job, ADM_return_t deploy_adhoc_storage(const server& srv, ADM_job_t job, - ADM_adhoc_storage_handle_t adhoc_handle) { + ADM_storage_t adhoc_storage) { (void) srv; (void) job; - (void) adhoc_handle; + (void) adhoc_storage; scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; diff --git a/src/lib/admire.h b/src/lib/admire.h index 01bacc3a..fdac2b29 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -356,8 +356,6 @@ ADM_pfs_context_create(const char* mountpoint); ADM_return_t ADM_pfs_context_destroy(ADM_pfs_context_t ctx); -typedef ADM_adhoc_context_t* ADM_adhoc_storage_handle_t; - /** The I/O requirements for a job */ typedef struct adm_job_requirements* ADM_job_requirements_t; @@ -436,7 +434,7 @@ ADM_remove_job(ADM_server_t server, ADM_job_t job); * @param[in] server The server to which the request is directed * @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 + * @param[out] adhoc_storage An ADM_STORAGE referring to the newly-created * adhoc storage instance. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. @@ -444,7 +442,7 @@ ADM_remove_job(ADM_server_t server, ADM_job_t job); ADM_return_t ADM_register_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t* adhoc_handle); + ADM_storage_t* adhoc_storage); /** * Update an already-registered adhoc storage system. @@ -452,42 +450,41 @@ ADM_register_adhoc_storage(ADM_server_t server, ADM_job_t job, * @param[in] server The server to which the request is directed * @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 + * @param[in] adhoc_storage An ADM_STORAGE referring to the adhoc storage * instance of interest. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t ADM_update_adhoc_storage(ADM_server_t server, ADM_job_t job, - ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t adhoc_handle); + ADM_adhoc_context_t ctx, ADM_storage_t adhoc_storage); /** * Remove an already-registered adhoc storage system. * * @param[in] server The server to which the request is directed * @param[in] job An ADM_JOB identifying the originating job. - * @param[in] adhoc_handle An ADHOC_HANDLE referring to the adhoc storage + * @param[in] adhoc_storage An ADM_STORAGE 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_t job, - ADM_adhoc_storage_handle_t adhoc_handle); + ADM_storage_t adhoc_storage); /** * Initiate the deployment of an adhoc storage system instance. * * @param[in] server The server to which the request is directed * @param[in] job An ADM_JOB identifying the originating job. - * @param[in] adhoc_handle An ADHOC_HANDLE referring to the adhoc storage + * @param[in] adhoc_storage An ADM_STORAGE 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_t job, - ADM_adhoc_storage_handle_t adhoc_handle); + ADM_storage_t adhoc_storage); /** * Transfers the dataset identified by the source_name to the storage tier diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index d779baaf..a9114474 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -57,20 +57,19 @@ remove_job(const server& srv, ADM_job_t job); ADM_return_t register_adhoc_storage(const server& srv, ADM_job_t job, - ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t* adhoc_handle); + ADM_adhoc_context_t ctx, ADM_storage_t* adhoc_storage); ADM_return_t update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t adhoc_handle); + ADM_storage_t adhoc_storage); ADM_return_t remove_adhoc_storage(const server& srv, ADM_job_t job, - ADM_adhoc_storage_handle_t adhoc_handle); + ADM_storage_t adhoc_storage); ADM_return_t deploy_adhoc_storage(const server& srv, ADM_job_t job, - ADM_adhoc_storage_handle_t adhoc_handle); + ADM_storage_t adhoc_storage); ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index c2bdb67d..d599fb78 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -554,39 +554,38 @@ ADM_remove_job(ADM_server_t server, ADM_job_t job) { ADM_return_t ADM_register_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t* adhoc_handle) { + ADM_storage_t* adhoc_storage) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::register_adhoc_storage(srv, job, ctx, adhoc_handle); + return admire::register_adhoc_storage(srv, job, ctx, adhoc_storage); } ADM_return_t ADM_update_adhoc_storage(ADM_server_t server, ADM_job_t job, - ADM_adhoc_context_t ctx, - ADM_adhoc_storage_handle_t adhoc_handle) { + ADM_adhoc_context_t ctx, ADM_storage_t adhoc_storage) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::update_adhoc_storage(srv, job, ctx, adhoc_handle); + return admire::update_adhoc_storage(srv, job, ctx, adhoc_storage); } ADM_return_t ADM_remove_adhoc_storage(ADM_server_t server, ADM_job_t job, - ADM_adhoc_storage_handle_t adhoc_handle) { + ADM_storage_t adhoc_storage) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::remove_adhoc_storage(srv, job, adhoc_handle); + return admire::remove_adhoc_storage(srv, job, adhoc_storage); } ADM_return_t ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, - ADM_adhoc_storage_handle_t adhoc_handle) { + ADM_storage_t adhoc_storage) { const admire::server srv{server->s_protocol, server->s_address}; - return admire::deploy_adhoc_storage(srv, job, adhoc_handle); + return admire::deploy_adhoc_storage(srv, job, adhoc_storage); } ADM_return_t -- GitLab From 97b0dddd2901e6e185f79f7848a3df98b4d44719 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 20:18:55 +0200 Subject: [PATCH 14/19] Add ADM_(register|update|remove)_pfs_storage() --- examples/cxx/ADM_register_pfs_storage.cpp | 39 ++++++++++ examples/cxx/ADM_remove_pfs_storage.cpp | 38 +++++++++ examples/cxx/ADM_update_pfs_storage.cpp | 39 ++++++++++ examples/cxx/CMakeLists.txt | 4 +- src/lib/admire.cpp | 83 ++++++++++++++++++++ src/lib/admire.h | 44 +++++++++++ src/lib/admire.hpp | 11 +++ src/lib/c_wrapper.cpp | 27 +++++++ src/lib/rpcs/public.cpp | 93 +++++++++++++++++++++++ src/lib/rpcs/public.hpp | 21 +++++ 10 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 examples/cxx/ADM_register_pfs_storage.cpp create mode 100644 examples/cxx/ADM_remove_pfs_storage.cpp create mode 100644 examples/cxx/ADM_update_pfs_storage.cpp diff --git a/examples/cxx/ADM_register_pfs_storage.cpp b/examples/cxx/ADM_register_pfs_storage.cpp new file mode 100644 index 00000000..0adafce8 --- /dev/null +++ b/examples/cxx/ADM_register_pfs_storage.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "Usage: ADM_register_pfs_storage " + "\n"); + exit(EXIT_FAILURE); + } + + admire::server server{"tcp", argv[1]}; + + ADM_job_t job{}; + ADM_pfs_context_t ctx{}; + ADM_storage_t pfs_storage{}; + ADM_return_t ret = ADM_SUCCESS; + + try { + ret = admire::register_pfs_storage(server, job, ctx, &pfs_storage); + } catch(const std::exception& e) { + fmt::print(stderr, "FATAL: ADM_register_pfs_storage() failed: {}\n", + e.what()); + exit(EXIT_FAILURE); + } + + if(ret != ADM_SUCCESS) { + fmt::print(stdout, + "ADM_register_pfs_storage() remote procedure not completed " + "successfully\n"); + exit(EXIT_FAILURE); + } + + fmt::print(stdout, "ADM_register_pfs_storage() remote procedure completed " + "successfully\n"); +} diff --git a/examples/cxx/ADM_remove_pfs_storage.cpp b/examples/cxx/ADM_remove_pfs_storage.cpp new file mode 100644 index 00000000..2df326ac --- /dev/null +++ b/examples/cxx/ADM_remove_pfs_storage.cpp @@ -0,0 +1,38 @@ +#include "fmt/format.h" +#include "admire.hpp" + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "Usage: ADM_remove_pfs_storage " + "\n"); + exit(EXIT_FAILURE); + } + + admire::server server{"tcp", argv[1]}; + + ADM_job_t job{}; + ADM_storage_t pfs_storage{}; + ADM_return_t ret = ADM_SUCCESS; + + try { + ret = admire::remove_pfs_storage(server, job, pfs_storage); + } catch(const std::exception& e) { + fmt::print(stderr, "FATAL: ADM_remove_pfs_storage() failed: {}\n", + e.what()); + exit(EXIT_FAILURE); + } + + if(ret != ADM_SUCCESS) { + fmt::print(stdout, + "ADM_remove_pfs_storage() remote procedure not completed " + "successfully\n"); + exit(EXIT_FAILURE); + } + + fmt::print(stdout, "ADM_remove_pfs_storage() remote procedure completed " + "successfully\n"); +} diff --git a/examples/cxx/ADM_update_pfs_storage.cpp b/examples/cxx/ADM_update_pfs_storage.cpp new file mode 100644 index 00000000..f8be2569 --- /dev/null +++ b/examples/cxx/ADM_update_pfs_storage.cpp @@ -0,0 +1,39 @@ +#include +#include + + +int +main(int argc, char* argv[]) { + + if(argc != 3) { + fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "Usage: ADM_update_pfs_storage " + "\n"); + exit(EXIT_FAILURE); + } + + admire::server server{"tcp", argv[1]}; + + ADM_job_t job{}; + ADM_pfs_context_t ctx{}; + ADM_storage_t pfs_storage{}; + ADM_return_t ret = ADM_SUCCESS; + + try { + ret = admire::update_pfs_storage(server, job, ctx, pfs_storage); + } catch(const std::exception& e) { + fmt::print(stderr, "FATAL: ADM_update_pfs_storage() failed: {}\n", + e.what()); + exit(EXIT_FAILURE); + } + + if(ret != ADM_SUCCESS) { + fmt::print(stdout, + "ADM_update_pfs_storage() remote procedure not completed " + "successfully\n"); + exit(EXIT_FAILURE); + } + + fmt::print(stdout, "ADM_update_pfs_storage() remote procedure completed " + "successfully\n"); +} diff --git a/examples/cxx/CMakeLists.txt b/examples/cxx/CMakeLists.txt index 4df33f0d..1ee8d2d5 100644 --- a/examples/cxx/CMakeLists.txt +++ b/examples/cxx/CMakeLists.txt @@ -27,7 +27,9 @@ list(APPEND examples_cxx 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_register_pfs_storage ADM_update_pfs_storage + ADM_remove_pfs_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 diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 9e12ddaf..03e8d01c 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -361,6 +361,89 @@ deploy_adhoc_storage(const server& srv, ADM_job_t job, return ADM_SUCCESS; } +ADM_return_t +register_pfs_storage(const server& srv, ADM_job_t job, ADM_pfs_context_t ctx, + ADM_storage_t* pfs_storage) { + (void) srv; + (void) job; + (void) ctx; + (void) pfs_storage; + + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; + + auto endp = rpc_client.lookup(srv.m_address); + + LOGGER_INFO("ADM_register_pfs_storage(...)"); + + ADM_register_pfs_storage_in_t in{}; + ADM_register_pfs_storage_out_t out; + + endp.call("ADM_register_pfs_storage", &in, &out); + + if(out.ret < 0) { + LOGGER_ERROR("ADM_register_pfs_storage() = {}", out.ret); + return static_cast(out.ret); + } + + LOGGER_INFO("ADM_register_pfs_storage() = {}", ADM_SUCCESS); + return ADM_SUCCESS; +} + +ADM_return_t +update_pfs_storage(const server& srv, ADM_job_t job, ADM_pfs_context_t ctx, + ADM_storage_t pfs_storage) { + (void) srv; + (void) job; + (void) ctx; + (void) pfs_storage; + + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; + + auto endp = rpc_client.lookup(srv.m_address); + + LOGGER_INFO("ADM_update_pfs_storage(...)"); + + ADM_update_pfs_storage_in_t in{}; + ADM_update_pfs_storage_out_t out; + + endp.call("ADM_update_pfs_storage", &in, &out); + + if(out.ret < 0) { + LOGGER_ERROR("ADM_update_pfs_storage() = {}", out.ret); + return static_cast(out.ret); + } + + LOGGER_INFO("ADM_update_pfs_storage() = {}", ADM_SUCCESS); + return ADM_SUCCESS; +} + +ADM_return_t +remove_pfs_storage(const server& srv, ADM_job_t job, + ADM_storage_t pfs_storage) { + (void) srv; + (void) job; + (void) pfs_storage; + + scord::network::rpc_client rpc_client{srv.m_protocol, rpc_registration_cb}; + + auto endp = rpc_client.lookup(srv.m_address); + + LOGGER_INFO("ADM_remove_pfs_storage(...)"); + + ADM_remove_pfs_storage_in_t in{}; + ADM_remove_pfs_storage_out_t out; + + endp.call("ADM_remove_pfs_storage", &in, &out); + + if(out.ret < 0) { + LOGGER_ERROR("ADM_remove_pfs_storage() = {}", out.ret); + return static_cast(out.ret); + } + + LOGGER_INFO("ADM_remove_pfs_storage() = {}", ADM_SUCCESS); + return ADM_SUCCESS; +} + ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, diff --git a/src/lib/admire.h b/src/lib/admire.h index fdac2b29..b1adb016 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -486,6 +486,50 @@ ADM_return_t ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, ADM_storage_t adhoc_storage); +/** + * Register a PFS storage tier. + * + * @param[in] server The server to which the request is directed + * @param[in] job An ADM_JOB identifying the originating job. + * @param[in] ctx The EXECUTION_CONTEXT for the PFS. + * @param[out] adhoc_storage An ADM_STORAGE referring to the newly-created + * PFS instance. + * @return Returns ADM_SUCCESS if the remote procedure has completed + * successfully. + */ +ADM_return_t +ADM_register_pfs_storage(ADM_server_t server, ADM_job_t job, + ADM_pfs_context_t ctx, ADM_storage_t* pfs_storage); + +/** + * Update an already-registered PFS storage tier. + * + * @param[in] server The server to which the request is directed + * @param[in] job An ADM_JOB identifying the originating job. + * @param[in] ctx The updated EXECUTION_CONTEXT for the PFS. + * @param[in] adhoc_storage An ADM_STORAGE referring to the PFS + * instance of interest. + * @return Returns ADM_SUCCESS if the remote procedure has completed + * successfully. + */ +ADM_return_t +ADM_update_pfs_storage(ADM_server_t server, ADM_job_t job, + ADM_pfs_context_t ctx, ADM_storage_t adhoc_storage); + +/** + * Remove an already-registered PFS storage tier. + * + * @param[in] server The server to which the request is directed + * @param[in] job An ADM_JOB identifying the originating job. + * @param[in] adhoc_storage An ADM_STORAGE referring to the PFS + * instance of interest. + * @return Returns ADM_SUCCESS if the remote procedure has completed + * successfully. + */ +ADM_return_t +ADM_remove_pfs_storage(ADM_server_t server, ADM_job_t job, + ADM_storage_t adhoc_storage); + /** * Transfers the dataset identified by the source_name to the storage tier * defined by destination_name, and apply the provided constraints during the diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index a9114474..e1fdf631 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -71,6 +71,17 @@ ADM_return_t deploy_adhoc_storage(const server& srv, ADM_job_t job, ADM_storage_t adhoc_storage); +ADM_return_t +register_pfs_storage(const server& srv, ADM_job_t job, ADM_pfs_context_t ctx, + ADM_storage_t* pfs_storage); + +ADM_return_t +update_pfs_storage(const server& srv, ADM_job_t job, ADM_pfs_context_t ctx, + ADM_storage_t pfs_storage); + +ADM_return_t +remove_pfs_storage(const server& srv, ADM_job_t job, ADM_storage_t pfs_storage); + ADM_return_t transfer_dataset(const server& srv, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, ADM_qos_limit_t** limits, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index d599fb78..30adfd44 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -588,6 +588,33 @@ ADM_deploy_adhoc_storage(ADM_server_t server, ADM_job_t job, return admire::deploy_adhoc_storage(srv, job, adhoc_storage); } +ADM_return_t +ADM_register_pfs_storage(ADM_server_t server, ADM_job_t job, + ADM_pfs_context_t ctx, ADM_storage_t* pfs_storage) { + + const admire::server srv{server->s_protocol, server->s_address}; + + return admire::register_pfs_storage(srv, job, ctx, pfs_storage); +} + +ADM_return_t +ADM_update_pfs_storage(ADM_server_t server, ADM_job_t job, + ADM_pfs_context_t ctx, ADM_storage_t pfs_storage) { + + const admire::server srv{server->s_protocol, server->s_address}; + + return admire::update_pfs_storage(srv, job, ctx, pfs_storage); +} + +ADM_return_t +ADM_remove_pfs_storage(ADM_server_t server, ADM_job_t job, + ADM_storage_t pfs_storage) { + + const admire::server srv{server->s_protocol, server->s_address}; + + return admire::remove_pfs_storage(srv, job, pfs_storage); +} + ADM_return_t ADM_transfer_dataset(ADM_server_t server, ADM_job_t job, ADM_dataset_t** sources, ADM_dataset_t** targets, diff --git a/src/lib/rpcs/public.cpp b/src/lib/rpcs/public.cpp index d166f727..e10b6587 100644 --- a/src/lib/rpcs/public.cpp +++ b/src/lib/rpcs/public.cpp @@ -258,6 +258,99 @@ ADM_deploy_adhoc_storage(hg_handle_t h) { DEFINE_MARGO_RPC_HANDLER(ADM_deploy_adhoc_storage); +static void +ADM_register_pfs_storage(hg_handle_t h) { + + hg_return_t ret; + + ADM_register_pfs_storage_in_t in; + ADM_register_pfs_storage_out_t out; + + [[maybe_unused]] margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + + LOGGER_INFO("ADM_register_pfs_storage()"); + + out.ret = 0; + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_register_pfs_storage); + +static void +ADM_update_pfs_storage(hg_handle_t h) { + + hg_return_t ret; + + ADM_update_pfs_storage_in_t in; + ADM_update_pfs_storage_out_t out; + + [[maybe_unused]] margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + + LOGGER_INFO("ADM_update_pfs_storage()"); + + out.ret = 0; + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_update_pfs_storage); + +static void +ADM_remove_pfs_storage(hg_handle_t h) { + + hg_return_t ret; + + ADM_remove_pfs_storage_in_t in; + ADM_remove_pfs_storage_out_t out; + + [[maybe_unused]] margo_instance_id mid = margo_hg_handle_get_instance(h); + + ret = margo_get_input(h, &in); + assert(ret == HG_SUCCESS); + + out.ret = -1; + + LOGGER_INFO("ADM_remove_pfs_storage()"); + + out.ret = 0; + + ret = margo_respond(h, &out); + assert(ret == HG_SUCCESS); + + ret = margo_free_input(h, &in); + assert(ret == HG_SUCCESS); + + ret = margo_destroy(h); + assert(ret == HG_SUCCESS); +} + +DEFINE_MARGO_RPC_HANDLER(ADM_remove_pfs_storage); + /** * Specifes the origin location in a storage tier where input is located, as * well as the target location where it should be placed in a different storage diff --git a/src/lib/rpcs/public.hpp b/src/lib/rpcs/public.hpp index 6b9f9d4f..5e03eef0 100644 --- a/src/lib/rpcs/public.hpp +++ b/src/lib/rpcs/public.hpp @@ -87,6 +87,27 @@ MERCURY_GEN_PROC(ADM_deploy_adhoc_storage_out_t, ((int32_t) (ret))) DECLARE_MARGO_RPC_HANDLER(ADM_deploy_adhoc_storage); +/// ADM_register_pfs_storage +MERCURY_GEN_PROC(ADM_register_pfs_storage_in_t, ((int32_t) (reqs))) + +MERCURY_GEN_PROC(ADM_register_pfs_storage_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_register_pfs_storage); + +/// ADM_update_pfs_storage +MERCURY_GEN_PROC(ADM_update_pfs_storage_in_t, ((int32_t) (reqs))) + +MERCURY_GEN_PROC(ADM_update_pfs_storage_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_update_pfs_storage); + +/// ADM_remove_pfs_storage +MERCURY_GEN_PROC(ADM_remove_pfs_storage_in_t, ((int32_t) (reqs))) + +MERCURY_GEN_PROC(ADM_remove_pfs_storage_out_t, ((int32_t) (ret))) + +DECLARE_MARGO_RPC_HANDLER(ADM_remove_pfs_storage); + /// ADM_input MERCURY_GEN_PROC(ADM_input_in_t, ((hg_const_string_t) (origin))((hg_const_string_t) (target))) -- GitLab From 27e9830e23f8d18bb894e766bc9d6e5925cf644c Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 20:29:28 +0200 Subject: [PATCH 15/19] Refactor ADM_storage_resources_t --- src/lib/admire.h | 25 ++++++++++++++++++++++--- src/lib/c_wrapper.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index b1adb016..db23a85f 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -264,9 +264,28 @@ ADM_return_t ADM_storage_destroy(ADM_storage_t storage); /** Information about resources assigned to a storage tier */ -typedef struct { - // TODO: empty for now -} ADM_storage_resources_t; +typedef struct adm_storage_resources* ADM_storage_resources_t; + +/** + * Create an ADM_STORAGE_RESOURCES from information about storage resources. + * + * @remark ADM_STORAGE_RESOURCES need to be freed by calling + * ADM_storage_resources_destroy(). + * + * @return A valid ADM_STORAGE_RESOURCES, or NULL in case of failure + */ +ADM_storage_resources_t +ADM_storage_resources_create(); + +/** + * Destroy a ADM_STORAGE_RESOURCES created by ADM_storage_resources_create(). + * + * @param[in] res A valid ADM_STORAGE + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_storage_resources_destroy(ADM_storage_resources_t res); + typedef int ADM_transfer_priority_t; diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 30adfd44..013e93c1 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -82,6 +82,10 @@ struct adm_storage { }; }; +struct adm_storage_resources { + // TODO: empty for now +}; + struct adm_adhoc_context { /** The adhoc storage system execution mode */ ADM_adhoc_mode_t c_mode; @@ -364,6 +368,35 @@ ADM_storage_destroy(ADM_storage_t storage) { return ret; } +ADM_storage_resources_t +ADM_storage_resources_create() { + + struct adm_storage_resources* adm_storage_resources = + (struct adm_storage_resources*) malloc( + sizeof(*adm_storage_resources)); + + if(!adm_storage_resources) { + LOGGER_ERROR("Could not allocate ADM_storage_resources_t"); + return NULL; + } + + return adm_storage_resources; +} + +ADM_return_t +ADM_storage_resources_destroy(ADM_storage_resources_t res) { + + ADM_return_t ret = ADM_SUCCESS; + + if(!res) { + LOGGER_ERROR("Invalid ADM_storage_resources_t") + return ADM_EBADARGS; + } + + free(res); + return ret; +} + ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, ADM_adhoc_access_t access_type, uint32_t nodes, -- GitLab From b8a9aac498987e0d583d232e1c24759809f75e8d Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 20:31:24 +0200 Subject: [PATCH 16/19] Rename ADM_data_operation_handle_t to ADM_data_operation_t --- examples/cxx/ADM_define_data_operation.cpp | 2 +- examples/cxx/ADM_finalize_data_operation.cpp | 2 +- examples/cxx/ADM_link_transfer_to_data_operation.cpp | 2 +- src/lib/admire.cpp | 8 ++++---- src/lib/admire.h | 8 ++++---- src/lib/admire.hpp | 8 ++++---- src/lib/c_wrapper.cpp | 9 +++++---- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/examples/cxx/ADM_define_data_operation.cpp b/examples/cxx/ADM_define_data_operation.cpp index 36c90205..bd6cdf2d 100644 --- a/examples/cxx/ADM_define_data_operation.cpp +++ b/examples/cxx/ADM_define_data_operation.cpp @@ -17,7 +17,7 @@ main(int argc, char* argv[]) { ADM_job_t job{}; const char* path = ""; - ADM_data_operation_handle_t op_handle; + ADM_data_operation_t op_handle; va_list args; // FIXME: placeholder 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 e396577b..da05c8d4 100644 --- a/examples/cxx/ADM_finalize_data_operation.cpp +++ b/examples/cxx/ADM_finalize_data_operation.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_data_operation_handle_t op_handle{}; + ADM_data_operation_t op_handle{}; ADM_data_operation_status_t status; 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 df0e7268..a22633d2 100644 --- a/examples/cxx/ADM_link_transfer_to_data_operation.cpp +++ b/examples/cxx/ADM_link_transfer_to_data_operation.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_data_operation_handle_t op_handle; + ADM_data_operation_t op_handle; bool should_stream = false; va_list args; ADM_return_t ret = ADM_SUCCESS; diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 03e8d01c..6c42295b 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -703,7 +703,7 @@ get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, ADM_return_t define_data_operation(const server& srv, ADM_job_t job, const char* path, - ADM_data_operation_handle_t* op, va_list args) { + ADM_data_operation_t* op, va_list args) { (void) srv; (void) job; (void) path; @@ -764,7 +764,7 @@ connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_t input, ADM_return_t finalize_data_operation(const server& srv, ADM_job_t job, - ADM_data_operation_handle_t op, + ADM_data_operation_t op, ADM_data_operation_status_t* status) { (void) srv; (void) job; @@ -794,8 +794,8 @@ finalize_data_operation(const server& srv, ADM_job_t job, ADM_return_t 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_data_operation_t op, bool should_stream, + va_list args) { (void) srv; (void) job; (void) op; diff --git a/src/lib/admire.h b/src/lib/admire.h index db23a85f..6858dc8b 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -291,7 +291,7 @@ typedef int ADM_transfer_priority_t; typedef struct { // TODO: empty for now -} ADM_data_operation_handle_t; +} ADM_data_operation_t; typedef struct { // TODO: empty for now @@ -720,7 +720,7 @@ ADM_get_qos_constraints(ADM_server_t server, ADM_job_t job, */ ADM_return_t ADM_define_data_operation(ADM_server_t server, ADM_job_t job, const char* path, - ADM_data_operation_handle_t* op, ...); + ADM_data_operation_t* op, ...); /** @@ -759,7 +759,7 @@ ADM_connect_data_operation(ADM_server_t server, ADM_job_t job, */ ADM_return_t ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, - ADM_data_operation_handle_t op, + ADM_data_operation_t op, ADM_data_operation_status_t* status); @@ -783,7 +783,7 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, */ ADM_return_t ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_t job, - ADM_data_operation_handle_t op, + ADM_data_operation_t op, ADM_transfer_t transfer, bool should_stream, ...); diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index e1fdf631..9f58a953 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -120,7 +120,7 @@ get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_entity_t entity, ADM_return_t define_data_operation(const server& srv, ADM_job_t job, const char* path, - ADM_data_operation_handle_t* op, va_list args); + ADM_data_operation_t* op, va_list args); ADM_return_t connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_t input, @@ -128,13 +128,13 @@ connect_data_operation(const server& srv, ADM_job_t job, ADM_dataset_t input, ADM_return_t finalize_data_operation(const server& srv, ADM_job_t job, - ADM_data_operation_handle_t op, + ADM_data_operation_t op, ADM_data_operation_status_t* status); ADM_return_t 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_data_operation_t op, bool should_stream, + va_list args); ADM_return_t get_statistics(const server& srv, ADM_job_t job, ADM_job_stats_t** stats); diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 013e93c1..0c0d8c03 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -86,6 +86,7 @@ struct adm_storage_resources { // TODO: empty for now }; + struct adm_adhoc_context { /** The adhoc storage system execution mode */ ADM_adhoc_mode_t c_mode; @@ -735,7 +736,7 @@ ADM_get_qos_constraints(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_define_data_operation(ADM_server_t server, ADM_job_t job, const char* path, - ADM_data_operation_handle_t* op, ...) { + ADM_data_operation_t* op, ...) { const admire::server srv{server->s_protocol, server->s_address}; @@ -765,7 +766,7 @@ ADM_connect_data_operation(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, - ADM_data_operation_handle_t op, + ADM_data_operation_t op, ADM_data_operation_status_t* status) { const admire::server srv{server->s_protocol, server->s_address}; @@ -775,8 +776,8 @@ ADM_finalize_data_operation(ADM_server_t server, ADM_job_t job, ADM_return_t ADM_link_transfer_to_data_operation(ADM_server_t server, ADM_job_t job, - ADM_data_operation_handle_t op, - bool should_stream, ...) { + ADM_data_operation_t op, bool should_stream, + ...) { const admire::server srv{server->s_protocol, server->s_address}; -- GitLab From 5a384253ce14eea6510742bb5f018f07ad380868 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 20:36:37 +0200 Subject: [PATCH 17/19] Refactor ADM_data_operation_t --- .../ADM_link_transfer_to_data_operation.cpp | 2 +- src/lib/admire.h | 24 ++++++++++++-- src/lib/c_wrapper.cpp | 33 +++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/examples/cxx/ADM_link_transfer_to_data_operation.cpp b/examples/cxx/ADM_link_transfer_to_data_operation.cpp index a22633d2..623b6409 100644 --- a/examples/cxx/ADM_link_transfer_to_data_operation.cpp +++ b/examples/cxx/ADM_link_transfer_to_data_operation.cpp @@ -15,7 +15,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; ADM_job_t job{}; - ADM_data_operation_t op_handle; + ADM_data_operation_t op_handle{}; bool should_stream = false; va_list args; ADM_return_t ret = ADM_SUCCESS; diff --git a/src/lib/admire.h b/src/lib/admire.h index 6858dc8b..95e50862 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -289,9 +289,27 @@ ADM_storage_resources_destroy(ADM_storage_resources_t res); typedef int ADM_transfer_priority_t; -typedef struct { - // TODO: empty for now -} ADM_data_operation_t; +typedef struct adm_data_operation* ADM_data_operation_t; + +/** + * Create an ADM_DATA_OPERATION from information about storage resources. + * + * @remark ADM_DATA_OPERATION need to be freed by calling + * ADM_storage_resources_destroy(). + * + * @return A valid ADM_DATA_OPERATION, or NULL in case of failure + */ +ADM_data_operation_t +ADM_data_operation_create(); + +/** + * Destroy a ADM_DATA_OPERATION created by ADM_storage_resources_create(). + * + * @param[in] op A valid ADM_DATA_OPERATION + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_data_operation_destroy(ADM_data_operation_t op); typedef struct { // TODO: empty for now diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 0c0d8c03..8b94a596 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -86,6 +86,10 @@ struct adm_storage_resources { // TODO: empty for now }; +struct adm_data_operation { + // TODO: empty for now +}; + struct adm_adhoc_context { /** The adhoc storage system execution mode */ @@ -398,6 +402,35 @@ ADM_storage_resources_destroy(ADM_storage_resources_t res) { return ret; } +ADM_data_operation_t +ADM_data_operation_create() { + + struct adm_data_operation* adm_data_operation = + (struct adm_data_operation*) malloc(sizeof(*adm_data_operation)); + + if(!adm_data_operation) { + LOGGER_ERROR("Could not allocate ADM_data_operation_t"); + return NULL; + } + + return adm_data_operation; +} + +ADM_return_t +ADM_data_operation_destroy(ADM_data_operation_t op) { + + ADM_return_t ret = ADM_SUCCESS; + + if(!op) { + LOGGER_ERROR("Invalid ADM_data_operation_t") + return ADM_EBADARGS; + } + + free(op); + return ret; +} + + ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, ADM_adhoc_access_t access_type, uint32_t nodes, -- GitLab From 282b6262ed870eeb61e2090cf4518db0189725af Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 20:39:38 +0200 Subject: [PATCH 18/19] Add missing docstrings --- src/lib/admire.h | 5 ++++- src/lib/c_wrapper.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/admire.h b/src/lib/admire.h index 95e50862..5234dc52 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -286,9 +286,10 @@ ADM_storage_resources_create(); ADM_return_t ADM_storage_resources_destroy(ADM_storage_resources_t res); - +/** A transfer priority */ typedef int ADM_transfer_priority_t; +/** A data operation */ typedef struct adm_data_operation* ADM_data_operation_t; /** @@ -311,10 +312,12 @@ ADM_data_operation_create(); ADM_return_t ADM_data_operation_destroy(ADM_data_operation_t op); +/** A data operation status */ typedef struct { // TODO: empty for now } ADM_data_operation_status_t; +/** I/O stats from a job */ typedef struct { // TODO: empty for now } ADM_job_stats_t; diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 8b94a596..6cf1747f 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -90,7 +90,6 @@ struct adm_data_operation { // TODO: empty for now }; - struct adm_adhoc_context { /** The adhoc storage system execution mode */ ADM_adhoc_mode_t c_mode; -- GitLab From 6803d913e9f80a0c82f7aa81c2c00a60e3ac946c Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 6 Jul 2022 20:47:30 +0200 Subject: [PATCH 19/19] Move API type defintions to types.h --- src/lib/CMakeLists.txt | 2 +- src/lib/admire.h | 389 +------------------------------- src/lib/types.h | 498 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 501 insertions(+), 388 deletions(-) create mode 100644 src/lib/types.h diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 94a90638..4ef754f0 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -35,7 +35,7 @@ set_property(TARGET api_rpcs PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(adm_iosched SHARED) target_sources(adm_iosched - PUBLIC admire.h admire.hpp + PUBLIC admire.h types.h admire.hpp PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp errors.c) target_include_directories(adm_iosched PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/lib/admire.h b/src/lib/admire.h index 5234dc52..fa431602 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -28,6 +28,7 @@ #include #include #include +#include "types.h" #ifdef __cplusplus extern "C" { @@ -43,393 +44,7 @@ extern "C" { /* Public type definitions and type-related functions */ /******************************************************************************/ -/* Error return codes */ -typedef enum { - ADM_SUCCESS = 0, - ADM_ESNAFU, - ADM_EBADARGS, - ADM_ENOMEM, - ADM_EOTHER, - ADM_ERR_MAX = 512 -} ADM_return_t; - -/* A server */ -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 struct adm_node* ADM_node_t; - -/** - * Initialize a node from a user-provided hostname/address. - * - * @remark Nodes need to be freed by calling ADM_server_destroy(). - * - * @param[in] hostname The hostname of the node. - * @return A valid ADM_server_t if successful or NULL in case of failure. - */ -ADM_node_t -ADM_node_create(const char* hostname); - -/** - * Destroy a node created by ADM_node_create(). - * - * @param[in] node A valid ADM_node_t - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_node_destroy(ADM_node_t node); - - -/** A dataset */ -typedef struct adm_dataset* ADM_dataset_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_t -ADM_dataset_create(const char* id); - -/** - * Destroy a dataset created by ADM_dataset_create(). - * - * @param[in] dataset A valid ADM_dataset_t - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_dataset_destroy(ADM_dataset_t dataset); - -/* A job handle */ -typedef struct adm_job* ADM_job_t; - -/* The scope affected by a QoS limit */ -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 */ -typedef enum { ADM_QOS_CLASS_BANDWIDTH, ADM_QOS_CLASS_IOPS } ADM_qos_class_t; - -/** An ADMIRE entity upon which QoS can be defined */ -typedef struct adm_qos_entity* ADM_qos_entity_t; - -/** - * Create a QoS entity given a scope, a node, a dataset, or a job. - * - * @remark QoS entities need to be freed by calling ADM_qos_entity_destroy(). - * - * @param scope The scope of the entity, i.e. ADM_QOS_SCOPE_DATASET, - * ADM_QOS_SCOPE_NODE, or ADM_QOS_SCOPE_JOB. - * @param ... A single argument with data from either a ADM_dataset_t, - * ADM_node_t, or ADM_job_t variable. The argument must correspond properly - * to the scope provided. - * @return A valid ADM_qos_entity_t if successful or NULL in case of failure. - */ -ADM_qos_entity_t -ADM_qos_entity_create(ADM_qos_scope_t scope, ...); - -/** - * Destroy a QoS entity created by ADM_qos_entity_create(). - * - * @param[in] entity A valid ADM_qos_entity_t - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_qos_entity_destroy(ADM_qos_entity_t entity); - -/** A QoS limit */ -typedef struct adm_qos_limit* ADM_qos_limit_t; - -/** - * Create a QoS limit given an entity and a QoS class. - * - * @remark QoS limits need to be freed by calling ADM_qos_limit_destroy(). - * - * @param[in] entity The entity upon which the QoS limit should be enforced. - * @param[in] cls The QoS restriction class to apply. - * @param[in] value The limit's value. - * @return A valid ADM_qos_limit_t if successful or NULL in case of failure. - */ -ADM_qos_limit_t -ADM_qos_limit_create(ADM_qos_entity_t entity, ADM_qos_class_t cls, - uint64_t value); - -/** - * Destroy a QoS limit created by ADM_qos_limit_create(). - * - * @param[in] limit A valid ADM_qos_limit_t - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_qos_limit_destroy(ADM_qos_limit_t limit); - - -/** A transfer mapping */ -typedef enum { - ADM_MAPPING_ONE_TO_ONE, - ADM_MAPPING_ONE_TO_N, - ADM_MAPPING_N_TO_N -} ADM_transfer_mapping_t; - -/** A handle to a created transfer */ -typedef struct adm_transfer* ADM_transfer_t; - -/** Information about a dataset */ -typedef struct adm_dataset_info* ADM_dataset_info_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_info_destroy(). - * - * @return A valid ADM_DATASET_INFO if successful or NULL in case of - * failure. - */ -ADM_dataset_info_t -ADM_dataset_info_create(); - -/** - * Destroy a dataset created by ADM_dataset_info_create(). - * - * @param[in] dataset A valid ADM_dataset_info_t - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info); - -typedef enum { - ADM_STORAGE_GEKKOFS, - ADM_STORAGE_DATACLAY, - ADM_STORAGE_EXPAND, - ADM_STORAGE_HERCULES, - ADM_STORAGE_LUSTRE, - ADM_STORAGE_GPFS, -} ADM_storage_type_t; - -/** A storage tier */ -typedef struct adm_storage* ADM_storage_t; - -/** - * Create a ADM_STORAGE to represent a storage tier. - * - * @remark ADM_STORAGEs need to be freed by calling ADM_storage_destroy(). - * - * @param[in] id An identifier for the storage tier - * @param[in] type The type 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. - */ -ADM_storage_t -ADM_storage_create(const char* id, ADM_storage_type_t type, void* ctx); - -/** - * Destroy a ADM_STORAGE created by ADM_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); - -/** Information about resources assigned to a storage tier */ -typedef struct adm_storage_resources* ADM_storage_resources_t; - -/** - * Create an ADM_STORAGE_RESOURCES from information about storage resources. - * - * @remark ADM_STORAGE_RESOURCES need to be freed by calling - * ADM_storage_resources_destroy(). - * - * @return A valid ADM_STORAGE_RESOURCES, or NULL in case of failure - */ -ADM_storage_resources_t -ADM_storage_resources_create(); - -/** - * Destroy a ADM_STORAGE_RESOURCES created by ADM_storage_resources_create(). - * - * @param[in] res A valid ADM_STORAGE - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_storage_resources_destroy(ADM_storage_resources_t res); - -/** A transfer priority */ -typedef int ADM_transfer_priority_t; - -/** A data operation */ -typedef struct adm_data_operation* ADM_data_operation_t; - -/** - * Create an ADM_DATA_OPERATION from information about storage resources. - * - * @remark ADM_DATA_OPERATION need to be freed by calling - * ADM_storage_resources_destroy(). - * - * @return A valid ADM_DATA_OPERATION, or NULL in case of failure - */ -ADM_data_operation_t -ADM_data_operation_create(); - -/** - * Destroy a ADM_DATA_OPERATION created by ADM_storage_resources_create(). - * - * @param[in] op A valid ADM_DATA_OPERATION - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_data_operation_destroy(ADM_data_operation_t op); - -/** A data operation status */ -typedef struct { - // TODO: empty for now -} ADM_data_operation_status_t; - -/** I/O stats from a job */ -typedef struct { - // TODO: empty for now -} ADM_job_stats_t; - -/** Execution modes for an adhoc storage system */ -typedef enum { - ADM_ADHOC_MODE_IN_JOB_SHARED, - ADM_ADHOC_MODE_IN_JOB_DEDICATED, - ADM_ADHOC_MODE_SEPARATE_NEW, - ADM_ADHOC_MODE_SEPARATE_EXISTING -} ADM_adhoc_mode_t; - -/** Access modes for an adhoc storage system */ -typedef enum { - ADM_ADHOC_ACCESS_RDONLY, - ADM_ADHOC_ACCESS_WRONLY, - ADM_ADHOC_ACCESS_RDWR, -} ADM_adhoc_access_t; - -/** Abstract type to represent data distributions for adhoc storage systems */ -typedef struct adm_adhoc_data_distribution* ADM_adhoc_data_distribution_t; - -/** The context for an adhoc storage instance */ -typedef struct adm_adhoc_context* ADM_adhoc_context_t; - -/** - * Create an ADM_ADHOC_CONTEXT from information about how an adhoc storage - * instance should be executed. - * - * @remark ADM_ADHOC_CONTEXTs need to be freed by calling - * ADM_adhoc_context_destroy(). - * - * @param[in] exec_mode The adhoc storage system execution mode - * @param[in] access_type The adhoc storage system execution type - * @param[in] nodes The number of nodes for the adhoc storage system - * @param[in] walltime The adhoc storage system walltime - * @param[in] should_flush Whether the adhoc storage system should flush data in - * the background - * @return A valid ADM_ADHOC_CONTEXT if successful. NULL otherwise. - */ -ADM_adhoc_context_t -ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, - ADM_adhoc_access_t access_type, uint32_t nodes, - uint32_t walltime, bool should_flush); - -/** - * Destroy an ADM_ADHOC_CONTEXT created by ADM_adhoc_context_create(). - * - * @param[in] ctx A valid ADM_ADHOC_CONTEXT - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_adhoc_context_destroy(ADM_adhoc_context_t ctx); - -/** The context for a parallel file system storage */ -typedef struct adm_pfs_context* ADM_pfs_context_t; - -/** - * Create an ADM_PFS_CONTEXT from information about how a PFS is configured. - * - * @remark ADM_PFS_CONTEXTs need to be freed by calling - * ADM_pfs_context_destroy(). - * - * @param[in] mountpoint The PFS mount point - * @return A valid ADM_PFS_CONTEXT if successful. NULL otherwise. - */ -ADM_pfs_context_t -ADM_pfs_context_create(const char* mountpoint); - -/** - * Destroy an ADM_PFS_CONTEXT created by ADM_pfs_context_create(). - * - * @param[in] ctx A valid ADM_PFS_CONTEXT - * @return ADM_SUCCESS or corresponding ADM error code - */ -ADM_return_t -ADM_pfs_context_destroy(ADM_pfs_context_t ctx); - -/** The I/O requirements for a job */ -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] 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_t inputs[], size_t inputs_len, - ADM_dataset_t outputs[], size_t outputs_len, - ADM_storage_t 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); +// See types.h /******************************************************************************/ diff --git a/src/lib/types.h b/src/lib/types.h new file mode 100644 index 00000000..4ff80dc8 --- /dev/null +++ b/src/lib/types.h @@ -0,0 +1,498 @@ +/****************************************************************************** + * 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_TYPES_H +#define SCORD_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************/ +/* Public type and struct definitions */ +/******************************************************************************/ + +/* ----------------------------------------------------- */ +/* Error return codes */ +/* ----------------------------------------------------- */ +typedef enum { + ADM_SUCCESS = 0, + ADM_ESNAFU, + ADM_EBADARGS, + ADM_ENOMEM, + ADM_EOTHER, + ADM_ERR_MAX = 512 +} ADM_return_t; + + +/* ----------------------------------------------------- */ +/* General library types */ +/* ----------------------------------------------------- */ + +/** A RPC server */ +typedef struct adm_server* ADM_server_t; + +/** A node */ +typedef struct adm_node* ADM_node_t; + +/** A job */ +typedef struct adm_job* ADM_job_t; + + +/* ----------------------------------------------------- */ +/* Jobs */ +/* ----------------------------------------------------- */ + +/** I/O stats from a job */ +typedef struct { + // TODO: empty for now +} ADM_job_stats_t; + +/** The I/O requirements for a job */ +typedef struct adm_job_requirements* ADM_job_requirements_t; + + +/* ----------------------------------------------------- */ +/* Datasets */ +/* ----------------------------------------------------- */ + +/** A dataset */ +typedef struct adm_dataset* ADM_dataset_t; + +/** Information about a dataset */ +typedef struct adm_dataset_info* ADM_dataset_info_t; + + +/* ----------------------------------------------------- */ +/* Storage tiers */ +/* ----------------------------------------------------- */ + +/** 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; + +/** A storage tier */ +typedef struct adm_storage* ADM_storage_t; + +/** Information about resources assigned to a storage tier */ +typedef struct adm_storage_resources* ADM_storage_resources_t; + +/** Execution modes for an adhoc storage system */ +typedef enum { + ADM_ADHOC_MODE_IN_JOB_SHARED, + ADM_ADHOC_MODE_IN_JOB_DEDICATED, + ADM_ADHOC_MODE_SEPARATE_NEW, + ADM_ADHOC_MODE_SEPARATE_EXISTING +} ADM_adhoc_mode_t; + +/** Access modes for an adhoc storage system */ +typedef enum { + ADM_ADHOC_ACCESS_RDONLY, + ADM_ADHOC_ACCESS_WRONLY, + ADM_ADHOC_ACCESS_RDWR, +} ADM_adhoc_access_t; + +/** Abstract type to represent data distributions for adhoc storage systems */ +typedef struct adm_adhoc_data_distribution* ADM_adhoc_data_distribution_t; + +/** The context for an adhoc storage instance */ +typedef struct adm_adhoc_context* ADM_adhoc_context_t; + +/** The context for a parallel file system storage */ +typedef struct adm_pfs_context* ADM_pfs_context_t; + + +/* ----------------------------------------------------- */ +/* Quality of Service */ +/* ----------------------------------------------------- */ + +/** The scope affected by a QoS limit */ +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 */ +typedef enum { ADM_QOS_CLASS_BANDWIDTH, ADM_QOS_CLASS_IOPS } ADM_qos_class_t; + +/** An ADMIRE entity upon which QoS can be defined */ +typedef struct adm_qos_entity* ADM_qos_entity_t; + +/** A QoS limit */ +typedef struct adm_qos_limit* ADM_qos_limit_t; + + +/* ----------------------------------------------------- */ +/* Data transfers */ +/* ----------------------------------------------------- */ + +/** A transfer mapping */ +typedef enum { + ADM_MAPPING_ONE_TO_ONE, + ADM_MAPPING_ONE_TO_N, + ADM_MAPPING_N_TO_N +} ADM_transfer_mapping_t; + +/** A handle to a created transfer */ +typedef struct adm_transfer* ADM_transfer_t; + +/** A transfer priority */ +typedef int ADM_transfer_priority_t; + + +/* ----------------------------------------------------- */ +/* Data operations */ +/* ----------------------------------------------------- */ + +/** A data operation */ +typedef struct adm_data_operation* ADM_data_operation_t; + +/** A data operation status */ +typedef struct { + // TODO: empty for now +} ADM_data_operation_status_t; + + +/******************************************************************************/ +/* Public type-related functions */ +/******************************************************************************/ + +/* ----------------------------------------------------- */ +/* General library types */ +/* ----------------------------------------------------- */ + +/** + * 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); + +/** + * Initialize a node from a user-provided hostname/address. + * + * @remark Nodes need to be freed by calling ADM_server_destroy(). + * + * @param[in] hostname The hostname of the node. + * @return A valid ADM_server_t if successful or NULL in case of failure. + */ +ADM_node_t +ADM_node_create(const char* hostname); + +/** + * Destroy a node created by ADM_node_create(). + * + * @param[in] node A valid ADM_node_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_node_destroy(ADM_node_t node); + +/* ----------------------------------------------------- */ +/* Jobs */ +/* ----------------------------------------------------- */ + +/** + * 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] 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_t inputs[], size_t inputs_len, + ADM_dataset_t outputs[], size_t outputs_len, + ADM_storage_t 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); + + +/* ----------------------------------------------------- */ +/* Datasets */ +/* ----------------------------------------------------- */ + +/** + * 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_t +ADM_dataset_create(const char* id); + +/** + * Destroy a dataset created by ADM_dataset_create(). + * + * @param[in] dataset A valid ADM_dataset_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_dataset_destroy(ADM_dataset_t dataset); + +/** + * 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_info_destroy(). + * + * @return A valid ADM_DATASET_INFO if successful or NULL in case of + * failure. + */ +ADM_dataset_info_t +ADM_dataset_info_create(); + +/** + * Destroy a dataset created by ADM_dataset_info_create(). + * + * @param[in] dataset A valid ADM_dataset_info_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info); + + +/* ----------------------------------------------------- */ +/* Storage tiers */ +/* ----------------------------------------------------- */ + +/** + * Create a ADM_STORAGE to represent a storage tier. + * + * @remark ADM_STORAGEs need to be freed by calling ADM_storage_destroy(). + * + * @param[in] id An identifier for the storage tier + * @param[in] type The type 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. + */ +ADM_storage_t +ADM_storage_create(const char* id, ADM_storage_type_t type, void* ctx); + +/** + * Destroy a ADM_STORAGE created by ADM_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); + +/** + * Create an ADM_STORAGE_RESOURCES from information about storage resources. + * + * @remark ADM_STORAGE_RESOURCES need to be freed by calling + * ADM_storage_resources_destroy(). + * + * @return A valid ADM_STORAGE_RESOURCES, or NULL in case of failure + */ +ADM_storage_resources_t +ADM_storage_resources_create(); + +/** + * Destroy a ADM_STORAGE_RESOURCES created by ADM_storage_resources_create(). + * + * @param[in] res A valid ADM_STORAGE + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_storage_resources_destroy(ADM_storage_resources_t res); + +/** + * Create an ADM_ADHOC_CONTEXT from information about how an adhoc storage + * instance should be executed. + * + * @remark ADM_ADHOC_CONTEXTs need to be freed by calling + * ADM_adhoc_context_destroy(). + * + * @param[in] exec_mode The adhoc storage system execution mode + * @param[in] access_type The adhoc storage system execution type + * @param[in] nodes The number of nodes for the adhoc storage system + * @param[in] walltime The adhoc storage system walltime + * @param[in] should_flush Whether the adhoc storage system should flush data in + * the background + * @return A valid ADM_ADHOC_CONTEXT if successful. NULL otherwise. + */ +ADM_adhoc_context_t +ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, + ADM_adhoc_access_t access_type, uint32_t nodes, + uint32_t walltime, bool should_flush); + +/** + * Destroy an ADM_ADHOC_CONTEXT created by ADM_adhoc_context_create(). + * + * @param[in] ctx A valid ADM_ADHOC_CONTEXT + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_adhoc_context_destroy(ADM_adhoc_context_t ctx); + +/** + * Create an ADM_PFS_CONTEXT from information about how a PFS is configured. + * + * @remark ADM_PFS_CONTEXTs need to be freed by calling + * ADM_pfs_context_destroy(). + * + * @param[in] mountpoint The PFS mount point + * @return A valid ADM_PFS_CONTEXT if successful. NULL otherwise. + */ +ADM_pfs_context_t +ADM_pfs_context_create(const char* mountpoint); + +/** + * Destroy an ADM_PFS_CONTEXT created by ADM_pfs_context_create(). + * + * @param[in] ctx A valid ADM_PFS_CONTEXT + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_pfs_context_destroy(ADM_pfs_context_t ctx); + + +/* ----------------------------------------------------- */ +/* Quality of Service */ +/* ----------------------------------------------------- */ + +/** + * Create a QoS entity given a scope, a node, a dataset, or a job. + * + * @remark QoS entities need to be freed by calling ADM_qos_entity_destroy(). + * + * @param[in] scope The scope of the entity, i.e. ADM_QOS_SCOPE_DATASET, + * ADM_QOS_SCOPE_NODE, or ADM_QOS_SCOPE_JOB. + * @param[in] ... A single argument with data from either a ADM_dataset_t, + * ADM_node_t, or ADM_job_t variable. The argument must correspond properly + * to the scope provided. + * @return A valid ADM_qos_entity_t if successful or NULL in case of failure. + */ +ADM_qos_entity_t +ADM_qos_entity_create(ADM_qos_scope_t scope, ...); + +/** + * Destroy a QoS entity created by ADM_qos_entity_create(). + * + * @param[in] entity A valid ADM_qos_entity_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_qos_entity_destroy(ADM_qos_entity_t entity); + +/** + * Create a QoS limit given an entity and a QoS class. + * + * @remark QoS limits need to be freed by calling ADM_qos_limit_destroy(). + * + * @param[in] entity The entity upon which the QoS limit should be enforced. + * @param[in] cls The QoS restriction class to apply. + * @param[in] value The limit's value. + * @return A valid ADM_qos_limit_t if successful or NULL in case of failure. + */ +ADM_qos_limit_t +ADM_qos_limit_create(ADM_qos_entity_t entity, ADM_qos_class_t cls, + uint64_t value); + +/** + * Destroy a QoS limit created by ADM_qos_limit_create(). + * + * @param[in] limit A valid ADM_qos_limit_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_qos_limit_destroy(ADM_qos_limit_t limit); + + +/* ----------------------------------------------------- */ +/* Data operations */ +/* ----------------------------------------------------- */ + +/** + * Create an ADM_DATA_OPERATION from information about storage resources. + * + * @remark ADM_DATA_OPERATION need to be freed by calling + * ADM_storage_resources_destroy(). + * + * @return A valid ADM_DATA_OPERATION, or NULL in case of failure + */ +ADM_data_operation_t +ADM_data_operation_create(); + +/** + * Destroy a ADM_DATA_OPERATION created by ADM_storage_resources_create(). + * + * @param[in] op A valid ADM_DATA_OPERATION + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_data_operation_destroy(ADM_data_operation_t op); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // SCORD_TYPES_H -- GitLab