Verified Commit 8a18b27f authored by Marc Vef's avatar Marc Vef
Browse files

Added metadata proxy

parent b1570a27
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
/*
  Copyright 2018-2020, Barcelona Supercomputing Center (BSC), Spain
  Copyright 2015-2020, Johannes Gutenberg Universitaet Mainz, Germany

  This software was partially supported by the
  EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).

  This software was partially supported by the
  ADA-FS project under the SPPEXA project funded by the DFG.

  SPDX-License-Identifier: MIT
*/

#ifndef GEKKOFS_FORWARD_METADATA_PROXY_HPP
#define GEKKOFS_FORWARD_METADATA_PROXY_HPP

namespace gkfs {
namespace rpc {

int forward_create_proxy(const std::string& path, const mode_t mode);

int forward_stat_proxy(const std::string& path, std::string& attr);

}
}

#endif //GEKKOFS_FORWARD_METADATA_PROXY_HPP
+348 −0
Original line number Diff line number Diff line
@@ -2447,6 +2447,354 @@ struct read_data_proxy {
    };
};

//==============================================================================
// definitions for create
struct create_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 = create_proxy;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_mk_node_in_t;
    using mercury_output_type = rpc_err_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;

    // 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_create;

    // 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_mk_node_in_t);

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

    class input {

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

    public:
        input(const std::string& path,
              uint32_t mode) :
                m_path(path),
                m_mode(mode) {}

        input(input&& rhs) = default;

        input(const input& other) = default;

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

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

        std::string
        path() const {
            return m_path;
        }

        uint32_t
        mode() const {
            return m_mode;
        }

        explicit
        input(const rpc_mk_node_in_t& other) :
                m_path(other.path),
                m_mode(other.mode) {}

        explicit
        operator rpc_mk_node_in_t() {
            return {m_path.c_str(), m_mode};
        }

    private:
        std::string m_path;
        uint32_t m_mode;
    };

    class output {

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

    public:
        output() :
                m_err() {}

        output(int32_t err) :
                m_err(err) {}

        output(output&& rhs) = default;

        output(const output& other) = default;

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

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

        explicit
        output(const rpc_err_out_t& out) {
            m_err = out.err;
        }

        int32_t
        err() const {
            return m_err;
        }

    private:
        int32_t m_err;
    };
};

//==============================================================================
// definitions for stat
struct 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 = stat_proxy;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_path_only_in_t;
    using mercury_output_type = rpc_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 = 2552037376;

    // 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_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_path_only_in_t);

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

    class input {

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

    public:
        input(const std::string& path) :
                m_path(path) {}

        input(input&& rhs) = default;

        input(const input& other) = default;

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

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

        std::string
        path() const {
            return m_path;
        }

        explicit
        input(const rpc_path_only_in_t& other) :
                m_path(other.path) {}

        explicit
        operator rpc_path_only_in_t() {
            return {m_path.c_str()};
        }

    private:
        std::string m_path;
    };

    class output {

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

    public:
        output() :
                m_err(),
                m_db_val() {}

        output(int32_t err, const std::string& db_val) :
                m_err(err),
                m_db_val(db_val) {}

        output(output&& rhs) = default;

        output(const output& other) = default;

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

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

        explicit
        output(const rpc_stat_out_t& out) {
            m_err = out.err;

            if (out.db_val != nullptr) {
                m_db_val = out.db_val;
            }
        }

        int32_t
        err() const {
            return m_err;
        }

        std::string
        db_val() const {
            return m_db_val;
        }

    private:
        int32_t m_err;
        std::string m_db_val;
    };
};

//==============================================================================
// definitions for remove
struct remove_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 = remove_proxy;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_rm_node_in_t;
    using mercury_output_type = rpc_err_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 = 2616000512;

    // 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_remove;

    // 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_rm_node_in_t);

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

    class input {

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

    public:
        input(const std::string& path) :
                m_path(path) {}

        input(input&& rhs) = default;

        input(const input& other) = default;

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

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

        std::string
        path() const {
            return m_path;
        }

        explicit
        input(const rpc_rm_node_in_t& other) :
                m_path(other.path) {}

        explicit
        operator rpc_rm_node_in_t() {
            return {m_path.c_str()};
        }

    private:
        std::string m_path;
    };

    class output {

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

    public:
        output() :
                m_err() {}

        output(int32_t err) :
                m_err(err) {}

        output(output&& rhs) = default;

        output(const output& other) = default;

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

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

        explicit
        output(const rpc_err_out_t& out) {
            m_err = out.err;
        }

        int32_t
        err() const {
            return m_err;
        }

    private:
        int32_t m_err;
    };
};

} // namespace rpc
} // namespace gkfs

+6 −0
Original line number Diff line number Diff line
@@ -56,6 +56,12 @@ constexpr auto use_blocks = false;

namespace proxy {
constexpr auto pid_path = "/tmp/gkfs_proxy.pid";
constexpr auto fwd_create = true;
constexpr auto fwd_stat = true;
constexpr auto fwd_io = true;
// Only use proxy for io if write/read size is higher than set value
constexpr auto fwd_io_count_threshold = 4000;

} // namespace proxy

namespace rpc {
+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@ constexpr auto write = "rpc_srv_write_data";
constexpr auto read = "rpc_srv_read_data";
constexpr auto truncate = "rpc_srv_trunc_data";
constexpr auto get_chunk_stat = "rpc_srv_chunk_stat";
constexpr auto proxy_create = "proxy_rpc_srv_create";
constexpr auto proxy_stat = "proxy_rpc_srv_stat";
constexpr auto proxy_remove = "proxy_rpc_srv_remove";
constexpr auto proxy_write = "proxy_rpc_srv_write_data";
constexpr auto proxy_read = "proxy_rpc_srv_read_data";
} // namespace tag
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ class Distributor;
namespace proxy {

struct margo_client_ids {
    hg_id_t rpc_create_id;
    hg_id_t rpc_stat_id;
    hg_id_t rpc_remove_id;
    hg_id_t rpc_write_id;
    hg_id_t rpc_read_id;
};
Loading