From: František Dvořák Date: Sun, 1 Dec 2013 00:31:31 +0000 (+0100) Subject: Work with replicas. X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=4c6c3e2bef9f2ac37480c89c81e69c5c95303c60;p=dmlite-clients.git Work with replicas. --- 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