From: Sage Weil Date: Sun, 3 Nov 2013 01:53:03 +0000 (-0700) Subject: os/ObjectStore: add static create() method X-Git-Tag: v0.74~43^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=237d6b83758321fe74a5da30819e5da5b5ce366c;p=ceph.git os/ObjectStore: add static create() method 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 --- diff --git a/src/os/ObjectStore.cc b/src/os/ObjectStore.cc index 327c64167d5c..9d5d258c5df2 100644 --- a/src/os/ObjectStore.cc +++ b/src/os/ObjectStore.cc @@ -17,6 +17,16 @@ #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 << ")"; diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 6494290b5411..12565522414c 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -78,6 +78,16 @@ static inline void encode(const map *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);