From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/rgw/driver/dbstore/dbstore_mgr.h | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/rgw/driver/dbstore/dbstore_mgr.h (limited to 'src/rgw/driver/dbstore/dbstore_mgr.h') 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 +#include +#include +#include +#include +#include +#include + +#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 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(); +}; -- cgit v1.2.3