Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed May 9, 2024
1 parent cbbc7c6 commit 561ff3c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions pkg/core/basic_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func NewBasicCluster() *BasicCluster {

// UpdateStoreStatus updates the information of the store.
func (bc *BasicCluster) UpdateStoreStatus(storeID uint64) {
leaderCount, regionCount, witnessCount, learnerCount, pendingPeerCount, leaderRegionSize, regionSize := bc.RegionsInfo.GetStoreStats(storeID)
leaderCount, regionCount, witnessCount, learnerCount, pendingPeerCount, leaderRegionSize, regionSize := bc.GetStoreStats(storeID)
bc.StoresInfo.UpdateStoreStatus(storeID, leaderCount, regionCount, witnessCount, learnerCount, pendingPeerCount, leaderRegionSize, regionSize)
}

/* Regions read operations */

// GetLeaderStoreByRegionID returns the leader store of the given region.
func (bc *BasicCluster) GetLeaderStoreByRegionID(regionID uint64) *StoreInfo {
region := bc.RegionsInfo.GetRegion(regionID)
region := bc.GetRegion(regionID)
if region == nil || region.GetLeader() == nil {
return nil
}
Expand All @@ -63,12 +63,12 @@ func (bc *BasicCluster) getWriteRate(

// GetStoresLeaderWriteRate get total write rate of each store's leaders.
func (bc *BasicCluster) GetStoresLeaderWriteRate() (storeIDs []uint64, bytesRates, keysRates []float64) {
return bc.getWriteRate(bc.RegionsInfo.GetStoreLeaderWriteRate)
return bc.getWriteRate(bc.GetStoreLeaderWriteRate)

Check warning on line 66 in pkg/core/basic_cluster.go

View check run for this annotation

Codecov / codecov/patch

pkg/core/basic_cluster.go#L66

Added line #L66 was not covered by tests
}

// GetStoresWriteRate get total write rate of each store's regions.
func (bc *BasicCluster) GetStoresWriteRate() (storeIDs []uint64, bytesRates, keysRates []float64) {
return bc.getWriteRate(bc.RegionsInfo.GetStoreWriteRate)
return bc.getWriteRate(bc.GetStoreWriteRate)
}

// UpdateAllStoreStatus updates the information of all stores.
Expand Down
10 changes: 5 additions & 5 deletions pkg/keyspace/keyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,20 @@ func (manager *Manager) splitKeyspaceRegion(id uint32, waitRegionSplit bool) (er
for {
select {
case <-ticker.C:
regionsInfo := manager.cluster.GetBasicCluster().RegionsInfo
region := regionsInfo.GetRegionByKey(rawLeftBound)
c := manager.cluster.GetBasicCluster()
region := c.GetRegionByKey(rawLeftBound)

Check warning on line 347 in pkg/keyspace/keyspace.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/keyspace.go#L346-L347

Added lines #L346 - L347 were not covered by tests
if region == nil || !bytes.Equal(region.GetStartKey(), rawLeftBound) {
continue
}
region = regionsInfo.GetRegionByKey(rawRightBound)
region = c.GetRegionByKey(rawRightBound)

Check warning on line 351 in pkg/keyspace/keyspace.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/keyspace.go#L351

Added line #L351 was not covered by tests
if region == nil || !bytes.Equal(region.GetStartKey(), rawRightBound) {
continue
}
region = regionsInfo.GetRegionByKey(txnLeftBound)
region = c.GetRegionByKey(txnLeftBound)

Check warning on line 355 in pkg/keyspace/keyspace.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/keyspace.go#L355

Added line #L355 was not covered by tests
if region == nil || !bytes.Equal(region.GetStartKey(), txnLeftBound) {
continue
}
region = regionsInfo.GetRegionByKey(txnRightBound)
region = c.GetRegionByKey(txnRightBound)

Check warning on line 359 in pkg/keyspace/keyspace.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/keyspace.go#L359

Added line #L359 was not covered by tests
if region == nil || !bytes.Equal(region.GetStartKey(), txnRightBound) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func (c *Cluster) collectMetrics() {
// collect hot cache metrics
c.hotStat.CollectMetrics()
// collect the lock metrics
c.RegionsInfo.CollectWaitLockMetrics()
c.CollectWaitLockMetrics()
}

func resetMetrics() {
Expand Down
8 changes: 4 additions & 4 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,10 @@ func TestRegionHeartbeat(t *testing.T) {

time.Sleep(50 * time.Millisecond)
for _, store := range cluster.GetStores() {
re.Equal(cluster.BasicCluster.GetStoreLeaderCount(store.GetID()), store.GetLeaderCount())
re.Equal(cluster.BasicCluster.GetStoreRegionCount(store.GetID()), store.GetRegionCount())
re.Equal(cluster.BasicCluster.GetStoreLeaderRegionSize(store.GetID()), store.GetLeaderSize())
re.Equal(cluster.BasicCluster.GetStoreRegionSize(store.GetID()), store.GetRegionSize())
re.Equal(cluster.GetStoreLeaderCount(store.GetID()), store.GetLeaderCount())
re.Equal(cluster.GetStoreRegionCount(store.GetID()), store.GetRegionCount())
re.Equal(cluster.GetStoreLeaderRegionSize(store.GetID()), store.GetLeaderSize())
re.Equal(cluster.GetStoreRegionSize(store.GetID()), store.GetRegionSize())
}

// Test with storage.
Expand Down
2 changes: 1 addition & 1 deletion server/cluster/scheduling_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (sc *schedulingController) collectSchedulingMetrics() {
// collect hot cache metrics
sc.hotStat.CollectMetrics()
// collect the lock metrics
sc.RegionsInfo.CollectWaitLockMetrics()
sc.CollectWaitLockMetrics()
}

func (sc *schedulingController) removeStoreStatistics(storeID uint64) {
Expand Down

0 comments on commit 561ff3c

Please sign in to comment.