]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/KeyValueDB: pass kv_options map to ctor
authorSage Weil <sage@redhat.com>
Mon, 20 Nov 2017 20:52:18 +0000 (14:52 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:09 +0000 (14:44 -0600)
This will let us avoid passing options via global config options.

Signed-off-by: Sage Weil <sage@redhat.com>
src/kv/KeyValueDB.cc
src/kv/KeyValueDB.h
src/kv/RocksDBStore.h
src/test/objectstore/TestRocksdbOptionParse.cc

index 7a917b7a1836f1c9304b3d827359671268feaace..30e7e671114473ae206e7a86a7ab607a7fcb4d26 100644 (file)
@@ -15,6 +15,7 @@
 
 KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
                               const string& dir,
+                              map<string,string> options,
                               void *p)
 {
 #ifdef WITH_LEVELDB
@@ -30,7 +31,7 @@ KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
 #endif
 #ifdef HAVE_LIBROCKSDB
   if (type == "rocksdb") {
-    return new RocksDBStore(cct, dir, p);
+    return new RocksDBStore(cct, dir, options, p);
   }
 #endif
 
index 0b5b061b6aa0106727b424e28628bcfaa0952b29..50714d247136920108573a93311fc664c46cc91d 100644 (file)
@@ -151,6 +151,7 @@ public:
   /// create a new instance
   static KeyValueDB *create(CephContext *cct, const std::string& type,
                            const std::string& dir,
+                           map<std::string,std::string> options = {},
                            void *p = NULL);
 
   /// test whether we can successfully initialize; may have side effects (e.g., create)
index e6649548cd88961e7a6fe6e7214cc07d070b58a0..99d0941e7a41735b0bde761b3facc09ec54a6e3b 100644 (file)
@@ -71,6 +71,7 @@ class RocksDBStore : public KeyValueDB {
   CephContext *cct;
   PerfCounters *logger;
   string path;
+  map<string,string> kv_options;
   void *priv;
   rocksdb::DB *db;
   rocksdb::Env *env;
@@ -138,10 +139,11 @@ public:
     compact_range_async(combine_strings(prefix, start), combine_strings(prefix, end));
   }
 
-  RocksDBStore(CephContext *c, const string &path, void *p) :
+  RocksDBStore(CephContext *c, const string &path, map<string,string> opt, void *p) :
     cct(c),
     logger(NULL),
     path(path),
+    kv_options(opt),
     priv(p),
     db(NULL),
     env(static_cast<rocksdb::Env*>(p)),
index aae81bed4d612df3384b00a836f43112721d4194..c2b08735383ee374b69e50027a035b3a672e683a 100644 (file)
@@ -13,7 +13,8 @@ const string dir("rocksdb.test_temp_dir");
 TEST(RocksDBOption, simple) {
   rocksdb::Options options;
   rocksdb::Status status;
-  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, NULL);
+  map<string,string> kvoptions;
+  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, kvoptions, NULL);
   string options_string = ""
                          "write_buffer_size=536870912;"
                          "create_if_missing=true;"
@@ -42,7 +43,8 @@ TEST(RocksDBOption, simple) {
 TEST(RocksDBOption, interpret) {
   rocksdb::Options options;
   rocksdb::Status status;
-  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, NULL);
+  map<string,string> kvoptions;
+  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, kvoptions, NULL);
   string options_string = "compact_on_mount = true; compaction_threads=10;flusher_threads=5;";
   
   int r = db->ParseOptionsFromString(options_string, options);