raft: expose RecentActive in Progress

release-2.3
Xiang Li 2015-12-10 12:17:18 -08:00
parent 9b26753dbf
commit 9df46f9d6f
2 changed files with 6 additions and 6 deletions

View File

@ -59,7 +59,7 @@ type Progress struct {
// recentActive is true if the progress is recently active. Receiving any messages
// from the corresponding follower indicates the progress is active.
// recentActive can be reset to false after an election timeout.
recentActive bool
RecentActive bool
// inflights is a sliding window for the inflight messages.
// When inflights is full, no more message should be sent.
@ -73,7 +73,7 @@ type Progress struct {
func (pr *Progress) resetState(state ProgressStateType) {
pr.Paused = false
pr.recentActive = false
pr.RecentActive = false
pr.PendingSnapshot = 0
pr.State = state
pr.ins.reset()

View File

@ -600,7 +600,7 @@ func stepLeader(r *raft, m pb.Message) {
}
switch m.Type {
case pb.MsgAppResp:
pr.recentActive = true
pr.RecentActive = true
if m.Reject {
r.logger.Debugf("%x received msgApp rejection(lastindex: %d) from %x for index %d",
@ -635,7 +635,7 @@ func stepLeader(r *raft, m pb.Message) {
}
}
case pb.MsgHeartbeatResp:
pr.recentActive = true
pr.RecentActive = true
// free one slot for the full inflights window to allow progress.
if pr.State == ProgressStateReplicate && pr.ins.full() {
@ -867,11 +867,11 @@ func (r *raft) checkQuorumActive() bool {
continue
}
if r.prs[id].recentActive {
if r.prs[id].RecentActive {
act += 1
}
r.prs[id].recentActive = false
r.prs[id].RecentActive = false
}
return act >= r.q()