Skip to content

Commit

Permalink
rename default_partition_num to default_slot_num in pika.conf (OpenAt…
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep authored Jul 18, 2019
1 parent 01a7027 commit 4d01e19
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ userblacklist :
# if this option is set to 'classic', that means pika support multiple DB, in
# this mode, option databases enable
# if this option is set to 'sharding', that means pika support multiple Table, you
# can specify partition num for each table, in this mode, option default-partition-num enable
# can specify slot num for each table, in this mode, option default-slot-num enable
# Pika instance mode [classic | sharding]
instance-mode : classic
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases' - 1, limited in [1, 8]
databases : 1
# default partition number each table in sharding mode
default-partition-num : 1024
# default slot number each table in sharding mode
default-slot-num : 1024
# Dump Prefix
dump-prefix :
# daemonize [yes | no]
Expand Down
4 changes: 2 additions & 2 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PikaConf : public slash::BaseConf {
const std::vector<std::string>& vuser_blacklist() { RWLock l(&rwlock_, false); return user_blacklist_;}
bool classic_mode() { RWLock l(&rwlock_, false); return classic_mode_;}
int databases() { RWLock l(&rwlock_, false); return databases_;}
int default_partition_num() { RWLock l(&rwlock_, false); return default_partition_num_;}
int default_slot_num() { RWLock l(&rwlock_, false); return default_slot_num_;}
const std::vector<TableStruct>& table_structs() { RWLock l(&rwlock_, false); return table_structs_; }
std::string default_table() { RWLock l(&rwlock_, false); return default_table_;}
std::string compression() { RWLock l(&rwlock_, false); return compression_; }
Expand Down Expand Up @@ -259,7 +259,7 @@ class PikaConf : public slash::BaseConf {
std::vector<std::string> user_blacklist_;
bool classic_mode_;
int databases_;
int default_partition_num_;
int default_slot_num_;
std::vector<TableStruct> table_structs_;
std::string default_table_;
std::string bgsave_path_;
Expand Down
6 changes: 3 additions & 3 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,10 +1087,10 @@ void ConfigCmd::ConfigGet(std::string &ret) {
}

if (!g_pika_conf->classic_mode()
&& slash::stringmatch(pattern.data(), "default-partition-num", 1)) {
&& slash::stringmatch(pattern.data(), "default-slot-num", 1)) {
elements += 2;
EncodeString(&config_body, "default-partition-num");
EncodeInt32(&config_body, g_pika_conf->default_partition_num());
EncodeString(&config_body, "default-slot-num");
EncodeInt32(&config_body, g_pika_conf->default_slot_num());
}

if (slash::stringmatch(pattern.data(), "daemonize", 1)) {
Expand Down
2 changes: 1 addition & 1 deletion src/pika_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ Status PkClusterDelSlotsCmd::RemoveSlotsSanityCheck(const std::string& table_nam

/* pkcluster slotsslaveof no one [0-3,8-11 | all]
* pkcluster slotsslaveof ip port [0-3,8,9,10,11 | all]
* pkcluster slotsslaveof ip port [0,2,4,6 force | all]
* pkcluster slotsslaveof ip port [0,2,4,6,7,8,9 | all] force
*/
void PkClusterSlotsSlaveofCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
Expand Down
10 changes: 5 additions & 5 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ int PikaConf::Load()
table_structs_.push_back({"db" + std::to_string(idx), 1, {0}});
}
} else {
GetConfInt("default-partition-num", &default_partition_num_);
if (default_partition_num_ <= 0) {
LOG(FATAL) << "config default-partition-num error,"
GetConfInt("default-slot-num", &default_slot_num_);
if (default_slot_num_ <= 0) {
LOG(FATAL) << "config default-slot-num error,"
<< " it should greater than zero, the actual is: "
<< default_partition_num_;
<< default_slot_num_;
}
std::string pika_meta_path = db_path_ + kPikaMeta;
if (!slash::FileExists(pika_meta_path)) {
local_meta_->StableSave({{"db0", static_cast<uint32_t>(default_partition_num_), {}}});
local_meta_->StableSave({{"db0", static_cast<uint32_t>(default_slot_num_), {}}});
}
Status s = local_meta_->ParseMeta(&table_structs_);
if (!s.ok()) {
Expand Down
2 changes: 1 addition & 1 deletion src/pika_slot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void SlotsMgrtTagSlotAsyncCmd::DoInitial() {

std::string str_slot_num = *it++;
if (!slash::string2l(str_slot_num.data(), str_slot_num.size(), &slot_num_)
|| slot_num_ < 0 || slot_num_ >= g_pika_conf->default_partition_num()) {
|| slot_num_ < 0 || slot_num_ >= g_pika_conf->default_slot_num()) {
res_.SetRes(CmdRes::kInvalidInt, kCmdNameSlotsMgrtTagSlotAsync);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion third/blackwidow

0 comments on commit 4d01e19

Please sign in to comment.