diff --git a/examples/c/ADM_cancel_transfer.c b/examples/c/ADM_cancel_transfer.c index 9d215cce8009645f2e8218147933850ff090eb10..ce046dc9f4524099d4104d8c786a87040f7aabb8 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 bcdbaa122723cc683ec8243ba14020d377f37e69..230ed0b1bf220852cd2e9dbd6838557de77a6950 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 c23257fe8e24170604cc140055686222fb78b0de..dc4a95f5b064624c2341c6992f284e77406bfb06 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 a8d653cf0bd48b7ce30873730e8cfae6ce95a0d8..1e0f05f9cf3dae53fc295e88e1a09201c7126abf 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 e7d2f0d46c86f6f913cde99d782f03d2439d51c8..7a2e602cf12532d955dd146298358eb367786aa1 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 f167aa1627759a8512b3ebdfd048bb504b9b5bfe..296151afded694392d73e21a5188a490a678936a 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 78ce2ee2f21a69187201dfac7b47f04ec7e50b7f..431b2997f3019690bec350c093a8f0e88ce20846 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 e3c639420d28688996392252fb33b16459fc492e..b00a6af24b11286204a400d50dc6d9eaf514121c 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 7aec6040ef44d4450125e167ca656be83b641e48..3098c25c3949bc1960fab629a51d94fad3bd8a8b 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 482607d147a27198e4f82ada823fd80e91aa769c..dc2481519ac773753ee4918ebf84fb06829f9664 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 dd0dabcc3bb30f426f746a92c9f3be28198e4f83..9842c5c4ae6d34cfef8546213e67058422a90723 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 34c9a5ab80a79b5dd75b660bf15cbe30dd7a7fdb..235d59862f9acfc8340040a540a3bbdb08faa6cb 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 2fd90e6fd571aa05cc10d33145d345b485e01bff..2543d37dce2cbed318f96c0270d09966965ed24c 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 58fdb024c3936265ac953b886adc781b98545cdd..dd87df903a2d0d17a380091e7300c5bdee8d74ce 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 eee815a63a8e6722cb569ed3fa3915d150bb53d5..9e0629d8f893051ad62a2f1524119d5df3908994 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 19464da5ffe2134621732f90b35652ce7d3f3a46..6c0906a2eb16c91c302d4fcc763e55b004254996 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 7ee5e5a82442eaba6c32773a4653bba292c06ea8..afeb521cfe00b0508411e9a0b759d2c9bba718d8 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 Binary files /dev/null and b/examples/c/foo differ diff --git a/examples/c/foo.c b/examples/c/foo.c new file mode 100644 index 0000000000000000000000000000000000000000..682b7968176b85a7f4d1e479a0c800cb9c4906a4 --- /dev/null +++ b/examples/c/foo.c @@ -0,0 +1,32 @@ +#include + +#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 05f07f5e0816d04c3cca859ba4fc4e3f216aaca4..463e319d748403c1322aff349805575c9bc28ad7 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 682de21665d16ceb45ed017537aa7eba6ce0516c..0bd8fb87884603d49e711abaa515c2d34de625e7 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 e74ed3509cd889bf9c578893f3d516af7d81af03..88842c19865c0c8f8eb05fd45742e45a086cd5ba 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 b08f50e17b45796ed91a5c6139199e9d8c0b94b9..bb26ec3e22665a8fcaadc9acc8bcff76683ea039 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 e8d60befeda3a3f674b016d4cb61472145519252..104adb3005e9bffe077b5cf1a6fa7bf87e11dc3c 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 341ccb4f525dd8a319964f6006fe1a33fbc8fcde..6f1e131a77ff0f1933ffd7e3f36be14099c9ddc0 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 6dfda147cc9b1e3b07886531c497106d1212abc9..aa3065a439ad9c3a67fff9637e8ba2dea8e50732 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 2f7e536a8bddbf29a3b7631bc348f6501274b1cb..a3a7e2c626d10c2550d476c1569ae2fe2fcd2a94 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 71efcccc2425c02605ce43bd70e56804447c8d20..183db2dcebce2acf129278cc88cb4f865961362b 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 3ebb14fd4c8d7f924524df1eb07c8dc8e9aa0513..e54c5430873030cfa784697963a79cb6ff6e7fa9 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 d3e2722467aa78f97837f31c621cdf9f8069b730..56b01c58f896c91799a42c7616d7ce10d78d596a 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 0bd3e7f605fe5f6f0ed1606db66952f9549fe901..21d43f148c9173ccf034f170df3aa93f56a84ef5 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 3782210394a9c2263df11251faa430d114b76257..5bb433c030acba6316fec718a7412b27ec333a8e 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 4c7092945ae38be3146337bc8fa7555db4246406..4a07acb696a88ed47daf94cb7d4e00334c9f9e5f 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 214673960b64a90745ab9d9b6d84c8e6adc4417f..2f97d0f93af3b06e038ed4bf8095ddf1f2dd139f 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 497d728afa3d7550d256b92ff2969921f7b6a088..afc8ae844c546aeaf9d630499308eb2a9fe0bbb4 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();