diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 8feb1a2953bbbd6047267f654751d667fb5a9712..14831a4097a529bac89e102bb143a9f0e1749fce 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_connect_data_operation.c b/examples/c/ADM_connect_data_operation.c index 6fc25c3416e4457cb60cbab57616be1487ec737a..38cc1daa724fe8446da32574a980258c72a78c64 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,23 +46,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_define_data_operation.c b/examples/c/ADM_define_data_operation.c index ac18ff92573b38b1933d39da1f74fce3df310640..ac952793cc950719b482265cba2f5531ded4a975 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -45,13 +47,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -61,7 +76,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_deploy_adhoc_storage.c b/examples/c/ADM_deploy_adhoc_storage.c index f3c324478016d4ed1ed2fd1237f12626ab39e58b..a882a80ed83fac90f6888724556544ddc3d0af98 100644 --- a/examples/c/ADM_deploy_adhoc_storage.c +++ b/examples/c/ADM_deploy_adhoc_storage.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_finalize_data_operation.c b/examples/c/ADM_finalize_data_operation.c index a38c393a0ac47162d4b868fa36cf29af75bd94f0..cc6bb5a1325be789741b90bb22fdc1eb3cbbd74c 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -45,23 +47,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_pending_transfers.c b/examples/c/ADM_get_pending_transfers.c index e089247ccf6cb9b966ac36a399a633946958b5df..fe320b25545300c7569ea440efbbffe037129497 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_qos_constraints.c b/examples/c/ADM_get_qos_constraints.c index 88497d33c049f70a224d43af551061eee927e374..366790951263cf683aa725aa61bc833b0df9d55c 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,23 +46,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_statistics.c b/examples/c/ADM_get_statistics.c index a980a2e4ff95c58cec379c58c5dbae4b3fa8819a..294cc6c25198cb0aed600f4a4dcd0f9acceeb9ae 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,23 +46,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_get_transfer_priority.c b/examples/c/ADM_get_transfer_priority.c index 8529a2f32f7834f2c40ac7e5ead997247d2540f8..c243fea926a18eef149536f03a9bd3780aefafa9 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_link_transfer_to_data_operation.c b/examples/c/ADM_link_transfer_to_data_operation.c index 476cf605275291ccbc4b571309f7615c5cad11bb..12f9024d33331b5010ae9d0481496060a599603b 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -45,23 +47,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_register_adhoc_storage.c b/examples/c/ADM_register_adhoc_storage.c index 6667bd74f2d976dd3ffeb1005a9033a02927de72..e6b7865e6a41d2fabe2549853564435c935a2aca 100644 --- a/examples/c/ADM_register_adhoc_storage.c +++ b/examples/c/ADM_register_adhoc_storage.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NADHOC_NODES 25 +#define NJOB_NODES 50 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 72744b91490e8244f6a5f406ade0dbe12df12bce..6b4b02ca7d33cbd97ab781a938ee9cc2c63b251a 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_remove_adhoc_storage.c b/examples/c/ADM_remove_adhoc_storage.c index 544ded6afffa1ea3b7298a0f5efb24f9f2afe291..95826ebd7e6d1c944df52ac30beacfc2eaded741 100644 --- a/examples/c/ADM_remove_adhoc_storage.c +++ b/examples/c/ADM_remove_adhoc_storage.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index 4cd38d544abc75b807cf54909e8616d64b5a076f..979acc06baa41cecea9f8d6cef8429345779adc3 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index 53dbe38e77e5ecf800a528d6ed287fec5667b26d..c43169f69a989a488a4a2891e67520e033844bbf 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -45,23 +47,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_set_io_resources.c b/examples/c/ADM_set_io_resources.c index 785eb001f2a8a1f71527c744a043f184b28654df..9baed9a5a74094cae1e5b2dea0fd1032db97410e 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -28,9 +28,10 @@ #include #include "common.h" - -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -45,23 +46,36 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); assert(st); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + ADM_job_requirements_t reqs = ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " @@ -70,7 +84,7 @@ main(int argc, char* argv[]) { } ADM_storage_t tier = NULL; - ADM_storage_resources_t resources = NULL; + ADM_adhoc_resources_t resources = NULL; ret = ADM_set_io_resources(server, job, tier, resources); if(ret != ADM_SUCCESS) { diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index 61248527d4c04ef13cb83b7a210b708aeef04ab2..20cc389cf3efb96adcc45fabb9acb30beff767bb 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_set_transfer_priority.c b/examples/c/ADM_set_transfer_priority.c index bdd45e70467f07713b0af3d2047415431cd5b554..77875968f72bd4085674ad8eb3638c222c60e2e6 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_transfer_datasets.c b/examples/c/ADM_transfer_datasets.c index cd5ad062cd935f8043f042be80ef376711abc631..f157c2bae142783b2f370e7f9e3636e1982e583b 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -28,11 +28,13 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 -#define NSOURCES 5 -#define NTARGETS 5 -#define NLIMITS 3 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 +#define NSOURCES 5 +#define NTARGETS 5 +#define NLIMITS 3 int main(int argc, char* argv[]) { @@ -47,13 +49,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -63,7 +78,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_update_adhoc_storage.c b/examples/c/ADM_update_adhoc_storage.c index 45a90d542cd840406cc46d8b37fbab47db9ea659..bd876193569b34afd6a6be17aeda0f780545c752 100644 --- a/examples/c/ADM_update_adhoc_storage.c +++ b/examples/c/ADM_update_adhoc_storage.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index da4ee588103fb49b04b4868829a79ccfebdb6326..be0b22b6ccb709565f1a7a9bf490c33eb8f3a965 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -28,8 +28,10 @@ #include #include "common.h" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -44,13 +46,26 @@ main(int argc, char* argv[]) { ADM_server_t server = ADM_server_create("tcp", argv[1]); ADM_job_t job; + ADM_node_t* job_nodes = prepare_nodes(NJOB_NODES); + assert(job_nodes); + ADM_node_t* adhoc_nodes = prepare_nodes(NADHOC_NODES); + assert(adhoc_nodes); ADM_dataset_t* inputs = prepare_datasets("input-dataset-%d", NINPUTS); assert(inputs); ADM_dataset_t* outputs = prepare_datasets("output-dataset-%d", NOUTPUTS); assert(outputs); + ADM_job_resources_t job_resources = + ADM_job_resources_create(job_nodes, NJOB_NODES); + assert(job_resources); + + ADM_adhoc_resources_t adhoc_resources = + ADM_adhoc_resources_create(adhoc_nodes, NADHOC_NODES); + assert(adhoc_resources); + ADM_adhoc_context_t ctx = ADM_adhoc_context_create( - ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false); + ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, adhoc_resources, + 100, false); assert(ctx); ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx); @@ -60,7 +75,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st); assert(reqs); - ADM_return_t ret = ADM_register_job(server, reqs, &job); + ADM_return_t ret = ADM_register_job(server, job_resources, reqs, &job); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_register_job() remote procedure not completed " @@ -91,7 +106,7 @@ main(int argc, char* argv[]) { ADM_job_requirements_t new_reqs = ADM_job_requirements_create( new_inputs, NINPUTS, new_outputs, NOUTPUTS, st); - ret = ADM_update_job(server, job, new_reqs); + ret = ADM_update_job(server, job, job_resources, new_reqs); if(ret != ADM_SUCCESS) { fprintf(stdout, "ADM_update_job() remote procedure not completed " diff --git a/examples/c/common.c b/examples/c/common.c index 1e47a17019c6d948aab8af4ff50c8a7e0a3c82c0..ccb779b479865771992171b8f211fe4ec260e290 100644 --- a/examples/c/common.c +++ b/examples/c/common.c @@ -5,6 +5,28 @@ #include "common.h" #include "admire_types.h" +ADM_node_t* +prepare_nodes(size_t n) { + + ADM_node_t* nodes = calloc(n, sizeof(ADM_node_t)); + + if(!nodes) { + return NULL; + } + + for(size_t i = 0; i < n; ++i) { + size_t len = snprintf(NULL, 0, "node-%02zu", i); + char* id = (char*) alloca(len + 1); + snprintf(id, len + 1, "node-%02zu", i); + nodes[i] = ADM_node_create(id); + if(!nodes[i]) { + return NULL; + } + } + + return nodes; +} + ADM_dataset_t* prepare_datasets(const char* pattern, size_t n) { diff --git a/examples/c/common.h b/examples/c/common.h index 16b383dc465e9c0f3df7489ada0cf29ea640949c..43e0536ee863c8c60df3ded0ff2c4cd88e247ef4 100644 --- a/examples/c/common.h +++ b/examples/c/common.h @@ -3,6 +3,9 @@ #include +ADM_node_t* +prepare_nodes(size_t n); + ADM_dataset_t* prepare_datasets(const char* pattern, size_t n); diff --git a/examples/cxx/ADM_register_adhoc_storage.cpp b/examples/cxx/ADM_register_adhoc_storage.cpp index 7cae76be45c927a9c075d6a851ac095eb33cb3be..542acad2f4b11a4d1c81b24777966cba598201c3 100644 --- a/examples/cxx/ADM_register_adhoc_storage.cpp +++ b/examples/cxx/ADM_register_adhoc_storage.cpp @@ -26,8 +26,10 @@ #include #include "common.hpp" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -41,24 +43,29 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; + const auto job_nodes = prepare_nodes(NJOB_NODES); + const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); auto p = std::make_unique( admire::storage::type::gekkofs, "foobar", admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false); + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false); admire::job_requirements reqs(inputs, outputs, std::move(p)); std::string user_id = "adhoc_storage_42"; const auto adhoc_storage_ctx = admire::adhoc_storage::ctx{ admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false}; + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false}; ADM_return_t ret = ADM_SUCCESS; try { - const auto job = admire::register_job(server, reqs); + const auto job = admire::register_job( + server, admire::job::resources{job_nodes}, reqs); const auto adhoc_storage = admire::register_adhoc_storage( server, job, user_id, adhoc_storage_ctx); } catch(const std::exception& e) { diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index bec2e5ed8efb63f9853d2675ec00268b55ebb27e..c75c06b04d8d8901c09c35c5bca2f50e035165dc 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -26,8 +26,10 @@ #include #include "common.hpp" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -40,18 +42,22 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; + const auto job_nodes = prepare_nodes(NJOB_NODES); + const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); auto p = std::make_unique( admire::storage::type::gekkofs, "foobar", admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false); + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false); admire::job_requirements reqs(inputs, outputs, std::move(p)); try { - [[maybe_unused]] const auto job = admire::register_job(server, reqs); + [[maybe_unused]] const auto job = admire::register_job( + server, admire::job::resources{job_nodes}, reqs); // do something with job diff --git a/examples/cxx/ADM_set_io_resources.cpp b/examples/cxx/ADM_set_io_resources.cpp index cf394845b8bc78f7660b0406c1e58171f16e0f5c..bad2726d16aeae28ff84324c87f3e045e2be559a 100644 --- a/examples/cxx/ADM_set_io_resources.cpp +++ b/examples/cxx/ADM_set_io_resources.cpp @@ -39,7 +39,7 @@ main(int argc, char* argv[]) { ADM_job_t job{}; ADM_storage_t tier{}; - ADM_storage_resources_t resources{}; + ADM_adhoc_resources_t resources{}; ADM_return_t ret = ADM_SUCCESS; try { diff --git a/examples/cxx/ADM_transfer_datasets.cpp b/examples/cxx/ADM_transfer_datasets.cpp index 7d39e932b47fa9ac97051401fa5250d9ef44341b..c48ac934872fb04bc15dc52a3e3f186f2f3721f2 100644 --- a/examples/cxx/ADM_transfer_datasets.cpp +++ b/examples/cxx/ADM_transfer_datasets.cpp @@ -26,11 +26,13 @@ #include #include "common.hpp" -#define NINPUTS 10 -#define NOUTPUTS 5 -#define NSOURCES 5 -#define NTARGETS 5 -#define NLIMITS 4 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 +#define NSOURCES 5 +#define NTARGETS 5 +#define NLIMITS 4 int main(int argc, char* argv[]) { @@ -43,6 +45,8 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; + const auto job_nodes = prepare_nodes(NJOB_NODES); + const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); @@ -54,12 +58,14 @@ main(int argc, char* argv[]) { auto p = std::make_unique( admire::storage::type::gekkofs, "foobar", admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false); + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false); admire::job_requirements reqs(inputs, outputs, std::move(p)); try { - const auto job = admire::register_job(server, reqs); + const auto job = admire::register_job( + server, admire::job::resources{job_nodes}, reqs); const auto transfer = admire::transfer_datasets( server, job, sources, targets, qos_limits, mapping); diff --git a/examples/cxx/ADM_update_job.cpp b/examples/cxx/ADM_update_job.cpp index a115691141939bb58afe4dba86dcc60e6d3e5754..70bc1c8aabfcdd04c9b98f7dde5fe19f6349b9c1 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -26,8 +26,10 @@ #include #include "common.hpp" -#define NINPUTS 10 -#define NOUTPUTS 5 +#define NJOB_NODES 50 +#define NADHOC_NODES 25 +#define NINPUTS 10 +#define NOUTPUTS 5 int main(int argc, char* argv[]) { @@ -40,13 +42,16 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; + const auto job_nodes = prepare_nodes(NJOB_NODES); + const auto adhoc_nodes = prepare_nodes(NADHOC_NODES); const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS); const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS); auto p = std::make_unique( admire::storage::type::gekkofs, "foobar", admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false); + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false); admire::job_requirements reqs{inputs, outputs, std::move(p)}; @@ -58,15 +63,17 @@ main(int argc, char* argv[]) { auto p2 = std::make_unique( admire::storage::type::gekkofs, "foobar", admire::adhoc_storage::execution_mode::separate_new, - admire::adhoc_storage::access_type::read_write, 42, 100, false); + admire::adhoc_storage::access_type::read_write, + admire::adhoc_storage::resources{adhoc_nodes}, 100, false); admire::job_requirements new_reqs{new_inputs, new_outputs, std::move(p2)}; try { - [[maybe_unused]] const auto job = admire::register_job(server, reqs); + [[maybe_unused]] const auto job = admire::register_job( + server, admire::job::resources{job_nodes}, reqs); - [[maybe_unused]] ADM_return_t ret = - admire::update_job(server, job, new_reqs); + [[maybe_unused]] ADM_return_t ret = admire::update_job( + server, job, admire::job::resources{job_nodes}, new_reqs); fmt::print( stdout, diff --git a/examples/cxx/common.cpp b/examples/cxx/common.cpp index 5461521bec7d0e0d14b8e01a109f58e969a754d7..be3585d92eb0da3812486c3f7f4936a561259164 100644 --- a/examples/cxx/common.cpp +++ b/examples/cxx/common.cpp @@ -1,5 +1,16 @@ #include "common.hpp" +std::vector +prepare_nodes(size_t n) { + std::vector nodes; + nodes.reserve(n); + for(size_t i = 0; i < n; ++i) { + nodes.emplace_back(fmt::format("node-{:02d}", i)); + } + + return nodes; +} + std::vector prepare_datasets(const std::string& pattern, size_t n) { std::vector datasets; diff --git a/examples/cxx/common.hpp b/examples/cxx/common.hpp index f3618be58a907e046b4999471b5d447046b981c7..ca08c7e514124d19a676d10ce741bd8f039dce66 100644 --- a/examples/cxx/common.hpp +++ b/examples/cxx/common.hpp @@ -4,6 +4,9 @@ #include #include +std::vector +prepare_nodes(size_t n); + std::vector prepare_datasets(const std::string& pattern, size_t n); diff --git a/src/common/api/admire_types.h b/src/common/api/admire_types.h index 0cb5db799bc79bf84ee789bfb3ec994cc3673ac3..10e419bd71fe7568106e59d6033137e94a1fbbce 100644 --- a/src/common/api/admire_types.h +++ b/src/common/api/admire_types.h @@ -61,6 +61,9 @@ typedef struct adm_server* ADM_server_t; /** A node */ typedef struct adm_node* ADM_node_t; +/** A list of nodes */ +typedef struct adm_node_list* ADM_node_list_t; + /** A job */ typedef struct adm_job* ADM_job_t; @@ -69,6 +72,9 @@ typedef struct adm_job* ADM_job_t; /* Jobs */ /* ----------------------------------------------------- */ +/** Information about resources assigned to a job */ +typedef struct adm_job_resources* ADM_job_resources_t; + /** I/O stats from a job */ typedef struct { // TODO: empty for now @@ -113,7 +119,7 @@ typedef enum { typedef struct adm_storage* ADM_storage_t; /** Information about resources assigned to a storage tier */ -typedef struct adm_storage_resources* ADM_storage_resources_t; +typedef struct adm_adhoc_resources* ADM_adhoc_resources_t; /** Execution modes for an adhoc storage system */ typedef enum { @@ -242,10 +248,57 @@ ADM_node_create(const char* hostname); ADM_return_t ADM_node_destroy(ADM_node_t node); +/** + * Create a node list from an array of ADM_NODEs and its + * length. + * + * @remark node lists need to be freed by calling ADM_node_list_destroy(). + * + * @param[in] datasets The array of nodes. + * @param[in] len The length of the array. + * @return A valid ADM_node_list_t if successful or NULL in case of + * failure. + */ +ADM_node_list_t +ADM_node_list_create(ADM_node_t nodes[], size_t len); + +/** + * Destroy a node list created by ADM_node_list_create(). + * + * @param[in] list A valid ADM_node_list_t + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_node_list_destroy(ADM_node_list_t list); + /* ----------------------------------------------------- */ /* Jobs */ /* ----------------------------------------------------- */ +/** + * Create an ADM_JOB_RESOURCES from information about storage resources. + * + * @remark ADM_JOB_RESOURCES need to be freed by calling + * ADM_job_resources_destroy(). + * + * @param[in] nodes An array of ADM_NODES describing the nodes assigned + * by the job_storage. + * @param[in] nodes_len The number of ADM_NODES stored in nodes. + * + * @return A valid ADM_JOB_RESOURCES, or NULL in case of failure + */ +ADM_job_resources_t +ADM_job_resources_create(ADM_node_t nodes[], size_t nodes_len); + +/** + * Destroy a ADM_JOB_RESOURCES created by ADM_job_resources_create(). + * + * @param[in] res A valid ADM_JOB_RESOURCES + * @return ADM_SUCCESS or corresponding ADM error code + */ +ADM_return_t +ADM_job_resources_destroy(ADM_job_resources_t res); + /** * Create a JOB_REQUIREMENTS from user-provided information. * @@ -379,24 +432,28 @@ ADM_return_t ADM_storage_destroy(ADM_storage_t storage); /** - * Create an ADM_STORAGE_RESOURCES from information about storage resources. + * Create an ADM_ADHOC_RESOURCES from information about storage resources. + * + * @remark ADM_ADHOC_RESOURCES need to be freed by calling + * ADM_adhoc_resources_destroy(). * - * @remark ADM_STORAGE_RESOURCES need to be freed by calling - * ADM_storage_resources_destroy(). + * @param[in] nodes An array of ADM_NODES describing the nodes assigned + * by the adhoc_storage. + * @param[in] nodes_len The number of ADM_NODES stored in nodes. * - * @return A valid ADM_STORAGE_RESOURCES, or NULL in case of failure + * @return A valid ADM_ADHOC_RESOURCES, or NULL in case of failure */ -ADM_storage_resources_t -ADM_storage_resources_create(); +ADM_adhoc_resources_t +ADM_adhoc_resources_create(ADM_node_t nodes[], size_t nodes_len); /** - * Destroy a ADM_STORAGE_RESOURCES created by ADM_storage_resources_create(). + * Destroy a ADM_ADHOC_RESOURCES created by ADM_adhoc_resources_create(). * - * @param[in] res A valid ADM_STORAGE + * @param[in] res A valid ADM_ADHOC_RESOURCES * @return ADM_SUCCESS or corresponding ADM error code */ ADM_return_t -ADM_storage_resources_destroy(ADM_storage_resources_t res); +ADM_adhoc_resources_destroy(ADM_adhoc_resources_t res); /** * Create an ADM_ADHOC_CONTEXT from information about how an adhoc storage @@ -407,7 +464,7 @@ ADM_storage_resources_destroy(ADM_storage_resources_t res); * * @param[in] exec_mode The adhoc storage system execution mode * @param[in] access_type The adhoc storage system execution type - * @param[in] nodes The number of nodes for the adhoc storage system + * @param[in] adhoc_resources The resources assigned for the storage system * @param[in] walltime The adhoc storage system walltime * @param[in] should_flush Whether the adhoc storage system should flush data in * the background @@ -415,7 +472,8 @@ ADM_storage_resources_destroy(ADM_storage_resources_t res); */ ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, - ADM_adhoc_access_t access_type, uint32_t nodes, + ADM_adhoc_access_t access_type, + ADM_adhoc_resources_t adhoc_resources, uint32_t walltime, bool should_flush); /** @@ -533,7 +591,7 @@ ADM_qos_limit_list_destroy(ADM_qos_limit_list_t list); * Create an ADM_DATA_OPERATION from information about storage resources. * * @remark ADM_DATA_OPERATION need to be freed by calling - * ADM_storage_resources_destroy(). + * ADM_adhoc_resources_destroy(). * * @return A valid ADM_DATA_OPERATION, or NULL in case of failure */ diff --git a/src/common/api/admire_types.hpp b/src/common/api/admire_types.hpp index 28293cd3ff1da08cfd33207871f2d39a5f992107..b6ad713623b841acc3f383a7b07282c8d11bcaea 100644 --- a/src/common/api/admire_types.hpp +++ b/src/common/api/admire_types.hpp @@ -82,6 +82,17 @@ private: struct job { + struct resources { + explicit resources(std::vector nodes); + explicit resources(ADM_job_resources_t res); + + std::vector + nodes() const; + + private: + std::vector m_nodes; + }; + explicit job(job_id id); explicit job(ADM_job_t job); job(const job&) noexcept; @@ -268,10 +279,22 @@ struct adhoc_storage : public storage { read_write = ADM_ADHOC_ACCESS_RDWR, }; + struct resources { + explicit resources(std::vector nodes); + explicit resources(ADM_adhoc_resources_t res); + + std::vector + nodes() const; + + private: + std::vector m_nodes; + }; + struct ctx : storage::ctx { ctx(execution_mode exec_mode, access_type access_type, - std::uint32_t nodes, std::uint32_t walltime, bool should_flush); + adhoc_storage::resources resources, std::uint32_t walltime, + bool should_flush); explicit ctx(ADM_adhoc_context_t ctx); @@ -279,8 +302,8 @@ struct adhoc_storage : public storage { exec_mode() const; enum access_type access_type() const; - std::uint32_t - nodes() const; + adhoc_storage::resources + resources() const; std::uint32_t walltime() const; bool @@ -289,14 +312,14 @@ struct adhoc_storage : public storage { private: execution_mode m_exec_mode; enum access_type m_access_type; - std::uint32_t m_nodes; + adhoc_storage::resources m_resources; std::uint32_t m_walltime; bool m_should_flush; }; adhoc_storage(enum storage::type type, std::string user_id, execution_mode exec_mode, access_type access_type, - std::uint32_t nodes, std::uint32_t walltime, + adhoc_storage::resources res, std::uint32_t walltime, bool should_flush); adhoc_storage(enum storage::type type, std::string user_id, ADM_adhoc_context_t ctx); @@ -627,6 +650,22 @@ struct fmt::formatter : formatter { } }; +template <> +struct fmt::formatter + : formatter { + // parse is inherited from formatter. + template + auto + format(const admire::adhoc_storage::resources& r, + FormatContext& ctx) const { + + const auto str = fmt::format("{{nodes: {}}}", r.nodes()); + + return formatter::format(str, ctx); + } +}; + + template <> struct fmt::formatter : formatter { @@ -637,8 +676,8 @@ struct fmt::formatter const auto str = fmt::format("{{execution_mode: {}, access_type: {}, " - "nodes: {}, walltime: {}, should_flush: {}}}", - c.exec_mode(), c.access_type(), c.nodes(), + "resources: {}, walltime: {}, should_flush: {}}}", + c.exec_mode(), c.access_type(), c.resources(), c.walltime(), c.should_flush()); return formatter::format(str, ctx); @@ -672,6 +711,17 @@ struct fmt::formatter : formatter { } }; +template <> +struct fmt::formatter : formatter { + // parse is inherited from formatter. + template + auto + format(const admire::job::resources& r, FormatContext& ctx) const { + const auto str = fmt::format("{{nodes: {}}}", r.nodes()); + return formatter::format(str, ctx); + } +}; + template <> struct fmt::formatter : formatter { // parse is inherited from formatter. @@ -825,6 +875,17 @@ struct fmt::formatter : formatter { } }; +template <> +struct fmt::formatter> : formatter { + // parse is inherited from formatter. + template + auto + format(const std::vector& v, FormatContext& ctx) const { + const auto str = fmt::format("[{}]", fmt::join(v, ", ")); + return formatter::format(str, ctx); + } +}; + template <> struct fmt::formatter> : formatter { diff --git a/src/common/api/convert.cpp b/src/common/api/convert.cpp index c9873ee61556fe85babcb61bcc78a5371e402339..8f6e5f80d7ae8bca94c4d96b5f50139ed737643d 100644 --- a/src/common/api/convert.cpp +++ b/src/common/api/convert.cpp @@ -35,6 +35,19 @@ ADM_transfer_create(uint64_t id); namespace { +admire::api::managed_ctype_array +as_ctype_array(const std::vector& nodes) { + + std::vector tmp; + + std::transform(nodes.cbegin(), nodes.cend(), std::back_inserter(tmp), + [](const admire::node& n) { + return ADM_node_create(n.hostname().c_str()); + }); + + return admire::api::managed_ctype_array{std::move(tmp)}; +} + admire::api::managed_ctype_array as_ctype_array(const std::vector& datasets) { @@ -57,12 +70,30 @@ convert(const node& node) { return managed_ctype(ADM_node_create(node.hostname().c_str())); } +managed_ctype +convert(const adhoc_storage::resources& res) { + + auto managed_nodes = as_ctype_array(res.nodes()); + + ADM_adhoc_resources_t c_res = ADM_adhoc_resources_create( + managed_nodes.data(), managed_nodes.size()); + + return managed_ctype{c_res, + std::move(managed_nodes)}; +} + managed_ctype convert(const adhoc_storage::ctx& ctx) { - return managed_ctype{ADM_adhoc_context_create( - static_cast(ctx.exec_mode()), - static_cast(ctx.access_type()), ctx.nodes(), - ctx.walltime(), ctx.should_flush())}; + + auto managed_adhoc_resources = convert(ctx.resources()); + + return managed_ctype{ + ADM_adhoc_context_create( + static_cast(ctx.exec_mode()), + static_cast(ctx.access_type()), + managed_adhoc_resources.get(), ctx.walltime(), + ctx.should_flush()), + std::move(managed_adhoc_resources)}; } managed_ctype @@ -129,6 +160,17 @@ convert(ADM_dataset_list_t list) { return rv; } +managed_ctype +convert(const job::resources& res) { + + auto managed_nodes = as_ctype_array(res.nodes()); + + ADM_job_resources_t c_res = ADM_job_resources_create(managed_nodes.data(), + managed_nodes.size()); + + return managed_ctype{c_res, std::move(managed_nodes)}; +} + managed_ctype convert(const admire::job_requirements& reqs) { diff --git a/src/common/api/convert.hpp b/src/common/api/convert.hpp index 2b5697910a22a980c896a0cd0aa7c1bc3c73600e..7d1e84a7af8a5c32f0ed46eacb10fa9b3c58f0c5 100644 --- a/src/common/api/convert.hpp +++ b/src/common/api/convert.hpp @@ -42,6 +42,9 @@ struct managed_ctype_array; managed_ctype convert(const node& node); +managed_ctype +convert(const adhoc_storage::resources& res); + managed_ctype convert(const adhoc_storage::ctx& ctx); @@ -60,6 +63,9 @@ convert(ADM_dataset_t datasets[], size_t datasets_len); std::vector convert(ADM_dataset_list_t list); +managed_ctype +convert(const job::resources& res); + managed_ctype convert(const admire::job_requirements& reqs); @@ -109,10 +115,66 @@ struct admire::api::managed_ctype { scord::utils::ctype_ptr m_node; }; +template <> +struct admire::api::managed_ctype_array { + + explicit managed_ctype_array(ADM_node_t* data, size_t size) + : m_nodes(data, size) {} + + explicit managed_ctype_array(std::vector&& v) + : m_nodes(v.data(), v.size()) {} + + constexpr size_t + size() const { + return m_nodes.size(); + } + + constexpr const ADM_node_t* + data() const noexcept { + return m_nodes.data(); + } + + constexpr ADM_node_t* + data() noexcept { + return m_nodes.data(); + } + + constexpr ADM_node_t* + release() noexcept { + return m_nodes.release(); + } + + scord::utils::ctype_ptr_vector m_nodes; +}; + +template <> +struct admire::api::managed_ctype { + + explicit managed_ctype(ADM_adhoc_resources_t res, + managed_ctype_array&& nodes) + : m_adhoc_resources(res), m_nodes(std::move(nodes)) {} + + ADM_adhoc_resources_t + get() const { + return m_adhoc_resources.get(); + } + + ADM_adhoc_resources_t + release() { + return m_adhoc_resources.release(); + } + + scord::utils::ctype_ptr + m_adhoc_resources; + managed_ctype_array m_nodes; +}; + template <> struct admire::api::managed_ctype { - explicit managed_ctype(ADM_adhoc_context_t ctx) : m_adhoc_context(ctx) {} + explicit managed_ctype(ADM_adhoc_context_t ctx, + managed_ctype&& resources) + : m_adhoc_context(ctx), m_adhoc_resources(std::move(resources)) {} ADM_adhoc_context_t get() const { @@ -126,6 +188,7 @@ struct admire::api::managed_ctype { scord::utils::ctype_ptr m_adhoc_context; + managed_ctype m_adhoc_resources; }; template <> @@ -219,6 +282,28 @@ struct admire::api::managed_ctype { m_list; }; +template <> +struct admire::api::managed_ctype { + + explicit managed_ctype(ADM_job_resources_t res, + managed_ctype_array&& nodes) + : m_adhoc_resources(res), m_nodes(std::move(nodes)) {} + + ADM_job_resources_t + get() const { + return m_adhoc_resources.get(); + } + + ADM_job_resources_t + release() { + return m_adhoc_resources.release(); + } + + scord::utils::ctype_ptr + m_adhoc_resources; + managed_ctype_array m_nodes; +}; + template <> struct admire::api::managed_ctype { diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index f778737d94e2a9e93c5094c3820ec1bf22dda709..3319471a12e100aeb633612bdd88e95f4033bf14 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -83,11 +83,35 @@ ADM_node_create(const char* hostname) { return NULL; } - adm_node->n_hostname = hostname; + if(hostname) { + size_t n = strlen(hostname); + adm_node->n_hostname = (const char*) calloc(n + 1, sizeof(char)); + strcpy((char*) adm_node->n_hostname, hostname); + } return adm_node; } +ADM_node_t +ADM_node_copy(ADM_node_t dst, const ADM_node_t src) { + + if(!src || !dst) { + return NULL; + } + + // copy all primitive types + *dst = *src; + + // duplicate copy any pointer types + if(src->n_hostname) { + size_t n = strlen(src->n_hostname); + dst->n_hostname = (const char*) calloc(n + 1, sizeof(char)); + strncpy((char*) dst->n_hostname, src->n_hostname, n); + } + + return dst; +} + ADM_return_t ADM_node_destroy(ADM_node_t node) { ADM_return_t ret = ADM_SUCCESS; @@ -97,10 +121,80 @@ ADM_node_destroy(ADM_node_t node) { return ADM_EBADARGS; } + if(node->n_hostname) { + free((void*) node->n_hostname); + } + free(node); return ret; } +ADM_node_list_t +ADM_node_list_create(ADM_node_t nodes[], size_t length) { + + ADM_node_list_t p = (ADM_node_list_t) malloc(sizeof(*p)); + + if(!p) { + LOGGER_ERROR("Could not allocate ADM_node_list_t") + return NULL; + } + + const char* error_msg = NULL; + + p->l_length = length; + p->l_nodes = (struct adm_node*) calloc(length, sizeof(adm_node)); + + if(!p->l_nodes) { + error_msg = "Could not allocate ADM_node_list_t"; + goto cleanup_on_error; + } + + for(size_t i = 0; i < length; ++i) { + + if(!ADM_node_copy(&p->l_nodes[i], nodes[i])) { + error_msg = "Could not allocate ADM_node_list_t"; + goto cleanup_on_error; + }; + } + + return p; + +cleanup_on_error: + if(p->l_nodes) { + free(p->l_nodes); + } + free(p); + + if(error_msg) { + LOGGER_ERROR(error_msg); + } + + return NULL; +} + +ADM_return_t +ADM_node_list_destroy(ADM_node_list_t list) { + ADM_return_t ret = ADM_SUCCESS; + + if(!list) { + LOGGER_ERROR("Invalid ADM_node_list_t") + return ADM_EBADARGS; + } + + // We cannot call ADM_node_destroy here because adm_nodes + // are stored as a consecutive array in memory. Thus, we free + // the node ids themselves and then the array. + if(list->l_nodes) { + for(size_t i = 0; i < list->l_length; ++i) { + free((void*) list->l_nodes[i].n_hostname); + } + free(list->l_nodes); + } + + free(list); + return ret; +} + ADM_dataset_t ADM_dataset_create(const char* id) { @@ -449,23 +543,45 @@ ADM_storage_destroy(ADM_storage_t storage) { return ret; } -ADM_storage_resources_t -ADM_storage_resources_create() { +ADM_adhoc_resources_t +ADM_adhoc_resources_create(ADM_node_t nodes[], size_t nodes_len) { - struct adm_storage_resources* adm_storage_resources = - (struct adm_storage_resources*) malloc( - sizeof(*adm_storage_resources)); + struct adm_adhoc_resources* adm_adhoc_resources = + (struct adm_adhoc_resources*) malloc(sizeof(*adm_adhoc_resources)); - if(!adm_storage_resources) { - LOGGER_ERROR("Could not allocate ADM_storage_resources_t"); - return NULL; + const char* error_msg = NULL; + ADM_node_list_t nodes_list = NULL; + + if(!adm_adhoc_resources) { + error_msg = "Could not allocate ADM_adhoc_resources_t"; + goto cleanup_on_error; + } + + nodes_list = ADM_node_list_create(nodes, nodes_len); + + if(!nodes_list) { + error_msg = "Could not allocate ADM_adhoc_resources_t"; + goto cleanup_on_error; + } + + adm_adhoc_resources->r_nodes = nodes_list; + + return adm_adhoc_resources; + +cleanup_on_error: + if(error_msg) { + LOGGER_ERROR(error_msg); + } + + if(adm_adhoc_resources) { + ADM_adhoc_resources_destroy(adm_adhoc_resources); } - return adm_storage_resources; + return NULL; } ADM_return_t -ADM_storage_resources_destroy(ADM_storage_resources_t res) { +ADM_adhoc_resources_destroy(ADM_adhoc_resources_t res) { ADM_return_t ret = ADM_SUCCESS; @@ -474,6 +590,10 @@ ADM_storage_resources_destroy(ADM_storage_resources_t res) { return ADM_EBADARGS; } + if(res->r_nodes) { + ADM_node_list_destroy(res->r_nodes); + } + free(res); return ret; } @@ -509,7 +629,8 @@ ADM_data_operation_destroy(ADM_data_operation_t op) { ADM_adhoc_context_t ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, - ADM_adhoc_access_t access_type, uint32_t nodes, + ADM_adhoc_access_t access_type, + ADM_adhoc_resources_t adhoc_resources, uint32_t walltime, bool should_flush) { struct adm_adhoc_context* adm_adhoc_context = @@ -522,7 +643,7 @@ ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode, adm_adhoc_context->c_mode = exec_mode; adm_adhoc_context->c_access = access_type; - adm_adhoc_context->c_nodes = nodes; + adm_adhoc_context->c_resources = adhoc_resources; adm_adhoc_context->c_walltime = walltime; adm_adhoc_context->c_should_bg_flush = should_flush; @@ -573,6 +694,62 @@ ADM_pfs_context_destroy(ADM_pfs_context_t ctx) { return ret; } +ADM_job_resources_t +ADM_job_resources_create(ADM_node_t nodes[], size_t nodes_len) { + + struct adm_job_resources* adm_job_resources = + (struct adm_job_resources*) malloc(sizeof(*adm_job_resources)); + + const char* error_msg = NULL; + ADM_node_list_t nodes_list = NULL; + + if(!adm_job_resources) { + error_msg = "Could not allocate ADM_job_resources_t"; + goto cleanup_on_error; + } + + nodes_list = ADM_node_list_create(nodes, nodes_len); + + if(!nodes_list) { + error_msg = "Could not allocate ADM_job_resources_t"; + goto cleanup_on_error; + } + + adm_job_resources->r_nodes = nodes_list; + + return adm_job_resources; + +cleanup_on_error: + if(error_msg) { + LOGGER_ERROR(error_msg); + } + + if(adm_job_resources) { + ADM_job_resources_destroy(adm_job_resources); + } + + return NULL; +} + +ADM_return_t +ADM_job_resources_destroy(ADM_job_resources_t res) { + + ADM_return_t ret = ADM_SUCCESS; + + if(!res) { + LOGGER_ERROR("Invalid ADM_job_resources_t") + return ADM_EBADARGS; + } + + if(res->r_nodes) { + ADM_node_list_destroy(res->r_nodes); + } + + free(res); + 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, @@ -938,6 +1115,23 @@ private: job_id m_id; }; +job::resources::resources(std::vector nodes) + : m_nodes(std::move(nodes)) {} + +job::resources::resources(ADM_job_resources_t res) { + assert(res->r_nodes); + m_nodes.reserve(res->r_nodes->l_length); + + for(size_t i = 0; i < res->r_nodes->l_length; ++i) { + m_nodes.emplace_back(res->r_nodes->l_nodes[i].n_hostname); + } +} + +std::vector +job::resources::nodes() const { + return m_nodes; +} + job::job(job_id id) : m_pimpl(std::make_unique(id)) {} job::job(ADM_job_t job) : job::job(job->j_id) {} @@ -1071,18 +1265,36 @@ storage::type() const { return m_type; } +adhoc_storage::resources::resources(std::vector nodes) + : m_nodes(std::move(nodes)) {} + +adhoc_storage::resources::resources(ADM_adhoc_resources_t res) { + assert(res->r_nodes); + m_nodes.reserve(res->r_nodes->l_length); + + for(size_t i = 0; i < res->r_nodes->l_length; ++i) { + m_nodes.emplace_back(res->r_nodes->l_nodes[i].n_hostname); + } +} + +std::vector +adhoc_storage::resources::nodes() const { + return m_nodes; +} + adhoc_storage::ctx::ctx(adhoc_storage::execution_mode exec_mode, adhoc_storage::access_type access_type, - std::uint32_t nodes, std::uint32_t walltime, - bool should_flush) - : m_exec_mode(exec_mode), m_access_type(access_type), m_nodes(nodes), - m_walltime(walltime), m_should_flush(should_flush) {} + adhoc_storage::resources resources, + std::uint32_t walltime, bool should_flush) + : m_exec_mode(exec_mode), m_access_type(access_type), + m_resources(std::move(resources)), m_walltime(walltime), + m_should_flush(should_flush) {} adhoc_storage::ctx::ctx(ADM_adhoc_context_t ctx) : adhoc_storage::ctx(static_cast(ctx->c_mode), static_cast(ctx->c_access), - ctx->c_nodes, ctx->c_walltime, - ctx->c_should_bg_flush) {} + adhoc_storage::resources{ctx->c_resources}, + ctx->c_walltime, ctx->c_should_bg_flush) {} adhoc_storage::execution_mode adhoc_storage::ctx::exec_mode() const { @@ -1094,9 +1306,9 @@ adhoc_storage::ctx::access_type() const { return m_access_type; } -std::uint32_t -adhoc_storage::ctx::nodes() const { - return m_nodes; +adhoc_storage::resources +adhoc_storage::ctx::resources() const { + return m_resources; } std::uint32_t @@ -1144,11 +1356,11 @@ private: adhoc_storage::adhoc_storage(enum storage::type type, std::string user_id, execution_mode exec_mode, access_type access_type, - std::uint32_t nodes, std::uint32_t walltime, - bool should_flush) + adhoc_storage::resources res, + std::uint32_t walltime, bool should_flush) : storage(type, std::move(user_id)), m_pimpl(std::make_unique(adhoc_storage::ctx{ - exec_mode, access_type, nodes, walltime, should_flush})) {} + exec_mode, access_type, res, walltime, should_flush})) {} adhoc_storage::adhoc_storage(enum storage::type type, std::string user_id, ADM_adhoc_context_t ctx) diff --git a/src/common/net/proto/rpc_types.c b/src/common/net/proto/rpc_types.c index dfdb9c2b3911d134b97d0d76743abfa1e0c8e890..8a2aa6645e09dcdafbaddddd9cf6925c7ec87577 100644 --- a/src/common/net/proto/rpc_types.c +++ b/src/common/net/proto/rpc_types.c @@ -110,7 +110,7 @@ hg_proc_ADM_dataset_t(hg_proc_t proc, void* data) { case HG_ENCODE: // find out the length of the adm_dataset object we need to send - dataset_length = *dataset ? sizeof(adm_node) : 0; + dataset_length = *dataset ? sizeof(adm_dataset) : 0; ret = hg_proc_hg_size_t(proc, &dataset_length); if(ret != HG_SUCCESS) { @@ -821,3 +821,217 @@ hg_proc_ADM_qos_entity_t(hg_proc_t proc, void* data) { return ret; } + +hg_return_t +hg_proc_ADM_node_list_t(hg_proc_t proc, void* data) { + + hg_return_t ret = HG_SUCCESS; + ADM_node_list_t* list = (ADM_node_list_t*) data; + ADM_node_list_t tmp = NULL; + + hg_size_t length = 0; + + switch(hg_proc_get_op(proc)) { + + case HG_ENCODE: + tmp = *list; + // write the length of the list + length = tmp->l_length; + ret = hg_proc_hg_size_t(proc, &tmp->l_length); + + if(ret != HG_SUCCESS) { + break; + } + + // write the list + for(size_t i = 0; i < length; ++i) { + ret = hg_proc_adm_node(proc, &tmp->l_nodes[i]); + + if(ret != HG_SUCCESS) { + break; + } + } + break; + + case HG_DECODE: { + + // find out the length of the list + ret = hg_proc_hg_size_t(proc, &length); + + if(ret != HG_SUCCESS) { + break; + } + + // loop and create list elements + tmp = (ADM_node_list_t) calloc(1, sizeof(struct adm_node_list)); + tmp->l_length = length; + tmp->l_nodes = (adm_node*) calloc(length, sizeof(adm_node)); + + for(size_t i = 0; i < length; ++i) { + ret = hg_proc_adm_node(proc, &tmp->l_nodes[i]); + + if(ret != HG_SUCCESS) { + break; + } + } + + // return the newly-created list + *list = tmp; + + break; + } + + case HG_FREE: + tmp = *list; + free(tmp->l_nodes); + free(tmp); + ret = HG_SUCCESS; + break; + } + + return ret; +} + +hg_return_t +hg_proc_ADM_adhoc_resources_t(hg_proc_t proc, void* data) { + + hg_return_t ret = HG_SUCCESS; + ADM_adhoc_resources_t* res = (ADM_adhoc_resources_t*) data; + ADM_adhoc_resources_t tmp = NULL; + hg_size_t res_length = 0; + + switch(hg_proc_get_op(proc)) { + + case HG_ENCODE: + // find out the length of the adm_adhoc_resources object we need to + // send + res_length = *res ? sizeof(adm_adhoc_resources) : 0; + ret = hg_proc_hg_size_t(proc, &res_length); + + if(ret != HG_SUCCESS) { + break; + } + + if(!res_length) { + return HG_SUCCESS; + } + + // if we actually need to send an adm_transfer object, + // write it to the mercury buffer + tmp = *res; + + ret = hg_proc_adm_adhoc_resources(proc, tmp); + + if(ret != HG_SUCCESS) { + break; + } + + break; + + case HG_DECODE: + // find out the length of the adm_transfer object + ret = hg_proc_hg_size_t(proc, &res_length); + + if(ret != HG_SUCCESS) { + break; + } + + if(!res_length) { + *res = NULL; + break; + } + + // if the received adm_adhoc_resources object was not NULL, read + // each of its fields from the mercury buffer + tmp = (adm_adhoc_resources*) calloc(1, sizeof(adm_adhoc_resources)); + + ret = hg_proc_adm_adhoc_resources(proc, tmp); + + if(ret != HG_SUCCESS) { + break; + } + + // return the newly-created ctx + *res = tmp; + break; + + case HG_FREE: + tmp = *res; + free(tmp); + break; + } + + return ret; +} + +hg_return_t +hg_proc_ADM_job_resources_t(hg_proc_t proc, void* data) { + + hg_return_t ret = HG_SUCCESS; + ADM_job_resources_t* res = (ADM_job_resources_t*) data; + ADM_job_resources_t tmp = NULL; + hg_size_t res_length = 0; + + switch(hg_proc_get_op(proc)) { + + case HG_ENCODE: + // find out the length of the adm_job_resources object we need to + // send + res_length = *res ? sizeof(adm_job_resources) : 0; + ret = hg_proc_hg_size_t(proc, &res_length); + + if(ret != HG_SUCCESS) { + break; + } + + if(!res_length) { + return HG_SUCCESS; + } + + // if we actually need to send an adm_transfer object, + // write it to the mercury buffer + tmp = *res; + + ret = hg_proc_adm_job_resources(proc, tmp); + + if(ret != HG_SUCCESS) { + break; + } + + break; + + case HG_DECODE: + // find out the length of the adm_transfer object + ret = hg_proc_hg_size_t(proc, &res_length); + + if(ret != HG_SUCCESS) { + break; + } + + if(!res_length) { + *res = NULL; + break; + } + + // if the received adm_job_resources object was not NULL, read + // each of its fields from the mercury buffer + tmp = (adm_job_resources*) calloc(1, sizeof(adm_job_resources)); + + ret = hg_proc_adm_job_resources(proc, tmp); + + if(ret != HG_SUCCESS) { + break; + } + + // return the newly-created ctx + *res = tmp; + break; + + case HG_FREE: + tmp = *res; + free(tmp); + break; + } + + return ret; +} diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index e8b44482dddca218d83f8594134a38b4d43dd38d..d4826fe81b49c12c4b0ffd5945ef011700dd58e2 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -145,22 +145,25 @@ typedef struct adm_adhoc_context { 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 resources assigned for the adhoc storage system */ + ADM_adhoc_resources_t c_resources; /** The adhoc storage system walltime */ uint32_t c_walltime; /** Whether the adhoc storage system should flush data in the background */ bool c_should_bg_flush; } adm_adhoc_context; +hg_return_t +hg_proc_ADM_adhoc_resources_t(hg_proc_t proc, void* data); + // clang-format off MERCURY_GEN_STRUCT_PROC( adm_adhoc_context, // NOLINT - ((hg_int32_t) (c_mode)) - ((hg_int32_t) (c_access)) - ((hg_uint32_t) (c_nodes)) - ((hg_uint32_t) (c_walltime)) - ((hg_bool_t) (c_should_bg_flush)) + ((hg_int32_t) (c_mode)) + ((hg_int32_t) (c_access)) + ((ADM_adhoc_resources_t) (c_resources)) + ((hg_uint32_t) (c_walltime)) + ((hg_bool_t) (c_should_bg_flush)) ) // clang-format on @@ -189,15 +192,25 @@ typedef struct adm_storage { hg_return_t hg_proc_ADM_storage_t(hg_proc_t proc, void* data); -typedef struct adm_storage_resources { - // TODO: undefined for now - int32_t placeholder; -} adm_storage_resources; + +struct adm_node_list { + /** An array of nodes */ + adm_node* l_nodes; + /** The length of the array */ + size_t l_length; +}; + +hg_return_t +hg_proc_ADM_node_list_t(hg_proc_t proc, void* data); + +typedef struct adm_adhoc_resources { + ADM_node_list_t r_nodes; +} adm_adhoc_resources; // clang-format off MERCURY_GEN_STRUCT_PROC( - adm_storage_resources, // NOLINT - ((hg_int32_t) (placeholder)) + adm_adhoc_resources, // NOLINT + ((ADM_node_list_t) (r_nodes)) ); // clang-format on @@ -250,6 +263,18 @@ MERCURY_GEN_STRUCT_PROC( ); // clang-format on +/** The resources assigned to a job */ +typedef struct adm_job_resources { + ADM_node_list_t r_nodes; +} adm_job_resources; + +// clang-format off +MERCURY_GEN_STRUCT_PROC( + adm_job_resources, // NOLINT + ((ADM_node_list_t) (r_nodes)) +); +// clang-format on + // clang-format off MERCURY_GEN_PROC( @@ -258,9 +283,13 @@ MERCURY_GEN_PROC( ((int32_t) (retval)) ); +hg_return_t +hg_proc_ADM_job_resources_t(hg_proc_t proc, void* data); + /// ADM_register_job MERCURY_GEN_PROC( ADM_register_job_in_t, + ((ADM_job_resources_t) (job_resources)) ((adm_job_requirements) (reqs)) ); @@ -275,6 +304,7 @@ MERCURY_GEN_PROC( MERCURY_GEN_PROC( ADM_update_job_in_t, ((ADM_job_t) (job)) + ((ADM_job_resources_t) (job_resources)) ((adm_job_requirements) (reqs)) ); diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 8b2af22831daa3195997ec685cfd09ebc30c186c..e94ad7f702fa40075130d4dddfa324d614807269 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -209,9 +209,10 @@ ping(const server& srv) { admire::job -register_job(const server& srv, const job_requirements& reqs) { +register_job(const server& srv, const job::resources& resources, + const job_requirements& reqs) { - const auto rv = detail::register_job(srv, reqs); + const auto rv = detail::register_job(srv, resources, reqs); if(!rv) { throw std::runtime_error(fmt::format("ADM_register_job() error: {}", @@ -219,12 +220,12 @@ register_job(const server& srv, const job_requirements& reqs) { } return rv.value(); - } ADM_return_t -update_job(const server& srv, const job& job, const job_requirements& reqs) { - return detail::update_job(srv, job, reqs); +update_job(const server& srv, const job& job, + const job::resources& job_resources, const job_requirements& reqs) { + return detail::update_job(srv, job, job_resources, reqs); } ADM_return_t @@ -457,7 +458,7 @@ set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, ADM_return_t set_io_resources(const server& srv, ADM_job_t job, ADM_storage_t tier, - ADM_storage_resources_t resources) { + ADM_adhoc_resources_t resources) { (void) srv; (void) job; (void) tier; diff --git a/src/lib/admire.h b/src/lib/admire.h index 972a8d030c1f266f793d1c2c36ffe3d699715044..355da02e58e9ed048205dd9097b2478084bafd35 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -68,17 +68,19 @@ ADM_ping(ADM_server_t server); * ADM_remove_job(). * * @param[in] server The server to which the request is directed + * @param[in] res The resources for the job. * @param[in] reqs The requirements for the job. * @param[out] job An ADM_JOB referring to the newly-registered job. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t -ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, - ADM_job_t* job); +ADM_register_job(ADM_server_t server, ADM_job_resources_t res, + ADM_job_requirements_t reqs, ADM_job_t* job); ADM_return_t -ADM_update_job(ADM_server_t server, ADM_job_t job, ADM_job_requirements_t reqs); +ADM_update_job(ADM_server_t server, ADM_job_t job, + ADM_job_resources_t job_resources, ADM_job_requirements_t reqs); ADM_return_t ADM_remove_job(ADM_server_t server, ADM_job_t job); @@ -243,7 +245,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_t tier, - ADM_storage_resources_t resources); + ADM_adhoc_resources_t resources); /** diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index 4e3c59c9d730aa37bf9301b429b0ffea3da8ceb0..d44275cb506c3b878054dc1e168764328f96a40e 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -48,10 +48,12 @@ void ping(const server& srv); admire::job -register_job(const server& srv, const job_requirements& reqs); +register_job(const server& srv, const job::resources& job_resources, + const job_requirements& reqs); ADM_return_t -update_job(const server& srv, const job&, const job_requirements& reqs); +update_job(const server& srv, const job&, const job::resources& job_resources, + const job_requirements& reqs); ADM_return_t remove_job(const server& srv, const job& job); @@ -95,7 +97,7 @@ set_dataset_information(const server& srv, ADM_job_t job, ADM_dataset_t target, ADM_return_t set_io_resources(const server& srv, ADM_job_t job, ADM_storage_t tier, - ADM_storage_resources_t resources); + ADM_adhoc_resources_t resources); ADM_return_t get_transfer_priority(const server& srv, ADM_job_t job, ADM_transfer_t transfer, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 5a36a08d4d977f7c908acac8e1b4e84515106747..cf375e0c84093724e189cb8fc40938badd337453 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -43,13 +43,14 @@ ADM_ping(ADM_server_t server) { } ADM_return_t -ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, - ADM_job_t* job) { +ADM_register_job(ADM_server_t server, ADM_job_resources_t resources, + ADM_job_requirements_t reqs, ADM_job_t* job) { const admire::server srv{server}; const auto rv = - admire::detail::register_job(srv, admire::job_requirements{reqs}); + admire::detail::register_job(srv, admire::job::resources{resources}, + admire::job_requirements{reqs}); if(!rv) { return rv.error(); @@ -62,11 +63,12 @@ ADM_register_job(ADM_server_t server, ADM_job_requirements_t reqs, ADM_return_t ADM_update_job(ADM_server_t server, ADM_job_t job, - ADM_job_requirements_t reqs) { + ADM_job_resources_t job_resources, ADM_job_requirements_t reqs) { const admire::server srv{server}; return admire::update_job(srv, admire::job{job}, + admire::job::resources{job_resources}, admire::job_requirements{reqs}); } @@ -184,7 +186,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_t tier, - ADM_storage_resources_t resources) { + ADM_adhoc_resources_t resources) { const admire::server srv{server}; diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 49ce4597537d673ddf3f238efe20230c26c8345f..e8188d7a040f45d8e523eab442602f5bbeca74fb 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -197,7 +197,9 @@ ping(const server& srv) { } tl::expected -register_job(const admire::server& srv, const admire::job_requirements& reqs) { +register_job(const admire::server& srv, + const admire::job::resources& job_resources, + const admire::job_requirements& reqs) { scord::network::rpc_client rpc_client{srv.protocol(), rpc_registration_cb}; @@ -205,13 +207,14 @@ register_job(const admire::server& srv, const admire::job_requirements& reqs) { auto endp = rpc_client.lookup(srv.address()); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{job_requirements: {}}}", + "body: {{job_resources: {}, job_requirements: {}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), reqs); + std::quoted(rpc_client.self_address()), job_resources, reqs); + auto rpc_job_resources = api::convert(job_resources); auto rpc_reqs = api::convert(reqs); - ADM_register_job_in_t in{*rpc_reqs.get()}; + ADM_register_job_in_t in{rpc_job_resources.get(), *rpc_reqs.get()}; ADM_register_job_out_t out; const auto rpc = endp.call("ADM_register_job", &in, &out); @@ -235,7 +238,8 @@ register_job(const admire::server& srv, const admire::job_requirements& reqs) { } admire::error_code -update_job(const server& srv, const job& job, const job_requirements& reqs) { +update_job(const server& srv, const job& job, + const job::resources& job_resources, const job_requirements& reqs) { scord::network::rpc_client rpc_client{srv.protocol(), rpc_registration_cb}; @@ -243,14 +247,17 @@ update_job(const server& srv, const job& job, const job_requirements& reqs) { auto endp = rpc_client.lookup(srv.address()); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{job: {}, job_requirements: {}}}", + "body: {{job: {}, job_resources: {}, job_requirements: {}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), job, reqs); + std::quoted(rpc_client.self_address()), job, job_resources, + reqs); const auto rpc_job = api::convert(job); + const auto rpc_job_resources = api::convert(job_resources); const auto rpc_reqs = api::convert(reqs); - ADM_update_job_in_t in{rpc_job.get(), *rpc_reqs.get()}; + ADM_update_job_in_t in{rpc_job.get(), rpc_job_resources.get(), + *rpc_reqs.get()}; ADM_update_job_out_t out; const auto rpc = endp.call("ADM_update_job", &in, &out); diff --git a/src/lib/detail/impl.hpp b/src/lib/detail/impl.hpp index 662f4e4778ac5f57ca573d0a0eb50674edfc6d42..2a5eb1b1725692bad7c7ac5553474cd970a9b693 100644 --- a/src/lib/detail/impl.hpp +++ b/src/lib/detail/impl.hpp @@ -35,10 +35,12 @@ admire::error_code ping(const server& srv); tl::expected -register_job(const server& srv, const job_requirements& reqs); +register_job(const server& srv, const job::resources& job_resources, + const job_requirements& reqs); admire::error_code -update_job(const server& srv, const job& job, const job_requirements& reqs); +update_job(const server& srv, const job& job, + const job::resources& job_resources, const job_requirements& reqs); admire::error_code remove_job(const server& srv, const job& job); diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 73c380f6894cc38db5e52f0affb51979aadaf508..d236c32e694e5e48acc71cd6ef35c0c1733e9676 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -98,12 +98,13 @@ ADM_register_job(hg_handle_t h) { assert(ret == HG_SUCCESS); const admire::job_requirements reqs(&in.reqs); + const admire::job::resources job_resources(in.job_resources); const auto id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{job_requirements: {}}}", + "body: {{job_resources: {}, job_requirements: {}}}", id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - reqs); + job_resources, reqs); const auto job = admire::job{42}; @@ -147,13 +148,14 @@ ADM_update_job(hg_handle_t h) { assert(ret == HG_SUCCESS); const admire::job job(in.job); + const admire::job::resources job_resources(in.job_resources); const admire::job_requirements reqs(&in.reqs); const auto id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{job: {}, job_requirements: {}}}", + "body: {{job: {}, job_resources: {}, job_requirements: {}}}", id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), job, - reqs); + job_resources, reqs); admire::error_code rv = ADM_SUCCESS; out.op_id = id;