Skip to content

Commit 40f0193

Browse files
authored
Merge pull request #6938 from bdarnell/ispaused
raft: Export Progress.IsPaused
2 parents d844440 + f60a5d6 commit 40f0193

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

raft/progress.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ func (pr *Progress) maybeDecrTo(rejected, last uint64) bool {
155155
func (pr *Progress) pause() { pr.Paused = true }
156156
func (pr *Progress) resume() { pr.Paused = false }
157157

158-
// isPaused returns whether progress stops sending message.
159-
func (pr *Progress) isPaused() bool {
158+
// IsPaused returns whether sending log entries to this node has been
159+
// paused. A node may be paused because it has rejected recent
160+
// MsgApps, is currently waiting for a snapshot, or has reached the
161+
// MaxInflightMsgs limit.
162+
func (pr *Progress) IsPaused() bool {
160163
switch pr.State {
161164
case ProgressStateProbe:
162165
return pr.Paused
@@ -178,7 +181,7 @@ func (pr *Progress) needSnapshotAbort() bool {
178181
}
179182

180183
func (pr *Progress) String() string {
181-
return fmt.Sprintf("next = %d, match = %d, state = %s, waiting = %v, pendingSnapshot = %d", pr.Next, pr.Match, pr.State, pr.isPaused(), pr.PendingSnapshot)
184+
return fmt.Sprintf("next = %d, match = %d, state = %s, waiting = %v, pendingSnapshot = %d", pr.Next, pr.Match, pr.State, pr.IsPaused(), pr.PendingSnapshot)
182185
}
183186

184187
type inflights struct {

raft/raft.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ func (r *raft) send(m pb.Message) {
367367
// sendAppend sends RPC, with entries to the given peer.
368368
func (r *raft) sendAppend(to uint64) {
369369
pr := r.prs[to]
370-
if pr.isPaused() {
370+
if pr.IsPaused() {
371371
return
372372
}
373373
m := pb.Message{}
@@ -870,7 +870,7 @@ func stepLeader(r *raft, m pb.Message) {
870870
r.sendAppend(m.From)
871871
}
872872
} else {
873-
oldPaused := pr.isPaused()
873+
oldPaused := pr.IsPaused()
874874
if pr.maybeUpdate(m.Index) {
875875
switch {
876876
case pr.State == ProgressStateProbe:

raft/raft_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func TestProgressIsPaused(t *testing.T) {
236236
Paused: tt.paused,
237237
ins: newInflights(256),
238238
}
239-
if g := p.isPaused(); g != tt.w {
239+
if g := p.IsPaused(); g != tt.w {
240240
t.Errorf("#%d: paused= %t, want %t", i, g, tt.w)
241241
}
242242
}

0 commit comments

Comments
 (0)