--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "KeyValueDB.h"
+#include "LevelDBStore.h"
+
+KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
+ const string& dir)
+{
+ if (type == "leveldb") {
+ return new LevelDBStore(cct, dir);
+ }
+#ifdef HAVE_KINETIC
+ if (kv_type == KV_TYPE_KINETIC) {
+ store = new KineticStore(g_ceph_context);
+ }
+#endif
+ return NULL;
+}
+
+int KeyValueDB::test_init(const string& type, const string& dir)
+{
+ if (type == "leveldb"){
+ return LevelDBStore::_test_init(dir);
+ }
+#ifdef HAVE_KINETIC
+ if (kv_type == KV_TYPE_KINETIC) {
+ return 0;
+ }
+#endif
+ return -EINVAL;
+}
};
typedef ceph::shared_ptr< TransactionImpl > Transaction;
+ /// create a new instance
+ static KeyValueDB *create(CephContext *cct, const string& type,
+ const string& dir);
+
+ /// test whether we can successfully initialize; may have side effects (e.g., create)
+ static int test_init(const string& type, const string& dir);
virtual int init() = 0;
virtual int open(ostream &out) = 0;
virtual int create_and_open(ostream &out) = 0;
return 0;
}
+int LevelDBStore::_test_init(const string& dir)
+{
+ leveldb::Options options;
+ options.create_if_missing = true;
+ leveldb::DB *db;
+ leveldb::Status status = leveldb::DB::Open(options, dir, &db);
+ delete db;
+ return status.ok() ? 0 : -EIO;
+}
+
LevelDBStore::~LevelDBStore()
{
close();
~LevelDBStore();
+ static int _test_init(const string& dir);
int init();
/// Opens underlying db
os/LevelDBStore.cc \
os/LFNIndex.cc \
os/MemStore.cc \
+ os/KeyValueDB.cc \
os/KeyValueStore.cc \
os/ObjectStore.cc \
os/WBThrottle.cc \