From: Samuel Just Date: Thu, 2 May 2013 22:23:48 +0000 (-0700) Subject: ceph-monstore-tool: added replay X-Git-Tag: v0.63~64^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dbcd738a22f1b34a4de8276cd3ccb4bdd9e97c4e;p=ceph.git ceph-monstore-tool: added replay --- diff --git a/src/tools/ceph-monstore-tool.cc b/src/tools/ceph-monstore-tool.cc index 37a49fb6f945..c62e16721f40 100644 --- a/src/tools/ceph-monstore-tool.cc +++ b/src/tools/ceph-monstore-tool.cc @@ -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(&store_path), @@ -121,6 +125,14 @@ int main(int argc, char **argv) { "transaction num to start dumping at") ("dump-end", po::value(&dstop), "transaction num to stop dumping at") + ("num-replays", po::value(&num_replays), + "number of times to replay") + ("trans-size", po::value(&tsize), + "keys to write in each transaction") + ("trans-val-size", po::value(&tvalsize), + "val to write in each key") + ("num-trans", po::value(&ntrans), + "number of transactions to run") ("command", po::value(&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;