diff --git a/src/lib/scord/types.hpp b/src/lib/scord/types.hpp index 8d2d23410e9d511c1878e626c007294eb723a2c5..731d478fa4f6f25556035eda1611a56b41787f17 100644 --- a/src/lib/scord/types.hpp +++ b/src/lib/scord/types.hpp @@ -128,8 +128,8 @@ using slurm_job_id = std::uint64_t; using transfer_id = std::uint64_t; namespace internal { -struct job_info; -struct adhoc_storage_info; +struct job_metadata; +struct adhoc_storage_metadata; } // namespace internal struct server { diff --git a/src/scord/adhoc_storage_manager.hpp b/src/scord/adhoc_storage_manager.hpp index c504151b03781e012cdf6f33e075b997886b745b..e0bccc0797761273df57d674e6fb7d6a9eb66bfa 100644 --- a/src/scord/adhoc_storage_manager.hpp +++ b/src/scord/adhoc_storage_manager.hpp @@ -74,7 +74,7 @@ namespace scord { struct adhoc_storage_manager { - tl::expected, + tl::expected, scord::error_code> create(enum scord::adhoc_storage::type type, const std::string& name, const scord::adhoc_storage::ctx& ctx, @@ -88,10 +88,11 @@ struct adhoc_storage_manager { if(const auto it = m_adhoc_storages.find(id); it == m_adhoc_storages.end()) { const auto& [it_adhoc, inserted] = m_adhoc_storages.emplace( - id, std::make_shared( - ::generate_adhoc_uuid(type), - scord::adhoc_storage{type, name, id, ctx, - resources})); + id, + std::make_shared( + ::generate_adhoc_uuid(type), + scord::adhoc_storage{type, name, id, ctx, + resources})); if(!inserted) { LOGGER_ERROR("{}: Emplace failed", __FUNCTION__); @@ -121,7 +122,7 @@ struct adhoc_storage_manager { return scord::error_code::no_such_entity; } - tl::expected, + tl::expected, scord::error_code> find(std::uint64_t id) { @@ -156,7 +157,7 @@ struct adhoc_storage_manager { scord::error_code add_client_info(std::uint64_t adhoc_id, - std::shared_ptr job_info) { + std::shared_ptr job_info) { if(auto am_result = find(adhoc_id); am_result.has_value()) { const auto adhoc_storage_info = am_result.value(); @@ -181,7 +182,7 @@ struct adhoc_storage_manager { private: mutable abt::shared_mutex m_adhoc_storages_mutex; std::unordered_map> + std::shared_ptr> m_adhoc_storages; }; diff --git a/src/scord/internal_types.cpp b/src/scord/internal_types.cpp index 2a87141fd69d5b5e8dc6bcf207dc1853b6f6d89a..eb82d0c09d5e075e02d25818bd7127362a1753fa 100644 --- a/src/scord/internal_types.cpp +++ b/src/scord/internal_types.cpp @@ -29,48 +29,48 @@ namespace scord::internal { -job_info::job_info(scord::job job, scord::job::resources resources, - scord::job::requirements requirements) +job_metadata::job_metadata(scord::job job, scord::job::resources resources, + scord::job::requirements requirements) : m_job(std::move(job)), m_resources(std::move(resources)), m_requirements(std::move(requirements)) {} scord::job -job_info::job() const { +job_metadata::job() const { return m_job; } std::optional -job_info::resources() const { +job_metadata::resources() const { return m_resources; } void -job_info::update(scord::job::resources resources) { +job_metadata::update(scord::job::resources resources) { m_resources = std::move(resources); } -adhoc_storage_info::adhoc_storage_info(std::string uuid, - scord::adhoc_storage adhoc_storage) +adhoc_storage_metadata::adhoc_storage_metadata( + std::string uuid, scord::adhoc_storage adhoc_storage) : m_uuid(std::move(uuid)), m_adhoc_storage(std::move(adhoc_storage)) {} scord::adhoc_storage const& -adhoc_storage_info::adhoc_storage() const { +adhoc_storage_metadata::adhoc_storage() const { return m_adhoc_storage; } std::string const& -adhoc_storage_info::uuid() const { +adhoc_storage_metadata::uuid() const { return m_uuid; } void -adhoc_storage_info::update(scord::adhoc_storage::resources new_resources) { +adhoc_storage_metadata::update(scord::adhoc_storage::resources new_resources) { m_adhoc_storage.update(std::move(new_resources)); } scord::error_code -adhoc_storage_info::add_client_info( - std::shared_ptr job_info) { +adhoc_storage_metadata::add_client_info( + std::shared_ptr job_info) { scord::abt::unique_lock lock(m_info_mutex); @@ -86,27 +86,27 @@ adhoc_storage_info::add_client_info( } void -adhoc_storage_info::remove_client_info() { +adhoc_storage_metadata::remove_client_info() { scord::abt::unique_lock lock(m_info_mutex); m_client_info.reset(); } -std::shared_ptr -adhoc_storage_info::client_info() const { +std::shared_ptr +adhoc_storage_metadata::client_info() const { scord::abt::shared_lock lock(m_info_mutex); return m_client_info; } -pfs_storage_info::pfs_storage_info(scord::pfs_storage pfs_storage) +pfs_storage_metadata::pfs_storage_metadata(scord::pfs_storage pfs_storage) : m_pfs_storage(std::move(pfs_storage)) {} scord::pfs_storage -pfs_storage_info::pfs_storage() const { +pfs_storage_metadata::pfs_storage() const { return m_pfs_storage; } void -pfs_storage_info::update(scord::pfs_storage::ctx pfs_context) { +pfs_storage_metadata::update(scord::pfs_storage::ctx pfs_context) { m_pfs_storage.update(std::move(pfs_context)); } diff --git a/src/scord/internal_types.hpp b/src/scord/internal_types.hpp index f141a81e5e6fbc35349bcae8daf48bc660ff4272..08fb6c0de42e17132c093bc1a6593f74ba176fa8 100644 --- a/src/scord/internal_types.hpp +++ b/src/scord/internal_types.hpp @@ -32,10 +32,10 @@ namespace scord::internal { -struct job_info { +struct job_metadata { - job_info(scord::job job, scord::job::resources resources, - scord::job::requirements requirements); + job_metadata(scord::job job, scord::job::resources resources, + scord::job::requirements requirements); scord::job job() const; @@ -56,9 +56,10 @@ struct job_info { std::optional m_requirements; }; -struct adhoc_storage_info { +struct adhoc_storage_metadata { - adhoc_storage_info(std::string uuid, scord::adhoc_storage adhoc_storage); + adhoc_storage_metadata(std::string uuid, + scord::adhoc_storage adhoc_storage); scord::adhoc_storage const& adhoc_storage() const; @@ -70,23 +71,23 @@ struct adhoc_storage_info { update(scord::adhoc_storage::resources new_resources); scord::error_code - add_client_info(std::shared_ptr job_info); + add_client_info(std::shared_ptr job_info); void remove_client_info(); - std::shared_ptr + std::shared_ptr client_info() const; std::string m_uuid; scord::adhoc_storage m_adhoc_storage; - std::shared_ptr m_client_info; + std::shared_ptr m_client_info; mutable scord::abt::shared_mutex m_info_mutex; }; -struct pfs_storage_info { +struct pfs_storage_metadata { - explicit pfs_storage_info(scord::pfs_storage pfs_storage); + explicit pfs_storage_metadata(scord::pfs_storage pfs_storage); scord::pfs_storage pfs_storage() const; @@ -95,7 +96,7 @@ struct pfs_storage_info { update(scord::pfs_storage::ctx pfs_context); scord::pfs_storage m_pfs_storage; - std::shared_ptr m_client_info; + std::shared_ptr m_client_info; }; } // namespace scord::internal diff --git a/src/scord/job_manager.hpp b/src/scord/job_manager.hpp index 17feef77baae6152be5ed7b412752a4c4a89f6d1..ce11595f599c18ff3ded8c02efd12289b36f6524 100644 --- a/src/scord/job_manager.hpp +++ b/src/scord/job_manager.hpp @@ -38,7 +38,8 @@ namespace scord { struct job_manager { - tl::expected, scord::error_code> + tl::expected, + scord::error_code> create(scord::slurm_job_id slurm_id, scord::job::resources job_resources, scord::job::requirements job_requirements) { @@ -50,7 +51,7 @@ struct job_manager { if(const auto it = m_jobs.find(id); it == m_jobs.end()) { const auto& [it_job, inserted] = m_jobs.emplace( id, - std::make_shared( + std::make_shared( scord::job{id, slurm_id}, std::move(job_resources), std::move(job_requirements))); @@ -81,7 +82,8 @@ struct job_manager { return scord::error_code::no_such_entity; } - tl::expected, scord::error_code> + tl::expected, + scord::error_code> find(scord::job_id id) { abt::shared_lock lock(m_jobs_mutex); @@ -94,7 +96,8 @@ struct job_manager { return tl::make_unexpected(scord::error_code::no_such_entity); } - tl::expected, scord::error_code> + tl::expected, + scord::error_code> remove(scord::job_id id) { abt::unique_lock lock(m_jobs_mutex); @@ -112,7 +115,7 @@ struct job_manager { private: mutable abt::shared_mutex m_jobs_mutex; std::unordered_map> + std::shared_ptr> m_jobs; }; diff --git a/src/scord/pfs_storage_manager.hpp b/src/scord/pfs_storage_manager.hpp index a5bb0548de36c1b3ad8ddacdd0637975f5849361..d03e89571fb8155858d7d4c59b87512937cb2848 100644 --- a/src/scord/pfs_storage_manager.hpp +++ b/src/scord/pfs_storage_manager.hpp @@ -38,7 +38,7 @@ namespace scord { struct pfs_storage_manager { - tl::expected, + tl::expected, scord::error_code> create(enum scord::pfs_storage::type type, const std::string& name, const scord::pfs_storage::ctx& ctx) { @@ -51,7 +51,7 @@ struct pfs_storage_manager { if(const auto it = m_pfs_storages.find(id); it == m_pfs_storages.end()) { const auto& [it_pfs, inserted] = m_pfs_storages.emplace( - id, std::make_shared( + id, std::make_shared( scord::pfs_storage{type, name, id, ctx})); if(!inserted) { @@ -82,7 +82,7 @@ struct pfs_storage_manager { return scord::error_code::no_such_entity; } - tl::expected, + tl::expected, scord::error_code> find(std::uint64_t id) { @@ -118,7 +118,7 @@ struct pfs_storage_manager { private: mutable abt::shared_mutex m_pfs_storages_mutex; std::unordered_map> + std::shared_ptr> m_pfs_storages; }; diff --git a/src/scord/rpc_server.cpp b/src/scord/rpc_server.cpp index 6e9bbd99adb207254de433d328ac982eb0f6fab0..4e14eb0b7ca6c52de673ad4f2575fe88a2dceab6 100644 --- a/src/scord/rpc_server.cpp +++ b/src/scord/rpc_server.cpp @@ -102,20 +102,20 @@ rpc_server::register_job(const network::request& req, m_job_manager.create(slurm_id, job_resources, job_requirements); jm_result.has_value()) { - const auto& job_info = jm_result.value(); + const auto& job_metadata = jm_result.value(); // if the job requires an adhoc storage instance, inform the appropriate // adhoc_storage instance (if registered) if(job_requirements.adhoc_storage()) { const auto adhoc_id = job_requirements.adhoc_storage()->id(); - ec = m_adhoc_manager.add_client_info(adhoc_id, job_info); + ec = m_adhoc_manager.add_client_info(adhoc_id, job_metadata); if(!ec) { goto respond; } } - job_id = job_info->job().id(); + job_id = job_metadata->job().id(); } else { LOGGER_ERROR("rpc id: {} error_msg: \"Error creating job: {}\"", rpc.id(), jm_result.error()); @@ -174,9 +174,10 @@ rpc_server::remove_job(const network::request& req, scord::job_id job_id) { if(jm_result) { // if the job was using an adhoc storage instance, inform the // appropriate adhoc_storage that the job is no longer its client - const auto& job_info = jm_result.value(); + const auto& job_metadata = jm_result.value(); - if(const auto adhoc_storage = job_info->requirements()->adhoc_storage(); + if(const auto adhoc_storage = + job_metadata->requirements()->adhoc_storage(); adhoc_storage.has_value()) { ec = m_adhoc_manager.remove_client_info(adhoc_storage->id()); } @@ -309,10 +310,10 @@ rpc_server::deploy_adhoc_storage(const network::request& req, * information about the instance to deploy. * @return */ - const auto deploy_helper = [&](const auto& adhoc_info) + const auto deploy_helper = [&](const auto& adhoc_metadata) -> tl::expected { - assert(adhoc_info); - const auto adhoc_storage = adhoc_info->adhoc_storage(); + assert(adhoc_metadata); + const auto adhoc_storage = adhoc_metadata->adhoc_storage(); const auto endp = lookup(adhoc_storage.context().controller_address()); if(!endp) { @@ -324,10 +325,10 @@ rpc_server::deploy_adhoc_storage(const network::request& req, rpc.add_child(adhoc_storage.context().controller_address()); LOGGER_INFO("rpc {:<} body: {{uuid: {}, type: {}, resources: {}}}", - child_rpc, std::quoted(adhoc_info->uuid()), + child_rpc, std::quoted(adhoc_metadata->uuid()), adhoc_storage.type(), adhoc_storage.get_resources()); - if(const auto call_rv = endp->call(rpc.name(), adhoc_info->uuid(), + if(const auto call_rv = endp->call(rpc.name(), adhoc_metadata->uuid(), adhoc_storage.type(), adhoc_storage.get_resources()); call_rv.has_value()) { @@ -388,9 +389,10 @@ rpc_server::terminate_adhoc_storage(const network::request& req, * information about the instance to terminate. * @return */ - const auto terminate_helper = [&](const auto& adhoc_info) -> error_code { - assert(adhoc_info); - const auto adhoc_storage = adhoc_info->adhoc_storage(); + const auto terminate_helper = + [&](const auto& adhoc_metadata) -> error_code { + assert(adhoc_metadata); + const auto adhoc_storage = adhoc_metadata->adhoc_storage(); const auto endp = lookup(adhoc_storage.context().controller_address()); if(!endp) { @@ -402,9 +404,9 @@ rpc_server::terminate_adhoc_storage(const network::request& req, rpc.add_child(adhoc_storage.context().controller_address()); LOGGER_INFO("rpc {:<} body: {{uuid: {}, type: {}}}", child_rpc, - std::quoted(adhoc_info->uuid()), adhoc_storage.type()); + std::quoted(adhoc_metadata->uuid()), adhoc_storage.type()); - if(const auto call_rv = endp->call(rpc.name(), adhoc_info->uuid(), + if(const auto call_rv = endp->call(rpc.name(), adhoc_metadata->uuid(), adhoc_storage.type()); call_rv.has_value()) { diff --git a/src/scord/rpc_server.hpp b/src/scord/rpc_server.hpp index 0254328fe628da3bb948100bc2c97fa3405272c2..6fe2331acd565059a032b89732d923eb1ac8749d 100644 --- a/src/scord/rpc_server.hpp +++ b/src/scord/rpc_server.hpp @@ -71,10 +71,11 @@ private: remove_adhoc_storage(const network::request& req, std::uint64_t adhoc_id); void - deploy_adhoc_storage(const network::request& req, std::uint64_t adhoc_id); + deploy_adhoc_storage(const network::request& adhoc_metadata, + std::uint64_t adhoc_id); void - terminate_adhoc_storage(const network::request& req, + terminate_adhoc_storage(const network::request& adhoc_metadata, std::uint64_t adhoc_id); void