// SelectSource selects the store that can pass all filters and has the maximal resource score.
SelectSource selects the store that can pass all filters and has the maximal resource score.
// SelectSource selects the store that can pass all filters and has the maximal resource score .
func (s *UserSelector) SelectSource(opt opt.Options, stores []*core.StoreInfo, filterSet [][]filter.Filter) *core.StoreInfo {
	var result *core.StoreInfo
	for idx, store := range stores {
		filterFlag := false
		for id, filters := range filterSet {
			if !filter.Source(opt, store, filters) {
				fmt.Printf("[userSelector] check source - store %d pass filters %d\n", store.GetID(), id+1)
				filterFlag = true
				break
			}
		}
		if filterFlag {
			fmt.Printf("[userSelector] filt source - store %d\n", store.GetID())
			continue
		}
		fmt.Printf("[userSelector] pass source - store %d\n", store.GetID())
		if idx == 0{
			return store
		}
		if result == nil ||
			result.ResourceScore(s.kind, opt.GetHighSpaceRatio(), opt.GetLowSpaceRatio(), 0) <
				store.ResourceScore(s.kind, opt.GetHighSpaceRatio(), opt.GetLowSpaceRatio(), 0) {
			result = store
		}
	}
	return result
}
func ( s * UserSelector ) SelectSource ( opt opt . Options , stores [ ] * core . StoreInfo , filterSet [ ] [ ] filter . Filter ) * core . StoreInfo { var result * core . StoreInfo for idx , store := range stores { filterFlag := false for id , filters := range filterSet { if ! filter . Source ( opt , store , filters ) { fmt . Printf ( " \n " , store . GetID ( ) , id + 1 ) filterFlag = true break } } if filterFlag { fmt . Printf ( " \n " , store . GetID ( ) ) continue } fmt . Printf ( " \n " , store . GetID ( ) ) if idx == 0 { return store } if result == nil || result . ResourceScore ( s . kind , opt . GetHighSpaceRatio ( ) , opt . GetLowSpaceRatio ( ) , 0 ) < store . ResourceScore ( s . kind , opt . GetHighSpaceRatio ( ) , opt . GetLowSpaceRatio ( ) , 0 ) { result = store } } return result }
SelectSource selects the store that can pass all filters and has the maximal resource score.
SelectSource selects the store that can pass all filters and has the maximal resource score .
// if the store pass one of filters in the filterSet, we don't need to schedule // else choose the other stores who has the maximal resource score