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 b332efb
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -3709,31 +3709,37 @@ integer_list
;

balance_sentence
: KW_BALANCE KW_LEADER {
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 b332efb

Please sign in to comment.