Work with replicas.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 1 Dec 2013 00:31:31 +0000 (01:31 +0100)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 1 Dec 2013 00:31:31 +0000 (01:31 +0100)
run.cpp

diff --git a/run.cpp b/run.cpp
index fbd8520..3225933 100644 (file)
--- 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<dmlite::Replica> 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