Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Command "pkcluster slotsslaveof ip port all table_id", "all" option
adapts to default table instead of "table_id" option.
  • Loading branch information
whoiami committed May 21, 2020
1 parent cd78df2 commit c3c7cc9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/pika_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,10 @@ void PkClusterSlotsSlaveofCmd::DoInitial() {
}
}

bool all_slots = false;
if (!strcasecmp(argv_[4].data(), "all")) {
std::string table_name = g_pika_conf->default_table();
slots_ = g_pika_server->GetTablePartitionIds(table_name);
// not know which table yet
all_slots = true;
} else {
Status s = ParseSlotGroup(argv_[4], &slots_);
if (!s.ok()) {
Expand All @@ -509,10 +510,6 @@ void PkClusterSlotsSlaveofCmd::DoInitial() {
}
}

if (slots_.empty()) {
res_.SetRes(CmdRes::kErrOther, "Slots set empty");
}

uint64_t table_id;
switch (argv_.size()) {
case 5:
Expand Down Expand Up @@ -545,11 +542,19 @@ void PkClusterSlotsSlaveofCmd::DoInitial() {
res_.SetRes(CmdRes::kErrOther, "syntax error");
return;
}

if (!g_pika_server->IsTableExist(table_name_)) {
res_.SetRes(CmdRes::kInvalidTable);
return;
}

if (all_slots) {
slots_ = g_pika_server->GetTablePartitionIds(table_name_);
}

if (slots_.empty()) {
res_.SetRes(CmdRes::kErrOther, "Slots set empty");
}
}

void PkClusterSlotsSlaveofCmd::Do(std::shared_ptr<Partition> partition) {
Expand Down

0 comments on commit c3c7cc9

Please sign in to comment.