etcdserver: update stats when become leader

This commit is contained in:
Xiang Li 2014-12-15 16:55:17 -08:00
parent 04522baeee
commit c27c288bef
2 changed files with 13 additions and 0 deletions

View File

@ -385,6 +385,11 @@ func (s *EtcdServer) run() {
atomic.StoreUint64(&s.raftLead, rd.SoftState.Lead)
if rd.RaftState == raft.StateLeader {
syncC = s.SyncTicker
// TODO: remove the nil checking
// current test utility does not provide the stats
if s.stats != nil {
s.stats.BecomeLeader()
}
} else {
syncC = nil
}

View File

@ -141,3 +141,11 @@ func (ss *ServerStats) SendAppendReq(reqSize int) {
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()
}
}