提交 d9b6fd05 编写于 作者: Y yudong.cai

MS-574 rename config deploy_mode


Former-commit-id: b3f2c2cc539c3cd7419c091b6eaf17df0a57f0eb
上级 d0b888c0
......@@ -77,7 +77,7 @@ Status DBImpl::Start() {
shutting_down_.store(false, std::memory_order_release);
//for distribute version, some nodes are read only
if (options_.mode_ != DBOptions::MODE::READ_ONLY) {
if (options_.mode_ != DBOptions::MODE::CLUSTER_READONLY) {
ENGINE_LOG_TRACE << "StartTimerTasks";
bg_timer_thread_ = std::thread(&DBImpl::BackgroundTimerTask, this);
}
......@@ -98,7 +98,7 @@ Status DBImpl::Stop() {
//wait compaction/buildindex finish
bg_timer_thread_.join();
if (options_.mode_ != DBOptions::MODE::READ_ONLY) {
if (options_.mode_ != DBOptions::MODE::CLUSTER_READONLY) {
meta_ptr_->CleanUp();
}
......@@ -684,7 +684,7 @@ void DBImpl::BackgroundCompaction(std::set<std::string> table_ids) {
meta_ptr_->Archive();
int ttl = 5*meta::M_SEC;//default: file will be deleted after 5 minutes
if (options_.mode_ == DBOptions::MODE::CLUSTER) {
if (options_.mode_ == DBOptions::MODE::CLUSTER_WRITABLE) {
ttl = meta::D_SEC;
}
meta_ptr_->CleanUpFilesWithTTL(ttl);
......
......@@ -60,9 +60,9 @@ struct DBMetaOptions {
struct DBOptions {
typedef enum {
SINGLE,
CLUSTER,
READ_ONLY
SINGLE = 0,
CLUSTER_READONLY,
CLUSTER_WRITABLE
} MODE;
uint16_t merge_trigger_number_ = 2;
......
......@@ -284,7 +284,7 @@ Status MySQLMetaImpl::Initialize() {
//step 5: create meta tables
try {
if (mode_ != DBOptions::MODE::READ_ONLY) {
if (mode_ != DBOptions::MODE::CLUSTER_READONLY) {
CleanUp();
}
......@@ -758,7 +758,7 @@ Status MySQLMetaImpl::DeleteTable(const std::string &table_id) {
} //Scoped Connection
if (mode_ == DBOptions::MODE::CLUSTER) {
if (mode_ == DBOptions::MODE::CLUSTER_WRITABLE) {
DeleteTableFiles(table_id);
}
......
......@@ -84,7 +84,7 @@ Config::ValidateConfig() {
if (!s.ok()) return s;
std::string server_mode;
s = GetServerConfigMode(server_mode);
s = GetServerConfigDeployMode(server_mode);
if (!s.ok()) return s;
std::string server_time_zone;
......@@ -219,7 +219,7 @@ Config::CheckServerConfigPort(const std::string &value) {
}
Status
Config::CheckServerConfigMode(const std::string &value) {
Config::CheckServerConfigDeployMode(const std::string &value) {
if (value != "single" &&
value != "cluster_readonly" &&
value != "cluster_writable") {
......@@ -511,12 +511,12 @@ Config::GetServerConfigStrPort() {
}
std::string
Config::GetServerConfigStrMode() {
Config::GetServerConfigStrDeployMode() {
std::string value;
if (!GetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_MODE, value).ok()) {
value = GetConfigNode(CONFIG_SERVER).GetValue(CONFIG_SERVER_MODE,
CONFIG_SERVER_MODE_DEFAULT);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_MODE, value);
if (!GetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_DEPLOY_MODE, value).ok()) {
value = GetConfigNode(CONFIG_SERVER).GetValue(CONFIG_SERVER_DEPLOY_MODE,
CONFIG_SERVER_DEPLOY_MODE_DEFAULT);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_DEPLOY_MODE, value);
}
return value;
}
......@@ -755,9 +755,9 @@ Config::GetServerConfigPort(std::string& value) {
}
Status
Config::GetServerConfigMode(std::string& value) {
value = GetServerConfigStrMode();
return CheckServerConfigMode(value);
Config::GetServerConfigDeployMode(std::string& value) {
value = GetServerConfigStrDeployMode();
return CheckServerConfigDeployMode(value);
}
Status
......@@ -938,10 +938,10 @@ Config::SetServerConfigPort(const std::string& value) {
}
Status
Config::SetServerConfigMode(const std::string& value) {
Status s = CheckServerConfigMode(value);
Config::SetServerConfigDeployMode(const std::string& value) {
Status s = CheckServerConfigDeployMode(value);
if (!s.ok()) return s;
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_MODE, value);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_DEPLOY_MODE, value);
return Status::OK();
}
......
......@@ -34,8 +34,8 @@ static const char* CONFIG_SERVER_ADDRESS = "address";
static const char* CONFIG_SERVER_ADDRESS_DEFAULT = "127.0.0.1";
static const char* CONFIG_SERVER_PORT = "port";
static const char* CONFIG_SERVER_PORT_DEFAULT = "19530";
static const char* CONFIG_SERVER_MODE = "mode";
static const char* CONFIG_SERVER_MODE_DEFAULT = "single";
static const char* CONFIG_SERVER_DEPLOY_MODE = "deploy_mode";
static const char* CONFIG_SERVER_DEPLOY_MODE_DEFAULT = "single";
static const char* CONFIG_SERVER_TIME_ZONE = "time_zone";
static const char* CONFIG_SERVER_TIME_ZONE_DEFAULT = "UTC+8";
......@@ -117,7 +117,7 @@ class Config {
/* server config */
Status CheckServerConfigAddress(const std::string& value);
Status CheckServerConfigPort(const std::string& value);
Status CheckServerConfigMode(const std::string& value);
Status CheckServerConfigDeployMode(const std::string& value);
Status CheckServerConfigTimeZone(const std::string& value);
/* db config */
......@@ -153,7 +153,7 @@ class Config {
/* server config */
std::string GetServerConfigStrAddress();
std::string GetServerConfigStrPort();
std::string GetServerConfigStrMode();
std::string GetServerConfigStrDeployMode();
std::string GetServerConfigStrTimeZone();
/* db config */
......@@ -188,7 +188,7 @@ class Config {
/* server config */
Status GetServerConfigAddress(std::string& value);
Status GetServerConfigPort(std::string& value);
Status GetServerConfigMode(std::string& value);
Status GetServerConfigDeployMode(std::string& value);
Status GetServerConfigTimeZone(std::string& value);
/* db config */
......@@ -224,7 +224,7 @@ class Config {
/* server config */
Status SetServerConfigAddress(const std::string& value);
Status SetServerConfigPort(const std::string& value);
Status SetServerConfigMode(const std::string& value);
Status SetServerConfigDeployMode(const std::string& value);
Status SetServerConfigTimeZone(const std::string& value);
/* db config */
......
......@@ -60,20 +60,20 @@ Status DBWrapper::StartService() {
if (!s.ok()) return s;
std::string mode;
s = config.GetServerConfigMode(mode);
s = config.GetServerConfigDeployMode(mode);
if (!s.ok()) return s;
if (mode == "single") {
opt.mode_ = engine::DBOptions::MODE::SINGLE;
}
else if (mode == "cluster") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER;
else if (mode == "cluster_readonly") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER_READONLY;
}
else if (mode == "read_only") {
opt.mode_ = engine::DBOptions::MODE::READ_ONLY;
else if (mode == "cluster_writable") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER_WRITABLE;
}
else {
std::cerr << "ERROR: mode specified in server_config is not one of ['single', 'cluster', 'read_only']" << std::endl;
std::cerr << "ERROR: mode specified in server_config must be ['single', 'cluster_readonly', 'cluster_writable']" << std::endl;
kill(0, SIGUSR1);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册