Resolve "Move options to hostfile instead of initial RPC"

Closes #350 (closed)

Merge request reports

Loading
+8 −7
Changes for src/client/preload.cpp: 8 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -329,13 +329,14 @@ init_environment() {
        }
    }

    LOG(INFO, "Retrieving file system configuration...");

    if(!gkfs::rpc::forward_get_fs_config()) {
        exit_error_msg(
                EXIT_FAILURE,
                "Unable to fetch file system configurations from daemon process through RPC.");
    }
    //    LOG(INFO, "Retrieving file system configuration...");

    //   if(!gkfs::rpc::forward_get_fs_config()) {
    //       exit_error_msg(
    //               EXIT_FAILURE,
    //               "Unable to fetch file system configurations from daemon
    //               process through RPC.");
    //   }
    // Initialize random number generator and seed for replica selection
    // in case of failure, a new replica will be selected
    if(CTX->get_replicas() > 0) {
+19 −1
Changes for src/client/preload_util.cpp: 19 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -166,8 +166,10 @@ load_hostfile(const std::string& path) {
                                        path, strerror(errno)));
    }
    vector<pair<string, string>> hosts;
    const regex line_re("^(\\S+)\\s+(\\S+)\\s*(\\S*)$",
    const regex line_re(
            "^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$",
            regex::ECMAScript | regex::optimize);

    string line;
    string host;
    string uri;
@@ -185,9 +187,25 @@ load_hostfile(const std::string& path) {
            throw runtime_error(
                    fmt::format("unrecognized line format: '{}'", line));
        }

        host = match[1];
        uri = match[2];
        // match[3] that is the proxy (not used here)
        hosts.emplace_back(host, uri);

        // info will be repeated line per line:
        CTX->mountdir(match[4]);
        LOG(INFO, "Mountdir: '{}'", CTX->mountdir());

        CTX->fs_conf()->rootdir = match[5];
        CTX->fs_conf()->atime_state = match[6] == '1';
        CTX->fs_conf()->mtime_state = match[7] == '1';
        CTX->fs_conf()->ctime_state = match[8] == '1';
        CTX->fs_conf()->link_cnt_state = match[9] == '1';
        CTX->fs_conf()->blocks_state = match[10] == '1';
        // convert match[11] and match[12] to unsigned integers.
        CTX->fs_conf()->uid = std::stoi(match[11]);
        CTX->fs_conf()->gid = std::stoi(match[12]);
    }
    if(hosts.empty()) {
        throw runtime_error(
+3 −1
Changes for src/daemon/malleability/malleable_manager.cpp: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -75,8 +75,10 @@ MalleableManager::load_hostfile(const std::string& path) {
                                        path, strerror(errno)));
    }
    vector<pair<string, string>> hosts;
    const regex line_re("^(\\S+)\\s+(\\S+)\\s*(\\S*)$",
    const regex line_re(
            "^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$",
            regex::ECMAScript | regex::optimize);

    string line;
    string host;
    string uri;
+11 −0
Changes for src/daemon/util.cpp: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include <iostream>
#include <limits>
#include <thread>
#include <unistd.h>

using namespace std;

@@ -114,6 +115,16 @@ populate_hosts_file() {
    auto line_out = fmt::format("{} {}", hostname, daemon_addr);
    if(!proxy_addr.empty())
        line_out = fmt::format("{} {}", line_out, proxy_addr);
    if(proxy_addr.empty())
        line_out = fmt::format("{} {}", line_out, "NOPROXY");

    line_out = fmt::format(
            "{} {} {} {} {} {} {} {} {} {}", line_out, GKFS_DATA->mountdir(),
            GKFS_DATA->rootdir(), (int) GKFS_DATA->atime_state(),
            (int) GKFS_DATA->mtime_state(), (int) GKFS_DATA->ctime_state(),
            (int) GKFS_DATA->link_cnt_state(), (int) GKFS_DATA->blocks_state(),
            getuid(), getgid());

    // Constants for retry mechanism
    const int MAX_RETRIES = 5; // Maximum number of retry attempts
    const std::chrono::milliseconds RETRY_DELAY(
+3 −1
Changes for src/proxy/util.cpp: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -56,8 +56,10 @@ load_hostfile(const std::string& lfpath) {
                                        lfpath, strerror(errno)));
    }
    vector<pair<string, string>> hosts;
    const regex line_re("^(\\S+)\\s+(\\S+)\\s*(\\S*)$",
    const regex line_re(
            "^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$",
            regex::ECMAScript | regex::optimize);

    string line;
    string host;
    string uri;
Loading
Loading