mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: Export Progress.IsPaused
CockroachDB would like to use this method for monitoring.
This commit is contained in:
parent
d844440ffb
commit
f60a5d6025
@ -155,8 +155,11 @@ func (pr *Progress) maybeDecrTo(rejected, last uint64) bool {
|
|||||||
func (pr *Progress) pause() { pr.Paused = true }
|
func (pr *Progress) pause() { pr.Paused = true }
|
||||||
func (pr *Progress) resume() { pr.Paused = false }
|
func (pr *Progress) resume() { pr.Paused = false }
|
||||||
|
|
||||||
// isPaused returns whether progress stops sending message.
|
// IsPaused returns whether sending log entries to this node has been
|
||||||
func (pr *Progress) isPaused() bool {
|
// paused. A node may be paused because it has rejected recent
|
||||||
|
// MsgApps, is currently waiting for a snapshot, or has reached the
|
||||||
|
// MaxInflightMsgs limit.
|
||||||
|
func (pr *Progress) IsPaused() bool {
|
||||||
switch pr.State {
|
switch pr.State {
|
||||||
case ProgressStateProbe:
|
case ProgressStateProbe:
|
||||||
return pr.Paused
|
return pr.Paused
|
||||||
@ -178,7 +181,7 @@ func (pr *Progress) needSnapshotAbort() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pr *Progress) String() string {
|
func (pr *Progress) String() string {
|
||||||
return fmt.Sprintf("next = %d, match = %d, state = %s, waiting = %v, pendingSnapshot = %d", pr.Next, pr.Match, pr.State, pr.isPaused(), pr.PendingSnapshot)
|
return fmt.Sprintf("next = %d, match = %d, state = %s, waiting = %v, pendingSnapshot = %d", pr.Next, pr.Match, pr.State, pr.IsPaused(), pr.PendingSnapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
type inflights struct {
|
type inflights struct {
|
||||||
|
@ -367,7 +367,7 @@ func (r *raft) send(m pb.Message) {
|
|||||||
// sendAppend sends RPC, with entries to the given peer.
|
// sendAppend sends RPC, with entries to the given peer.
|
||||||
func (r *raft) sendAppend(to uint64) {
|
func (r *raft) sendAppend(to uint64) {
|
||||||
pr := r.prs[to]
|
pr := r.prs[to]
|
||||||
if pr.isPaused() {
|
if pr.IsPaused() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m := pb.Message{}
|
m := pb.Message{}
|
||||||
@ -870,7 +870,7 @@ func stepLeader(r *raft, m pb.Message) {
|
|||||||
r.sendAppend(m.From)
|
r.sendAppend(m.From)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oldPaused := pr.isPaused()
|
oldPaused := pr.IsPaused()
|
||||||
if pr.maybeUpdate(m.Index) {
|
if pr.maybeUpdate(m.Index) {
|
||||||
switch {
|
switch {
|
||||||
case pr.State == ProgressStateProbe:
|
case pr.State == ProgressStateProbe:
|
||||||
|
@ -236,7 +236,7 @@ func TestProgressIsPaused(t *testing.T) {
|
|||||||
Paused: tt.paused,
|
Paused: tt.paused,
|
||||||
ins: newInflights(256),
|
ins: newInflights(256),
|
||||||
}
|
}
|
||||||
if g := p.isPaused(); g != tt.w {
|
if g := p.IsPaused(); g != tt.w {
|
||||||
t.Errorf("#%d: paused= %t, want %t", i, g, tt.w)
|
t.Errorf("#%d: paused= %t, want %t", i, g, tt.w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user