Commit f7c4db33 authored by Ramon Nou's avatar Ramon Nou
Browse files

Implemented statuses (completed/running/failed)

has the output filename
BW shows mean BW for the file.
parent e3993fd5
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -309,7 +309,6 @@ master_server::transfer_datasets(const network::request& req,
            .map([&](auto&& r) {
                assert(v_s_new.size() == v_d_new.size());


                // For all the files
                for(std::size_t i = 0; i < v_s_new.size(); ++i) {
                    const auto& s = v_s_new[i];
@@ -404,7 +403,7 @@ master_server::transfer_statuses(const network::request& req,
                        v{};
                for(auto& r : rs) {
                    v.push_back(std::make_tuple(r.name(), r.state(), r.bw(),
                                                r.error().value()));
                                                r.error()));
                    LOGGER_INFO(
                            "rpc {:<} body: {{retval: {}, name: {}, status: {}}}",
                            rpc, error_code::success, r.name(), r.state());
+9 −2
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ parallel_request::nworkers() const {
}

request_status::request_status(part_status s)
    : m_name(s.name()), m_state(s.state()), m_bw(s.bw()), m_error_code(s.error()) {}
    : m_name(s.name()), m_state(s.state()), m_bw(s.bw()),
      m_error_code(s.error()) {}

request_status::request_status(std::string name, transfer_state s, float bw,
                               std::optional<error_code> ec)
@@ -72,6 +73,12 @@ float
request_status::bw() const {
    return m_bw;
}

void
request_status::bw(float bw) {
    m_bw = bw;
}

std::string
part_status::name() const {
    return m_name;
@@ -95,7 +102,7 @@ part_status::error() const {
void
part_status::update(std::string name, transfer_state s, float bw,
                    std::optional<error_code> ec) noexcept {
    m_name = std::move(name);
    m_name = name;
    m_state = s;
    m_bw = bw;
    m_error_code = ec;
+4 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
#include <vector>
#include <optional>
#include <fmt/format.h>

#include "../lib/cargo.hpp"
namespace cargo {

class dataset;
@@ -106,6 +106,9 @@ public:
    [[nodiscard]] float
    bw() const;

    void
    bw (float bw);
    
private:
    std::string m_name;
    transfer_state m_state{transfer_state::pending};
+4 −4
Original line number Diff line number Diff line
@@ -253,13 +253,13 @@ struct fmt::formatter<cargo::status_message> : formatter<std::string_view> {
        const auto str =
                s.error_code()
                        ? fmt::format(
                                  "{{tid: {}, seqno: {}, state: {}, bw: {}, "
                                  "{{tid: {}, seqno: {}, name: {}, state: {}, bw: {}, "
                                  "error_code: {}}}",
                                  s.tid(), s.seqno(), s.state(), s.bw(),
                                  s.tid(), s.seqno(), s.name(), s.state(), s.bw(),
                                  *s.error_code())
                        : fmt::format(
                                  "{{tid: {}, seqno: {}, state: {}, bw: {}}}",
                                  s.tid(), s.seqno(), s.state(), s.bw());
                                  "{{tid: {}, seqno: {}, name: {}, state: {}, bw: {}}}",
                                  s.tid(), s.seqno(), s.name(), s.state(), s.bw());
        return formatter<std::string_view>::format(str, ctx);
    }
};
+11 −4
Original line number Diff line number Diff line
@@ -109,13 +109,20 @@ request_manager::lookup_all(std::uint64_t tid) {
    if(const auto it = m_requests.find(tid); it != m_requests.end()) {

        const auto& file_statuses = it->second;

        // we calculate always the mean of the BW
        for(const auto& fs : file_statuses) {
            float bw = 0;
            request_status rs(*fs.begin());
            for(const auto& ps : fs) {

                request_status rs{ps};
                result.push_back(rs);
                bw += ps.bw();
                if(ps.state() == transfer_state::completed) {
                    continue;
                }
                // not finished
                rs = request_status{ps};
            }
            rs.bw(bw/(double)fs.size());
            result.push_back(rs);
        }
        return result;
    }
Loading