Rename config flags.

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D446
This commit is contained in:
Dominik Gleich 2017-06-09 10:34:47 +02:00
parent 6308ec6a34
commit 1057d253ca
11 changed files with 51 additions and 51 deletions

View File

@ -10,18 +10,18 @@
#include "storage/edge.hpp"
#include "storage/garbage_collector.hpp"
DEFINE_int32(GC_CYCLE_SEC, 30,
DEFINE_int32(gc_cycle_sec, 30,
"Amount of time between starts of two cleaning cycles in seconds. "
"-1 to turn off.");
DEFINE_int32(MAX_RETAINED_SNAPSHOTS, -1,
DEFINE_int32(max_retained_snapshots, -1,
"Number of retained snapshots, -1 means without limit.");
DEFINE_int32(SNAPSHOT_CYCLE_SEC, -1,
DEFINE_int32(snapshot_cycle_sec, -1,
"Amount of time between starts of two snapshooters in seconds. -1 "
"to turn off.");
DEFINE_bool(SNAPSHOT_ON_DB_DESTRUCTION, false,
DEFINE_bool(snapshot_on_db_destruction, false,
"Snapshot on database destruction.");
DECLARE_string(SNAPSHOT_DIRECTORY);
DECLARE_string(snapshot_directory);
GraphDb::GraphDb(const std::string &name, const fs::path &snapshot_db_dir)
: name_(name),
@ -29,8 +29,8 @@ GraphDb::GraphDb(const std::string &name, const fs::path &snapshot_db_dir)
vertex_version_list_deleter_),
gc_edges_(edges_, edge_record_deleter_, edge_version_list_deleter_) {
// Pause of -1 means we shouldn't run the GC.
if (FLAGS_GC_CYCLE_SEC != -1) {
gc_scheduler_.Run(std::chrono::seconds(FLAGS_GC_CYCLE_SEC), [this]() {
if (FLAGS_gc_cycle_sec != -1) {
gc_scheduler_.Run(std::chrono::seconds(FLAGS_gc_cycle_sec), [this]() {
// main garbage collection logic
// see wiki documentation for logic explanation
const auto next_id = this->tx_engine.count() + 1;
@ -60,14 +60,14 @@ GraphDb::GraphDb(const std::string &name, const fs::path &snapshot_db_dir)
}
void GraphDb::StartSnapshooting() {
if (FLAGS_SNAPSHOT_CYCLE_SEC != -1) {
if (FLAGS_snapshot_cycle_sec != -1) {
auto create_snapshot = [this]() -> void {
GraphDbAccessor db_accessor(*this);
snapshooter_.MakeSnapshot(db_accessor,
fs::path(FLAGS_SNAPSHOT_DIRECTORY) / name_,
FLAGS_MAX_RETAINED_SNAPSHOTS);
fs::path(FLAGS_snapshot_directory) / name_,
FLAGS_max_retained_snapshots);
};
snapshot_creator_.Run(std::chrono::seconds(FLAGS_SNAPSHOT_CYCLE_SEC),
snapshot_creator_.Run(std::chrono::seconds(FLAGS_snapshot_cycle_sec),
create_snapshot);
}
}
@ -97,11 +97,11 @@ GraphDb::~GraphDb() {
snapshot_creator_.Stop();
// Create last database snapshot
if (FLAGS_SNAPSHOT_ON_DB_DESTRUCTION == true) {
if (FLAGS_snapshot_on_db_destruction == true) {
GraphDbAccessor db_accessor(*this);
snapshooter_.MakeSnapshot(db_accessor,
fs::path(FLAGS_SNAPSHOT_DIRECTORY) / name_,
FLAGS_MAX_RETAINED_SNAPSHOTS);
fs::path(FLAGS_snapshot_directory) / name_,
FLAGS_max_retained_snapshots);
}
// Delete vertices and edges which weren't collected before, also deletes

View File

@ -2,9 +2,9 @@
#include "dbms/dbms.hpp"
DEFINE_string(SNAPSHOT_DIRECTORY, "snapshots",
DEFINE_string(snapshot_directory, "snapshots",
"Relative path to directory in which to save snapshots.");
DEFINE_bool(RECOVER_ON_STARTUP, false, "Recover database on startup.");
DEFINE_bool(recover_on_startup, false, "Recover database on startup.");
std::unique_ptr<GraphDbAccessor> Dbms::active() {
return std::make_unique<GraphDbAccessor>(

View File

@ -11,18 +11,18 @@
#include "database/graph_db_accessor.hpp"
#include "durability/recovery.hpp"
DECLARE_string(SNAPSHOT_DIRECTORY);
DECLARE_bool(RECOVER_ON_STARTUP);
DECLARE_string(snapshot_directory);
DECLARE_bool(recover_on_startup);
namespace fs = std::experimental::filesystem;
class Dbms {
public:
Dbms() {
if (FLAGS_RECOVER_ON_STARTUP) {
if (fs::exists(fs::path(FLAGS_SNAPSHOT_DIRECTORY))) {
if (FLAGS_recover_on_startup) {
if (fs::exists(fs::path(FLAGS_snapshot_directory))) {
auto accessor = dbs.access();
for (auto &snapshot_db :
fs::directory_iterator(FLAGS_SNAPSHOT_DIRECTORY)) {
fs::directory_iterator(FLAGS_snapshot_directory)) {
// create db and set it active
active(snapshot_db.path().filename(), snapshot_db);
}

View File

@ -87,7 +87,7 @@ int main(int argc, char **argv) {
fs::current_path(fs::path(argv[0]).parent_path());
load_config(argc, argv);
// Logging init.
// Logging init.
#ifdef SYNC_LOGGER
logging::init_sync();
#else

View File

@ -1,6 +1,6 @@
#include "query/engine.hpp"
DEFINE_bool(INTERPRET, true,
DEFINE_bool(interpret, true,
"Use interpretor instead of compiler for query execution.");
DEFINE_string(COMPILE_DIRECTORY, "./compiled/",
DEFINE_string(compile_directory, "./compiled/",
"Directory in which to write compiled libraries.");

View File

@ -13,8 +13,8 @@ namespace fs = std::experimental::filesystem;
#include "query/plan_interface.hpp"
#include "utils/dynamic_lib.hpp"
DECLARE_bool(INTERPRET);
DECLARE_string(COMPILE_DIRECTORY);
DECLARE_bool(interpret);
DECLARE_string(compile_directory);
/**
* Responsible for query execution.
@ -64,7 +64,7 @@ class QueryEngine : public Loggable {
*/
auto Run(const std::string &query, GraphDbAccessor &db_accessor,
Stream &stream) {
if (FLAGS_INTERPRET) {
if (FLAGS_interpret) {
interpreter_.Interpret(query, db_accessor, stream);
return true;
}
@ -154,13 +154,13 @@ class QueryEngine : public Loggable {
return query_plan_it->second->instance();
// find hardcoded query plan if exists
auto hardcoded_path = fs::path(FLAGS_COMPILE_DIRECTORY + "hardcode/" +
auto hardcoded_path = fs::path(FLAGS_compile_directory + "hardcode/" +
std::to_string(stripped.hash()) + ".cpp");
if (fs::exists(hardcoded_path))
return LoadCpp(hardcoded_path, stripped.hash());
// generate query plan
auto generated_path = fs::path(FLAGS_COMPILE_DIRECTORY +
auto generated_path = fs::path(FLAGS_compile_directory +
std::to_string(stripped.hash()) + ".cpp");
return LoadCpp(generated_path, stripped.hash());
}
@ -189,7 +189,7 @@ class QueryEngine : public Loggable {
// and that is a problem because at this point we want brand new
// dynamic lib. That is the tmp solution. The right solution would be
// to deal with this problem in DynamicLib
auto path_so = FLAGS_COMPILE_DIRECTORY + std::to_string(hash) + "_" +
auto path_so = FLAGS_compile_directory + std::to_string(hash) + "_" +
(std::string)Timestamp::now() + ".so";
PlanCompiler().Compile(path_cpp, path_so);

View File

@ -5,8 +5,8 @@
#include "dbms/dbms.hpp"
#include "query_engine_common.hpp"
DECLARE_bool(INTERPRET);
DECLARE_string(COMPILE_DIRECTORY);
DECLARE_bool(interpret);
DECLARE_string(compile_directory);
using namespace std::chrono_literals;
using namespace tests::integration;
@ -32,10 +32,10 @@ int main(int argc, char *argv[]) {
auto log = init_logging("IntegrationQueryEngine");
// Manually set config compile_path to avoid loading whole config file with
// the test.
FLAGS_COMPILE_DIRECTORY = "../compiled/";
FLAGS_compile_directory = "../compiled/";
// Set the interpret to false to avoid calling the interpreter which doesn't
// support all the queries yet.
FLAGS_INTERPRET = false;
FLAGS_interpret = false;
Dbms dbms;
StreamT stream(std::cout);
QueryEngineT query_engine;

View File

@ -5,7 +5,7 @@
#include "communication/bolt/v1/session.hpp"
#include "query/engine.hpp"
DECLARE_bool(INTERPRET);
DECLARE_bool(interpret);
// Shortcuts for writing variable initializations in tests
#define INIT_VARS \
@ -577,7 +577,7 @@ int main(int argc, char **argv) {
logging::log->pipe(std::make_unique<Stdout>());
// Set the interpret to true to avoid calling the compiler which only
// supports a limited set of queries.
FLAGS_INTERPRET = true;
FLAGS_interpret = true;
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -5,9 +5,9 @@
#include "dbms/dbms.hpp"
DECLARE_bool(RECOVERY_ON_STARTUP);
DECLARE_string(SNAPSHOT_DIRECTORY);
DECLARE_int32(SNAPSHOT_CYCLE_SEC);
DECLARE_bool(recovery_on_startup);
DECLARE_string(snapshot_directory);
DECLARE_int32(snapshot_cycle_sec);
namespace fs = std::experimental::filesystem;
@ -36,13 +36,13 @@ class DbmsRecoveryTest : public ::testing::Test {
virtual void SetUp() {
CleanDbDir();
FLAGS_SNAPSHOT_DIRECTORY = SNAPSHOTS_DBMS_RECOVERY_ALL_DB;
FLAGS_SNAPSHOT_CYCLE_SEC = -1;
FLAGS_snapshot_directory = SNAPSHOTS_DBMS_RECOVERY_ALL_DB;
FLAGS_snapshot_cycle_sec = -1;
}
};
void CreateSnapshot() {
FLAGS_RECOVER_ON_STARTUP = false;
FLAGS_recover_on_startup = false;
Dbms dbms;
auto dba = dbms.active();
@ -61,7 +61,7 @@ void CreateSnapshot() {
}
void RecoverDbms() {
FLAGS_RECOVER_ON_STARTUP = true;
FLAGS_recover_on_startup = true;
Dbms dbms;
auto dba = dbms.active();

View File

@ -10,7 +10,7 @@
#include "durability/recovery.hpp"
#include "utils/assert.hpp"
DECLARE_int32(SNAPSHOT_CYCLE_SEC);
DECLARE_int32(snapshot_cycle_sec);
namespace fs = std::experimental::filesystem;
@ -39,7 +39,7 @@ class RecoveryTest : public ::testing::Test {
void SetUp() override {
CleanDbDir();
FLAGS_SNAPSHOT_CYCLE_SEC = -1;
FLAGS_snapshot_cycle_sec = -1;
}
const int max_retained_snapshots_ = 10;
};

View File

@ -6,9 +6,9 @@
#include "dbms/dbms.hpp"
#include "durability/snapshooter.hpp"
DECLARE_bool(SNAPSHOT_ON_DB_DESTRUCTION);
DECLARE_int32(SNAPSHOT_CYCLE_SEC);
DECLARE_string(SNAPSHOT_DIRECTORY);
DECLARE_bool(snapshot_on_db_destruction);
DECLARE_int32(snapshot_cycle_sec);
DECLARE_string(snapshot_directory);
namespace fs = std::experimental::filesystem;
@ -39,7 +39,7 @@ class SnapshotTest : public ::testing::Test {
virtual void SetUp() {
CleanDbDir();
FLAGS_SNAPSHOT_CYCLE_SEC = -1;
FLAGS_snapshot_cycle_sec = -1;
}
std::string snapshot_cycle_sec_setup_;
};
@ -100,8 +100,8 @@ TEST_F(SnapshotTest, CreateSnapshotWithUnlimitedMaxRetainedSnapshots) {
TEST_F(SnapshotTest, TestSnapshotFileOnDbDestruct) {
{
FLAGS_SNAPSHOT_DIRECTORY = SNAPSHOTS_FOLDER_ALL_DB;
FLAGS_SNAPSHOT_ON_DB_DESTRUCTION = true;
FLAGS_snapshot_directory = SNAPSHOTS_FOLDER_ALL_DB;
FLAGS_snapshot_on_db_destruction = true;
Dbms dbms;
auto dba = dbms.active();
}