-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISSUE-62: provide an interface to get raft members' offsets #63
Conversation
|
2072582
to
f7282a3
Compare
Hi jj, it seems that I don't have the permission to assign assignees or request reviewers, would you please help? |
src/infra/raft/v2/RaftCore.cpp
Outdated
mInSyncFollowers->push_back(peerLag); | ||
} | ||
std::sort(mInSyncFollowers->begin(), mInSyncFollowers->end(), | ||
[](MemberOffsetInfo x, MemberOffsetInfo y) { return x.mId > y.mId; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const &
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't sort at infra level
src/infra/raft/RaftInterface.h
Outdated
@@ -103,6 +112,7 @@ class RaftInterface { | |||
virtual uint64_t getLastLogIndex() const = 0; | |||
virtual std::optional<uint64_t> getLeaderHint() const = 0; | |||
virtual std::vector<MemberInfo> getClusterMembers() const = 0; | |||
virtual void getInSyncFollowers(const int64_t &, std::vector<MemberOffsetInfo> *) const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return leader offset and followers' offset
src/infra/raft/v2/RaftCore.cpp
Outdated
mInSyncFollowers->push_back(peerLag); | ||
} | ||
std::sort(mInSyncFollowers->begin(), mInSyncFollowers->end(), | ||
[](MemberOffsetInfo x, MemberOffsetInfo y) { return x.mId > y.mId; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't sort at infra level
cafe548
to
7a47e82
Compare
src/infra/raft/v2/RaftCore.cpp
Outdated
mMemberOffsets->push_back(peerOffset); | ||
} | ||
/// put leader offset info at the back | ||
mMemberOffsets->push_back({mSelfInfo.mId, mSelfInfo.mAddress, mMajorityIndex, true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back
src/infra/raft/v2/RaftCore.cpp
Outdated
peerOffset.mAddress = peer.mAddress; | ||
peerOffset.mOffset = peer.mMatchIndex; | ||
peerOffset.mIsLeader = false; | ||
mMemberOffsets->push_back(peerOffset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back
src/infra/raft/v2/RaftCore.h
Outdated
@@ -297,6 +299,7 @@ class RaftCore : public RaftInterface { | |||
uint64_t mBeginIndex = 1; | |||
|
|||
RaftRole mRaftRole = RaftRole::Follower; | |||
std::atomic<uint64_t> mMajorityIndex = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use commited index
Using commit index instead of majority index as leader offset is due to one edge case for getting in-sync replica (ISR). |
No description provided.