Skip to content

Commit

Permalink
rsync optimized for speed (OpenAtomFoundation#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leviathan1995 authored and KernelMaker committed Aug 5, 2017
1 parent 92114dd commit cab9580
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -686,24 +686,25 @@ void PikaServer::DBSyncSendFile(const std::string& ip, int port) {
}
// Get all files need to send
std::vector<std::string> descendant;
if (!slash::GetDescendant(bg_path, descendant)) {
LOG(WARNING) << "Get Descendant when try to do db sync failed";
if (!slash::GetChildren(bg_path, descendant)) {
LOG(WARNING) << "Get child directory when try to do db sync failed";
}

// Iterate to send files
int ret = 0;
std::string target_path;
std::string local_path, target_path;
std::string module = kDBSyncModule + "_" + slash::IpPortString(host_, port_);
std::vector<std::string>::iterator it = descendant.begin();
slash::RsyncRemote remote(ip, port, module, g_pika_conf->db_sync_speed() * 1024);
for (; it != descendant.end(); ++it) {
target_path = (*it).substr(bg_path.size() + 1);
local_path = bg_path + "/" + *it;
target_path = *it;

if (target_path == kBgsaveInfoFile) {
continue;
}
// We need specify the speed limit for every single file
ret = slash::RsyncSendFile(*it, target_path, remote);

ret = slash::RsyncSendFile(local_path, target_path, remote);

if (0 != ret) {
LOG(WARNING) << "rsync send file failed! From: " << *it
Expand Down

0 comments on commit cab9580

Please sign in to comment.