Skip to content

Commit

Permalink
raft: extract progressTracker and Progress
Browse files Browse the repository at this point in the history
Mechanically extract `progressTracker`, `Progress`, and `inflights`
to their own package named `tracker`. This is done mechanically and
with as little manual intervention as possible. (In consequence, the
merit of this commit is not in the resulting aesthetics; those will
be cleaned up in the next commit).

This passes tests, but has various lint violations addressed in a
follow-up commit (if desired, they can be squashed after review).

The follow-up commit also improves documentation throughout.
  • Loading branch information
tbg committed Jun 8, 2019
1 parent 7b8e2c2 commit 5dae63a
Show file tree
Hide file tree
Showing 17 changed files with 1,008 additions and 922 deletions.
9 changes: 4 additions & 5 deletions etcdserver/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/wal"
"go.etcd.io/etcd/wal/walpb"

"go.uber.org/zap"
)

Expand All @@ -44,7 +43,7 @@ const (
maxSizePerMsg = 1 * 1024 * 1024
// Never overflow the rafthttp buffer, which is 4096.
// TODO: a better const?
maxInflightMsgs = 4096 / 8
MaxInflightMsgs = 4096 / 8
)

var (
Expand Down Expand Up @@ -464,7 +463,7 @@ func startNode(cfg ServerConfig, cl *membership.RaftCluster, ids []types.ID) (id
HeartbeatTick: 1,
Storage: s,
MaxSizePerMsg: maxSizePerMsg,
MaxInflightMsgs: maxInflightMsgs,
MaxInflightMsgs: MaxInflightMsgs,
CheckQuorum: true,
PreVote: cfg.PreVote,
}
Expand Down Expand Up @@ -518,7 +517,7 @@ func restartNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *member
HeartbeatTick: 1,
Storage: s,
MaxSizePerMsg: maxSizePerMsg,
MaxInflightMsgs: maxInflightMsgs,
MaxInflightMsgs: MaxInflightMsgs,
CheckQuorum: true,
PreVote: cfg.PreVote,
}
Expand Down Expand Up @@ -615,7 +614,7 @@ func restartAsStandaloneNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types
HeartbeatTick: 1,
Storage: s,
MaxSizePerMsg: maxSizePerMsg,
MaxInflightMsgs: maxInflightMsgs,
MaxInflightMsgs: MaxInflightMsgs,
CheckQuorum: true,
PreVote: cfg.PreVote,
}
Expand Down
10 changes: 5 additions & 5 deletions raft/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ func (n *node) run(r *raft) {
}
case m := <-n.recvc:
// filter out response message from unknown From.
if pr := r.prs.getProgress(m.From); pr != nil || !IsResponseMsg(m.Type) {
if pr := r.prs.GetProgress(m.From); pr != nil || !IsResponseMsg(m.Type) {
r.Step(m)
}
case cc := <-n.confc:
if cc.NodeID == None {
select {
case n.confstatec <- pb.ConfState{
Nodes: r.prs.voterNodes(),
Learners: r.prs.learnerNodes()}:
Nodes: r.prs.VoterNodes(),
Learners: r.prs.LearnerNodes()}:
case <-n.done:
}
break
Expand All @@ -384,8 +384,8 @@ func (n *node) run(r *raft) {
}
select {
case n.confstatec <- pb.ConfState{
Nodes: r.prs.voterNodes(),
Learners: r.prs.learnerNodes()}:
Nodes: r.prs.VoterNodes(),
Learners: r.prs.LearnerNodes()}:
case <-n.done:
}
case <-n.tickc:
Expand Down
Loading

0 comments on commit 5dae63a

Please sign in to comment.