From 4c6c3e2bef9f2ac37480c89c81e69c5c95303c60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Sun, 1 Dec 2013 01:31:31 +0100 Subject: [PATCH] Work with replicas. --- run.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/run.cpp b/run.cpp index fbd8520..3225933 100644 --- a/run.cpp +++ b/run.cpp @@ -247,6 +247,43 @@ int main(int argc, char *argv[]) { break; } + + case 'p': { + dmlite::ExtendedStat xstat; + dmlite::Replica replica; + std::vector replicas; + char *cmd, *path, *rfn; + size_t i; + + if (argc < 4) { + std::cerr << "Missing command" << std::endl; + return 1; + } + cmd = argv[3]; + if (strcasecmp(cmd, "add") == 0 && argc >= 6) { + operation = "replica add"; + path = argv[4]; + rfn = argv[5]; + + xstat = catalog->extendedStat(path); + replica.fileid = xstat.stat.st_ino; + replica.rfn = rfn; + catalog->addReplica(replica); + } else if (strcasecmp(cmd, "list") == 0 && argc >= 5) { + operation = "replica list"; + path = argv[4]; + + replicas = catalog->getReplicas(path); + printf("Replicas of '%s':\n", path); + for (i = 0; i < replicas.size(); i++) { + printf(" %lu: inode %lu, server '%s', rfn '%s'\n", replicas[i].replicaid, replicas[i].fileid, replicas[i].server.c_str(), replicas[i].rfn.c_str()); + } + } else { + std::cerr << "Bad aruments for 'p'" << std::endl; + return 1; + } + } + } } catch (dmlite::DmException& e) { std::cout << "Could not " << operation << "." << std::endl -- 1.8.2.3