]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/ObjectStore: add static create() method
authorSage Weil <sage@inktank.com>
Sun, 3 Nov 2013 01:53:03 +0000 (18:53 -0700)
committerSage Weil <sage@inktank.com>
Sat, 30 Nov 2013 06:28:35 +0000 (22:28 -0800)
Generic way to create an ObjectStore implementation of the required type,
so that users don't need to know anything about it.

Signed-off-by: Sage Weil <sage@inktank.com>
src/os/ObjectStore.cc
src/os/ObjectStore.h

index 327c64167d5cf16aa50c77ff1040ef53d36754c5..9d5d258c5df220c44a05f173581175326820517f 100644 (file)
 #include "common/Formatter.h"
 #include "FileStore.h"
 
+ObjectStore *ObjectStore::create(const string& type,
+                                const string& data,
+                                const string& journal)
+{
+  if (type == "filestore") {
+    return new FileStore(data, journal);
+  }
+  return NULL;
+}
+
 ostream& operator<<(ostream& out, const ObjectStore::Sequencer& s)
 {
   return out << "osr(" << s.get_name() << " " << &s << ")";
index 6494290b54112d130be64ca55e98400db1e87c56..12565522414c069b678cb3879f55f415915c690b 100644 (file)
@@ -78,6 +78,16 @@ static inline void encode(const map<string,bufferptr> *attrset, bufferlist &bl)
 
 class ObjectStore {
 public:
+  /**
+   * create - create an ObjectStore instance
+   *
+   * @param type type of store
+   * @param data path (or other descriptor) for data
+   * @param journal path (or other descriptor) for journal (optional)
+   */
+  static ObjectStore *create(const string& type,
+                            const string& data,
+                            const string& journal);
 
   Logger *logger;
 
@@ -1040,8 +1050,6 @@ public:
   virtual void inject_data_error(const ghobject_t &oid) {}
   virtual void inject_mdata_error(const ghobject_t &oid) {}
 };
-
-
 WRITE_CLASS_ENCODER(ObjectStore::Transaction)
 
 ostream& operator<<(ostream& out, const ObjectStore::Sequencer& s);