Loading include/client/preload_context.hpp +0 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ struct FsConfig { // rpc infos std::map<uint64_t, std::string> hosts; std::map<std::string, std::string> sys_hostfile; std::unordered_map<std::string, std::string> endpoints; uint64_t host_id; // my host number size_t host_size; Loading include/client/preload_util.hpp +0 −2 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ int get_daemon_pid(); std::unordered_map<std::string, std::string> load_lookup_file(const std::string& lfpath); bool read_system_hostfile(); hg_addr_t get_local_addr(); bool lookup_all_hosts(); Loading include/global/rpc/rpc_utils.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ hg_bool_t bool_to_merc_bool(bool state); std::string get_my_hostname(bool short_hostname = false); std::string get_host_by_name(const std::string & hostname); bool is_handle_sm(margo_instance_id mid, const hg_addr_t& addr); #endif //IFS_RPC_UTILS_HPP src/client/preload.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -146,11 +146,6 @@ void init_ld_environment_() { exit(EXIT_FAILURE); } if (!read_system_hostfile()) { CTX->log()->error("{}() Unable to read system hostfile /etc/hosts for address mapping.", __func__); exit(EXIT_FAILURE); } if (!lookup_all_hosts()) { CTX->log()->error("{}() Unable to lookup all host RPC addresses.", __func__); exit(EXIT_FAILURE); Loading src/client/preload_util.cpp +2 −32 Original line number Diff line number Diff line #include <client/preload_util.hpp> #include <global/rpc/distributor.hpp> #include <global/rpc/rpc_utils.hpp> #include <global/global_func.hpp> #include <fstream> Loading Loading @@ -136,33 +137,6 @@ unordered_map<string, string> load_lookup_file(const std::string& lfpath) { return endpoints_map; } /** * Read /etc/hosts and put hostname - ip association into a map in fs config. * We are working with hostnames but some network layers (such as Omnipath) does not look into /etc/hosts. * Hence, we have to store the mapping ourselves. * @return success */ bool read_system_hostfile() { ifstream hostfile("/etc/hosts"); if (!hostfile.is_open()) return false; string line; map<string, string> sys_hostfile; while (getline(hostfile, line)) { if (line.empty() || line == "\n" || line.at(0) == '#') continue; std::istringstream iss(line); std::vector<string> tmp_list((istream_iterator<string>(iss)), istream_iterator<string>()); for (unsigned int i = 1; i < tmp_list.size(); i++) { if (tmp_list[i].find(CTX->fs_conf()->hostname_suffix) != string::npos) sys_hostfile.insert(make_pair(tmp_list[i], tmp_list[0])); } } CTX->fs_conf()->sys_hostfile = sys_hostfile; CTX->log()->info("{}() /etc/hosts successfully mapped into ADA-FS", __func__); return true; } hg_addr_t margo_addr_lookup_retry(const std::string& uri) { // try to look up 3 times before erroring out hg_return_t ret; Loading Loading @@ -197,11 +171,7 @@ std::string get_uri_from_hostname(const std::string& hostname) { return CTX->fs_conf()->endpoints.at(hostname); } auto host = hostname + CTX->fs_conf()->hostname_suffix; // get the ip address from /etc/hosts which is mapped to the sys_hostfile map if (CTX->fs_conf()->sys_hostfile.count(host) == 1) { host = CTX->fs_conf()->sys_hostfile.at(host); } auto host = get_host_by_name(hostname + CTX->fs_conf()->hostname_suffix); return fmt::format("{}://{}:{}", RPC_PROTOCOL, host, CTX->fs_conf()->rpc_port); } Loading Loading
include/client/preload_context.hpp +0 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ struct FsConfig { // rpc infos std::map<uint64_t, std::string> hosts; std::map<std::string, std::string> sys_hostfile; std::unordered_map<std::string, std::string> endpoints; uint64_t host_id; // my host number size_t host_size; Loading
include/client/preload_util.hpp +0 −2 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ int get_daemon_pid(); std::unordered_map<std::string, std::string> load_lookup_file(const std::string& lfpath); bool read_system_hostfile(); hg_addr_t get_local_addr(); bool lookup_all_hosts(); Loading
include/global/rpc/rpc_utils.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ hg_bool_t bool_to_merc_bool(bool state); std::string get_my_hostname(bool short_hostname = false); std::string get_host_by_name(const std::string & hostname); bool is_handle_sm(margo_instance_id mid, const hg_addr_t& addr); #endif //IFS_RPC_UTILS_HPP
src/client/preload.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -146,11 +146,6 @@ void init_ld_environment_() { exit(EXIT_FAILURE); } if (!read_system_hostfile()) { CTX->log()->error("{}() Unable to read system hostfile /etc/hosts for address mapping.", __func__); exit(EXIT_FAILURE); } if (!lookup_all_hosts()) { CTX->log()->error("{}() Unable to lookup all host RPC addresses.", __func__); exit(EXIT_FAILURE); Loading
src/client/preload_util.cpp +2 −32 Original line number Diff line number Diff line #include <client/preload_util.hpp> #include <global/rpc/distributor.hpp> #include <global/rpc/rpc_utils.hpp> #include <global/global_func.hpp> #include <fstream> Loading Loading @@ -136,33 +137,6 @@ unordered_map<string, string> load_lookup_file(const std::string& lfpath) { return endpoints_map; } /** * Read /etc/hosts and put hostname - ip association into a map in fs config. * We are working with hostnames but some network layers (such as Omnipath) does not look into /etc/hosts. * Hence, we have to store the mapping ourselves. * @return success */ bool read_system_hostfile() { ifstream hostfile("/etc/hosts"); if (!hostfile.is_open()) return false; string line; map<string, string> sys_hostfile; while (getline(hostfile, line)) { if (line.empty() || line == "\n" || line.at(0) == '#') continue; std::istringstream iss(line); std::vector<string> tmp_list((istream_iterator<string>(iss)), istream_iterator<string>()); for (unsigned int i = 1; i < tmp_list.size(); i++) { if (tmp_list[i].find(CTX->fs_conf()->hostname_suffix) != string::npos) sys_hostfile.insert(make_pair(tmp_list[i], tmp_list[0])); } } CTX->fs_conf()->sys_hostfile = sys_hostfile; CTX->log()->info("{}() /etc/hosts successfully mapped into ADA-FS", __func__); return true; } hg_addr_t margo_addr_lookup_retry(const std::string& uri) { // try to look up 3 times before erroring out hg_return_t ret; Loading Loading @@ -197,11 +171,7 @@ std::string get_uri_from_hostname(const std::string& hostname) { return CTX->fs_conf()->endpoints.at(hostname); } auto host = hostname + CTX->fs_conf()->hostname_suffix; // get the ip address from /etc/hosts which is mapped to the sys_hostfile map if (CTX->fs_conf()->sys_hostfile.count(host) == 1) { host = CTX->fs_conf()->sys_hostfile.at(host); } auto host = get_host_by_name(hostname + CTX->fs_conf()->hostname_suffix); return fmt::format("{}://{}:{}", RPC_PROTOCOL, host, CTX->fs_conf()->rpc_port); } Loading