Merge pull request #2003 from xiang90/raft_clean
raft: remove unnecessary funcs in raft.gorelease-2.0
commit
00b4e919d0
|
@ -244,19 +244,19 @@ func (n *node) run(r *raft) {
|
|||
}
|
||||
}
|
||||
|
||||
if lead != r.leader() {
|
||||
if lead != r.lead {
|
||||
if r.hasLeader() {
|
||||
if lead == None {
|
||||
log.Printf("raft.node: %x elected leader %x at term %d", r.id, r.leader(), r.Term)
|
||||
log.Printf("raft.node: %x elected leader %x at term %d", r.id, r.lead, r.Term)
|
||||
} else {
|
||||
log.Printf("raft.node: %x changed leader from %x to %x at term %d", r.id, lead, r.leader(), r.Term)
|
||||
log.Printf("raft.node: %x changed leader from %x to %x at term %d", r.id, lead, r.lead, r.Term)
|
||||
}
|
||||
propc = n.propc
|
||||
} else {
|
||||
log.Printf("raft.node: %x lost leader %x at term %d", r.id, lead, r.Term)
|
||||
propc = nil
|
||||
}
|
||||
lead = r.leader()
|
||||
lead = r.lead
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
@ -52,10 +52,6 @@ func (st StateType) String() string {
|
|||
return stmap[uint64(st)]
|
||||
}
|
||||
|
||||
func (st StateType) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("%q", st.String())), nil
|
||||
}
|
||||
|
||||
type progress struct {
|
||||
match, next uint64
|
||||
wait int
|
||||
|
@ -190,8 +186,6 @@ func newRaft(id uint64, peers []uint64, election, heartbeat int, storage Storage
|
|||
|
||||
func (r *raft) hasLeader() bool { return r.lead != None }
|
||||
|
||||
func (r *raft) leader() uint64 { return r.lead }
|
||||
|
||||
func (r *raft) softState() *SoftState { return &SoftState{Lead: r.lead, RaftState: r.state} }
|
||||
|
||||
func (r *raft) q() int { return len(r.prs)/2 + 1 }
|
||||
|
|
|
@ -23,6 +23,10 @@ import (
|
|||
pb "github.com/coreos/etcd/raft/raftpb"
|
||||
)
|
||||
|
||||
func (st StateType) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("%q", st.String())), nil
|
||||
}
|
||||
|
||||
// uint64Slice implements sort interface
|
||||
type uint64Slice []uint64
|
||||
|
||||
|
|
Loading…
Reference in New Issue