Loading src/common/api/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ add_library(_api_types STATIC) target_sources(_api_types PUBLIC admire_types.h admire_types.hpp PRIVATE types.cpp convert.hpp convert.cpp) types.cpp convert.hpp convert.cpp internal_types.hpp) target_include_directories(_api_types PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) Loading src/common/api/admire_types.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ using job_id = std::uint64_t; using slurm_job_id = std::uint64_t; using transfer_id = std::uint64_t; namespace internal { struct job_info; } // namespace internal struct server { server(std::string protocol, std::string address); Loading src/common/api/internal_types.hpp 0 → 100644 +60 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #ifndef SCORD_INTERNAL_TYPES_HPP #define SCORD_INTERNAL_TYPES_HPP namespace admire::internal { struct job_info { explicit job_info(admire::job job) : m_job(std::move(job)) {} job_info(admire::job job, admire::job::resources resources, admire::job_requirements requirements) : m_job(std::move(job)), m_resources(std::move(resources)), m_requirements(std::move(requirements)) {} admire::job job() const { return m_job; } std::optional<admire::job::resources> resources() const { return m_resources; } std::optional<admire::job_requirements> requirements() const { return m_requirements; } admire::job m_job; std::optional<admire::job::resources> m_resources; std::optional<admire::job_requirements> m_requirements; }; } // namespace admire::internal #endif // SCORD_INTERNAL_TYPES_HPP src/common/api/types.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <variant> #include <optional> #include "admire_types.hpp" #include "internal_types.hpp" /******************************************************************************/ /* C Type definitions and related functions */ Loading src/scord/job_manager.hpp +12 −37 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #define SCORD_JOB_MANAGER_HPP #include <admire_types.hpp> #include <internal_types.hpp> #include <atomic> #include <utility> #include <utils/utils.hpp> Loading @@ -36,37 +37,10 @@ namespace scord { struct job_info { explicit job_info(admire::job job) : m_job(std::move(job)) {} job_info(admire::job job, admire::job::resources resources, admire::job_requirements requirements) : m_job(std::move(job)), m_resources(std::move(resources)), m_requirements(std::move(requirements)) {} admire::job job() const { return m_job; } std::optional<admire::job::resources> resources() const { return m_resources; } std::optional<admire::job_requirements> requirements() const { return m_requirements; } admire::job m_job; std::optional<admire::job::resources> m_resources; std::optional<admire::job_requirements> m_requirements; }; struct job_manager : scord::utils::singleton<job_manager> { tl::expected<job_info, admire::error_code> tl::expected<admire::internal::job_info, admire::error_code> create(admire::slurm_job_id slurm_id, admire::job::resources job_resources, admire::job_requirements job_requirements) { Loading @@ -76,8 +50,9 @@ struct job_manager : scord::utils::singleton<job_manager> { abt::unique_lock lock(m_jobs_mutex); if(const auto it = m_jobs.find(id); it == m_jobs.end()) { const auto& [it_job, inserted] = m_jobs.emplace(id, job_info{admire::job{id, slurm_id}, const auto& [it_job, inserted] = m_jobs.emplace( id, admire::internal::job_info{admire::job{id, slurm_id}, std::move(job_resources), std::move(job_requirements)}); Loading @@ -102,8 +77,8 @@ struct job_manager : scord::utils::singleton<job_manager> { if(const auto it = m_jobs.find(id); it != m_jobs.end()) { const auto& current_job_info = it->second; it->second = job_info{current_job_info.job(), std::move(job_resources), it->second = admire::internal::job_info{ current_job_info.job(), std::move(job_resources), std::move(job_requirements)}; return ADM_SUCCESS; } Loading @@ -112,7 +87,7 @@ struct job_manager : scord::utils::singleton<job_manager> { return ADM_ENOENT; } tl::expected<job_info, admire::error_code> tl::expected<admire::internal::job_info, admire::error_code> find(admire::job_id id) { abt::shared_lock lock(m_jobs_mutex); Loading Loading @@ -145,7 +120,7 @@ private: job_manager() = default; mutable abt::shared_mutex m_jobs_mutex; std::unordered_map<admire::job_id, job_info> m_jobs; std::unordered_map<admire::job_id, admire::internal::job_info> m_jobs; }; } // namespace scord Loading Loading
src/common/api/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ add_library(_api_types STATIC) target_sources(_api_types PUBLIC admire_types.h admire_types.hpp PRIVATE types.cpp convert.hpp convert.cpp) types.cpp convert.hpp convert.cpp internal_types.hpp) target_include_directories(_api_types PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) Loading
src/common/api/admire_types.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ using job_id = std::uint64_t; using slurm_job_id = std::uint64_t; using transfer_id = std::uint64_t; namespace internal { struct job_info; } // namespace internal struct server { server(std::string protocol, std::string address); Loading
src/common/api/internal_types.hpp 0 → 100644 +60 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #ifndef SCORD_INTERNAL_TYPES_HPP #define SCORD_INTERNAL_TYPES_HPP namespace admire::internal { struct job_info { explicit job_info(admire::job job) : m_job(std::move(job)) {} job_info(admire::job job, admire::job::resources resources, admire::job_requirements requirements) : m_job(std::move(job)), m_resources(std::move(resources)), m_requirements(std::move(requirements)) {} admire::job job() const { return m_job; } std::optional<admire::job::resources> resources() const { return m_resources; } std::optional<admire::job_requirements> requirements() const { return m_requirements; } admire::job m_job; std::optional<admire::job::resources> m_resources; std::optional<admire::job_requirements> m_requirements; }; } // namespace admire::internal #endif // SCORD_INTERNAL_TYPES_HPP
src/common/api/types.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <variant> #include <optional> #include "admire_types.hpp" #include "internal_types.hpp" /******************************************************************************/ /* C Type definitions and related functions */ Loading
src/scord/job_manager.hpp +12 −37 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #define SCORD_JOB_MANAGER_HPP #include <admire_types.hpp> #include <internal_types.hpp> #include <atomic> #include <utility> #include <utils/utils.hpp> Loading @@ -36,37 +37,10 @@ namespace scord { struct job_info { explicit job_info(admire::job job) : m_job(std::move(job)) {} job_info(admire::job job, admire::job::resources resources, admire::job_requirements requirements) : m_job(std::move(job)), m_resources(std::move(resources)), m_requirements(std::move(requirements)) {} admire::job job() const { return m_job; } std::optional<admire::job::resources> resources() const { return m_resources; } std::optional<admire::job_requirements> requirements() const { return m_requirements; } admire::job m_job; std::optional<admire::job::resources> m_resources; std::optional<admire::job_requirements> m_requirements; }; struct job_manager : scord::utils::singleton<job_manager> { tl::expected<job_info, admire::error_code> tl::expected<admire::internal::job_info, admire::error_code> create(admire::slurm_job_id slurm_id, admire::job::resources job_resources, admire::job_requirements job_requirements) { Loading @@ -76,8 +50,9 @@ struct job_manager : scord::utils::singleton<job_manager> { abt::unique_lock lock(m_jobs_mutex); if(const auto it = m_jobs.find(id); it == m_jobs.end()) { const auto& [it_job, inserted] = m_jobs.emplace(id, job_info{admire::job{id, slurm_id}, const auto& [it_job, inserted] = m_jobs.emplace( id, admire::internal::job_info{admire::job{id, slurm_id}, std::move(job_resources), std::move(job_requirements)}); Loading @@ -102,8 +77,8 @@ struct job_manager : scord::utils::singleton<job_manager> { if(const auto it = m_jobs.find(id); it != m_jobs.end()) { const auto& current_job_info = it->second; it->second = job_info{current_job_info.job(), std::move(job_resources), it->second = admire::internal::job_info{ current_job_info.job(), std::move(job_resources), std::move(job_requirements)}; return ADM_SUCCESS; } Loading @@ -112,7 +87,7 @@ struct job_manager : scord::utils::singleton<job_manager> { return ADM_ENOENT; } tl::expected<job_info, admire::error_code> tl::expected<admire::internal::job_info, admire::error_code> find(admire::job_id id) { abt::shared_lock lock(m_jobs_mutex); Loading Loading @@ -145,7 +120,7 @@ private: job_manager() = default; mutable abt::shared_mutex m_jobs_mutex; std::unordered_map<admire::job_id, job_info> m_jobs; std::unordered_map<admire::job_id, admire::internal::job_info> m_jobs; }; } // namespace scord Loading