From d1f8b55b8f5e8ad2266f6e0d67c6a115a146dc1e Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Fri, 21 Jan 2022 17:57:28 +0800 Subject: [PATCH] resolve conflicts Signed-off-by: Ryan Leung --- server/api/region_test.go | 1 - server/cluster/cluster.go | 9 ++------- server/statistics/topn.go | 7 +++++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/server/api/region_test.go b/server/api/region_test.go index 3b2896820bb7..f95b8b2d6b26 100644 --- a/server/api/region_test.go +++ b/server/api/region_test.go @@ -99,7 +99,6 @@ func (s *testRegionSuite) SetUpSuite(c *C) { s.urlPrefix = fmt.Sprintf("%s%s/api/v1", addr, apiPrefix) mustBootstrapCluster(c, s.svr) - s.svr.GetRaftCluster().SetPrepared() } func (s *testRegionSuite) TearDownSuite(c *C) { diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index ee492dc107c8..ad866af62c54 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -210,7 +210,6 @@ func (c *RaftCluster) InitCluster( c.labelLevelStats = statistics.NewLabelStatistics() c.hotStat = statistics.NewHotStat(c.ctx) c.changedRegions = make(chan *core.RegionInfo, defaultChangedRegionsLimit) - c.statsTaskCh = make(chan []*statsTask, defaultStatsJobLimit) } // Start starts a cluster. @@ -1283,11 +1282,8 @@ func (c *RaftCluster) collectStatsMetrics() { } func (c *RaftCluster) collectHotStatsMetrics() { - c.RLock() - hotStat := c.hotStat - c.RUnlock() // collect hot cache metrics - hotStat.CollectMetrics() + c.hotStat.CollectMetrics() } func (c *RaftCluster) resetClusterMetrics() { @@ -1298,10 +1294,9 @@ func (c *RaftCluster) resetClusterMetrics() { } c.regionStats.Reset() c.labelLevelStats.Reset() - hotStat := c.hotStat c.RUnlock() // reset hot cache metrics - hotStat.ResetMetrics() + c.hotStat.ResetMetrics() } func (c *RaftCluster) collectHealthStatus() { diff --git a/server/statistics/topn.go b/server/statistics/topn.go index 6046de557b46..0cbc208259ac 100644 --- a/server/statistics/topn.go +++ b/server/statistics/topn.go @@ -289,8 +289,11 @@ func (hp *indexedHeap) Get(id uint64) TopNItem { if !ok { return nil } - < - + item := hp.items[idx] + return item +} + +// GetAll returns all the items. func (hp *indexedHeap) GetAll() []TopNItem { all := make([]TopNItem, len(hp.items)) copy(all, hp.items)