Commit 3279efdf authored by Marc Vef's avatar Marc Vef
Browse files

Adding get_chunk_stat proxy to client

parent a7c3c8a3
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -30,13 +30,9 @@
#ifndef GEKKOFS_CLIENT_FORWARD_DATA_HPP
#define GEKKOFS_CLIENT_FORWARD_DATA_HPP

namespace gkfs::rpc {
#include <common/common_defs.hpp>

struct ChunkStat {
    unsigned long chunk_size;
    unsigned long chunk_total;
    unsigned long chunk_free;
};
namespace gkfs::rpc {

// TODO once we have LEAF, remove all the error code returns and throw them as
// an exception.
+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
#ifndef GEKKOFS_FORWARD_DATA_PROXY_HPP
#define GEKKOFS_FORWARD_DATA_PROXY_HPP

#include <common/common_defs.hpp>

namespace gkfs {
namespace rpc {

@@ -26,6 +28,9 @@ ssize_t
forward_read_proxy(const std::string& path, void* buf, off64_t offset,
                   size_t read_size);

std::pair<int, ChunkStat>
forward_get_chunk_stat_proxy();

} // namespace rpc
} // namespace gkfs

+133 −0
Original line number Diff line number Diff line
@@ -2558,6 +2558,139 @@ struct read_data_proxy {
    };
};

//==============================================================================
// definitions for chunk_stat_proxy
struct chunk_stat_proxy {

    // forward declarations of public input/output types for this RPC
    class input;

    class output;

    // traits used so that the engine knows what to do with the RPC
    using self_type = chunk_stat_proxy;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_chunk_stat_in_t;
    using mercury_output_type = rpc_chunk_stat_out_t;

    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 3054698496; // TODO

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = gkfs::rpc::tag::proxy_chunk_stat;

    // requires response?
    constexpr static const auto requires_response = true;

    // Mercury callback to serialize input arguments
    constexpr static const auto mercury_in_proc_cb =
            HG_GEN_PROC_NAME(rpc_chunk_stat_in_t);

    // Mercury callback to serialize output arguments
    constexpr static const auto mercury_out_proc_cb =
            HG_GEN_PROC_NAME(rpc_chunk_stat_out_t);

    class input {

        template <typename ExecutionContext>
        friend hg_return_t
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        input(int32_t dummy) : m_dummy(dummy) {}

        input(input&& rhs) = default;

        input(const input& other) = default;

        input&
        operator=(input&& rhs) = default;

        input&
        operator=(const input& other) = default;

        int32_t
        dummy() const {
            return m_dummy;
        }

        explicit input(const rpc_chunk_stat_in_t& other)
            : m_dummy(other.dummy) {}

        explicit operator rpc_chunk_stat_in_t() {
            return {m_dummy};
        }

    private:
        int32_t m_dummy;
    };

    class output {

        template <typename ExecutionContext>
        friend hg_return_t
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        output() : m_err(), m_chunk_size(), m_chunk_total(), m_chunk_free() {}

        output(int32_t err, uint64_t chunk_size, uint64_t chunk_total,
               uint64_t chunk_free)
            : m_err(err), m_chunk_size(chunk_size), m_chunk_total(chunk_total),
              m_chunk_free(chunk_free) {}

        output(output&& rhs) = default;

        output(const output& other) = default;

        output&
        operator=(output&& rhs) = default;

        output&
        operator=(const output& other) = default;

        explicit output(const rpc_chunk_stat_out_t& out) {
            m_err = out.err;
            m_chunk_size = out.chunk_size;
            m_chunk_total = out.chunk_total;
            m_chunk_free = out.chunk_free;
        }

        int32_t
        err() const {
            return m_err;
        }

        uint64_t
        chunk_size() const {
            return m_chunk_size;
        }

        uint64_t
        chunk_total() const {
            return m_chunk_total;
        }

        uint64_t
        chunk_free() const {
            return m_chunk_free;
        }

    private:
        int32_t m_err;
        uint64_t m_chunk_size;
        uint64_t m_chunk_total;
        uint64_t m_chunk_free;
    };
};

//==============================================================================
// definitions for create
struct create_proxy {
+7 −0
Original line number Diff line number Diff line
@@ -34,6 +34,12 @@
namespace gkfs::rpc {

using chnk_id_t = unsigned long;
struct ChunkStat {
    unsigned long chunk_size;
    unsigned long chunk_total;
    unsigned long chunk_free;
};


namespace tag {

@@ -62,6 +68,7 @@ constexpr auto proxy_remove = "proxy_rpc_srv_remove";
constexpr auto proxy_update_size = "proxy_rpc_srv_update_metadentry_size";
constexpr auto proxy_write = "proxy_rpc_srv_write_data";
constexpr auto proxy_read = "proxy_rpc_srv_read_data";
constexpr auto proxy_chunk_stat = "proxy_rpc_srv_chunk_stat";
} // namespace tag

namespace protocol {
+2 −1
Original line number Diff line number Diff line
@@ -110,8 +110,9 @@ constexpr auto fwd_stat = true;
constexpr auto fwd_remove = true;
constexpr auto fwd_update_size = true;
constexpr auto fwd_io = true;
constexpr auto fwd_chunk_stat = true;
// Only use proxy for io if write/read size is higher than set value
constexpr auto fwd_io_count_threshold = 1;
constexpr auto fwd_io_count_threshold = 0;

} // namespace proxy

Loading