Skip to content

Commit

Permalink
Adding method to expose current leader uuid in RaftConsensus
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav04sharma committed Sep 17, 2019
1 parent 332a5d2 commit ae8899b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/kudu/consensus/raft_consensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,11 @@ int64_t RaftConsensus::CurrentTerm() const {
return CurrentTermUnlocked();
}

string RaftConsensus::GetLeaderUuid() const {
LockGuard l(lock_);
return GetLeaderUuidUnlocked();
}

void RaftConsensus::SetStateUnlocked(State new_state) {
switch (new_state) {
case kInitialized:
Expand Down
3 changes: 3 additions & 0 deletions src/kudu/consensus/raft_consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ class RaftConsensus : public std::enable_shared_from_this<RaftConsensus>,
// Returns the current term.
int64_t CurrentTerm() const;

// Returns uuid of the current leader
std::string GetLeaderUuid() const;

// Returns the uuid of this peer.
// Thread-safe.
const std::string& peer_uuid() const;
Expand Down

0 comments on commit ae8899b

Please sign in to comment.