Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Jul 28, 2023
1 parent be2ebc2 commit 91de394
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions pkg/schedule/operator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type Builder struct {

// build flags
useJointConsensus bool
lightRemovePeer bool
lightAddPeer bool
removeLightPeer bool
addLightPeer bool
forceTargetLeader bool

// intermediate states
Expand Down Expand Up @@ -371,15 +371,15 @@ func (b *Builder) SetExpectedRoles(roles map[uint64]placement.PeerRoleType) *Bui
return b
}

// SetLightAddPeer marks the add peer as light weight. It is used for scatter regions.
func (b *Builder) SetLightAddPeer() *Builder {
b.lightAddPeer = true
// SetAddLightPeer marks the add peer as light weight. It is used for scatter regions.
func (b *Builder) SetAddLightPeer() *Builder {
b.addLightPeer = true
return b
}

// SetLightRemovePeer marks the remove peer as light weight. It is used for scatter regions.
func (b *Builder) SetLightRemovePeer() *Builder {
b.lightRemovePeer = true
// SetRemoveLightPeer marks the remove peer as light weight. It is used for scatter regions.
func (b *Builder) SetRemoveLightPeer() *Builder {
b.removeLightPeer = true
return b
}

Expand Down Expand Up @@ -539,7 +539,7 @@ func (b *Builder) brief() string {
switch {
case len(b.toAdd) > 0 && len(b.toRemove) > 0:
op := "mv peer"
if b.lightAddPeer && b.lightRemovePeer {
if b.addLightPeer && b.removeLightPeer {
op = "mv light peer"
}
return fmt.Sprintf("%s: store %s to %s", op, b.toRemove, b.toAdd)
Expand Down Expand Up @@ -782,7 +782,7 @@ func (b *Builder) execPromoteNonWitness(peer *metapb.Peer) {
}

func (b *Builder) execAddPeer(peer *metapb.Peer) {
b.steps = append(b.steps, AddLearner{ToStore: peer.GetStoreId(), PeerID: peer.GetId(), IsLightWeight: b.lightAddPeer, IsWitness: peer.GetIsWitness(), SendStore: b.originLeaderStoreID})
b.steps = append(b.steps, AddLearner{ToStore: peer.GetStoreId(), PeerID: peer.GetId(), IsLightWeight: b.addLightPeer, IsWitness: peer.GetIsWitness(), SendStore: b.originLeaderStoreID})
if !core.IsLearner(peer) {
b.steps = append(b.steps, PromoteLearner{ToStore: peer.GetStoreId(), PeerID: peer.GetId(), IsWitness: peer.GetIsWitness()})
}
Expand All @@ -798,7 +798,7 @@ func (b *Builder) execRemovePeer(peer *metapb.Peer) {
if store != nil {
isDownStore = store.DownTime() > b.GetSharedConfig().GetMaxStoreDownTime()
}
b.steps = append(b.steps, RemovePeer{FromStore: removeStoreID, PeerID: peer.GetId(), IsDownStore: isDownStore, IsLightWeight: b.lightRemovePeer})
b.steps = append(b.steps, RemovePeer{FromStore: removeStoreID, PeerID: peer.GetId(), IsDownStore: isDownStore, IsLightWeight: b.removeLightPeer})
delete(b.currentPeers, removeStoreID)
delete(b.toRemove, removeStoreID)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/schedule/operator/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ func (suite *operatorBuilderTestSuite) TestRecord() {
3: {StoreId: 3, Role: metapb.PeerRole_Learner},
4: {StoreId: 4},
}
builder := suite.newBuilder().SetPeers(m).SetLightAddPeer()
builder := suite.newBuilder().SetPeers(m).SetAddLightPeer()
suite.Len(builder.targetPeers, 3)
suite.Equal(m[2], builder.targetPeers[2])
suite.Equal(m[3], builder.targetPeers[3])
suite.Equal(m[4], builder.targetPeers[4])
suite.Equal(uint64(0), builder.targetLeaderStoreID)
suite.True(builder.lightAddPeer)
suite.True(builder.addLightPeer)
}

func (suite *operatorBuilderTestSuite) TestPrepareBuild() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/schedule/operator/create_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ func CreateScatterRegionOperator(desc string, ci sche.SharedCluster, origin *cor

builder := NewBuilder(desc, ci, origin)
if skipLimitCheck {
builder.SetLightRemovePeer()
builder.SetRemoveLightPeer()
}

return builder.
SetPeers(targetPeers).
SetLeader(leader).
SetLightAddPeer().
SetAddLightPeer().
// EnableForceTargetLeader in order to ignore the leader schedule limit
EnableForceTargetLeader().
Build(OpAdmin)
Expand Down

0 comments on commit 91de394

Please sign in to comment.