Browse Source

raft: expose RecentActive in Progress

Xiang Li 10 years ago
parent
commit
9df46f9d6f
2 changed files with 6 additions and 6 deletions
  1. 2 2
      raft/progress.go
  2. 4 4
      raft/raft.go

+ 2 - 2
raft/progress.go

@@ -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()

+ 4 - 4
raft/raft.go

@@ -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()