// SelectTarget selects the store that can pass all filters and has the minimal resource score.
SelectTarget selects the store that can pass all filters and has the minimal resource score.
// SelectTarget selects the store that can pass all filters and has the minimal resource score .
func (s *UserSelector) SelectTarget(opt opt.Options, stores []*core.StoreInfo, filterSet [][]filter.Filter) *core.StoreInfo {
	var result *core.StoreInfo
	for _, store := range stores {
		filterFlag := true
		for id, filters := range filterSet {
			if !filter.Target(opt, store, filters) {
				fmt.Printf("[userSelector] check target - store %d pass filters %d\n", store.GetID(), id+1)
				filterFlag = false
				break
			}
		}
		if filterFlag {
			fmt.Printf("[userSelector] filt target - store %d\n", store.GetID())
			continue
		}
		fmt.Printf("[userSelector] pass target - store %d\n", store.GetID())
		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 ) SelectTarget ( opt opt . Options , stores [ ] * core . StoreInfo , filterSet [ ] [ ] filter . Filter ) * core . StoreInfo { var result * core . StoreInfo for _ , store := range stores { filterFlag := true for id , filters := range filterSet { if ! filter . Target ( opt , store , filters ) { fmt . Printf ( " \n " , store . GetID ( ) , id + 1 ) filterFlag = false break } } if filterFlag { fmt . Printf ( " \n " , store . GetID ( ) ) continue } fmt . Printf ( " \n " , store . GetID ( ) ) 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 }
SelectTarget selects the store that can pass all filters and has the minimal resource score.
SelectTarget selects the store that can pass all filters and has the minimal resource score .
// if the store can't pass either filters of the filterSet, we can't choose it // else choose the other stores who has the minimal resource score