Skip to content

Commit

Permalink
update store stats
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Sep 14, 2023
1 parent e295e62 commit 80bb8a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,28 @@ func (c *Cluster) HandleStoreHeartbeat(heartbeat *schedulingpb.StoreHeartbeatReq
c.hotStat.CheckReadAsync(statistics.NewCollectUnReportedPeerTask(storeID, regions, interval))
return nil
}

// RunUpdateStoreStats updates store stats periodically.
func (c *Cluster) RunUpdateStoreStats() {
defer logutil.LogPanic()

ticker := time.NewTicker(9 * time.Millisecond)
defer ticker.Stop()

for {
select {
case <-c.ctx.Done():
log.Info("update store stats background jobs has been stopped")
return
case <-ticker.C:
// Update related stores.
stores := c.GetStores()
for _, store := range stores {
if store.IsRemoved() {
continue

Check warning on line 369 in pkg/mcs/scheduling/server/cluster.go

View check run for this annotation

Codecov / codecov/patch

pkg/mcs/scheduling/server/cluster.go#L369

Added line #L369 was not covered by tests
}
c.UpdateStoreStatus(store.GetID())
}
}
}
}
1 change: 1 addition & 0 deletions pkg/mcs/scheduling/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ func (s *Server) startCluster(context.Context) error {
}
s.configWatcher.SetSchedulersController(s.cluster.GetCoordinator().GetSchedulersController())
go s.cluster.UpdateScheduler()
go s.cluster.RunUpdateStoreStats()
go s.GetCoordinator().RunUntilStop()
return nil
}
Expand Down

0 comments on commit 80bb8a1

Please sign in to comment.