Skip to content

Commit

Permalink
schdule: exclude offline store in filter source (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch authored and disksing committed Mar 9, 2018
1 parent cd898ee commit c337e36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 2 additions & 6 deletions server/schedule/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,12 @@ func NewStateFilter() Filter {
return &stateFilter{}
}

func (f *stateFilter) filter(store *core.StoreInfo) bool {
return !store.IsUp()
}

func (f *stateFilter) FilterSource(opt Options, store *core.StoreInfo) bool {
return f.filter(store)
return store.IsTombstone()
}

func (f *stateFilter) FilterTarget(opt Options, store *core.StoreInfo) bool {
return f.filter(store)
return !store.IsUp()
}

type healthFilter struct{}
Expand Down
4 changes: 4 additions & 0 deletions server/schedulers/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ func (s *testBalanceLeaderSchedulerSuite) TestBalanceFilter(c *C) {

CheckTransferLeader(c, s.schedule(nil), schedule.OpBalance, 4, 1)
// Test stateFilter.
// if store 4 is offline, we schould consider it
// because it still provides services
s.tc.setStoreOffline(4)
CheckTransferLeader(c, s.schedule(nil), schedule.OpBalance, 4, 1)
// If store 1 is down, it will be filtered,
// store 2 becomes the store with least leaders.
s.tc.setStoreDown(1)
Expand Down

0 comments on commit c337e36

Please sign in to comment.