// ScatterRegionsByID directly scatter regions by ScatterRegions
ScatterRegionsByID directly scatter regions by ScatterRegions
// ScatterRegionsByID directly scatter regions by ScatterRegions
func (r *RegionScatterer) ScatterRegionsByID(regionsID []uint64, group string, retryLimit int) ([]*operator.Operator, map[uint64]error, error) {
	if len(regionsID) < 1 {
		scatterCounter.WithLabelValues("skip", "empty-region").Inc()
		return nil, nil, errors.New("empty region")
	}
	failures := make(map[uint64]error, len(regionsID))
	regions := make([]*core.RegionInfo, 0, len(regionsID))
	for _, id := range regionsID {
		region := r.cluster.GetRegion(id)
		if region == nil {
			scatterCounter.WithLabelValues("skip", "no-region").Inc()
			log.Warn("failed to find region during scatter", zap.Uint64("region-id", id))
			failures[id] = errors.New(fmt.Sprintf("failed to find region %v", id))
			continue
		}
		regions = append(regions, region)
	}
	regionMap := make(map[uint64]*core.RegionInfo, len(regions))
	for _, region := range regions {
		regionMap[region.GetID()] = region
	}
	ops, err := r.ScatterRegions(regionMap, failures, group, retryLimit)
	if err != nil {
		return nil, nil, err
	}
	return ops, failures, nil
}
func ( r * RegionScatterer ) ScatterRegionsByID ( regionsID [ ] uint64 , group string , retryLimit int ) ( [ ] * operator . Operator , map [ uint64 ] error , error ) { if len ( regionsID ) < 1 { scatterCounter . WithLabelValues ( " " , " " ) . Inc ( ) return nil , nil , errors . New ( " " ) } failures := make ( map [ uint64 ] error , len ( regionsID ) ) regions := make ( [ ] * core . RegionInfo , 0 , len ( regionsID ) ) for _ , id := range regionsID { region := r . cluster . GetRegion ( id ) if region == nil { scatterCounter . WithLabelValues ( " " , " " ) . Inc ( ) log . Warn ( " " , zap . Uint64 ( " " , id ) ) failures [ id ] = errors . New ( fmt . Sprintf ( " " , id ) ) continue } regions = append ( regions , region ) } regionMap := make ( map [ uint64 ] * core . RegionInfo , len ( regions ) ) for _ , region := range regions { regionMap [ region . GetID ( ) ] = region } ops , err := r . ScatterRegions ( regionMap , failures , group , retryLimit ) if err != nil { return nil , nil , err } return ops , failures , nil }
ScatterRegionsByID directly scatter regions by ScatterRegions
ScatterRegionsByID directly scatter regions by ScatterRegions
// If there existed any region failed to relocated after retry, add it into unProcessedRegions