Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool: misc cleanup of ceph-kvstore-tool #18815

Merged
merged 2 commits into from Nov 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/tools/ceph_kvstore_tool.cc
Expand Up @@ -13,6 +13,7 @@
#include <map>
#include <set>
#include <string>
#include <fstream>

#include <boost/scoped_ptr.hpp>

Expand All @@ -23,7 +24,6 @@
#include "global/global_context.h"
#include "global/global_init.h"
#include "include/stringify.h"
#include "include/utime.h"
#include "common/Clock.h"
#include "kv/KeyValueDB.h"
#include "common/url_escape.h"
Expand Down Expand Up @@ -231,7 +231,7 @@ class StoreTool
uint64_t total_size = 0;
uint64_t total_txs = 0;

utime_t started_at = ceph_clock_now();
auto started_at = coarse_mono_clock::now();

do {
int num_keys = 0;
Expand All @@ -256,22 +256,22 @@ class StoreTool
if (num_keys > 0)
other->submit_transaction_sync(tx);

utime_t cur_duration = ceph_clock_now() - started_at;
std::cout << "ts = " << cur_duration << "s, copied " << total_keys
auto cur_duration = std::chrono::duration<double>(coarse_mono_clock::now() - started_at);
std::cout << "ts = " << cur_duration.count() << "s, copied " << total_keys
<< " keys so far (" << stringify(si_t(total_size)) << ")"
<< std::endl;

} while (it->valid());

utime_t time_taken = ceph_clock_now() - started_at;
auto time_taken = std::chrono::duration<double>(coarse_mono_clock::now() - started_at);

std::cout << "summary:" << std::endl;
std::cout << " copied " << total_keys << " keys" << std::endl;
std::cout << " used " << total_txs << " transactions" << std::endl;
std::cout << " total size " << stringify(si_t(total_size)) << std::endl;
std::cout << " from '" << store_path << "' to '" << other_path << "'"
<< std::endl;
std::cout << " duration " << time_taken << " seconds" << std::endl;
std::cout << " duration " << time_taken.count() << " seconds" << std::endl;

return 0;
}
Expand Down Expand Up @@ -558,8 +558,13 @@ int main(int argc, const char *argv[])
}

} else if (cmd == "store-crc") {
uint32_t crc = st.traverse(string(), true, NULL);
std::cout << "store at '" << path << "' crc " << crc << std::endl;
if (argc < 4) {
usage(argv[0]);
return 1;
}
std::ofstream fs(argv[4]);
Copy link
Contributor

@tchaikov tchaikov Nov 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be argv[3]. as cmd is argv[2].

could you use args[3] instead? nvm, seems we are using argv everywhere else ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be argv[4].

➜  build git:(wip-kv-store-crc) ✗ ./bin/ceph-kvstore-tool bluestore-kv dev/osd2 store-crc t2.txt 2>/dev/null 
store at 't2.txt' crc 4037852868

uint32_t crc = st.traverse(string(), true, &fs);
std::cout << "store at '" << argv[4] << "' crc " << crc << std::endl;

} else if (cmd == "compact") {
st.compact();
Expand Down