Skip to content

Commit

Permalink
rename removeslots to delslots (OpenAtomFoundation#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep authored Jul 17, 2019
1 parent 7ca5391 commit 01a7027
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions include/pika_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ class PkClusterAddSlotsCmd : public SlotParentCmd {
Status AddSlotsSanityCheck(const std::string& table_name);
};

class PkClusterRemoveSlotsCmd : public SlotParentCmd {
class PkClusterDelSlotsCmd : public SlotParentCmd {
public:
PkClusterRemoveSlotsCmd(const std::string& name, int32_t arity, uint16_t flag)
PkClusterDelSlotsCmd(const std::string& name, int32_t arity, uint16_t flag)
: SlotParentCmd(name, arity, flag) {}
virtual void Do(std::shared_ptr<Partition> partition = nullptr);
private:
virtual void DoInitial() override;
Status RemoveSlotsSanityCheck(const std::string& table_name);
};

class PkClusterSlotSlaveofCmd : public Cmd {
class PkClusterSlotsSlaveofCmd : public Cmd {
public:
PkClusterSlotSlaveofCmd(const std::string& name , int arity, uint16_t flag)
PkClusterSlotsSlaveofCmd(const std::string& name , int arity, uint16_t flag)
: Cmd(name, arity, flag) {}
virtual void Do(std::shared_ptr<Partition> partition = nullptr);
private:
Expand Down
4 changes: 2 additions & 2 deletions include/pika_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ const std::string kCmdNameSlotsMgrtTagOne = "slotsmgrttagone";
//Cluster
const std::string kCmdNamePkClusterInfo = "pkclusterinfo";
const std::string kCmdNamePkClusterAddSlots = "pkclusteraddslots";
const std::string kCmdNamePkClusterRemoveSlots = "pkclusterremoveslots";
const std::string kCmdNamePkClusterSlotSlaveof = "pkclusterslotslaveof";
const std::string kCmdNamePkClusterDelSlots = "pkclusterdelslots";
const std::string kCmdNamePkClusterSlotsSlaveof = "pkclusterslotsslaveof";

const std::string kClusterPrefix = "pkcluster";
typedef pink::RedisCmdArgsType PikaCmdArgsType;
Expand Down
2 changes: 1 addition & 1 deletion include/pika_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class PikaServer {
friend class Cmd;
friend class InfoCmd;
friend class PkClusterAddSlotsCmd;
friend class PkClusterRemoveSlotsCmd;
friend class PkClusterDelSlotsCmd;
friend class PikaReplClientConn;
friend class PkClusterInfoCmd;

Expand Down
26 changes: 13 additions & 13 deletions src/pika_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void SlotParentCmd::DoInitial() {
return;
}
if (g_pika_conf->classic_mode()) {
res_.SetRes(CmdRes::kErrOther, "PkClusterAddSlots/PkClusterRemoveSlots only support on sharding mode");
res_.SetRes(CmdRes::kErrOther, "PkClusterAddSlots/PkClusterDelSlots only support on sharding mode");
return;
}

Expand Down Expand Up @@ -286,18 +286,18 @@ Status PkClusterAddSlotsCmd::AddSlotsSanityCheck(const std::string& table_name)
return Status::OK();
}

/* pkcluster removeslots 0-3,8-11
* pkcluster removeslots 0-3,8,9,10,11
* pkcluster removeslots 0,2,4,6,8,10,12,14
/* pkcluster delslots 0-3,8-11
* pkcluster delslots 0-3,8,9,10,11
* pkcluster delslots 0,2,4,6,8,10,12,14
*/
void PkClusterRemoveSlotsCmd::DoInitial() {
void PkClusterDelSlotsCmd::DoInitial() {
SlotParentCmd::DoInitial();
if (!res_.ok()) {
return;
}
}

void PkClusterRemoveSlotsCmd::Do(std::shared_ptr<Partition> partition) {
void PkClusterDelSlotsCmd::Do(std::shared_ptr<Partition> partition) {
std::string table_name = g_pika_conf->default_table();
std::shared_ptr<Table> table_ptr = g_pika_server->GetTable(table_name);
if (!table_ptr) {
Expand Down Expand Up @@ -351,7 +351,7 @@ void PkClusterRemoveSlotsCmd::Do(std::shared_ptr<Partition> partition) {
LOG(INFO) << "Pika meta file overwrite success";
}

Status PkClusterRemoveSlotsCmd::RemoveSlotsSanityCheck(const std::string& table_name) {
Status PkClusterDelSlotsCmd::RemoveSlotsSanityCheck(const std::string& table_name) {
Status s = g_pika_conf->TablePartitionsSanityCheck(table_name, slots_, false);
if (!s.ok()) {
return s;
Expand All @@ -375,13 +375,13 @@ Status PkClusterRemoveSlotsCmd::RemoveSlotsSanityCheck(const std::string& table_
return Status::OK();
}

/* pkcluster slotslaveof no one [0-3,8-11 | all]
* pkcluster slotslaveof ip port [0-3,8,9,10,11 | all]
* pkcluster slotslaveof ip port [0,2,4,6 force | all]
/* 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]
*/
void PkClusterSlotSlaveofCmd::DoInitial() {
void PkClusterSlotsSlaveofCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNamePkClusterSlotSlaveof);
res_.SetRes(CmdRes::kWrongNum, kCmdNamePkClusterSlotsSlaveof);
return;
}
if (g_pika_conf->classic_mode()) {
Expand Down Expand Up @@ -432,7 +432,7 @@ void PkClusterSlotSlaveofCmd::DoInitial() {
}
}

void PkClusterSlotSlaveofCmd::Do(std::shared_ptr<Partition> partition) {
void PkClusterSlotsSlaveofCmd::Do(std::shared_ptr<Partition> partition) {
std::string table_name = g_pika_conf->default_table();
for (const auto& slot : slots_) {
std::shared_ptr<SyncSlavePartition> slave_partition =
Expand Down
8 changes: 4 additions & 4 deletions src/pika_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ void InitCmdTable(std::unordered_map<std::string, Cmd*> *cmd_table) {
cmd_table->insert(std::pair<std::string, Cmd*>(kCmdNamePkClusterInfo, pkclusterinfoptr));
Cmd* pkclusteraddslotsptr = new PkClusterAddSlotsCmd(kCmdNamePkClusterAddSlots, 3, kCmdFlagsRead | kCmdFlagsAdmin);
cmd_table->insert(std::pair<std::string, Cmd*>(kCmdNamePkClusterAddSlots, pkclusteraddslotsptr));
Cmd* pkclusterremoveslotsptr = new PkClusterRemoveSlotsCmd(kCmdNamePkClusterRemoveSlots, 3, kCmdFlagsRead | kCmdFlagsAdmin);
cmd_table->insert(std::pair<std::string, Cmd*>(kCmdNamePkClusterRemoveSlots, pkclusterremoveslotsptr));
Cmd* pkclusterslotslaveofptr = new PkClusterSlotSlaveofCmd(kCmdNamePkClusterSlotSlaveof, -5, kCmdFlagsRead | kCmdFlagsAdmin);
cmd_table->insert(std::pair<std::string, Cmd*>(kCmdNamePkClusterSlotSlaveof, pkclusterslotslaveofptr));
Cmd* pkclusterdelslotsptr = new PkClusterDelSlotsCmd(kCmdNamePkClusterDelSlots, 3, kCmdFlagsRead | kCmdFlagsAdmin);
cmd_table->insert(std::pair<std::string, Cmd*>(kCmdNamePkClusterDelSlots, pkclusterdelslotsptr));
Cmd* pkclusterslotsslaveofptr = new PkClusterSlotsSlaveofCmd(kCmdNamePkClusterSlotsSlaveof, -5, kCmdFlagsRead | kCmdFlagsAdmin);
cmd_table->insert(std::pair<std::string, Cmd*>(kCmdNamePkClusterSlotsSlaveof, pkclusterslotsslaveofptr));

#ifdef TCMALLOC_EXTENSION
Cmd* tcmallocptr = new TcmallocCmd(kCmdNameTcmalloc, -2, kCmdFlagsRead | kCmdFlagsAdmin);
Expand Down

0 comments on commit 01a7027

Please sign in to comment.