]> git.proxmox.com Git - ceph.git/blame - ceph/src/kv/KeyValueDB.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / kv / KeyValueDB.cc
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#include "KeyValueDB.h"
5#ifdef WITH_LEVELDB
6#include "LevelDBStore.h"
7#endif
8#include "MemDB.h"
9#ifdef HAVE_LIBROCKSDB
10#include "RocksDBStore.h"
11#endif
7c673cae
FG
12
13KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
14 const string& dir,
11fdf7f2 15 map<string,string> options,
7c673cae
FG
16 void *p)
17{
18#ifdef WITH_LEVELDB
19 if (type == "leveldb") {
20 return new LevelDBStore(cct, dir);
21 }
22#endif
7c673cae
FG
23#ifdef HAVE_LIBROCKSDB
24 if (type == "rocksdb") {
11fdf7f2 25 return new RocksDBStore(cct, dir, options, p);
7c673cae
FG
26 }
27#endif
28
29 if ((type == "memdb") &&
30 cct->check_experimental_feature_enabled("memdb")) {
31 return new MemDB(cct, dir, p);
32 }
33 return NULL;
34}
35
36int KeyValueDB::test_init(const string& type, const string& dir)
37{
38#ifdef WITH_LEVELDB
39 if (type == "leveldb") {
40 return LevelDBStore::_test_init(dir);
41 }
42#endif
7c673cae
FG
43#ifdef HAVE_LIBROCKSDB
44 if (type == "rocksdb") {
45 return RocksDBStore::_test_init(dir);
46 }
47#endif
48
49 if (type == "memdb") {
50 return MemDB::_test_init(dir);
51 }
52 return -EINVAL;
53}