From 9a02cba367603c3e065aec36a486231b83e90b6b Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 17 Oct 2022 13:58:32 +0200 Subject: [PATCH] ADM_register_job: Add slurm_id as call argument --- examples/c/ADM_cancel_transfer.c | 3 +- examples/c/ADM_connect_data_operation.c | 3 +- examples/c/ADM_define_data_operation.c | 3 +- examples/c/ADM_finalize_data_operation.c | 3 +- examples/c/ADM_get_pending_transfers.c | 3 +- examples/c/ADM_get_qos_constraints.c | 3 +- examples/c/ADM_get_statistics.c | 3 +- examples/c/ADM_get_transfer_priority.c | 3 +- .../c/ADM_link_transfer_to_data_operation.c | 3 +- examples/c/ADM_register_job.c | 3 +- examples/c/ADM_remove_job.c | 3 +- examples/c/ADM_set_dataset_information.c | 3 +- examples/c/ADM_set_io_resources.c | 3 +- examples/c/ADM_set_qos_constraints.c | 3 +- examples/c/ADM_set_transfer_priority.c | 3 +- examples/c/ADM_transfer_datasets.c | 3 +- examples/c/ADM_update_job.c | 3 +- examples/c/foo | Bin 0 -> 16936 bytes examples/c/foo.c | 32 ++++++++++++++++++ examples/cxx/ADM_register_job.cpp | 2 +- examples/cxx/ADM_remove_job.cpp | 2 +- examples/cxx/ADM_transfer_datasets.cpp | 2 +- examples/cxx/ADM_update_job.cpp | 2 +- src/common/api/admire_types.hpp | 9 +++-- src/common/api/convert.cpp | 4 +-- src/common/api/types.cpp | 23 ++++++++++--- src/common/net/proto/rpc_types.h | 5 ++- src/lib/admire.cpp | 4 +-- src/lib/admire.h | 4 ++- src/lib/admire.hpp | 2 +- src/lib/c_wrapper.cpp | 11 +++--- src/lib/detail/impl.cpp | 14 ++++---- src/lib/detail/impl.hpp | 2 +- src/scord/job_manager.hpp | 16 +++++---- src/scord/rpc_handlers.cpp | 8 +++-- 35 files changed, 138 insertions(+), 55 deletions(-) create mode 100755 examples/c/foo create mode 100644 examples/c/foo.c diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 9d215cce..ce046dc9 100644 --- a/examples/c/ADM_cancel_transfer.c +++ b/examples/c/ADM_cancel_transfer.c @@ -85,7 +85,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_connect_data_operation.c b/examples/c/ADM_connect_data_operation.c index bcdbaa12..230ed0b1 100644 --- a/examples/c/ADM_connect_data_operation.c +++ b/examples/c/ADM_connect_data_operation.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_define_data_operation.c b/examples/c/ADM_define_data_operation.c index c23257fe..dc4a95f5 100644 --- a/examples/c/ADM_define_data_operation.c +++ b/examples/c/ADM_define_data_operation.c @@ -87,7 +87,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_finalize_data_operation.c b/examples/c/ADM_finalize_data_operation.c index a8d653cf..1e0f05f9 100644 --- a/examples/c/ADM_finalize_data_operation.c +++ b/examples/c/ADM_finalize_data_operation.c @@ -87,7 +87,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_get_pending_transfers.c b/examples/c/ADM_get_pending_transfers.c index e7d2f0d4..7a2e602c 100644 --- a/examples/c/ADM_get_pending_transfers.c +++ b/examples/c/ADM_get_pending_transfers.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_get_qos_constraints.c b/examples/c/ADM_get_qos_constraints.c index f167aa16..296151af 100644 --- a/examples/c/ADM_get_qos_constraints.c +++ b/examples/c/ADM_get_qos_constraints.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_get_statistics.c b/examples/c/ADM_get_statistics.c index 78ce2ee2..431b2997 100644 --- a/examples/c/ADM_get_statistics.c +++ b/examples/c/ADM_get_statistics.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_get_transfer_priority.c b/examples/c/ADM_get_transfer_priority.c index e3c63942..b00a6af2 100644 --- a/examples/c/ADM_get_transfer_priority.c +++ b/examples/c/ADM_get_transfer_priority.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_link_transfer_to_data_operation.c b/examples/c/ADM_link_transfer_to_data_operation.c index 7aec6040..3098c25c 100644 --- a/examples/c/ADM_link_transfer_to_data_operation.c +++ b/examples/c/ADM_link_transfer_to_data_operation.c @@ -87,7 +87,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_register_job.c b/examples/c/ADM_register_job.c index 482607d1..dc248151 100644 --- a/examples/c/ADM_register_job.c +++ b/examples/c/ADM_register_job.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_remove_job.c b/examples/c/ADM_remove_job.c index dd0dabcc..9842c5c4 100644 --- a/examples/c/ADM_remove_job.c +++ b/examples/c/ADM_remove_job.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_set_dataset_information.c b/examples/c/ADM_set_dataset_information.c index 34c9a5ab..235d5986 100644 --- a/examples/c/ADM_set_dataset_information.c +++ b/examples/c/ADM_set_dataset_information.c @@ -87,7 +87,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_set_io_resources.c b/examples/c/ADM_set_io_resources.c index 2fd90e6f..2543d37d 100644 --- a/examples/c/ADM_set_io_resources.c +++ b/examples/c/ADM_set_io_resources.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_set_qos_constraints.c b/examples/c/ADM_set_qos_constraints.c index 58fdb024..dd87df90 100644 --- a/examples/c/ADM_set_qos_constraints.c +++ b/examples/c/ADM_set_qos_constraints.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_set_transfer_priority.c b/examples/c/ADM_set_transfer_priority.c index eee815a6..9e0629d8 100644 --- a/examples/c/ADM_set_transfer_priority.c +++ b/examples/c/ADM_set_transfer_priority.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_transfer_datasets.c b/examples/c/ADM_transfer_datasets.c index 19464da5..6c0906a2 100644 --- a/examples/c/ADM_transfer_datasets.c +++ b/examples/c/ADM_transfer_datasets.c @@ -89,7 +89,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/ADM_update_job.c b/examples/c/ADM_update_job.c index 7ee5e5a8..afeb521c 100644 --- a/examples/c/ADM_update_job.c +++ b/examples/c/ADM_update_job.c @@ -86,7 +86,8 @@ main(int argc, char* argv[]) { inputs, NINPUTS, outputs, NOUTPUTS, adhoc_storage); assert(reqs); - ret = ADM_register_job(server, job_resources, reqs, &job); + uint64_t slurm_job_id = 42; + 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 " diff --git a/examples/c/foo b/examples/c/foo new file mode 100755 index 0000000000000000000000000000000000000000..4bdcfa339c4dd941bd13d5a42d938cd19bef3e39 GIT binary patch literal 16936 zcmeHOZ)_aJ6`%9Pjswa00!eW~ORi~<0@N4VI3Y=8xO05Y8aX5cyMRj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n=W~!t4L=X=Z z9e!H)P=5x5-s~7^@J=#QqnZyg<#miIma?2D`XyYnc3^#;e=-fA%$|6?z}O~a?D}^o z|4iw7l|Au$h_P;D?D{;PWg1{XMVa(|^XHe^@Cn-OGxKvOT6p9Qr&DVtO?< zj6{#nAKG*D&XP)VK=r-8&d42X+6F?-EGr4)5@i`Pw z-(~;2j^lIc92k23D6t;5|I@(e7A<}C|DSO+5gsBXTVj2tbx^kJi;xm-HYxjI6RgMl zQYaI~{&`;QSNcwQ@?}rUm478}6|w$x7Gh>t-%h#j*hNFi;J6wXzJS6YF0K!ci%WoU i-R=4(>BWTffWtWZHA~HZ4^+~>d5bBr+M(cJ#lHYR#yq + +#define LOG_ERROR(mid, msg) + +int +main() { + ADM_server_t scord_server = + ADM_server_create("tcp", "ofi+tcp://127.0.0.1:52000"); + if(!scord_server) { + LOG_ERROR(mid, "Could not initialize Scord server"); + } + + ADM_adhoc_context_t adhoc_ctx; + adhoc_ctx.c_mode = ADM_ADHOC_MODE_IN_JOB_SHARED; + adhoc_ctx.c_access = ADM_ADHOC_ACCESS_RDWR; + adhoc_ctx.c_nodes = 3; + adhoc_ctx.c_walltime = 3600; + adhoc_ctx.c_should_bg_flush = 0; + + /* no inputs or outputs */ + ADM_job_requirements_t scord_reqs; + scord_reqs = ADM_job_requirements_create(NULL, 0, NULL, 0, &adhoc_ctx); + if(!scord_reqs) { + LOG_ERROR(mid, "Could not initialize Scord job requirements"); + } + + ADM_job_t scord_job; + ADM_register_job(scord_server, scord_reqs, &scord_job); + + ADM_job_requirements_destroy(scord_reqs); + ADM_server_destroy(scord_server); +} diff --git a/examples/cxx/ADM_register_job.cpp b/examples/cxx/ADM_register_job.cpp index 05f07f5e..463e319d 100644 --- a/examples/cxx/ADM_register_job.cpp +++ b/examples/cxx/ADM_register_job.cpp @@ -62,7 +62,7 @@ main(int argc, char* argv[]) { admire::job_requirements reqs(inputs, outputs, adhoc_storage); [[maybe_unused]] const auto job = admire::register_job( - server, admire::job::resources{job_nodes}, reqs); + server, admire::job::resources{job_nodes}, reqs, 0); // do something with job diff --git a/examples/cxx/ADM_remove_job.cpp b/examples/cxx/ADM_remove_job.cpp index 682de216..0bd8fb87 100644 --- a/examples/cxx/ADM_remove_job.cpp +++ b/examples/cxx/ADM_remove_job.cpp @@ -37,7 +37,7 @@ main(int argc, char* argv[]) { admire::server server{"tcp", argv[1]}; - admire::job job{42}; + admire::job job{42, 42}; try { [[maybe_unused]] const auto ret = admire::remove_job(server, job); diff --git a/examples/cxx/ADM_transfer_datasets.cpp b/examples/cxx/ADM_transfer_datasets.cpp index e74ed350..88842c19 100644 --- a/examples/cxx/ADM_transfer_datasets.cpp +++ b/examples/cxx/ADM_transfer_datasets.cpp @@ -69,7 +69,7 @@ main(int argc, char* argv[]) { admire::job_requirements reqs(inputs, outputs, adhoc_storage); const auto job = admire::register_job( - server, admire::job::resources{job_nodes}, reqs); + server, admire::job::resources{job_nodes}, reqs, 0); 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 b08f50e1..bb26ec3e 100644 --- a/examples/cxx/ADM_update_job.cpp +++ b/examples/cxx/ADM_update_job.cpp @@ -64,7 +64,7 @@ main(int argc, char* argv[]) { try { [[maybe_unused]] const auto job = admire::register_job( - server, admire::job::resources{job_nodes}, reqs); + server, admire::job::resources{job_nodes}, reqs, 0); [[maybe_unused]] ADM_return_t ret = admire::update_job( server, job, admire::job::resources{job_nodes}, new_reqs); diff --git a/src/common/api/admire_types.hpp b/src/common/api/admire_types.hpp index e8d60bef..104adb30 100644 --- a/src/common/api/admire_types.hpp +++ b/src/common/api/admire_types.hpp @@ -39,6 +39,7 @@ namespace admire { using error_code = ADM_return_t; using job_id = std::uint64_t; +using slurm_job_id = std::uint64_t; using transfer_id = std::uint64_t; struct server { @@ -95,7 +96,7 @@ struct job { std::vector m_nodes; }; - explicit job(job_id id); + job(job_id id, slurm_job_id slurm_id); explicit job(ADM_job_t job); job(const job&) noexcept; job(job&&) noexcept; @@ -108,6 +109,9 @@ struct job { job_id id() const; + slurm_job_id + slurm_id() const; + private: class impl; std::unique_ptr m_pimpl; @@ -472,7 +476,8 @@ struct fmt::formatter : formatter { auto format(const admire::job& j, FormatContext& ctx) const { return formatter::format( - fmt::format("{{id: {}}}", j.id()), ctx); + fmt::format("{{id: {}, slurm_id: {}}}", j.id(), j.slurm_id()), + ctx); } }; diff --git a/src/common/api/convert.cpp b/src/common/api/convert.cpp index 341ccb4f..6f1e131a 100644 --- a/src/common/api/convert.cpp +++ b/src/common/api/convert.cpp @@ -28,7 +28,7 @@ // forward declarations ADM_job_t -ADM_job_create(uint64_t id); +ADM_job_create(uint64_t id, uint64_t slurm_id); ADM_transfer_t ADM_transfer_create(uint64_t id); @@ -203,7 +203,7 @@ convert(const admire::job_requirements& reqs) { managed_ctype convert(const job& j) { - return managed_ctype(ADM_job_create(j.id())); + return managed_ctype(ADM_job_create(j.id(), j.slurm_id())); } job diff --git a/src/common/api/types.cpp b/src/common/api/types.cpp index 6dfda147..aa3065a4 100644 --- a/src/common/api/types.cpp +++ b/src/common/api/types.cpp @@ -850,10 +850,11 @@ ADM_job_requirements_destroy(ADM_job_requirements_t reqs) { * useful to have for internal purposes * * @param [in] id The identifier for this job + * @param [in] slurm_id The SLURM_JOB_ID for this job * @return A valid JOB HANDLE or NULL in case of failure. */ ADM_job_t -ADM_job_create(uint64_t id) { +ADM_job_create(uint64_t id, uint64_t slurm_id) { struct adm_job* adm_job = (struct adm_job*) malloc(sizeof(struct adm_job)); @@ -863,6 +864,7 @@ ADM_job_create(uint64_t id) { } adm_job->j_id = id; + adm_job->j_slurm_id = slurm_id; return adm_job; } @@ -1100,7 +1102,8 @@ node::hostname() const { class job::impl { public: - explicit impl(job_id id) : m_id(id) {} + impl(job_id id, slurm_job_id slurm_job_id) + : m_id(id), m_slurm_job_id(slurm_job_id) {} impl(const impl& rhs) = default; impl(impl&& rhs) = default; impl& @@ -1113,8 +1116,14 @@ public: return m_id; } + slurm_job_id + slurm_id() const { + return m_slurm_job_id; + } + private: job_id m_id; + slurm_job_id m_slurm_job_id; }; job::resources::resources(std::vector nodes) @@ -1134,9 +1143,10 @@ job::resources::nodes() const { return m_nodes; } -job::job(job_id id) : m_pimpl(std::make_unique(id)) {} +job::job(job_id id, slurm_job_id slurm_job_id) + : m_pimpl(std::make_unique(id, slurm_job_id)) {} -job::job(ADM_job_t job) : job::job(job->j_id) {} +job::job(ADM_job_t job) : job::job(job->j_id, job->j_slurm_id) {} job::job(job&&) noexcept = default; @@ -1159,6 +1169,11 @@ job::id() const { return m_pimpl->id(); } +job_id +job::slurm_id() const { + return m_pimpl->slurm_id(); +} + class transfer::impl { public: diff --git a/src/common/net/proto/rpc_types.h b/src/common/net/proto/rpc_types.h index 2f7e536a..a3a7e2c6 100644 --- a/src/common/net/proto/rpc_types.h +++ b/src/common/net/proto/rpc_types.h @@ -70,12 +70,14 @@ MERCURY_GEN_STRUCT_PROC( typedef struct adm_job { uint64_t j_id; + uint64_t j_slurm_id; } adm_job; // clang-format off MERCURY_GEN_STRUCT_PROC( adm_job, // NOLINT ((hg_uint64_t) (j_id)) + ((hg_uint64_t) (j_slurm_id)) ); // clang-format on @@ -291,8 +293,9 @@ 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_resources_t) (job_resources)) ((adm_job_requirements) (reqs)) + ((hg_uint64_t) (slurm_job_id)) ); MERCURY_GEN_PROC( diff --git a/src/lib/admire.cpp b/src/lib/admire.cpp index 71efcccc..183db2dc 100644 --- a/src/lib/admire.cpp +++ b/src/lib/admire.cpp @@ -210,9 +210,9 @@ ping(const server& srv) { admire::job register_job(const server& srv, const job::resources& resources, - const job_requirements& reqs) { + const job_requirements& reqs, admire::slurm_job_id slurm_job_id) { - const auto rv = detail::register_job(srv, resources, reqs); + const auto rv = detail::register_job(srv, resources, reqs, slurm_job_id); if(!rv) { throw std::runtime_error(fmt::format("ADM_register_job() error: {}", diff --git a/src/lib/admire.h b/src/lib/admire.h index 3ebb14fd..e54c5430 100644 --- a/src/lib/admire.h +++ b/src/lib/admire.h @@ -70,13 +70,15 @@ ADM_ping(ADM_server_t server); * @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[in] slurm_id The SLURM_JOB_ID for the newly-registered job. * @param[out] job An ADM_JOB referring to the newly-registered job. * @return Returns ADM_SUCCESS if the remote procedure has completed * successfully. */ ADM_return_t ADM_register_job(ADM_server_t server, ADM_job_resources_t res, - ADM_job_requirements_t reqs, ADM_job_t* job); + ADM_job_requirements_t reqs, uint64_t slurm_id, + ADM_job_t* job); ADM_return_t ADM_update_job(ADM_server_t server, ADM_job_t job, diff --git a/src/lib/admire.hpp b/src/lib/admire.hpp index d3e27224..56b01c58 100644 --- a/src/lib/admire.hpp +++ b/src/lib/admire.hpp @@ -49,7 +49,7 @@ ping(const server& srv); admire::job register_job(const server& srv, const job::resources& job_resources, - const job_requirements& reqs); + const job_requirements& reqs, admire::slurm_job_id slurm_id); ADM_return_t update_job(const server& srv, const job&, const job::resources& job_resources, diff --git a/src/lib/c_wrapper.cpp b/src/lib/c_wrapper.cpp index 0bd3e7f6..21d43f14 100644 --- a/src/lib/c_wrapper.cpp +++ b/src/lib/c_wrapper.cpp @@ -43,14 +43,15 @@ ADM_ping(ADM_server_t server) { } ADM_return_t -ADM_register_job(ADM_server_t server, ADM_job_resources_t resources, - 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, uint64_t slurm_id, + ADM_job_t* job) { const admire::server srv{server}; - const auto rv = - admire::detail::register_job(srv, admire::job::resources{resources}, - admire::job_requirements{reqs}); + const auto rv = admire::detail::register_job( + srv, admire::job::resources{res}, admire::job_requirements{reqs}, + slurm_id); if(!rv) { return rv.error(); diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 37822103..5bb433c0 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -197,9 +197,8 @@ ping(const server& srv) { } tl::expected -register_job(const admire::server& srv, - const admire::job::resources& job_resources, - const admire::job_requirements& reqs) { +register_job(const server& srv, const job::resources& job_resources, + const job_requirements& reqs, admire::slurm_job_id slurm_id) { scord::network::rpc_client rpc_client{srv.protocol(), rpc_registration_cb}; @@ -207,14 +206,17 @@ register_job(const admire::server& srv, auto endp = rpc_client.lookup(srv.address()); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{job_resources: {}, job_requirements: {}}}", + "body: {{job_resources: {}, job_requirements: {}, slurm_id: " + "{}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), job_resources, reqs); + std::quoted(rpc_client.self_address()), job_resources, reqs, + slurm_id); auto rpc_job_resources = api::convert(job_resources); auto rpc_reqs = api::convert(reqs); - ADM_register_job_in_t in{rpc_job_resources.get(), *rpc_reqs.get()}; + ADM_register_job_in_t in{rpc_job_resources.get(), *rpc_reqs.get(), + slurm_id}; ADM_register_job_out_t out; const auto rpc = endp.call("ADM_register_job", &in, &out); diff --git a/src/lib/detail/impl.hpp b/src/lib/detail/impl.hpp index 4c709294..4a07acb6 100644 --- a/src/lib/detail/impl.hpp +++ b/src/lib/detail/impl.hpp @@ -36,7 +36,7 @@ ping(const server& srv); tl::expected register_job(const server& srv, const job::resources& job_resources, - const job_requirements& reqs); + const job_requirements& reqs, admire::slurm_job_id slurm_id); admire::error_code update_job(const server& srv, const job& job, diff --git a/src/scord/job_manager.hpp b/src/scord/job_manager.hpp index 21467396..2f97d0f9 100644 --- a/src/scord/job_manager.hpp +++ b/src/scord/job_manager.hpp @@ -69,7 +69,7 @@ struct job_manager : scord::utils::singleton { tl::expected - create(admire::job::resources job_resources, + create(admire::slurm_job_id slurm_id, admire::job::resources job_resources, admire::job_requirements job_requirements) { abt::unique_lock lock(m_jobs_mutex); @@ -78,9 +78,10 @@ struct job_manager : scord::utils::singleton { admire::job_id id = current_id++; 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}, std::move(job_resources), - std::move(job_requirements)}); + const auto& [it_job, inserted] = + m_jobs.emplace(id, job_info{admire::job{id, slurm_id}, + std::move(job_resources), + std::move(job_requirements)}); if(!inserted) { LOGGER_ERROR("{}: Emplace failed", __FUNCTION__); @@ -101,8 +102,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()) { - it->second = job_info{admire::job{id}, std::move(job_resources), - std::move(job_requirements)}; + const auto& current_job_info = it->second; + + it->second = + job_info{current_job_info.job(), std::move(job_resources), + std::move(job_requirements)}; return ADM_SUCCESS; } diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 497d728a..afc8ae84 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -99,17 +99,19 @@ ADM_register_job(hg_handle_t h) { const admire::job_requirements reqs(&in.reqs); const admire::job::resources job_resources(in.job_resources); + const admire::slurm_job_id slurm_id = in.slurm_job_id; const auto rpc_id = remote_procedure::new_id(); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{job_resources: {}, job_requirements: {}}}", + "body: {{job_resources: {}, job_requirements: {}, slurm_id: " + "{}}}", rpc_id, std::quoted(__FUNCTION__), std::quoted(get_address(h)), - job_resources, reqs); + job_resources, reqs, slurm_id); admire::error_code ec = ADM_SUCCESS; auto& jm = scord::job_manager::instance(); - const auto rv = jm.create(job_resources, reqs); + const auto rv = jm.create(slurm_id, job_resources, reqs); if(rv) { const auto& job = rv->job(); -- GitLab