Commit f5ff9ac8 authored by Marc Vef's avatar Marc Vef
Browse files

Minimal RPC added for testing. works within fuse

parent 1cd5dcff
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -56,7 +56,9 @@ set(SOURCE_FILES src/main.cpp src/main.hpp src/fuse_ops.hpp src/configure.hpp
        # db header
        src/db/db_ops.hpp src/db/db_txn_ops.hpp src/db/db_util.hpp
        # rpc header
        src/rpc/rpcs_test.hpp src/rpc/rpc_util_test.hpp src/rpc/rpc_util.hpp
        src/rpc/rpcs_test.hpp src/rpc/rpc_util_test.hpp src/rpc/rpc_util.hpp src/rpc/rpc_types.hpp src/rpc/rpc_defs.hpp
        # rpcs header
        src/rpc/client/c_metadata.hpp

        # util
        src/util.cpp
@@ -70,6 +72,8 @@ set(SOURCE_FILES src/main.cpp src/main.hpp src/fuse_ops.hpp src/configure.hpp
        src/db/db_ops.cpp src/db/db_txn_ops.cpp src/db/db_util.cpp
        # rpc src
        src/rpc/rpc_util_test.cpp src/rpc/rpcs_test.cpp src/rpc/rpc_util.cpp
        # rpcs src
        src/rpc/server/s_metadata.cpp src/rpc/client/c_metadata.cpp
        )
add_executable(adafs ${SOURCE_FILES} src/main.cpp)
target_link_libraries(adafs ${FUSE3_LIBRARIES} ${ROCKSDB_LIBRARIES}
+24 −0
Original line number Diff line number Diff line
@@ -36,3 +36,27 @@ hg_context_t* RPCData::client_hg_context() const {
void RPCData::client_hg_context(hg_context_t* client_hg_context) {
    RPCData::client_hg_context_ = client_hg_context;
}

margo_instance* RPCData::server_mid() {
    return server_mid_;
}

void RPCData::server_mid(margo_instance* server_mid) {
    RPCData::server_mid_ = server_mid;
}

margo_instance* RPCData::client_mid() {
    return client_mid_;
}

void RPCData::client_mid(margo_instance* client_mid) {
    RPCData::client_mid_ = client_mid;
}

hg_id_t RPCData::rpc_minimal_id() const {
    return rpc_minimal_id_;
}

void RPCData::rpc_minimal_id(hg_id_t rpc_minimal_id) {
    RPCData::rpc_minimal_id_ = rpc_minimal_id;
}
+20 −1
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ class RPCData {
private:
    RPCData() {}

    // Can't use shared pointers here 'cause the Mercury environment has problems with it, e.g., unable to finalize,
    // resulting into a faulty fuse shutdown
    // Mercury Server
    hg_class_t* server_hg_class_;
    hg_context_t* server_hg_context_;
@@ -20,7 +22,13 @@ private:
    hg_class_t* client_hg_class_;
    hg_context_t* client_hg_context_;

    // TODO RPC IDs
    // Margo IDs. They can also be used to retrieve the Mercury classes and contexts that were created at init time
    margo_instance_id server_mid_;
    margo_instance_id client_mid_;

    // TODO RPC client IDs
    // RPC client IDs
    hg_id_t rpc_minimal_id_;

public:
    static RPCData* getInstance() {
@@ -48,6 +56,17 @@ public:

    void client_hg_context(hg_context_t* client_hg_context);

    margo_instance* server_mid();

    void server_mid(margo_instance* server_mid);

    margo_instance* client_mid();

    void client_mid(margo_instance* client_mid);

    hg_id_t rpc_minimal_id() const;

    void rpc_minimal_id(hg_id_t rpc_minimal_id);
};


+5 −2
Original line number Diff line number Diff line
@@ -3,9 +3,10 @@
#include "adafs_ops/mdata_ops.hpp"
#include "adafs_ops/dentry_ops.hpp"
#include "fuse_ops.hpp"
#include "rpc/rpc_util_test.hpp"
#include "rpc/rpc_util.hpp"

#include "rpc/client/c_metadata.hpp"

static struct fuse_lowlevel_ops adafs_ops;

using namespace std;
@@ -45,6 +46,8 @@ void adafs_ll_init(void* pdata, struct fuse_conn_info* conn) {
    err = init_rpc_client();
    assert(err);

    send_minimal_rpc();

    // Check if fs already has some data and read the inode count
    if (bfs::exists(ADAFS_DATA->mgmt_path() + "/inode_count"))
        Util::read_inode_cnt();
@@ -95,9 +98,9 @@ void adafs_ll_init(void* pdata, struct fuse_conn_info* conn) {
 * @param userdata the user data passed to fuse_session_new()
 */
void adafs_ll_destroy(void* pdata) {
    destroy_argobots();
    destroy_rpc_server();
    destroy_rpc_client();
    destroy_argobots();
    Util::write_inode_cnt();
}

+38 −0
Original line number Diff line number Diff line
//
// Created by evie on 6/22/17.
//

#include "c_metadata.hpp"

void send_minimal_rpc() {
    hg_handle_t handle;
    rpc_minimal_in_t in;
    rpc_minimal_out_t out;
    hg_addr_t svr_addr = HG_ADDR_NULL;

    ADAFS_DATA->spdlogger()->info("minimal RPC is running...");

    margo_addr_lookup(RPC_DATA->client_mid(), "cci+tcp://localhost:3344", &svr_addr);

    /* create handle */
    auto ret = HG_Create(RPC_DATA->client_hg_context(), svr_addr, RPC_DATA->rpc_minimal_id(), &handle);
    assert(ret == HG_SUCCESS);

    /* Send rpc. Note that we are also transmitting the bulk handle in the
     * input struct.  It was set above.
     */
    in.input = 42;
    margo_forward(RPC_DATA->client_mid(), handle, &in);

    /* decode response */
    ret = HG_Get_output(handle, &out);
    assert(ret == HG_SUCCESS);

    ADAFS_DATA->spdlogger()->info("Got response ret: {}", out.output);

    /* clean up resources consumed by this rpc */
    HG_Free_output(handle, &out);
    HG_Destroy(handle);

    ADAFS_DATA->spdlogger()->info("minimal RPC is done.");
}
 No newline at end of file
Loading