]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/store/dbstore/dbstore_mgr.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
12 #include "common/ceph_context.h"
13 #include "common/dbstore.h"
14 #include "sqlite/sqliteDB.h"
17 using namespace rgw::store
;
18 using DB
= rgw::store::DB
;
20 /* XXX: Should be a dbstore config option */
21 const static string default_tenant
= "default_ns";
25 class DBStoreManager
{
27 map
<string
, DB
*> DBStoreHandles
;
28 DB
*default_db
= NULL
;
32 DBStoreManager(CephContext
*_cct
): DBStoreHandles() {
34 default_db
= createDB(default_tenant
);
36 DBStoreManager(string logfile
, int loglevel
): DBStoreHandles() {
37 /* No ceph context. Create one with log args provided */
38 vector
<const char*> args
;
39 cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_CLIENT
,
40 CODE_ENVIRONMENT_DAEMON
, CINIT_FLAG_NO_MON_CONFIG
, 1)->get();
41 cct
->_log
->set_log_file(logfile
);
42 cct
->_log
->reopen_log_file();
43 cct
->_conf
->subsys
.set_log_level(ceph_subsys_rgw
, loglevel
);
45 ~DBStoreManager() { destroyAllHandles(); };
47 /* XXX: TBD based on testing
48 * 1) Lock to protect DBStoreHandles map.
49 * 2) Refcount of each DBStore to protect from
50 * being deleted while using it.
52 DB
* getDB () { return default_db
; };
53 DB
* getDB (string tenant
, bool create
);
54 DB
* createDB (string tenant
);
55 void deleteDB (string tenant
);
56 void deleteDB (DB
* db
);
57 void destroyAllHandles();