]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-monstore-tool: added replay
authorSamuel Just <sam.just@inktank.com>
Thu, 2 May 2013 22:23:48 +0000 (15:23 -0700)
committerSage Weil <sage@inktank.com>
Wed, 8 May 2013 18:03:43 +0000 (11:03 -0700)
src/tools/ceph-monstore-tool.cc

index 37a49fb6f9458c3de010bf17763e1a68c7f63ba6..c62e16721f40f846196181f2a0b2d3f89f5f7c6f 100644 (file)
@@ -107,6 +107,10 @@ int main(int argc, char **argv) {
   string store_path, cmd, out_path, tfile;
   unsigned dstart = 0;
   unsigned dstop = ~0;
+  unsigned num_replays = 1;
+  unsigned tsize = 200;
+  unsigned tvalsize = 1024;
+  unsigned ntrans = 100;
   desc.add_options()
     ("help", "produce help message")
     ("mon-store-path", po::value<string>(&store_path),
@@ -121,6 +125,14 @@ int main(int argc, char **argv) {
      "transaction num to start dumping at")
     ("dump-end", po::value<unsigned>(&dstop),
      "transaction num to stop dumping at")
+    ("num-replays", po::value<unsigned>(&num_replays),
+     "number of times to replay")
+    ("trans-size", po::value<unsigned>(&tsize),
+     "keys to write in each transaction")
+    ("trans-val-size", po::value<unsigned>(&tvalsize),
+     "val to write in each key")
+    ("num-trans", po::value<unsigned>(&ntrans),
+     "number of transactions to run")
     ("command", po::value<string>(&cmd),
      "command")
     ;
@@ -223,6 +235,55 @@ int main(int argc, char **argv) {
       iter.next();
     }
     std::cerr << "Read up to transaction " << iter.num() << std::endl;
+  } else if (cmd == "replay-trace") {
+    if (!store_path.size()) {
+      std::cerr << "need mon store path" << std::endl;
+      std::cerr << desc << std::endl;
+      goto done;
+    }
+    if (tfile.empty()) {
+      std::cerr << "Need trace_file" << std::endl;
+      std::cerr << desc << std::endl;
+      goto done;
+    }
+    unsigned num = 0;
+    for (unsigned i = 0; i < num_replays; ++i) {
+      TraceIter iter(tfile.c_str());
+      iter.init();
+      while (true) {
+       if (!iter.valid())
+         break;
+       if (num % 20 == 0)
+         std::cerr << "Replaying trans num " << num << std::endl;
+       st.apply_transaction(iter.cur());
+       iter.next();
+       ++num;
+      }
+      std::cerr << "Read up to transaction " << iter.num() << std::endl;
+    }
+  } else if (cmd == "random-gen") {
+    if (!store_path.size()) {
+      std::cerr << "need mon store path" << std::endl;
+      std::cerr << desc << std::endl;
+      goto done;
+    }
+    unsigned num = 0;
+    for (unsigned i = 0; i < ntrans; ++i) {
+      std::cerr << "Applying trans " << i << std::endl;
+      MonitorDBStore::Transaction t;
+      string prefix;
+      prefix.push_back((i%26)+'a');
+      for (unsigned j = 0; j < tsize; ++j) {
+       stringstream os;
+       os << num;
+       bufferlist bl;
+       for (unsigned k = 0; k < tvalsize; ++k) bl.append(rand());
+       t.put(prefix, os.str(), bl);
+       ++num;
+      }
+      t.compact_prefix(prefix);
+      st.apply_transaction(t);
+    }
   } else {
     std::cerr << "Unrecognized command: " << cmd << std::endl;
     goto done;