Loading lib/cargo.hpp +13 −4 Original line number Diff line number Diff line Loading @@ -59,20 +59,29 @@ private: class dataset { public: enum class type { posix, parallel }; dataset() noexcept = default; explicit dataset(std::string id) noexcept; explicit dataset(std::string path, dataset::type type = dataset::type::posix) noexcept; [[nodiscard]] std::string id() const noexcept; path() const noexcept; [[nodiscard]] bool supports_parallel_transfer() const noexcept; template <typename Archive> void serialize(Archive& ar) { ar& m_id; ar& m_path; ar& m_type; } private: std::string m_id; std::string m_path; dataset::type m_type = dataset::type::posix; }; Loading lib/fmt_formatters.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ struct fmt::formatter<cargo::dataset> : formatter<std::string_view> { template <typename FormatContext> auto format(const cargo::dataset& d, FormatContext& ctx) const { const auto str = fmt::format("{{id: {}}}", std::quoted(d.id())); const auto str = fmt::format("{{path: {}}}", std::quoted(d.path())); return formatter<std::string_view>::format(str, ctx); } }; Loading lib/libcargo.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -61,13 +61,19 @@ server::address() const noexcept { return m_address; } dataset::dataset(std::string id) noexcept : m_id(std::move(id)) {} dataset::dataset(std::string path, dataset::type type) noexcept : m_path(std::move(path)), m_type(type) {} std::string dataset::id() const noexcept { return m_id; dataset::path() const noexcept { return m_path; }; bool dataset::supports_parallel_transfer() const noexcept { return m_type == dataset::type::parallel; } transfer::transfer(transfer_id id) noexcept : m_id(id) {} [[nodiscard]] transfer_id Loading src/master.cpp +6 −23 Original line number Diff line number Diff line Loading @@ -41,39 +41,22 @@ get_address(auto&& req) { return req.get_endpoint(); } std::tuple<std::string, std::string> split(const std::string& id) { constexpr auto delim = "://"sv; const auto n = id.find(delim); if(n == std::string::npos) { return {std::string{}, id}; } return {id.substr(0, n), id.substr(n + delim.length(), id.length())}; } cargo::transfer_request_message create_request_message(const cargo::dataset& input, const cargo::dataset& output) { cargo::transfer_type tx_type; const auto& [input_prefix, input_path] = split(input.id()); const auto& [output_prefix, output_path] = split(output.id()); // FIXME: id should offer member functions to retrieve the parent // namespace if(input_prefix == "lustre") { if(input.supports_parallel_transfer()) { tx_type = cargo::parallel_read; } else if(output_prefix == "lustre") { } else if(output.supports_parallel_transfer()) { tx_type = cargo::parallel_write; } else { tx_type = cargo::sequential; } return cargo::transfer_request_message{input_path, output_path, tx_type}; return cargo::transfer_request_message{input.path(), output.path(), tx_type}; } } // namespace Loading Loading @@ -128,8 +111,8 @@ transfer_datasets(const net::request& req, boost::mpi::communicator world; for(auto i = 0u; i < sources.size(); ++i) { const auto& input_path = sources[i].id(); const auto& output_path = targets[i].id(); const auto& input_path = sources[i].path(); const auto& output_path = targets[i].path(); const auto m = ::create_request_message(sources[i], targets[i]); Loading tests/common.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -2,11 +2,12 @@ #include "common.hpp" std::vector<cargo::dataset> prepare_datasets(const std::string& pattern, size_t n) { prepare_datasets(cargo::dataset::type type, const std::string& pattern, size_t n) { std::vector<cargo::dataset> datasets; datasets.reserve(n); for(size_t i = 0; i < n; ++i) { datasets.emplace_back(fmt::format(fmt::runtime(pattern), i)); datasets.emplace_back(fmt::format(fmt::runtime(pattern), i), type); } return datasets; Loading Loading
lib/cargo.hpp +13 −4 Original line number Diff line number Diff line Loading @@ -59,20 +59,29 @@ private: class dataset { public: enum class type { posix, parallel }; dataset() noexcept = default; explicit dataset(std::string id) noexcept; explicit dataset(std::string path, dataset::type type = dataset::type::posix) noexcept; [[nodiscard]] std::string id() const noexcept; path() const noexcept; [[nodiscard]] bool supports_parallel_transfer() const noexcept; template <typename Archive> void serialize(Archive& ar) { ar& m_id; ar& m_path; ar& m_type; } private: std::string m_id; std::string m_path; dataset::type m_type = dataset::type::posix; }; Loading
lib/fmt_formatters.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ struct fmt::formatter<cargo::dataset> : formatter<std::string_view> { template <typename FormatContext> auto format(const cargo::dataset& d, FormatContext& ctx) const { const auto str = fmt::format("{{id: {}}}", std::quoted(d.id())); const auto str = fmt::format("{{path: {}}}", std::quoted(d.path())); return formatter<std::string_view>::format(str, ctx); } }; Loading
lib/libcargo.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -61,13 +61,19 @@ server::address() const noexcept { return m_address; } dataset::dataset(std::string id) noexcept : m_id(std::move(id)) {} dataset::dataset(std::string path, dataset::type type) noexcept : m_path(std::move(path)), m_type(type) {} std::string dataset::id() const noexcept { return m_id; dataset::path() const noexcept { return m_path; }; bool dataset::supports_parallel_transfer() const noexcept { return m_type == dataset::type::parallel; } transfer::transfer(transfer_id id) noexcept : m_id(id) {} [[nodiscard]] transfer_id Loading
src/master.cpp +6 −23 Original line number Diff line number Diff line Loading @@ -41,39 +41,22 @@ get_address(auto&& req) { return req.get_endpoint(); } std::tuple<std::string, std::string> split(const std::string& id) { constexpr auto delim = "://"sv; const auto n = id.find(delim); if(n == std::string::npos) { return {std::string{}, id}; } return {id.substr(0, n), id.substr(n + delim.length(), id.length())}; } cargo::transfer_request_message create_request_message(const cargo::dataset& input, const cargo::dataset& output) { cargo::transfer_type tx_type; const auto& [input_prefix, input_path] = split(input.id()); const auto& [output_prefix, output_path] = split(output.id()); // FIXME: id should offer member functions to retrieve the parent // namespace if(input_prefix == "lustre") { if(input.supports_parallel_transfer()) { tx_type = cargo::parallel_read; } else if(output_prefix == "lustre") { } else if(output.supports_parallel_transfer()) { tx_type = cargo::parallel_write; } else { tx_type = cargo::sequential; } return cargo::transfer_request_message{input_path, output_path, tx_type}; return cargo::transfer_request_message{input.path(), output.path(), tx_type}; } } // namespace Loading Loading @@ -128,8 +111,8 @@ transfer_datasets(const net::request& req, boost::mpi::communicator world; for(auto i = 0u; i < sources.size(); ++i) { const auto& input_path = sources[i].id(); const auto& output_path = targets[i].id(); const auto& input_path = sources[i].path(); const auto& output_path = targets[i].path(); const auto m = ::create_request_message(sources[i], targets[i]); Loading
tests/common.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -2,11 +2,12 @@ #include "common.hpp" std::vector<cargo::dataset> prepare_datasets(const std::string& pattern, size_t n) { prepare_datasets(cargo::dataset::type type, const std::string& pattern, size_t n) { std::vector<cargo::dataset> datasets; datasets.reserve(n); for(size_t i = 0; i < n; ++i) { datasets.emplace_back(fmt::format(fmt::runtime(pattern), i)); datasets.emplace_back(fmt::format(fmt::runtime(pattern), i), type); } return datasets; Loading