// checkConflict check if the operator is conflict with user specified policy
checkConflict check if the operator is conflict with user specified policy
// checkConflict check if the operator is conflict with user specified policy
func (c *ConflictHandler) checkConflict(id uint64, priority uint64, operators []*operator.Operator) bool {
	for _, op := range operators {
		conflict := false
		maxId := id
		maxPriority := priority
		region := c.cluster.GetRegion(op.RegionID())
		start := region.GetStartKey()
		end := region.GetEndKey()
		for _, s := range c.userSchedulers {
			if !c.PriorTo(s,maxId, maxPriority) {
				fmt.Printf("[ConflictHandler] op(id:%d,priority:%d) skiped scheduler(id:%d) conflit scheck(greater priority)\n", id, priority, s.scheduler.GetID())
				continue
			}
			if bytes.Compare(s.scheduler.GetStart(),start) > 0 || bytes.Compare(s.scheduler.GetEnd(),end) < 0|| len(end)==0{
				fmt.Printf("[ConflictHandler] op(id:%d,priority:%d) skiped scheduler(id:%d) conflit scheck (different range)\n", id, priority, s.scheduler.GetID())
				continue
			}
			if  s.scheduler.IsScheduleAllowed(c.cluster){
				InScope := false
				targets := c.Targets(op)
				for _, target := range targets {
					store := c.cluster.GetStore(target)
					InScope = false
					fmt.Printf("[ConflictHandler] check op(index:%d) region:%d ToStore:%d\n",id,op.RegionID(),target)
					for _, filters := range s.scheduler.GetFilters() {
						if !filter.Target(c.cluster, store, filters) {
							InScope = true
							break
						}
					}
					if !InScope {
						break
					}
				}
				maxId = s.scheduler.GetID()
				maxPriority = s.scheduler.GetPriority()
				if !InScope{
					fmt.Printf("[ConflictHandler] op(id:%d,priority:%d) conflict with scheduler(id:%d,priority:%d)\n", id, priority, maxId, maxPriority)
					conflict = true
				}else{
					conflict = false
					fmt.Printf("[ConflictHandler] op(id:%d,priority:%d) passed scheduler(id:%d,priority:%d) conflit scheck\n", id, priority, maxId, maxPriority)
				}
			} else {
				fmt.Printf("[ConflictHandler]scheduler %d invalid\n",s.scheduler.GetID())
				conflict = false
			}
		}
		if conflict {
			return true
		}
	}
	return false
}
func ( c * ConflictHandler ) checkConflict ( id uint64 , priority uint64 , operators [ ] * operator . Operator ) bool { for _ , op := range operators { conflict := false maxId := id maxPriority := priority region := c . cluster . GetRegion ( op . RegionID ( ) ) start := region . GetStartKey ( ) end := region . GetEndKey ( ) for _ , s := range c . userSchedulers { if ! c . PriorTo ( s , maxId , maxPriority ) { fmt . Printf ( " \n " , id , priority , s . scheduler . GetID ( ) ) continue } if bytes . Compare ( s . scheduler . GetStart ( ) , start ) > 0 || bytes . Compare ( s . scheduler . GetEnd ( ) , end ) < 0 || len ( end ) == 0 { fmt . Printf ( " \n " , id , priority , s . scheduler . GetID ( ) ) continue } if s . scheduler . IsScheduleAllowed ( c . cluster ) { InScope := false targets := c . Targets ( op ) for _ , target := range targets { store := c . cluster . GetStore ( target ) InScope = false fmt . Printf ( " \n " , id , op . RegionID ( ) , target ) for _ , filters := range s . scheduler . GetFilters ( ) { if ! filter . Target ( c . cluster , store , filters ) { InScope = true break } } if ! InScope { break } } maxId = s . scheduler . GetID ( ) maxPriority = s . scheduler . GetPriority ( ) if ! InScope { fmt . Printf ( " \n " , id , priority , maxId , maxPriority ) conflict = true } else { conflict = false fmt . Printf ( " \n " , id , priority , maxId , maxPriority ) } } else { fmt . Printf ( " \n " , s . scheduler . GetID ( ) ) conflict = false } } if conflict { return true } } return false }
checkConflict check if the operator is conflict with user specified policy
checkConflict check if the operator is conflict with user specified policy
// compare with user specified scheduler // don't need to check conflict with scheduler who's target region is different from op // don't need to check conflict with scheduler who's priority is smaller than current max-prior scheduler // if current scheduler is allowed to schedule and op's target doesn't in it's target scope // then conflict detected