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),
"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")
;
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;