std::bind(std::equal_to<std::string>(), _1,
"two_level")))
bbt_opts.index_type = rocksdb::BlockBasedTableOptions::IndexType::kTwoLevelIndexSearch;
- bbt_opts.cache_index_and_filter_blocks =
- g_conf->get_val<bool>("rocksdb_cache_index_and_filter_blocks");
- bbt_opts.cache_index_and_filter_blocks_with_high_priority =
- g_conf->get_val<bool>("rocksdb_cache_index_and_filter_blocks_with_high_priority");
+ if (!bbt_opts.no_block_cache) {
+ bbt_opts.cache_index_and_filter_blocks =
+ g_conf->get_val<bool>("rocksdb_cache_index_and_filter_blocks");
+ bbt_opts.cache_index_and_filter_blocks_with_high_priority =
+ g_conf->get_val<bool>("rocksdb_cache_index_and_filter_blocks_with_high_priority");
+ bbt_opts.pin_l0_filter_and_index_blocks_in_cache =
+ g_conf->get_val<bool>("rocksdb_pin_l0_filter_and_index_blocks_in_cache");
+ }
bbt_opts.partition_filters = g_conf->get_val<bool>("rocksdb_partition_filters");
if (g_conf->get_val<uint64_t>("rocksdb_metadata_block_size") > 0)
bbt_opts.metadata_block_size = g_conf->get_val<uint64_t>("rocksdb_metadata_block_size");
- bbt_opts.pin_l0_filter_and_index_blocks_in_cache =
- g_conf->get_val<bool>("rocksdb_pin_l0_filter_and_index_blocks_in_cache");
opt.table_factory.reset(rocksdb::NewBlockBasedTableFactory(bbt_opts));
dout(10) << __func__ << " block size " << g_conf->rocksdb_block_size
}
if (g_conf->rocksdb_collect_memory_stats) {
f->open_object_section("rocksdb_memtable_statistics");
- std::string str(stringify(bbt_opts.block_cache->GetUsage()));
- f->dump_string("block_cache_usage", str.data());
- str.clear();
- str.append(stringify(bbt_opts.block_cache->GetPinnedUsage()));
- f->dump_string("block_cache_pinned_blocks_usage", str);
- str.clear();
+ std::string str;
+ if (!bbt_opts.no_block_cache) {
+ str.append(stringify(bbt_opts.block_cache->GetUsage()));
+ f->dump_string("block_cache_usage", str.data());
+ str.clear();
+ str.append(stringify(bbt_opts.block_cache->GetPinnedUsage()));
+ f->dump_string("block_cache_pinned_blocks_usage", str);
+ str.clear();
+ }
db->GetProperty("rocksdb.cur-size-all-mem-tables", &str);
f->dump_string("rocksdb_memtable_usage", str);
str.clear();
cerr << "Completing" << std::endl;
bstore->mount();
}
+TEST_P(StoreTest, BluestoreStatistics) {
+ if (string(GetParam()) != "bluestore")
+ return;
+
+ SetVal(g_conf, "rocksdb_perf", "true");
+ SetVal(g_conf, "rocksdb_collect_compaction_stats", "true");
+ SetVal(g_conf, "rocksdb_collect_extended_stats","true");
+ SetVal(g_conf, "rocksdb_collect_memory_stats","true");
+
+ // disable cache
+ SetVal(g_conf, "bluestore_cache_size_ssd", "0");
+ SetVal(g_conf, "bluestore_cache_size_hdd", "0");
+ SetVal(g_conf, "bluestore_cache_size", "0");
+ g_ceph_context->_conf->apply_changes(NULL);
+
+ int r = store->umount();
+ ASSERT_EQ(r, 0);
+ r = store->mount();
+ ASSERT_EQ(r, 0);
+
+ BlueStore* bstore = NULL;
+ EXPECT_NO_THROW(bstore = dynamic_cast<BlueStore*> (store.get()));
+
+ coll_t cid;
+ ghobject_t hoid(hobject_t("test_db_statistics", "", CEPH_NOSNAP, 0, 0, ""));
+ auto ch = bstore->create_new_collection(cid);
+ bufferlist bl;
+ bl.append("0123456789abcdefghi");
+ {
+ ObjectStore::Transaction t;
+ t.create_collection(cid, 0);
+ t.touch(cid, hoid);
+ t.write(cid, hoid, 0, bl.length(), bl);
+ cerr << "Write object" << std::endl;
+ r = queue_transaction(bstore, ch, std::move(t));
+ ASSERT_EQ(r, 0);
+ }
+ {
+ bufferlist readback;
+ r = store->read(ch, hoid, 0, bl.length(), readback);
+ ASSERT_EQ(r, bl.length());
+ ASSERT_TRUE(bl_eq(bl, readback));
+ }
+ Formatter *f = Formatter::create("store_test", "json-pretty", "json-pretty");
+ EXPECT_NO_THROW(store->get_db_statistics(f));
+ f->flush(cout);
+ cout << std::endl;
+}
#endif // WITH_BLUESTORE
int main(int argc, char **argv) {