Skip to content

Commit

Permalink
Config consensus-level and replication-num only configurable under sh…
Browse files Browse the repository at this point in the history
…arding mode (OpenAtomFoundation#881)
  • Loading branch information
whoiami authored Mar 27, 2020
1 parent abe1dde commit 239a078
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
12 changes: 5 additions & 7 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ instance-mode : classic
databases : 1
# default slot number each table in sharding mode
default-slot-num : 1024
# replication num defines how many followers in a single raft group, only [0, 1, 2, 3, 4] is valid
replication-num : 0
# consensus level defines how many confirms does leader get, before commit this log to client,
# only [0, ...replicaiton-num] is valid
consensus-level : 0
# Dump Prefix
dump-prefix :
# daemonize [yes | no]
Expand Down Expand Up @@ -83,13 +88,6 @@ slave-priority : 100
# if the freesize/disksize > 60%. NOTICE:compact-interval is prior than compact-cron;
#compact-interval :


# replication num defines how many followers in a single raft group, only [0, 1, 2, 3, 4] is valid
replication-num : 0
# consensus level defines how many confirms does leader get, before commit this log to client,
# only [0, ...replicaiton-num] is valid
consensus-level : 0

# the size of flow control window while sync binlog between master and slave.Default is 9000 and the maximum is 90000.
sync-window-size : 9000
# max value of connection read buffer size: configurable value 67108864(64MB) or 268435456(256MB) or 536870912(512MB)
Expand Down
44 changes: 24 additions & 20 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,6 @@ int PikaConf::Load()
GetConfInt("slowlog-log-slower-than", &tmp_slowlog_log_slower_than);
slowlog_log_slower_than_.store(tmp_slowlog_log_slower_than);

int tmp_replication_num = 0;
GetConfInt("replication-num", &tmp_replication_num);
if (tmp_replication_num > 4 || tmp_replication_num < 0) {
LOG(FATAL) << "replication-num " << tmp_replication_num <<
"is invalid, please pick from [0...4]";
}
replication_num_.store(tmp_replication_num);


int tmp_consensus_level = 0;
GetConfInt("consensus-level", &tmp_consensus_level);
if (tmp_consensus_level < 0 ||
tmp_consensus_level > replication_num_.load()) {
LOG(FATAL) << "consensus-level " << tmp_consensus_level
<< " is invalid, current replication-num: " << replication_num_.load()
<< ", please pick from 0 to replication-num"
<< " [0..." << replication_num_.load() << "]";
}
consensus_level_.store(tmp_consensus_level);

GetConfInt("slowlog-max-len", &slowlog_max_len_);
if (slowlog_max_len_ == 0) {
slowlog_max_len_ = 128;
Expand Down Expand Up @@ -304,6 +284,30 @@ int PikaConf::Load()
}
default_table_ = table_structs_[0].table_name;

int tmp_replication_num = 0;
GetConfInt("replication-num", &tmp_replication_num);
if (tmp_replication_num > 4 || tmp_replication_num < 0) {
LOG(FATAL) << "replication-num " << tmp_replication_num <<
"is invalid, please pick from [0...4]";
}
replication_num_.store(tmp_replication_num);

int tmp_consensus_level = 0;
GetConfInt("consensus-level", &tmp_consensus_level);
if (tmp_consensus_level < 0 ||
tmp_consensus_level > replication_num_.load()) {
LOG(FATAL) << "consensus-level " << tmp_consensus_level
<< " is invalid, current replication-num: " << replication_num_.load()
<< ", please pick from 0 to replication-num"
<< " [0..." << replication_num_.load() << "]";
}
consensus_level_.store(tmp_consensus_level);
if (classic_mode_.load() &&
(consensus_level_.load() != 0 || replication_num_.load() != 0)) {
LOG(FATAL) << "consensus-level & replication-num only configurable under sharding mode,"
<< " set it to be 0 if you are using classic mode";
}

compact_cron_ = "";
GetConfStr("compact-cron", &compact_cron_);
if (compact_cron_ != "") {
Expand Down

0 comments on commit 239a078

Please sign in to comment.