Commit a8f4a32b authored by Ramon Nou's avatar Ramon Nou Committed by Ramon Nou
Browse files

Fast startup

parent aec508fa
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -329,13 +329,13 @@ init_environment() {
        }
    }

    LOG(INFO, "Retrieving file system configuration...");
//    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.");
    }
 //   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) {
+26 −5
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,28 @@ 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(
+11 −0
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(
+5 −3
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;