diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/rgw/driver/dbstore/dbstore_mgr.h | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/rgw/driver/dbstore/dbstore_mgr.h')
-rw-r--r-- | src/rgw/driver/dbstore/dbstore_mgr.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/rgw/driver/dbstore/dbstore_mgr.h b/src/rgw/driver/dbstore/dbstore_mgr.h new file mode 100644 index 000000000..77fc3aaf7 --- /dev/null +++ b/src/rgw/driver/dbstore/dbstore_mgr.h @@ -0,0 +1,56 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#pragma once + +#include <map> +#include <cerrno> +#include <cstdlib> +#include <string> +#include <cstdio> +#include <iostream> +#include <vector> + +#include "common/ceph_context.h" +#include "common/dbstore.h" +#include "sqlite/sqliteDB.h" + +using namespace rgw::store; +using DB = rgw::store::DB; + +/* XXX: Should be a dbstore config option */ +const static std::string default_tenant = "default_ns"; + +class DBStoreManager { +private: + std::map<std::string, DB*> DBStoreHandles; + DB *default_db = nullptr; + CephContext *cct; + +public: + DBStoreManager(CephContext *_cct): DBStoreHandles() { + cct = _cct; + default_db = createDB(default_tenant); + }; + DBStoreManager(CephContext *_cct, std::string logfile, int loglevel): DBStoreHandles() { + /* No ceph context. Create one with log args provided */ + cct = _cct; + cct->_log->set_log_file(logfile); + cct->_log->reopen_log_file(); + cct->_conf->subsys.set_log_level(ceph_subsys_rgw, loglevel); + default_db = createDB(default_tenant); + }; + ~DBStoreManager() { destroyAllHandles(); }; + + /* XXX: TBD based on testing + * 1) Lock to protect DBStoreHandles map. + * 2) Refcount of each DBStore to protect from + * being deleted while using it. + */ + DB* getDB () { return default_db; }; + DB* getDB (std::string tenant, bool create); + DB* createDB (std::string tenant); + void deleteDB (std::string tenant); + void deleteDB (DB* db); + void destroyAllHandles(); +}; |