Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
51964ee
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
0d7a429
server: resource ratio
huachaohuang Nov 22, 2016
e722cbe
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
1810d07
server: resource ratio
huachaohuang Nov 22, 2016
16a6222
server/coordinator: replace balancer worker with coordinator
huachaohuang Nov 24, 2016
f52ba19
server/balancer: tiny fix
huachaohuang Nov 29, 2016
2135361
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
f360706
server: resource ratio
huachaohuang Nov 22, 2016
12e4f4e
server/constraints: add replication constraints
huachaohuang Nov 29, 2016
206276f
server/constraints: check max replicas and constraints
huachaohuang Nov 30, 2016
1026c7b
server/coordinator: replace balancer worker with coordinator
huachaohuang Nov 24, 2016
84683db
server/coordinator: combine scheduler and controller
huachaohuang Dec 1, 2016
27a0758
fix rebase
huachaohuang Dec 7, 2016
27583a6
fix rebase
huachaohuang Dec 7, 2016
faa5fa5
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
baf0d77
server: resource ratio
huachaohuang Nov 22, 2016
da1e746
server/coordinator: replace balancer worker with coordinator
huachaohuang Nov 24, 2016
a983ea2
server/balancer: tiny fix
huachaohuang Nov 29, 2016
fa3834f
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
7a6395b
server: resource ratio
huachaohuang Nov 22, 2016
7b72028
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
4f18f20
server: resource ratio
huachaohuang Nov 22, 2016
61898c5
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
f4eece0
server: resource ratio
huachaohuang Nov 22, 2016
156b062
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
0d8da2f
server: resource ratio
huachaohuang Nov 22, 2016
1dc12ed
server/coordinator: replace balancer worker with coordinator
huachaohuang Nov 24, 2016
a3f0704
server/balancer: tiny fix
huachaohuang Nov 29, 2016
4149228
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
96acc75
server: resource ratio
huachaohuang Nov 22, 2016
1740c4e
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
ea57f59
server: resource ratio
huachaohuang Nov 22, 2016
51d2772
server/resource: replace score type with resource kind
huachaohuang Nov 21, 2016
5daff0a
server: resource ratio
huachaohuang Nov 22, 2016
b464247
server/filter: filter busy store
huachaohuang Dec 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions server/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func (c *testClusterInfo) setStoreUp(storeID uint64) {
c.putStore(store)
}

func (c *testClusterInfo) setStoreBusy(storeID uint64) {
store := c.getStore(storeID)
store.stats.IsBusy = true
store.stats.LastHeartbeatTS = time.Time{}
c.putStore(store)
}

func (c *testClusterInfo) setStoreDown(storeID uint64) {
store := c.getStore(storeID)
store.State = metapb.StoreState_Up
Expand Down Expand Up @@ -141,7 +148,7 @@ func (s *testLeaderBalancerSuite) Test(c *C) {
// Test leaderCountFilter.
// When leaderCount < 10, no schedule.
c.Assert(lb.Schedule(cluster), IsNil)
tc.updateLeaderCount(4, 11, 30)
tc.updateLeaderCount(4, 12, 30)
// When leaderCount > 10, transfer leader
// from store 4 (with most leaders) to store 1 (with least leaders).
checkTransferLeader(c, lb.Schedule(cluster), 4, 1)
Expand All @@ -151,12 +158,16 @@ func (s *testLeaderBalancerSuite) Test(c *C) {
// store 2 becomes the store with least leaders.
tc.setStoreDown(1)
checkTransferLeader(c, lb.Schedule(cluster), 4, 2)
// If store 2 is busy, it will be filtered,
// store 3 becomes the store with least leaders.
tc.setStoreBusy(2)
checkTransferLeader(c, lb.Schedule(cluster), 4, 3)

// Test MinBalanceDiffRatio.
// When diff leader ratio < MinBalanceDiffRatio, no schedule.
tc.updateLeaderCount(2, 10, 30)
tc.updateLeaderCount(3, 10, 30)
tc.updateLeaderCount(4, 11, 30)
tc.updateLeaderCount(4, 12, 30)
c.Assert(lb.Schedule(cluster), IsNil)
}

Expand Down
3 changes: 3 additions & 0 deletions server/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (f *stateFilter) filter(store *storeInfo) bool {
if !store.isUp() {
return true
}
if store.stats.GetIsBusy() {
return true
}
return store.downTime() > f.opt.GetMaxStoreDownTime()
}

Expand Down