Skip to content

Commit

Permalink
Prohibit the use of slot command in classic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
whoiami committed Jul 22, 2019
1 parent 3f5ae87 commit 6fd171a
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion src/pika_slot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ void SlotsInfoCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsInfo);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSINFO only support on sharding mode");
return;
}

return;
}

Expand Down Expand Up @@ -58,6 +64,12 @@ void SlotsHashKeyCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsHashKey);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSHASHKEY only support on sharding mode");
return;
}

return;
}

Expand All @@ -76,12 +88,18 @@ void SlotsHashKeyCmd::Do(std::shared_ptr<Partition> partition) {
return;
}

// SLOTSMGRTTAGSLOT host port timeout maxbulks maxbytes slot numkeys
// slotsmgrtslot-async host port timeout maxbulks maxbytes slot numkeys
void SlotsMgrtSlotAsyncCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsMgrtSlotAsync);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSMGRTTAGSLOT-ASYNC only support on sharding mode");
return;
}

return;
}

Expand All @@ -100,6 +118,11 @@ void SlotsMgrtTagSlotAsyncCmd::DoInitial() {
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSMGRTTAGSLOT-ASYNC only support on sharding mode");
return;
}

PikaCmdArgsType::const_iterator it = argv_.begin() + 1; //Remember the first args is the opt name
dest_ip_ = *it++;
slash::StringToLower(dest_ip_);
Expand Down Expand Up @@ -159,6 +182,12 @@ void SlotsScanCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsScan);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSSCAN only support on sharding mode");
return;
}

int64_t slotnum;
if (!slash::string2l(argv_[1].data(), argv_[1].size(), &slotnum)) {
res_.SetRes(CmdRes::kInvalidInt, kCmdNameSlotsScan);
Expand Down Expand Up @@ -231,6 +260,12 @@ void SlotsDelCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsDel);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSDEL only support on sharding mode");
return;
}

// iter starts from real key, first item in argv_ is command name
std::vector<std::string>::const_iterator iter = argv_.begin() + 1;
for (; iter != argv_.end(); iter++) {
Expand Down Expand Up @@ -278,6 +313,12 @@ void SlotsMgrtExecWrapperCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsMgrtExecWrapper);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSMGRT-EXEC-WRAPPER only support on sharding mode");
return;
}

PikaCmdArgsType::const_iterator it = argv_.begin() + 1;
key_ = *it++;
//slash::StringToLower(key_);
Expand All @@ -300,6 +341,12 @@ void SlotsMgrtAsyncStatusCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsMgrtAsyncStatus);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSMGRT-ASYNC-STATUS only support on sharding mode");
return;
}

return;
}

Expand Down Expand Up @@ -333,6 +380,12 @@ void SlotsMgrtAsyncCancelCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsMgrtAsyncCancel);
return;
}

if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "SLOTSMGRT-ASYNC-CANCEL only support on sharding mode");
return;
}

return;
}

Expand Down

0 comments on commit 6fd171a

Please sign in to comment.