Skip to content

Commit

Permalink
only register mutable configs of graph and storage (vesoft-inc#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 authored and dangleptr committed Dec 20, 2019
1 parent c274a0f commit 0c4bd45
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 281 deletions.
56 changes: 0 additions & 56 deletions share/resources/gflags.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"IMMUTABLE": [
],
"REBOOT": [
],
"MUTABLE": [
"load_data_interval_secs",
"max_edge_returned_per_vertex",
Expand All @@ -13,58 +9,6 @@
"slow_op_threshhold_ms",
"wal_ttl"
],
"IGNORED": [
"logging",
"flagfile",
"fromenv",
"tryfromenv",
"undefok",
"tab_completion_columns",
"tab_completion_word",
"alsologtostderr",
"drop_log_memory",
"log_backtrace_at",
"log_dir",
"log_link",
"log_prefix",
"logbuflevel",
"logbufsecs",
"logemaillevel",
"logfile_mode",
"logmailer",
"logtostderr",
"max_log_size",
"stderrthreshold",
"stop_logging_if_full_disk",
"symbolize_stacktrace",
"vmodule",
"help",
"helpon",
"helpxml",
"helpfull",
"helpmatch",
"helpshort",
"alsologtoemail",
"version",
"helppackage",
"sasl_policy",
"codel_enabled",
"codel_interval",
"colorlogtostderr",
"dcache_unit_test",
"service_identity",
"thrift_ssl_policy",
"codel_target_delay",
"pending_interval",
"threadtimeout_ms",
"pin_service_identity",
"thrift_pcap_logging_prohibit",
"thrift_security_kill_switch_file",
"thrift_cpp2_protocol_reader_string_limit",
"thrift_cpp2_protocol_reader_container_limit",
"zlib_compressor_buffer_growth",
"gflags_mode_json"
],
"NESTED": [
"rocksdb_db_options",
"rocksdb_column_family_options",
Expand Down
1 change: 0 additions & 1 deletion src/daemons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ nebula_add_executable(
$<TARGET_OBJECTS:process_obj>
$<TARGET_OBJECTS:ws_obj>
$<TARGET_OBJECTS:ws_common_obj>
$<TARGET_OBJECTS:kv_gflags_man_obj>
$<TARGET_OBJECTS:gflags_man_obj>
$<TARGET_OBJECTS:network_obj>
$<TARGET_OBJECTS:thread_obj>
Expand Down
12 changes: 0 additions & 12 deletions src/daemons/MetaDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "meta/ClusterIdMan.h"
#include "kvstore/NebulaStore.h"
#include "meta/ActiveHostsMan.h"
#include "meta/KVBasedGflagsManager.h"

using nebula::operator<<;
using nebula::ProcessUtils;
Expand Down Expand Up @@ -155,12 +154,6 @@ bool initWebService(nebula::kvstore::KVStore* kvstore,
return true;
}

bool initComponents(nebula::kvstore::KVStore* kvstore) {
auto gflagsManager = std::make_unique<nebula::meta::KVBasedGflagsManager>(kvstore);
gflagsManager->init();
return true;
}

int main(int argc, char *argv[]) {
google::SetVersionString(nebula::versionString());
folly::init(&argc, &argv, true);
Expand Down Expand Up @@ -220,11 +213,6 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}

if (!initComponents(kvstore.get())) {
LOG(ERROR) << "Init components failed";
return EXIT_FAILURE;
}

LOG(INFO) << "Start http service";
auto helper = std::make_unique<nebula::hdfs::HdfsCommandHelper>();
auto pool = std::make_unique<nebula::thread::GenericThreadPool>();
Expand Down
27 changes: 9 additions & 18 deletions src/graph/test/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ std::vector<meta::cpp2::ConfigItem> mockRegisterGflags() {
meta::toThriftValueStr(type, value)));
}
{
auto module = meta::cpp2::ConfigModule::META;
auto module = meta::cpp2::ConfigModule::GRAPH;
auto mode = meta::cpp2::ConfigMode::MUTABLE;
auto type = meta::cpp2::ConfigType::DOUBLE;
double value = 1.0;
configItems.emplace_back(meta::toThriftConfigItem(module, "k1", type, mode,
meta::toThriftValueStr(type, value)));
}
{
auto module = meta::cpp2::ConfigModule::META;
auto module = meta::cpp2::ConfigModule::GRAPH;
auto mode = meta::cpp2::ConfigMode::MUTABLE;
auto type = meta::cpp2::ConfigType::STRING;
std::string value = "nebula";
Expand All @@ -73,8 +73,6 @@ std::vector<meta::cpp2::ConfigItem> mockRegisterGflags() {
std::string value = "nebula";
configItems.emplace_back(meta::toThriftConfigItem(meta::cpp2::ConfigModule::GRAPH, "k3",
type, mode, meta::toThriftValueStr(type, value)));
configItems.emplace_back(meta::toThriftConfigItem(meta::cpp2::ConfigModule::META, "k3",
type, mode, meta::toThriftValueStr(type, value)));
configItems.emplace_back(meta::toThriftConfigItem(meta::cpp2::ConfigModule::STORAGE, "k3",
type, mode, meta::toThriftValueStr(type, value)));
}
Expand Down Expand Up @@ -145,17 +143,17 @@ TEST_F(ConfigTest, ConfigTest) {
}
{
cpp2::ExecutionResponse resp;
std::string query = "UPDATE CONFIGS meta:k1=3.14";
std::string query = "UPDATE CONFIGS graph:k1=3.14";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
{
cpp2::ExecutionResponse resp;
std::string query = "GET CONFIGS meta:k1";
std::string query = "GET CONFIGS graph:k1";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
std::vector<uniform_tuple_t<std::string, 5>>
expected { {"META", "k1", "DOUBLE", "MUTABLE", "3.140000"} };
expected { {"GRAPH", "k1", "DOUBLE", "MUTABLE", "3.140000"} };
ASSERT_TRUE(verifyResult(resp, expected));
}
{
Expand All @@ -176,17 +174,17 @@ TEST_F(ConfigTest, ConfigTest) {
}
{
cpp2::ExecutionResponse resp;
std::string query = "UPDATE CONFIGS meta:k2=abc";
std::string query = "UPDATE CONFIGS graph:k2=abc";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
{
cpp2::ExecutionResponse resp;
std::string query = "GET CONFIGS meta:k2";
std::string query = "GET CONFIGS graph:k2";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
std::vector<uniform_tuple_t<std::string, 5>> expected {
{"META", "k2", "STRING", "MUTABLE", "abc"}
{"GRAPH", "k2", "STRING", "MUTABLE", "abc"}
};
ASSERT_TRUE(verifyResult(resp, expected));
}
Expand All @@ -200,10 +198,9 @@ TEST_F(ConfigTest, ConfigTest) {
}
{
cpp2::ExecutionResponse resp;
std::string query = "SHOW CONFIGS meta";
std::string query = "SHOW CONFIGS graph";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
ASSERT_EQ(3, resp.get_rows()->size());
}
// set and get a config of all module
{
Expand All @@ -219,7 +216,6 @@ TEST_F(ConfigTest, ConfigTest) {
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
std::vector<uniform_tuple_t<std::string, 5>> expected {
{"GRAPH", "k3", "STRING", "MUTABLE", "vesoft"},
{"META", "k3", "STRING", "MUTABLE", "vesoft"},
{"STORAGE", "k3", "STRING", "MUTABLE", "vesoft"},
};
ASSERT_TRUE(verifyResult(resp, expected));
Expand All @@ -230,10 +226,6 @@ TEST_F(ConfigTest, ConfigTest) {
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

query = "UPDATE CONFIGS meta:k3=bcd";
code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

query = "UPDATE CONFIGS storage:k3=cde";
code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
Expand All @@ -245,7 +237,6 @@ TEST_F(ConfigTest, ConfigTest) {
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
std::vector<uniform_tuple_t<std::string, 5>> expected {
{"GRAPH", "k3", "STRING", "MUTABLE", "abc"},
{"META", "k3", "STRING", "MUTABLE", "bcd"},
{"STORAGE", "k3", "STRING", "MUTABLE", "cde"},
};
ASSERT_TRUE(verifyResult(resp, expected));
Expand Down
5 changes: 0 additions & 5 deletions src/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,4 @@ nebula_add_library(
ClientBasedGflagsManager.cpp
)

nebula_add_library(
kv_gflags_man_obj OBJECT
KVBasedGflagsManager.cpp
)

nebula_add_subdirectory(test)
27 changes: 9 additions & 18 deletions src/meta/GflagsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ GflagsManager::parseConfigJson(const std::string& path) {
LOG(ERROR) << "Load gflags json failed";
return configModeMap;
}
static std::vector<std::string> keys = {"IMMUTABLE", "REBOOT", "MUTABLE", "IGNORED"};
static std::vector<cpp2::ConfigMode> modes = {cpp2::ConfigMode::IMMUTABLE,
cpp2::ConfigMode::REBOOT,
cpp2::ConfigMode::MUTABLE,
cpp2::ConfigMode::IGNORED};
static std::vector<std::string> keys = {"MUTABLE"};
static std::vector<cpp2::ConfigMode> modes = {cpp2::ConfigMode::MUTABLE};
for (size_t i = 0; i < keys.size(); i++) {
std::vector<std::string> values;
if (!conf.fetchAsStringArray(keys[i].c_str(), values).ok()) {
Expand Down Expand Up @@ -67,7 +64,8 @@ std::vector<cpp2::ConfigItem> GflagsManager::declareGflags(const cpp2::ConfigMod
if (module == cpp2::ConfigModule::UNKNOWN) {
return configItems;
}
auto configModeMap = parseConfigJson(FLAGS_gflags_mode_json);
auto mutableConfig = parseConfigJson(FLAGS_gflags_mode_json);
// Get all flags by listing all defined gflags
std::vector<gflags::CommandLineFlagInfo> flags;
gflags::GetAllFlags(&flags);
for (auto& flag : flags) {
Expand All @@ -77,22 +75,15 @@ std::vector<cpp2::ConfigItem> GflagsManager::declareGflags(const cpp2::ConfigMod
VariantType value;
std::string valueStr;

// default config type would be immutable
cpp2::ConfigMode mode = cpp2::ConfigMode::IMMUTABLE;
// We only register mutable configs to meta
cpp2::ConfigMode mode = cpp2::ConfigMode::MUTABLE;
bool isNested = false;
auto iter = configModeMap.find(name);
if (iter != configModeMap.end()) {
mode = iter->second.first;
auto iter = mutableConfig.find(name);
if (iter != mutableConfig.end()) {
isNested = iter->second.second;
}
// ignore some useless gflags
if (mode == cpp2::ConfigMode::IGNORED) {
} else {
continue;
}
if (module == cpp2::ConfigModule::META) {
// all config of meta is immutable for now
mode = cpp2::ConfigMode::IMMUTABLE;
}

// TODO: all int32/uint32/uint64 gflags are converted to int64 for now
if (type == "uint32" || type == "int32" || type == "int64" || type == "uint64") {
Expand Down
113 changes: 0 additions & 113 deletions src/meta/KVBasedGflagsManager.cpp

This file was deleted.

Loading

0 comments on commit 0c4bd45

Please sign in to comment.