2016-08-30 07:45:07 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-09-08 20:25:52 +08:00
|
|
|
#include "config/config.hpp"
|
2016-08-30 07:45:07 +08:00
|
|
|
#include "data_structures/concurrent/concurrent_map.hpp"
|
2017-02-04 16:01:15 +08:00
|
|
|
#include "database/graph_db.hpp"
|
2017-02-15 21:10:16 +08:00
|
|
|
#include "database/graph_db_accessor.hpp"
|
|
|
|
|
2017-02-06 19:40:55 +08:00
|
|
|
//#include "dbms/cleaner.hpp"
|
|
|
|
//#include "snapshot/snapshoter.hpp"
|
2016-08-30 07:45:07 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
class Dbms {
|
|
|
|
public:
|
|
|
|
Dbms() {
|
|
|
|
// create the default database and set is a active
|
|
|
|
active("default");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an accessor to the active database.
|
|
|
|
*/
|
|
|
|
GraphDbAccessor active();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the database with the given name to be active.
|
|
|
|
* If there is no database with the given name,
|
|
|
|
* it's created.
|
|
|
|
*
|
|
|
|
* @return an accessor to the database with the given name.
|
|
|
|
*/
|
|
|
|
GraphDbAccessor active(const std::string &name);
|
|
|
|
|
|
|
|
// TODO: DELETE action
|
|
|
|
|
|
|
|
private:
|
|
|
|
// dbs container
|
|
|
|
ConcurrentMap<std::string, GraphDb> dbs;
|
|
|
|
|
|
|
|
// currently active database
|
|
|
|
std::atomic<GraphDb *> active_db;
|
|
|
|
|
|
|
|
// // Cleaning thread.
|
|
|
|
// TODO re-enable cleaning
|
|
|
|
// Cleaning cleaning = {dbs, CONFIG_INTEGER(config::CLEANING_CYCLE_SEC)};
|
|
|
|
//
|
|
|
|
// // Snapshoting thread.
|
|
|
|
// TODO re-enable cleaning
|
|
|
|
// Snapshoter snapshoter = {dbs,
|
|
|
|
// CONFIG_INTEGER(config::SNAPSHOT_CYCLE_SEC)};
|
2016-08-30 07:45:07 +08:00
|
|
|
};
|