Loading include/client/preload_context.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ struct FsConfig { // rpc infos std::map<uint64_t, std::string> hosts; std::unordered_map<std::string, std::string> endpoints; std::map<std::string, std::string> endpoints; uint64_t host_id; // my host number size_t host_size; std::string hostname_suffix; Loading include/client/preload_util.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ // third party libs #include <string> #include <iostream> #include <unordered_map> #include <map> extern "C" { #include <margo.h> Loading Loading @@ -67,7 +67,7 @@ int metadata_to_stat(const std::string& path, const Metadata& md, struct stat& a int get_daemon_pid(); std::unordered_map<std::string, std::string> load_lookup_file(const std::string& lfpath); std::map<std::string, std::string> load_lookup_file(const std::string& lfpath); hg_addr_t get_local_addr(); Loading src/client/preload_util.cpp +22 −17 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <fstream> #include <sstream> #include <regex> #include <csignal> #include <random> #include <sys/sysmacros.h> Loading Loading @@ -132,28 +133,32 @@ int get_daemon_pid() { return adafs_daemon_pid; } unordered_map<string, string> load_lookup_file(const std::string& lfpath) { CTX->log()->debug("{}() Loading lookup file: '{}'", __func__, lfpath); map<string, string> load_lookup_file(const std::string& lfpath) { CTX->log()->debug("{}() Loading lookup file: '{}'", __func__, lfpath); ifstream lf(lfpath); lf.exceptions(ifstream::badbit); unordered_map<string, string> endpoints_map; if (!lf) { throw runtime_error(fmt::format("Failed to open lookup file '{}': {}", lfpath, strerror(errno))); } map<string, string> hostmap; const regex line_re("^(\\S+)\\s+(\\S+)$", regex::ECMAScript | regex::optimize); string line; string hostname; string endpoint; string::size_type delim_pos; string host; string uri; std::smatch match; while (getline(lf, line)) { delim_pos = line.find(" ", delim_pos = 0); if(delim_pos == string::npos) { throw runtime_error(fmt::format("Failed to parse line in lookup file: '{}'", line)); if (!regex_match(line, match, line_re)) { spdlog::error("{}() Unrecognized line format: [path: '{}', line: '{}']", __func__, lfpath, line); throw runtime_error( fmt::format("unrecognized line format: '{}'", line)); } hostname = line.substr(0, delim_pos); endpoint = line.substr(delim_pos + 1); CTX->log()->trace("{}() endpoint loaded: '{}' '{}'", __func__, hostname, endpoint); endpoints_map.insert(make_pair(hostname, endpoint)); host = match[1]; uri = match[2]; hostmap.emplace(host, uri); } return endpoints_map; return hostmap; } hg_addr_t margo_addr_lookup_retry(const std::string& uri) { Loading Loading
include/client/preload_context.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ struct FsConfig { // rpc infos std::map<uint64_t, std::string> hosts; std::unordered_map<std::string, std::string> endpoints; std::map<std::string, std::string> endpoints; uint64_t host_id; // my host number size_t host_size; std::string hostname_suffix; Loading
include/client/preload_util.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ // third party libs #include <string> #include <iostream> #include <unordered_map> #include <map> extern "C" { #include <margo.h> Loading Loading @@ -67,7 +67,7 @@ int metadata_to_stat(const std::string& path, const Metadata& md, struct stat& a int get_daemon_pid(); std::unordered_map<std::string, std::string> load_lookup_file(const std::string& lfpath); std::map<std::string, std::string> load_lookup_file(const std::string& lfpath); hg_addr_t get_local_addr(); Loading
src/client/preload_util.cpp +22 −17 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <fstream> #include <sstream> #include <regex> #include <csignal> #include <random> #include <sys/sysmacros.h> Loading Loading @@ -132,28 +133,32 @@ int get_daemon_pid() { return adafs_daemon_pid; } unordered_map<string, string> load_lookup_file(const std::string& lfpath) { CTX->log()->debug("{}() Loading lookup file: '{}'", __func__, lfpath); map<string, string> load_lookup_file(const std::string& lfpath) { CTX->log()->debug("{}() Loading lookup file: '{}'", __func__, lfpath); ifstream lf(lfpath); lf.exceptions(ifstream::badbit); unordered_map<string, string> endpoints_map; if (!lf) { throw runtime_error(fmt::format("Failed to open lookup file '{}': {}", lfpath, strerror(errno))); } map<string, string> hostmap; const regex line_re("^(\\S+)\\s+(\\S+)$", regex::ECMAScript | regex::optimize); string line; string hostname; string endpoint; string::size_type delim_pos; string host; string uri; std::smatch match; while (getline(lf, line)) { delim_pos = line.find(" ", delim_pos = 0); if(delim_pos == string::npos) { throw runtime_error(fmt::format("Failed to parse line in lookup file: '{}'", line)); if (!regex_match(line, match, line_re)) { spdlog::error("{}() Unrecognized line format: [path: '{}', line: '{}']", __func__, lfpath, line); throw runtime_error( fmt::format("unrecognized line format: '{}'", line)); } hostname = line.substr(0, delim_pos); endpoint = line.substr(delim_pos + 1); CTX->log()->trace("{}() endpoint loaded: '{}' '{}'", __func__, hostname, endpoint); endpoints_map.insert(make_pair(hostname, endpoint)); host = match[1]; uri = match[2]; hostmap.emplace(host, uri); } return endpoints_map; return hostmap; } hg_addr_t margo_addr_lookup_retry(const std::string& uri) { Loading