Loading include/daemon/relocation/config_manager.hpp +9 −3 Original line number Diff line number Diff line Loading @@ -19,16 +19,22 @@ #include <utility> #include <vector> using hostmap_t = std::unordered_map<uint64_t, std::pair<std::string, std::string>>; namespace gkfs::relocation { void /** * @returns The hosts that need to be triggered for relocation. */ hostmap_t calculate_random_slicing(); std::unordered_map<uint64_t, std::pair<std::string, std::string>> hostmap_t read_hosts_file(); void do_relocation(); do_relocation(hostmap_t hosts); } // namespace gkfs::relocation Loading src/daemon/daemon.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -463,10 +463,9 @@ parse_input(const po::variables_map& vm) { if(gkfs::config::dynamic_placement && vm.count("start-relocation")) { std::cout << "Starting relocation...\n"; try { // TODO just testing at the moment gkfs::relocation::calculate_random_slicing(); auto trigger_hosts = gkfs::relocation::calculate_random_slicing(); gkfs::relocation::do_relocation(); gkfs::relocation::do_relocation(trigger_hosts); } catch(std::exception& e) { cerr << fmt::format("Error during start-relocation: '{}'. Exiting.", Loading src/daemon/relocation/config_manager.cpp +12 −24 Original line number Diff line number Diff line Loading @@ -41,13 +41,13 @@ using namespace std; namespace gkfs::relocation { void hostmap_t calculate_random_slicing() { using gkfs::rpc::host_t; // use id only for new configurations! auto hostsfile_hosts = read_hosts_file(); list<VDRIVE::Disk*> disks; hostmap_t trigger_hosts{}; auto filename = GKFS_DATA->hosts_file() + ".rsconfig"; auto dist = std::make_shared<VDRIVE::DistRandSlice>(); if(std::filesystem::exists(filename)) { Loading Loading @@ -97,25 +97,9 @@ calculate_random_slicing() { } } GKFS_DATA->spdlogger()->info("Hosts to be added: {}", new_uris_str); GKFS_DATA->spdlogger()->info("Hosts to be removed: {}", gone_uris_str); /* // gone = rs_hosts \ hostsfile_hosts std::set_difference(all_rs_hosts.begin(), all_rs_hosts.end(), all_hostsfile_hosts.begin(), all_hostsfile_hosts.end(), std::inserter(gone_uris, gone_uris.begin())); // new = hostsfile_hosts \ rs_hosts std::set_difference(all_hostsfile_hosts.begin(), all_hostsfile_hosts.end(), all_rs_hosts.begin(), all_rs_hosts.end(), std::inserter(new_uris, new_uris.begin())); */ // remove gone hosts if(gone_ids.size() > 0) { dist->removeDisks(gone_ids); Loading @@ -128,6 +112,10 @@ calculate_random_slicing() { } dist->addDisks(&disks); } // Trigger all the hosts of the old configuration since they will need // to be sinding away their data. trigger_hosts = rs_hosts; } else { GKFS_DATA->spdlogger()->info( "No existing random slicing configuration found, " Loading @@ -140,6 +128,7 @@ calculate_random_slicing() { cout << uri << "\n"; } dist->setConfiguration(&disks, 1, 1); trigger_hosts = hostsfile_hosts; } for(auto disk : disks) { delete disk; Loading @@ -151,13 +140,14 @@ calculate_random_slicing() { VDRIVE::DistRandSlice dist_read{}; dist_read.from_file(filename); dist_read.to_file(filename + ".debug-reexport"); return trigger_hosts; } unordered_map<uint64_t, pair<string, string>> hostmap_t read_hosts_file() { string hostfile = GKFS_DATA->hosts_file(); unordered_map<uint64_t, pair<string, string>> hosts; hostmap_t hosts; try { hosts = gkfs::utils::load_hostfile(hostfile); } catch(const exception& e) { Loading @@ -178,9 +168,7 @@ read_hosts_file() { * Send RPCs to all daemons in hosts file to trigger relocation. */ void do_relocation() { auto hosts = read_hosts_file(); do_relocation(hostmap_t hosts) { cout << "number of hosts: " << hosts.size() << "\n"; auto mid = margo_init(GKFS_DATA->bind_addr().c_str(), MARGO_CLIENT_MODE, 0, 0); Loading Loading
include/daemon/relocation/config_manager.hpp +9 −3 Original line number Diff line number Diff line Loading @@ -19,16 +19,22 @@ #include <utility> #include <vector> using hostmap_t = std::unordered_map<uint64_t, std::pair<std::string, std::string>>; namespace gkfs::relocation { void /** * @returns The hosts that need to be triggered for relocation. */ hostmap_t calculate_random_slicing(); std::unordered_map<uint64_t, std::pair<std::string, std::string>> hostmap_t read_hosts_file(); void do_relocation(); do_relocation(hostmap_t hosts); } // namespace gkfs::relocation Loading
src/daemon/daemon.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -463,10 +463,9 @@ parse_input(const po::variables_map& vm) { if(gkfs::config::dynamic_placement && vm.count("start-relocation")) { std::cout << "Starting relocation...\n"; try { // TODO just testing at the moment gkfs::relocation::calculate_random_slicing(); auto trigger_hosts = gkfs::relocation::calculate_random_slicing(); gkfs::relocation::do_relocation(); gkfs::relocation::do_relocation(trigger_hosts); } catch(std::exception& e) { cerr << fmt::format("Error during start-relocation: '{}'. Exiting.", Loading
src/daemon/relocation/config_manager.cpp +12 −24 Original line number Diff line number Diff line Loading @@ -41,13 +41,13 @@ using namespace std; namespace gkfs::relocation { void hostmap_t calculate_random_slicing() { using gkfs::rpc::host_t; // use id only for new configurations! auto hostsfile_hosts = read_hosts_file(); list<VDRIVE::Disk*> disks; hostmap_t trigger_hosts{}; auto filename = GKFS_DATA->hosts_file() + ".rsconfig"; auto dist = std::make_shared<VDRIVE::DistRandSlice>(); if(std::filesystem::exists(filename)) { Loading Loading @@ -97,25 +97,9 @@ calculate_random_slicing() { } } GKFS_DATA->spdlogger()->info("Hosts to be added: {}", new_uris_str); GKFS_DATA->spdlogger()->info("Hosts to be removed: {}", gone_uris_str); /* // gone = rs_hosts \ hostsfile_hosts std::set_difference(all_rs_hosts.begin(), all_rs_hosts.end(), all_hostsfile_hosts.begin(), all_hostsfile_hosts.end(), std::inserter(gone_uris, gone_uris.begin())); // new = hostsfile_hosts \ rs_hosts std::set_difference(all_hostsfile_hosts.begin(), all_hostsfile_hosts.end(), all_rs_hosts.begin(), all_rs_hosts.end(), std::inserter(new_uris, new_uris.begin())); */ // remove gone hosts if(gone_ids.size() > 0) { dist->removeDisks(gone_ids); Loading @@ -128,6 +112,10 @@ calculate_random_slicing() { } dist->addDisks(&disks); } // Trigger all the hosts of the old configuration since they will need // to be sinding away their data. trigger_hosts = rs_hosts; } else { GKFS_DATA->spdlogger()->info( "No existing random slicing configuration found, " Loading @@ -140,6 +128,7 @@ calculate_random_slicing() { cout << uri << "\n"; } dist->setConfiguration(&disks, 1, 1); trigger_hosts = hostsfile_hosts; } for(auto disk : disks) { delete disk; Loading @@ -151,13 +140,14 @@ calculate_random_slicing() { VDRIVE::DistRandSlice dist_read{}; dist_read.from_file(filename); dist_read.to_file(filename + ".debug-reexport"); return trigger_hosts; } unordered_map<uint64_t, pair<string, string>> hostmap_t read_hosts_file() { string hostfile = GKFS_DATA->hosts_file(); unordered_map<uint64_t, pair<string, string>> hosts; hostmap_t hosts; try { hosts = gkfs::utils::load_hostfile(hostfile); } catch(const exception& e) { Loading @@ -178,9 +168,7 @@ read_hosts_file() { * Send RPCs to all daemons in hosts file to trigger relocation. */ void do_relocation() { auto hosts = read_hosts_file(); do_relocation(hostmap_t hosts) { cout << "number of hosts: " << hosts.size() << "\n"; auto mid = margo_init(GKFS_DATA->bind_addr().c_str(), MARGO_CLIENT_MODE, 0, 0); Loading