Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Dec 1, 2022
1 parent 3d649d1 commit 85506f1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ func Test(t *testing.T) {
re.Nil(cache.GetRegionByKey(regionKey))
checkRegions(re, cache, regions[0:i])

origin, overlaps, rangeChanged := cache.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := cache.SetRegion(region, false)
cache.UpdateSubTree(region, origin, overlaps, rangeChanged)
checkRegion(re, cache.GetRegion(i), region)
checkRegion(re, cache.GetRegionByKey(regionKey), region)
Expand All @@ -1692,7 +1692,7 @@ func Test(t *testing.T) {
// Update leader to peer np-1.
newRegion := region.Clone(core.WithLeader(region.GetPeers()[np-1]))
regions[i] = newRegion
origin, overlaps, rangeChanged = cache.SetRegionWithUpdate(newRegion, false)
origin, overlaps, rangeChanged = cache.SetRegion(newRegion, false)
cache.UpdateSubTree(newRegion, origin, overlaps, rangeChanged)
checkRegion(re, cache.GetRegion(i), newRegion)
checkRegion(re, cache.GetRegionByKey(regionKey), newRegion)
Expand All @@ -1707,7 +1707,7 @@ func Test(t *testing.T) {
// Reset leader to peer 0.
newRegion = region.Clone(core.WithLeader(region.GetPeers()[0]))
regions[i] = newRegion
origin, overlaps, rangeChanged = cache.SetRegionWithUpdate(newRegion, false)
origin, overlaps, rangeChanged = cache.SetRegion(newRegion, false)
cache.UpdateSubTree(newRegion, origin, overlaps, rangeChanged)
checkRegion(re, cache.GetRegion(i), newRegion)
checkRegions(re, cache, regions[0:(i+1)])
Expand All @@ -1729,7 +1729,7 @@ func Test(t *testing.T) {
// check overlaps
// clone it otherwise there are two items with the same key in the tree
overlapRegion := regions[n-1].Clone(core.WithStartKey(regions[n-2].GetStartKey()))
origin, overlaps, rangeChanged := cache.SetRegionWithUpdate(overlapRegion, false)
origin, overlaps, rangeChanged := cache.SetRegion(overlapRegion, false)
cache.UpdateSubTree(overlapRegion, origin, overlaps, rangeChanged)
re.Nil(cache.GetRegion(n - 2))
re.NotNil(cache.GetRegion(n - 1))
Expand All @@ -1739,7 +1739,7 @@ func Test(t *testing.T) {
for j := 0; j < cache.GetStoreLeaderCount(i); j++ {
region := filter.SelectOneRegion(tc.RandLeaderRegions(i, []core.KeyRange{core.NewKeyRange("", "")}), nil, pendingFilter, downFilter)
newRegion := region.Clone(core.WithPendingPeers(region.GetPeers()))
origin, overlaps, rangeChanged = cache.SetRegionWithUpdate(newRegion, false)
origin, overlaps, rangeChanged = cache.SetRegion(newRegion, false)
cache.UpdateSubTree(newRegion, origin, overlaps, rangeChanged)
}
re.Nil(filter.SelectOneRegion(tc.RandLeaderRegions(i, []core.KeyRange{core.NewKeyRange("", "")}), nil, pendingFilter, downFilter))
Expand Down
8 changes: 4 additions & 4 deletions server/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,14 +750,14 @@ func (r *RegionsInfo) CheckAndPutRegion(region *RegionInfo) []*RegionInfo {
// return the state region to delete.
return []*RegionInfo{region}
}
origin, overlaps, rangeChanged := r.SetRegionWithUpdate(region, true, ols...)
origin, overlaps, rangeChanged := r.SetRegion(region, true, ols...)
r.UpdateSubTree(region, origin, overlaps, rangeChanged)
return overlaps
}

// PutRegion put a region.
func (r *RegionsInfo) PutRegion(region *RegionInfo) []*RegionInfo {
origin, overlaps, rangeChanged := r.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := r.SetRegion(region, false)
r.UpdateSubTree(region, origin, overlaps, rangeChanged)
return overlaps
}
Expand Down Expand Up @@ -821,8 +821,8 @@ func check(region, origin *RegionInfo, overlaps []*regionItem) error {
return nil
}

// SetRegionWithUpdate sets the RegionInfo to regionTree and regionMap and return the update info of subtree.
func (r *RegionsInfo) SetRegionWithUpdate(region *RegionInfo, withOverlaps bool, ol ...*regionItem) (*RegionInfo, []*RegionInfo, bool) {
// SetRegion sets the RegionInfo to regionTree and regionMap and return the update info of subtree.
func (r *RegionsInfo) SetRegion(region *RegionInfo, withOverlaps bool, ol ...*regionItem) (*RegionInfo, []*RegionInfo, bool) {
r.t.Lock()
defer r.t.Unlock()
return r.setRegionLocked(region, withOverlaps, ol...)
Expand Down
16 changes: 8 additions & 8 deletions server/core/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func TestSetRegion(t *testing.T) {
StartKey: []byte(fmt.Sprintf("%20d", i*10)),
EndKey: []byte(fmt.Sprintf("%20d", (i+1)*10)),
}, peer1)
origin, overlaps, rangeChanged := regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
}

Expand All @@ -480,13 +480,13 @@ func TestSetRegion(t *testing.T) {
EndKey: []byte(fmt.Sprintf("%20d", 211)),
}, peer1)
region.pendingPeers = append(region.pendingPeers, peer3)
origin, overlaps, rangeChanged := regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
checkRegions(re, regions)
re.Equal(97, regions.tree.length())
re.Len(regions.GetRegions(), 97)

origin, overlaps, rangeChanged = regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged = regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
peer1 = &metapb.Peer{StoreId: uint64(2), Id: uint64(101)}
peer2 = &metapb.Peer{StoreId: uint64(3), Id: uint64(102), Role: metapb.PeerRole_Learner}
Expand All @@ -498,7 +498,7 @@ func TestSetRegion(t *testing.T) {
EndKey: []byte(fmt.Sprintf("%20d", 212)),
}, peer1)
region.pendingPeers = append(region.pendingPeers, peer3)
origin, overlaps, rangeChanged = regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged = regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
checkRegions(re, regions)
re.Equal(97, regions.tree.length())
Expand All @@ -508,7 +508,7 @@ func TestSetRegion(t *testing.T) {
region = region.Clone(WithStartKey([]byte(fmt.Sprintf("%20d", 175))), WithNewRegionID(201))
re.NotNil(regions.GetRegion(21))
re.NotNil(regions.GetRegion(18))
origin, overlaps, rangeChanged = regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged = regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
checkRegions(re, regions)
re.Equal(96, regions.tree.length())
Expand All @@ -524,7 +524,7 @@ func TestSetRegion(t *testing.T) {
SetWrittenBytes(40),
SetWrittenKeys(10),
SetReportInterval(0, 5))
origin, overlaps, rangeChanged = regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged = regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
checkRegions(re, regions)
re.Equal(96, regions.tree.length())
Expand Down Expand Up @@ -636,7 +636,7 @@ func BenchmarkRandomRegion(b *testing.B) {
StartKey: []byte(fmt.Sprintf("%20d", i)),
EndKey: []byte(fmt.Sprintf("%20d", i+1)),
}, peer)
origin, overlaps, rangeChanged := regions.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := regions.SetRegion(region, false)
regions.UpdateSubTree(region, origin, overlaps, rangeChanged)
}
b.ResetTimer()
Expand Down Expand Up @@ -690,7 +690,7 @@ func BenchmarkAddRegion(b *testing.B) {
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
origin, overlaps, rangeChanged := regions.SetRegionWithUpdate(items[i], false)
origin, overlaps, rangeChanged := regions.SetRegion(items[i], false)
regions.UpdateSubTree(items[i], origin, overlaps, rangeChanged)
}
}
2 changes: 1 addition & 1 deletion server/schedule/range_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type RangeCluster struct {
func GenRangeCluster(cluster Cluster, startKey, endKey []byte) *RangeCluster {
subCluster := core.NewBasicCluster()
for _, r := range cluster.ScanRegions(startKey, endKey, -1) {
origin, overlaps, rangeChanged := subCluster.SetRegionWithUpdate(r, false)
origin, overlaps, rangeChanged := subCluster.SetRegion(r, false)
subCluster.UpdateSubTree(r, origin, overlaps, rangeChanged)
}
return &RangeCluster{
Expand Down
6 changes: 3 additions & 3 deletions server/schedulers/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ func TestScatterRangeBalance(t *testing.T) {
core.SetApproximateKeys(1),
core.SetApproximateSize(1),
)
origin, overlaps, rangeChanged := tc.SetRegionWithUpdate(regionInfo, false)
origin, overlaps, rangeChanged := tc.SetRegion(regionInfo, false)
tc.UpdateSubTree(regionInfo, origin, overlaps, rangeChanged)
}
for i := 0; i < 100; i++ {
Expand Down Expand Up @@ -1379,7 +1379,7 @@ func TestBalanceLeaderLimit(t *testing.T) {
core.SetApproximateSize(96),
)

origin, overlaps, rangeChanged := tc.SetRegionWithUpdate(regionInfo, false)
origin, overlaps, rangeChanged := tc.SetRegion(regionInfo, false)
tc.UpdateSubTree(regionInfo, origin, overlaps, rangeChanged)
}

Expand Down Expand Up @@ -1490,7 +1490,7 @@ func TestBalanceWhenRegionNotHeartbeat(t *testing.T) {
core.SetApproximateSize(96),
)

origin, overlaps, rangeChanged := tc.SetRegionWithUpdate(regionInfo, false)
origin, overlaps, rangeChanged := tc.SetRegion(regionInfo, false)
tc.UpdateSubTree(regionInfo, origin, overlaps, rangeChanged)
}

Expand Down
2 changes: 1 addition & 1 deletion server/schedulers/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestRejectLeader(t *testing.T) {
break
}
}
origin, overlaps, rangeChanged := tc.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := tc.SetRegion(region, false)
tc.UpdateSubTree(region, origin, overlaps, rangeChanged)
ops, _ = sl.Schedule(tc, false)
testutil.CheckTransferLeader(re, ops[0], operator.OpLeader, 1, 2)
Expand Down
2 changes: 1 addition & 1 deletion tools/pd-simulator/simulator/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (r *RaftEngine) GetRegions() []*core.RegionInfo {
func (r *RaftEngine) SetRegion(region *core.RegionInfo) []*core.RegionInfo {
r.Lock()
defer r.Unlock()
origin, overlaps, rangeChanged := r.regionsInfo.SetRegionWithUpdate(region, false)
origin, overlaps, rangeChanged := r.regionsInfo.SetRegion(region, false)
r.regionsInfo.UpdateSubTree(region, origin, overlaps, rangeChanged)
return overlaps
}
Expand Down

0 comments on commit 85506f1

Please sign in to comment.