Skip to content

Commit

Permalink
show peers in raft state (#4014)
Browse files Browse the repository at this point in the history
Co-authored-by: Doodle <[email protected]>
  • Loading branch information
liwenhui-soul and critical27 authored Mar 16, 2022
1 parent 3161f01 commit 37cc70b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/interface/raftex.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct GetStateResponse {
6: LogID last_log_id;
7: TermID last_log_term;
8: Status status;
9: list<binary> peers;
}

service RaftexService {
Expand Down
9 changes: 9 additions & 0 deletions src/kvstore/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,15 @@ void RaftPart::getState(cpp2::GetStateResponse& resp) {
resp.last_log_id_ref() = lastLogId_;
resp.last_log_term_ref() = lastLogTerm_;
resp.status_ref() = status_;
std::vector<std::string> peers;
for (auto& h : hosts_) {
std::string str = h->address().toString();
if (h->isLearner()) {
str += "_learner";
}
peers.emplace_back(str);
}
resp.peers_ref() = peers;
}

bool RaftPart::processElectionResponses(const RaftPart::ElectionResponses& results,
Expand Down

0 comments on commit 37cc70b

Please sign in to comment.