mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: update stats when become leader
This commit is contained in:
parent
04522baeee
commit
c27c288bef
@ -385,6 +385,11 @@ func (s *EtcdServer) run() {
|
|||||||
atomic.StoreUint64(&s.raftLead, rd.SoftState.Lead)
|
atomic.StoreUint64(&s.raftLead, rd.SoftState.Lead)
|
||||||
if rd.RaftState == raft.StateLeader {
|
if rd.RaftState == raft.StateLeader {
|
||||||
syncC = s.SyncTicker
|
syncC = s.SyncTicker
|
||||||
|
// TODO: remove the nil checking
|
||||||
|
// current test utility does not provide the stats
|
||||||
|
if s.stats != nil {
|
||||||
|
s.stats.BecomeLeader()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
syncC = nil
|
syncC = nil
|
||||||
}
|
}
|
||||||
|
@ -141,3 +141,11 @@ func (ss *ServerStats) SendAppendReq(reqSize int) {
|
|||||||
|
|
||||||
ss.SendAppendRequestCnt++
|
ss.SendAppendRequestCnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ss *ServerStats) BecomeLeader() {
|
||||||
|
if ss.State != raft.StateLeader {
|
||||||
|
ss.State = raft.StateLeader
|
||||||
|
ss.LeaderInfo.Name = ss.ID
|
||||||
|
ss.LeaderInfo.StartTime = time.Now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user