diff --git a/CMakeLists.txt b/CMakeLists.txt index cf1a30c9019e80510d07694be1407983ad81f216..5c2feca1666bbec8127e29e876e159c558a6152c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,7 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(fmt) +set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON) ### spdlog: required for logging message(STATUS "[${PROJECT_NAME}] Downloading and building spdlog") diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index ce046dc9f4524099d4104d8c786a87040f7aabb8..478f3ed3e068539a2dd4f7d69a108595ff4b36fd 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -75,8 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_adhoc_storage() remote procedure not " - "completed successfully\n"); + fprintf(stderr, + "ADM_register_adhoc_storage() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -89,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_dataset_t* sources = NULL; @@ -107,8 +112,10 @@ main(int argc, char* argv[]) { targets_len, limits, limits_len, mapping, &tx); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_transfer_datasets() remote procedure not " - "completed successfully\n"); + fprintf(stderr, + "ADM_transfer_datasets() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -116,8 +123,10 @@ main(int argc, char* argv[]) { ret = ADM_cancel_transfer(server, job, tx); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_cancel_transfer() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_cancel_transfer() remote procedure not completed " + "successfully\n, %s", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -126,6 +135,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: + ADM_remove_job(server, job); ADM_server_destroy(server); destroy_datasets(inputs, NINPUTS); destroy_datasets(outputs, NOUTPUTS); diff --git a/examples/c/ADM_connect_data_operation.c b/examples/c/ADM_connect_data_operation.c index 230ed0b1bf220852cd2e9dbd6838557de77a6950..8b6bf16fb95347bb16c834ea49699e5aba24ada7 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -71,9 +71,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } exit_status = EXIT_SUCCESS; @@ -103,9 +107,10 @@ main(int argc, char* argv[]) { if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_connect_data_operation() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -122,6 +127,7 @@ cleanup: ADM_dataset_destroy(outputs[i]); } + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_define_data_operation.c b/examples/c/ADM_define_data_operation.c index dc4a95f5b064624c2341c6992f284e77406bfb06..0c9520abc2480dd53e99870fcc1bf22766a7a15a 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -46,7 +46,7 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -76,9 +76,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -91,9 +92,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_data_operation_t op; @@ -103,9 +107,10 @@ main(int argc, char* argv[]) { ret = ADM_define_data_operation(server, job, path, &op); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_define_data_operation() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -114,7 +119,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_deploy_adhoc_storage.c b/examples/c/ADM_deploy_adhoc_storage.c index 810043ce4551cbfab107513aba1c131dd1235ea1..05d1ad4ceda80940e163b68da81034b144bc893f 100644 --- a/examples/c/ADM_deploy_adhoc_storage.c +++ b/examples/c/ADM_deploy_adhoc_storage.c @@ -67,9 +67,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -80,9 +81,10 @@ main(int argc, char* argv[]) { ret = ADM_deploy_adhoc_storage(server, adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_deploy_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -91,7 +93,6 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_finalize_data_operation.c b/examples/c/ADM_finalize_data_operation.c index 1e0f05f9cf3dae53fc295e88e1a09201c7126abf..9b125281e0df4d2f50b9a9d95645d4425fa4c19d 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -46,7 +46,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -72,9 +72,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -91,10 +92,14 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } + ADM_data_operation_t op; const char* path = "/tmpxxxxx"; @@ -104,9 +109,10 @@ main(int argc, char* argv[]) { ret = ADM_finalize_data_operation(server, job, op, &status); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_finalize_data_operation() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -115,7 +121,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_get_pending_transfers.c b/examples/c/ADM_get_pending_transfers.c index 7a2e602cf12532d955dd146298358eb367786aa1..d0c49c43ccd3d5ed047645c87cb9346e69a5d7f5 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,18 +91,23 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } + ADM_transfer_t** tx = NULL; ret = ADM_get_pending_transfers(server, job, tx); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_get_pending_transfers() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -110,7 +116,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_get_qos_constraints.c b/examples/c/ADM_get_qos_constraints.c index 296151afded694392d73e21a5188a490a678936a..bd9ba0652f323de66d73539202100e1a68c23250 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -71,9 +71,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_qos_entity_t entity = NULL; @@ -101,9 +105,10 @@ main(int argc, char* argv[]) { ret = ADM_get_qos_constraints(server, job, entity, &limits); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_get_qos_constraints() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -112,7 +117,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_get_statistics.c b/examples/c/ADM_get_statistics.c index 431b2997f3019690bec350c093a8f0e88ce20846..17f9384232d12bf402a83fbcf37c90a831965c9d 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -71,9 +71,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,17 +91,23 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } + ADM_job_stats_t* stats = NULL; ret = ADM_get_statistics(server, job, &stats); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_get_statistics() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_get_statistics() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -109,7 +116,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_get_transfer_priority.c b/examples/c/ADM_get_transfer_priority.c index b00a6af24b11286204a400d50dc6d9eaf514121c..30593254c1ca14f0811b756967ead6c927eb3d0d 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_dataset_t* sources = NULL; @@ -108,8 +112,10 @@ main(int argc, char* argv[]) { targets_len, limits, limits_len, mapping, &tx); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_transfer_datasets() remote procedure not " - "completed successfully\n"); + fprintf(stderr, + "ADM_transfer_datasets() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -118,9 +124,10 @@ main(int argc, char* argv[]) { ret = ADM_get_transfer_priority(server, job, tx, &priority); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_get_transfer_priority() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -129,7 +136,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_link_transfer_to_data_operation.c b/examples/c/ADM_link_transfer_to_data_operation.c index 3098c25c3949bc1960fab629a51d94fad3bd8a8b..7765f5cfb3458a9a44cf613fc7e3e4c50c452908 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -46,7 +46,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -72,9 +72,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -91,9 +92,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_data_operation_t op; @@ -114,8 +118,10 @@ main(int argc, char* argv[]) { if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_transfer_datasets() remote procedure not " - "completed successfully\n"); + fprintf(stderr, + "ADM_transfer_datasets() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -125,9 +131,10 @@ main(int argc, char* argv[]) { ret = ADM_link_transfer_to_data_operation(server, job, op, tx, should_stream, args); if(ret != ADM_SUCCESS) { - fprintf(stdout, - "ADM_link_transfer_to_data_operation() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_link_transfer_to_data_operation() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -137,7 +144,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_register_adhoc_storage.c b/examples/c/ADM_register_adhoc_storage.c index be126cceb88efd837fd39664fd194a8f6625d070..70888670dd68cc5a40ea481713a277962499287c 100644 --- a/examples/c/ADM_register_adhoc_storage.c +++ b/examples/c/ADM_register_adhoc_storage.c @@ -67,9 +67,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -78,7 +79,6 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index dc2481519ac773753ee4918ebf84fb06829f9664..09147bd645471d989da165db20692f1cf8ec9af9 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,8 +91,10 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -114,6 +117,7 @@ cleanup: ADM_job_requirements_destroy(reqs); + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_register_pfs_storage.c b/examples/c/ADM_register_pfs_storage.c index 149631a4430b4bf5549ee2d05c09acf307310d79..d5c86e0be58ed0bb5f226839b4281c587d20e5c3 100644 --- a/examples/c/ADM_register_pfs_storage.c +++ b/examples/c/ADM_register_pfs_storage.c @@ -60,9 +60,10 @@ main(int argc, char* argv[]) { ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_pfs_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } diff --git a/examples/c/ADM_remove_adhoc_storage.c b/examples/c/ADM_remove_adhoc_storage.c index 1818f55559925d6e3a18200b447defdc3f529df7..98a7459674d7aae93d53cdf45955cf931a263b6d 100644 --- a/examples/c/ADM_remove_adhoc_storage.c +++ b/examples/c/ADM_remove_adhoc_storage.c @@ -67,9 +67,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -80,9 +81,10 @@ main(int argc, char* argv[]) { ret = ADM_remove_adhoc_storage(server, adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_remove_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index 9842c5c4ae6d34cfef8546213e67058422a90723..219cff71ef89f0d1d962129a72bad26e2f27f5c8 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,16 +91,21 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ret = ADM_remove_job(server, job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_remove_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_remove_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -108,7 +114,6 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_remove_pfs_storage.c b/examples/c/ADM_remove_pfs_storage.c index b24b4178714f602bc0dc07745f2dfaa18cf18e3c..ee2638b9c43e52a5837eec286064b504d5594d14 100644 --- a/examples/c/ADM_remove_pfs_storage.c +++ b/examples/c/ADM_remove_pfs_storage.c @@ -46,9 +46,10 @@ main(int argc, char* argv[]) { ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_pfs_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -59,9 +60,10 @@ main(int argc, char* argv[]) { ret = ADM_remove_pfs_storage(server, pfs_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_remove_pfs_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index 235d59862f9acfc8340040a540a3bbdb08faa6cb..4dd160daf7a934bea7c4e295a11a755688388942 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -46,7 +46,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -72,9 +72,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -91,9 +92,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_dataset_t target = NULL; @@ -101,9 +105,10 @@ main(int argc, char* argv[]) { ret = ADM_set_dataset_information(server, job, target, info); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_set_dataset_information() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -113,6 +118,7 @@ main(int argc, char* argv[]) { cleanup: + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_set_io_resources.c b/examples/c/ADM_set_io_resources.c index 2543d37dce2cbed318f96c0270d09966965ed24c..21d0c5bd60e432469cfb8bc5b579c2f219d9af65 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -71,9 +71,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_storage_t tier = NULL; @@ -100,8 +104,10 @@ main(int argc, char* argv[]) { ret = ADM_set_io_resources(server, job, tier, resources); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_set_io_resources() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_set_io_resources() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -110,7 +116,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index dd87df903a2d0d17a380091e7300c5bdee8d74ce..0cfed1bf2d99f5e31f8124734fbc57a2aca7e463 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_qos_entity_t entity = NULL; @@ -101,9 +105,10 @@ main(int argc, char* argv[]) { ret = ADM_set_qos_constraints(server, job, entity, limit); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_set_qos_constraints() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -113,6 +118,7 @@ main(int argc, char* argv[]) { cleanup: + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_set_transfer_priority.c b/examples/c/ADM_set_transfer_priority.c index 9e0629d8f893051ad62a2f1524119d5df3908994..62ce6241dd09472539597439d0e85c47266805b6 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -45,7 +45,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_dataset_t* sources = NULL; @@ -108,8 +112,10 @@ main(int argc, char* argv[]) { targets_len, limits, limits_len, mapping, &tx); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_transfer_datasets() remote procedure not " - "completed successfully\n"); + fprintf(stderr, + "ADM_transfer_datasets() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -118,9 +124,10 @@ main(int argc, char* argv[]) { ret = ADM_set_transfer_priority(server, job, tx, incr); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_set_transfer_priority() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -129,7 +136,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_transfer_datasets.c b/examples/c/ADM_transfer_datasets.c index 6c0906a2eb16c91c302d4fcc763e55b004254996..d7b2ce66e40130debb925f23b498b249fdc444b9 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -48,7 +48,7 @@ main(int argc, char* argv[]) { int exit_status = EXIT_SUCCESS; ADM_server_t server = ADM_server_create("tcp", argv[1]); - ADM_job_t job; + ADM_job_t job = NULL; ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); assert(job_nodes); ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); @@ -78,9 +78,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -93,9 +94,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_dataset_t* sources = prepare_datasets("source-dataset-%d", NSOURCES); @@ -111,8 +115,10 @@ main(int argc, char* argv[]) { NTARGETS, limits, NLIMITS, mapping, &tx); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_transfer_datasets() remote procedure not " - "completed successfully\n"); + fprintf(stderr, + "ADM_transfer_datasets() remote procedure not " + "completed successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -121,7 +127,7 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index 7cb64a291e1b1be2793e0a6f394102e8b85575f4..b20bf515d4456caf6c38bfd0635ed4800014cf39 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -67,9 +67,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -80,9 +81,10 @@ main(int argc, char* argv[]) { ret = ADM_update_adhoc_storage(server, ctx, adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_update_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -91,7 +93,6 @@ main(int argc, char* argv[]) { "successfully\n"); cleanup: - ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index afeb521cfe00b0508411e9a0b759d2c9bba718d8..a9ecf2c1aa7b775d1500ee9b454597d8d205591b 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -75,9 +75,10 @@ main(int argc, char* argv[]) { server, name, ADM_STORAGE_GEKKOFS, ctx, &adhoc_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_adhoc_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -90,9 +91,12 @@ main(int argc, char* argv[]) { ret = ADM_register_job(server, job_resources, reqs, slurm_job_id, &job); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_register_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_register_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; + goto cleanup; } ADM_dataset_t new_inputs[NINPUTS]; @@ -121,8 +125,10 @@ main(int argc, char* argv[]) { ret = ADM_update_job(server, job, job_resources, new_reqs); if(ret != ADM_SUCCESS) { - fprintf(stdout, "ADM_update_job() remote procedure not completed " - "successfully\n"); + fprintf(stderr, + "ADM_update_job() remote procedure not completed " + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -140,6 +146,7 @@ cleanup: ADM_dataset_destroy(outputs[i]); } + ADM_remove_job(server, job); ADM_server_destroy(server); exit(exit_status); } diff --git a/examples/c/ADM_update_pfs_storage.c b/examples/c/ADM_update_pfs_storage.c index 96a95afa7cdde038d4257a161891298a33b4448d..90d0cf75ec65e6479b27e84f315e661371999458 100644 --- a/examples/c/ADM_update_pfs_storage.c +++ b/examples/c/ADM_update_pfs_storage.c @@ -46,9 +46,10 @@ main(int argc, char* argv[]) { ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_register_pfs_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } @@ -59,9 +60,10 @@ main(int argc, char* argv[]) { ret = ADM_update_pfs_storage(server, ctx, pfs_storage); if(ret != ADM_SUCCESS) { - fprintf(stdout, + fprintf(stderr, "ADM_update_pfs_storage() remote procedure not completed " - "successfully\n"); + "successfully: %s\n", + ADM_strerror(ret)); exit_status = EXIT_FAILURE; goto cleanup; } diff --git a/src/common/abt_cxx/shared_mutex.hpp b/src/common/abt_cxx/shared_mutex.hpp index 59964fb20e6888e71b0b57ebe1cc9f0d3775b667..1ec4b23041d8fb52a0ee647f87fcc7186a2fda09 100644 --- a/src/common/abt_cxx/shared_mutex.hpp +++ b/src/common/abt_cxx/shared_mutex.hpp @@ -22,6 +22,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ +#include #include #include #include @@ -59,9 +60,30 @@ public: // copy constructor and copy assignment operator are disabled shared_mutex(const shared_mutex&) = delete; + shared_mutex(shared_mutex&& rhs) noexcept { + m_lock = rhs.m_lock; + rhs.m_lock = ABT_RWLOCK_NULL; + } + shared_mutex& operator=(const shared_mutex&) = delete; + shared_mutex& + operator=(shared_mutex&& other) noexcept { + + if(this == &other) { + return *this; + } + + [[maybe_unused]] const auto ret = ABT_rwlock_free(&m_lock); + assert(ret == ABT_SUCCESS); + m_lock = other.m_lock; + other.m_lock = ABT_RWLOCK_NULL; + + return *this; + } + + // Exclusive ownership void diff --git a/src/common/api/CMakeLists.txt b/src/common/api/CMakeLists.txt index d81fa158c7e803ce5e83c0f8042bea9f393f62ab..b4c84785b3292f598fbad65bf6302ea91c2ed945 100644 --- a/src/common/api/CMakeLists.txt +++ b/src/common/api/CMakeLists.txt @@ -25,12 +25,12 @@ add_library(_api_types STATIC) target_sources(_api_types PUBLIC admire_types.h admire_types.hpp PRIVATE - types.cpp convert.hpp convert.cpp) + types.cpp convert.hpp convert.cpp internal_types.hpp) target_include_directories(_api_types PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(_api_types PRIVATE - Margo::Margo common::logger PUBLIC fmt::fmt) + Margo::Margo common::logger PUBLIC fmt::fmt common::abt_cxx) set_property(TARGET _api_types PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/common/api/admire_types.h b/src/common/api/admire_types.h index cfb056a76dcb32d04f3bef894a06dff3d78c07a3..40de25e7173059c480d4de512660da8ecc7db70f 100644 --- a/src/common/api/admire_types.h +++ b/src/common/api/admire_types.h @@ -46,9 +46,10 @@ typedef enum { ADM_ESNAFU, ADM_EBADARGS, ADM_ENOMEM, - ADM_EOTHER, ADM_EEXISTS, ADM_ENOENT, + ADM_EADHOC_BUSY, + ADM_EOTHER, ADM_ERR_MAX = 512 } ADM_return_t; diff --git a/src/common/api/admire_types.hpp b/src/common/api/admire_types.hpp index 104adb3005e9bffe077b5cf1a6fa7bf87e11dc3c..2f9b345592067612538e4d5e8229e9139554c109 100644 --- a/src/common/api/admire_types.hpp +++ b/src/common/api/admire_types.hpp @@ -42,6 +42,11 @@ using job_id = std::uint64_t; using slurm_job_id = std::uint64_t; using transfer_id = std::uint64_t; +namespace internal { +struct job_info; +struct adhoc_storage_info; +} // namespace internal + struct server { server(std::string protocol, std::string address); @@ -343,15 +348,12 @@ struct adhoc_storage : public storage { operator=(adhoc_storage&&) noexcept; ~adhoc_storage() override; - const std::uint64_t& - id() const; - - std::uint64_t& - id(); - std::shared_ptr context() const final; + void + update(admire::adhoc_storage::ctx new_ctx); + private: class impl; std::unique_ptr m_pimpl; @@ -452,15 +454,18 @@ struct fmt::formatter : formatter { case ADM_ENOMEM: name = "ADM_ENOMEM"; break; - case ADM_EOTHER: - name = "ADM_EOTHER"; - break; case ADM_EEXISTS: name = "ADM_EEXISTS"; break; case ADM_ENOENT: name = "ADM_ENOENT"; break; + case ADM_EADHOC_BUSY: + name = "ADM_EADHOC_BUSY"; + break; + case ADM_EOTHER: + name = "ADM_EOTHER"; + break; default: break; } @@ -636,28 +641,13 @@ struct fmt::formatter> } }; -template <> -struct fmt::formatter> - : formatter { - - // parse is inherited from formatter. - template - auto - format(const std::optional& v, FormatContext& ctx) const { - return formatter::format( - v ? std::to_string(v.value()) : "none", ctx); - } -}; - -template <> -struct fmt::formatter> - : formatter { +template +struct fmt::formatter> : formatter { // parse is inherited from formatter. template auto - format(const std::optional& v, - FormatContext& ctx) const { + format(const std::optional& v, FormatContext& ctx) const { return formatter::format( v ? fmt::format("{}", v.value()) : "none", ctx); } diff --git a/src/common/api/internal_types.hpp b/src/common/api/internal_types.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a1c1fdde46a33538912ef8629c3d6eb173138592 --- /dev/null +++ b/src/common/api/internal_types.hpp @@ -0,0 +1,106 @@ +/****************************************************************************** + * 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_INTERNAL_TYPES_HPP +#define SCORD_INTERNAL_TYPES_HPP + +#include + +namespace admire::internal { + +struct job_info { + explicit job_info(admire::job job) : m_job(std::move(job)) {} + + job_info(admire::job job, admire::job::resources resources, + admire::job_requirements requirements) + : m_job(std::move(job)), m_resources(std::move(resources)), + m_requirements(std::move(requirements)) {} + + admire::job + job() const { + return m_job; + } + + std::optional + resources() const { + return m_resources; + } + + std::optional + requirements() const { + return m_requirements; + } + + admire::job m_job; + std::optional m_resources; + std::optional m_requirements; +}; + +struct adhoc_storage_info { + + explicit adhoc_storage_info(admire::adhoc_storage adhoc_storage) + : m_adhoc_storage(std::move(adhoc_storage)) {} + + admire::adhoc_storage + adhoc_storage() const { + return m_adhoc_storage; + } + + admire::error_code + add_client_info(std::shared_ptr job_info) { + + scord::abt::unique_lock lock(m_info_mutex); + + if(m_client_info) { + LOGGER_ERROR("adhoc storage {} already has a client", + m_adhoc_storage.id()); + return ADM_EADHOC_BUSY; + } + + m_client_info = std::move(job_info); + + return ADM_SUCCESS; + } + + void + remove_client_info() { + scord::abt::unique_lock lock(m_info_mutex); + m_client_info.reset(); + } + + std::shared_ptr + client_info() const { + scord::abt::shared_lock lock(m_info_mutex); + return m_client_info; + } + + admire::adhoc_storage m_adhoc_storage; + std::shared_ptr m_client_info; + mutable scord::abt::shared_mutex m_info_mutex; +}; + +} // namespace admire::internal + +#endif // SCORD_INTERNAL_TYPES_HPP diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index aa3065a439ad9c3a67fff9637e8ba2dea8e50732..1eee0ec0e9393662121ee4b3d6d67d334668cdde 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -31,6 +31,7 @@ #include #include #include "admire_types.hpp" +#include "internal_types.hpp" /******************************************************************************/ /* C Type definitions and related functions */ @@ -1346,7 +1347,7 @@ adhoc_storage::ctx::should_flush() const { class adhoc_storage::impl { public: - explicit impl(adhoc_storage::ctx ctx) : m_id(), m_ctx(std::move(ctx)) {} + explicit impl(adhoc_storage::ctx ctx) : m_ctx(std::move(ctx)) {} impl(const impl& rhs) = default; impl(impl&& rhs) = default; impl& @@ -1355,23 +1356,17 @@ public: operator=(impl&&) noexcept = default; ~impl() = default; - const std::uint64_t& - id() const { - return m_id; - } - - std::uint64_t& - id() { - return m_id; - } - adhoc_storage::ctx context() const { return m_ctx; } + void + update(adhoc_storage::ctx new_ctx) { + m_ctx = std::move(new_ctx); + } + private: - std::uint64_t m_id; adhoc_storage::ctx m_ctx; }; @@ -1411,20 +1406,16 @@ adhoc_storage::operator=(const adhoc_storage& other) noexcept { adhoc_storage& adhoc_storage::operator=(adhoc_storage&&) noexcept = default; -const std::uint64_t& -adhoc_storage::id() const { - return m_pimpl->id(); -} - -std::uint64_t& -adhoc_storage::id() { - return m_pimpl->id(); -} - std::shared_ptr adhoc_storage::context() const { return std::make_shared(m_pimpl->context()); } + +void +adhoc_storage::update(admire::adhoc_storage::ctx new_ctx) { + return m_pimpl->update(std::move(new_ctx)); +} + adhoc_storage::~adhoc_storage() = default; pfs_storage::ctx::ctx(std::filesystem::path mount_point) diff --git a/src/lib/errors.c b/src/lib/errors.c index 87985cae37e26d145d6d12baafee89d0eaaf1d8b..3a57c92698f2c0a9ec9acae0b122c9466815531f 100644 --- a/src/lib/errors.c +++ b/src/lib/errors.c @@ -29,9 +29,13 @@ const char* const adm_errlist[ADM_ERR_MAX + 1] = { [ADM_ESNAFU] = "Internal error", [ADM_EBADARGS] = "Bad arguments", [ADM_ENOMEM] = "Cannot allocate memory", + [ADM_EEXISTS] = "Entity already exists", + [ADM_ENOENT] = "Entity does not exist", + [ADM_EADHOC_BUSY] = "Adhoc storage already in use", [ADM_EOTHER] = "Undetermined error", + /* fallback */ [ADM_ERR_MAX] = "Unknown error", diff --git a/src/scord/adhoc_storage_manager.hpp b/src/scord/adhoc_storage_manager.hpp index 7f519f08505a403b4177fc3835fb85ae48120fe1..78b22ba976ef6f2b7e3dbbe986fc9f2d1bd50d34 100644 --- a/src/scord/adhoc_storage_manager.hpp +++ b/src/scord/adhoc_storage_manager.hpp @@ -27,6 +27,8 @@ #define SCORD_ADHOC_STORAGE_MANAGER_HPP #include +#include +#include #include #include #include @@ -38,19 +40,21 @@ namespace scord { struct adhoc_storage_manager : scord::utils::singleton { - tl::expected + tl::expected, + admire::error_code> create(enum admire::adhoc_storage::type type, const std::string& name, const admire::adhoc_storage::ctx& ctx) { static std::atomic_uint64_t current_id; - admire::job_id id = current_id++; + std::uint64_t id = current_id++; abt::unique_lock lock(m_adhoc_storages_mutex); if(const auto it = m_adhoc_storages.find(id); it == m_adhoc_storages.end()) { const auto& [it_adhoc, inserted] = m_adhoc_storages.emplace( - id, admire::adhoc_storage{type, name, current_id++, ctx}); + id, std::make_shared( + admire::adhoc_storage{type, name, id, ctx})); if(!inserted) { LOGGER_ERROR("{}: Emplace failed", __FUNCTION__); @@ -65,18 +69,18 @@ struct adhoc_storage_manager : scord::utils::singleton { } admire::error_code - update(std::uint64_t id, admire::adhoc_storage::ctx ctx) { + update(std::uint64_t id, admire::adhoc_storage::ctx new_ctx) { abt::unique_lock lock(m_adhoc_storages_mutex); if(const auto it = m_adhoc_storages.find(id); it != m_adhoc_storages.end()) { - const auto& current_adhoc = it->second; + const auto current_adhoc_info = it->second; + auto tmp_adhoc = current_adhoc_info->adhoc_storage(); + tmp_adhoc.update(std::move(new_ctx)); - it->second = admire::adhoc_storage{ - current_adhoc.type(), current_adhoc.name(), - current_adhoc.id(), std::move(ctx)}; + *it->second = admire::internal::adhoc_storage_info{tmp_adhoc}; return ADM_SUCCESS; } @@ -84,8 +88,9 @@ struct adhoc_storage_manager : scord::utils::singleton { return ADM_ENOENT; } - tl::expected - find(admire::job_id id) { + tl::expected, + admire::error_code> + find(std::uint64_t id) { abt::shared_lock lock(m_adhoc_storages_mutex); @@ -100,7 +105,7 @@ struct adhoc_storage_manager : scord::utils::singleton { } admire::error_code - remove(admire::job_id id) { + remove(std::uint64_t id) { abt::unique_lock lock(m_adhoc_storages_mutex); @@ -116,12 +121,38 @@ struct adhoc_storage_manager : scord::utils::singleton { return ADM_ENOENT; } + admire::error_code + add_client_info(std::uint64_t adhoc_id, + std::shared_ptr job_info) { + + if(auto am_result = find(adhoc_id); am_result.has_value()) { + const auto adhoc_storage_info = am_result.value(); + return adhoc_storage_info->add_client_info(std::move(job_info)); + } + + return ADM_ENOENT; + } + + admire::error_code + remove_client_info(std::uint64_t adhoc_id) { + if(auto am_result = find(adhoc_id); am_result.has_value()) { + const auto adhoc_storage_info = *am_result; + adhoc_storage_info->remove_client_info(); + return ADM_SUCCESS; + } + + return ADM_ENOENT; + } + + private: friend class scord::utils::singleton; adhoc_storage_manager() = default; mutable abt::shared_mutex m_adhoc_storages_mutex; - std::unordered_map m_adhoc_storages; + std::unordered_map> + m_adhoc_storages; }; } // namespace scord diff --git a/src/scord/job_manager.hpp b/src/scord/job_manager.hpp index 45d7d493cfb113a44c5d51c30dde9a86b792cbd4..186434e66e8061f2e08eec5d506d3e1600195565 100644 --- a/src/scord/job_manager.hpp +++ b/src/scord/job_manager.hpp @@ -26,6 +26,7 @@ #define SCORD_JOB_MANAGER_HPP #include +#include #include #include #include @@ -36,37 +37,11 @@ namespace scord { -struct job_info { - explicit job_info(admire::job job) : m_job(std::move(job)) {} - job_info(admire::job job, admire::job::resources resources, - admire::job_requirements requirements) - : m_job(std::move(job)), m_resources(std::move(resources)), - m_requirements(std::move(requirements)) {} - - admire::job - job() const { - return m_job; - } - - std::optional - resources() const { - return m_resources; - } - - std::optional - requirements() const { - return m_requirements; - } - - admire::job m_job; - std::optional m_resources; - std::optional m_requirements; -}; struct job_manager : scord::utils::singleton { - - tl::expected + tl::expected, + admire::error_code> create(admire::slurm_job_id slurm_id, admire::job::resources job_resources, admire::job_requirements job_requirements) { @@ -76,10 +51,11 @@ struct job_manager : scord::utils::singleton { abt::unique_lock lock(m_jobs_mutex); if(const auto it = m_jobs.find(id); it == m_jobs.end()) { - const auto& [it_job, inserted] = - m_jobs.emplace(id, job_info{admire::job{id, slurm_id}, - std::move(job_resources), - std::move(job_requirements)}); + const auto& [it_job, inserted] = m_jobs.emplace( + id, + std::make_shared( + admire::job{id, slurm_id}, std::move(job_resources), + std::move(job_requirements))); if(!inserted) { LOGGER_ERROR("{}: Emplace failed", __FUNCTION__); @@ -102,9 +78,11 @@ struct job_manager : scord::utils::singleton { if(const auto it = m_jobs.find(id); it != m_jobs.end()) { const auto& current_job_info = it->second; - it->second = - job_info{current_job_info.job(), std::move(job_resources), - std::move(job_requirements)}; + const auto new_job_info = admire::internal::job_info{ + current_job_info->job(), std::move(job_resources), + std::move(job_requirements)}; + + *it->second = new_job_info; return ADM_SUCCESS; } @@ -112,7 +90,8 @@ struct job_manager : scord::utils::singleton { return ADM_ENOENT; } - tl::expected + tl::expected, + admire::error_code> find(admire::job_id id) { abt::shared_lock lock(m_jobs_mutex); @@ -125,19 +104,20 @@ struct job_manager : scord::utils::singleton { return tl::make_unexpected(ADM_ENOENT); } - admire::error_code + tl::expected, + admire::error_code> remove(admire::job_id id) { abt::unique_lock lock(m_jobs_mutex); - if(m_jobs.count(id) != 0) { - m_jobs.erase(id); - return ADM_SUCCESS; + if(const auto it = m_jobs.find(id); it != m_jobs.end()) { + auto nh = m_jobs.extract(it); + return nh.mapped(); } LOGGER_ERROR("Job '{}' was not registered or was already deleted", id); - return ADM_ENOENT; + return tl::make_unexpected(ADM_ENOENT); } private: @@ -145,7 +125,9 @@ private: job_manager() = default; mutable abt::shared_mutex m_jobs_mutex; - std::unordered_map m_jobs; + std::unordered_map> + m_jobs; }; } // namespace scord diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 6a4987d6be9dcdfe5e1b276011639f477440a4b3..fdf084afb65bc6b0e21fe547f6256f613861d7d2 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -99,27 +99,37 @@ ADM_register_job(hg_handle_t h) { job_resources, reqs, slurm_id); admire::error_code ec = ADM_SUCCESS; - + std::optional out_job; auto& jm = scord::job_manager::instance(); - const auto rv = jm.create(slurm_id, job_resources, reqs); - if(rv) { - const auto& job = rv->job(); - out.op_id = rpc_id; - out.retval = ec; - out.job = admire::api::convert(job).release(); + if(const auto jm_result = jm.create(slurm_id, job_resources, reqs); + jm_result.has_value()) { + + const auto& job_info = jm_result.value(); + + // if the job requires an adhoc storage instance, inform the appropriate + // adhoc_storage instance (if registered) + if(reqs.adhoc_storage()) { + const auto adhoc_id = reqs.adhoc_storage()->id(); + auto& adhoc_manager = scord::adhoc_storage_manager::instance(); + ec = adhoc_manager.add_client_info(adhoc_id, job_info); + } + + out_job = job_info->job(); } else { LOGGER_ERROR("rpc id: {} error_msg: \"Error creating job: {}\"", rpc_id, - rv.error()); - out.op_id = rpc_id; - out.retval = rv.error(); - out.job = nullptr; + jm_result.error()); + ec = jm_result.error(); } + out.op_id = rpc_id; + out.retval = ec; + out.job = out_job ? admire::api::convert(*out_job).release() : nullptr; + LOGGER_INFO("rpc id: {} name: {} to: {} <= " "body: {{retval: {}, job: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - ec, rv ? fmt::format("{}", rv->job()) : "none"); + ec, out_job); ret = margo_respond(h, &out); assert(ret == HG_SUCCESS); @@ -211,12 +221,24 @@ ADM_remove_job(hg_handle_t h) { rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), job); + admire::error_code ec = ADM_SUCCESS; auto& jm = scord::job_manager::instance(); - const auto ec = jm.remove(job.id()); + const auto jm_result = jm.remove(job.id()); - if(ec != ADM_SUCCESS) { + if(jm_result) { + // if the job was using an adhoc storage instance, inform the + // appropriate adhoc_storage that the job is no longer its client + const auto& job_info = jm_result.value(); + + if(const auto adhoc_storage = job_info->requirements()->adhoc_storage(); + adhoc_storage.has_value()) { + auto& adhoc_manager = scord::adhoc_storage_manager::instance(); + ec = adhoc_manager.remove_client_info(adhoc_storage->id()); + } + } else { LOGGER_ERROR("rpc id: {} error_msg: \"Error removing job: {}\"", rpc_id, - ec); + job.id()); + ec = jm_result.error(); } out.op_id = rpc_id; @@ -264,25 +286,25 @@ ADM_register_adhoc_storage(hg_handle_t h) { rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), name, type, ctx); - auto& adhoc_manager = scord::adhoc_storage_manager::instance(); - const auto rv = adhoc_manager.create(type, name, ctx); - admire::error_code ec = ADM_SUCCESS; + std::uint64_t out_adhoc_id = 0; + auto& adhoc_manager = scord::adhoc_storage_manager::instance(); - if(rv) { - const auto& adhoc_storage = rv.value(); - out.op_id = rpc_id; - out.retval = ec; - out.id = adhoc_storage.id(); + if(const auto am_result = adhoc_manager.create(type, name, ctx); + am_result.has_value()) { + const auto& adhoc_storage_info = am_result.value(); + out_adhoc_id = adhoc_storage_info->adhoc_storage().id(); } else { LOGGER_ERROR("rpc id: {} error_msg: \"Error creating adhoc_storage: " "{}\"", - rpc_id, rv.error()); - out.op_id = rpc_id; - out.retval = ec; - out.id = 0; + rpc_id, am_result.error()); + ec = am_result.error(); } + out.op_id = rpc_id; + out.retval = ec; + out.id = out_adhoc_id; + LOGGER_INFO("rpc id: {} name: {} to: {} => " "body: {{retval: {}, id: {}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)),