Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed May 24, 2024
1 parent 9911a5b commit 8413c4e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ func (mc *Cluster) CheckRegionRead(region *core.RegionInfo) []*statistics.HotPee
items = append(items, expiredItems...)
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
return append(items, mc.HotCache.CheckReadPeerSync(region, region.GetLoads(), interval)...)
return append(items, mc.HotCache.CheckReadPeerSync(region, region.GetPeers(), region.GetLoads(), interval)...)
}

// CheckRegionWrite checks region write info with all peers
Expand All @@ -906,7 +906,7 @@ func (mc *Cluster) CheckRegionWrite(region *core.RegionInfo) []*statistics.HotPe
items = append(items, expiredItems...)
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
return append(items, mc.HotCache.CheckWritePeerSync(region, region.GetLoads(), interval)...)
return append(items, mc.HotCache.CheckWritePeerSync(region, region.GetPeers(), region.GetLoads(), interval)...)
}

// CheckRegionLeaderRead checks region read info with leader peer
Expand All @@ -916,7 +916,7 @@ func (mc *Cluster) CheckRegionLeaderRead(region *core.RegionInfo) []*statistics.
items = append(items, expiredItems...)
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
return append(items, mc.HotCache.CheckReadLeaderSync(region, region.GetLoads(), interval)...)
return append(items, mc.HotCache.CheckReadPeerSync(region, []*metapb.Peer{region.GetLeader()}, region.GetLoads(), interval)...)
}

// ObserveRegionsStats records the current stores stats from region stats.
Expand Down
14 changes: 4 additions & 10 deletions pkg/statistics/hot_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,14 @@ func (w *HotCache) Update(item *HotPeerStat, kind utils.RWType) {

// CheckWritePeerSync checks the write status, returns update items.
// This is used for mockcluster, for test purpose.
func (w *HotCache) CheckWritePeerSync(region *core.RegionInfo, loads []float64, interval uint64) []*HotPeerStat {
return w.writeCache.checkPeerFlow(region, region.GetPeers(), loads, interval)
func (w *HotCache) CheckWritePeerSync(region *core.RegionInfo, peers []*metapb.Peer, loads []float64, interval uint64) []*HotPeerStat {
return w.writeCache.checkPeerFlow(region, peers, loads, interval)
}

// CheckReadPeerSync checks the read status, returns update items.
// This is used for mockcluster, for test purpose.
func (w *HotCache) CheckReadPeerSync(region *core.RegionInfo, loads []float64, interval uint64) []*HotPeerStat {
return w.readCache.checkPeerFlow(region, region.GetPeers(), loads, interval)
}

// CheckReadLeaderSync checks the read status, returns update items.
// This is used for mockcluster, for test purpose.
func (w *HotCache) CheckReadLeaderSync(region *core.RegionInfo, loads []float64, interval uint64) []*HotPeerStat {
return w.readCache.checkPeerFlow(region, []*metapb.Peer{region.GetLeader()}, loads, interval)
func (w *HotCache) CheckReadPeerSync(region *core.RegionInfo, peers []*metapb.Peer, loads []float64, interval uint64) []*HotPeerStat {
return w.readCache.checkPeerFlow(region, peers, loads, interval)
}

// ExpiredReadItems returns the read items which are already expired.
Expand Down
2 changes: 1 addition & 1 deletion tools/pd-ctl/tests/hot/hot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (suite *hotTestSuite) checkHot(cluster *pdTests.TestCluster) {
region := core.NewRegionInfo(&metapb.Region{
Id: hotRegionID,
}, leader)
hotStat.CheckReadAsync(statistics.NewCheckPeerTask(region, region.GetPeers(), loads, reportInterval))
hotStat.CheckReadAsync(statistics.NewCheckPeerTask(region, []*metapb.Peer{leader}, loads, reportInterval))
testutil.Eventually(re, func() bool {
hotPeerStat := getHotPeerStat(utils.Read, hotRegionID, hotStoreID)
return hotPeerStat != nil
Expand Down

0 comments on commit 8413c4e

Please sign in to comment.