compact-prefix <prefix>
compact-range <prefix> <start> <end>
destructive-repair (use only as last resort! may corrupt healthy data)
+ stats
<< " compact-prefix <prefix>\n"
<< " compact-range <prefix> <start> <end>\n"
<< " destructive-repair (use only as last resort! may corrupt healthy data)\n"
+ << " stats\n"
<< std::endl;
}
}
bool need_open_db = (cmd != "destructive-repair");
- StoreTool st(type, path, need_open_db);
+ bool need_stats = (cmd == "stats");
+ StoreTool st(type, path, need_open_db, need_stats);
if (cmd == "destructive-repair") {
int ret = st.destructive_repair();
string start(url_unescape(argv[5]));
string end(url_unescape(argv[6]));
st.compact_range(prefix, start, end);
+ } else if (cmd == "stats") {
+ st.print_stats();
} else {
std::cerr << "Unrecognized command: " << cmd << std::endl;
return 1;
#include "include/buffer.h"
#include "kv/KeyValueDB.h"
-StoreTool::StoreTool(const string& type, const string& path, bool need_open_db)
+StoreTool::StoreTool(const string& type,
+ const string& path,
+ bool need_open_db,
+ bool need_stats)
: store_path(path)
{
+
+ if (need_stats) {
+ g_conf()->rocksdb_perf = true;
+ g_conf()->rocksdb_collect_compaction_stats = true;
+ }
+
if (type == "bluestore-kv") {
#ifdef WITH_BLUESTORE
if (load_bluestore(path, need_open_db) != 0)
std::cout << " duration " << duration << " seconds" << std::endl;
}
+int StoreTool::print_stats() const
+{
+ ostringstream ostr;
+ Formatter* f = Formatter::create("json-pretty", "json-pretty", "json-pretty");
+ int ret = -1;
+ if (g_conf()->rocksdb_perf) {
+ db->get_statistics(f);
+ ostr << "db_statistics ";
+ f->flush(ostr);
+ ret = 0;
+ } else {
+ ostr << "db_statistics not enabled";
+ f->flush(ostr);
+ }
+ std::cout << ostr.str() << std::endl;
+ delete f;
+ return ret;
+}
+
int StoreTool::copy_store_to(const string& type, const string& other_path,
const int num_keys_per_tx,
const string& other_type)
public:
StoreTool(const std::string& type,
const std::string& path,
- bool need_open_db=true);
+ bool need_open_db = true,
+ bool need_stats = false);
int load_bluestore(const std::string& path, bool need_open_db);
uint32_t traverse(const std::string& prefix,
const bool do_crc,
const std::string& start,
const std::string& end);
int destructive_repair();
+
+ int print_stats() const;
};