Skip to content

Commit

Permalink
fix balance parser
Browse files Browse the repository at this point in the history
  • Loading branch information
liwenhui-soul committed Dec 24, 2021
1 parent 4365fdd commit aa58501
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -3710,30 +3710,42 @@ integer_list

balance_sentence
: KW_BALANCE KW_LEADER {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::LEADER_BALANCE);
$$ = sentence;
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::LEADER_BALANCE);
$$ = sentence;
}
|
KW_BALANCE KW_IN KW_ZONE {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::DATA_BALANCE);
$$ = sentence;
}
| KW_BALANCE KW_DATA {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::DATA_BALANCE);
$$ = sentence;
| KW_BALANCE KW_IN KW_ZONE KW_REMOVE host_list {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::DATA_BALANCE);
HostList* hl = $5;
std::vector<HostAddr> has = hl->hosts();
for (HostAddr& ha: has) {
sentence->addPara(ha.toString());
}
delete hl;
$$ = sentence;
}
| KW_BALANCE KW_DATA legal_integer {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::SHOW);
sentence->addPara(std::to_string($3));
$$ = sentence;
| KW_BALANCE KW_ACROSS KW_ZONE {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::ZONE_BALANCE);
$$ = sentence;
}
| KW_BALANCE KW_DATA KW_REMOVE host_list {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::DATA_BALANCE);
HostList* hl = $4;
std::vector<HostAddr> has = hl->hosts();
for (HostAddr& ha: has) {
sentence->addPara(ha.toString());
}
delete hl;
$$ = sentence;
| KW_BALANCE KW_ACROSS KW_ZONE KW_REMOVE zone_name_list {
auto sentence = new AdminJobSentence(meta::cpp2::AdminJobOp::ADD,
meta::cpp2::AdminCmd::ZONE_BALANCE);
ZoneNameList* nl = $5;
std::vector<std::string> names = nl->zoneNames();
for (std::string& name: names) {
sentence->addPara(name);
}
delete nl;
$$ = sentence;
}
;

Expand Down

0 comments on commit aa58501

Please sign in to comment.