diff --git a/docs/lcr.rst b/docs/lcr.rst index a6cd02362..2f0bc4632 100644 --- a/docs/lcr.rst +++ b/docs/lcr.rst @@ -37,10 +37,10 @@ Strategy indicates supplier selection algorithm and StrategyParams will be speci \*load_distribution (sorting/filter) The system will sort the suppliers in order to achieve the specified load distribution. - - if all have less than ponder return random order - - if some have a cdr count not divisible by ponder return them first and all ordered by cdr times, oldest first - - if all have a multiple of ponder return in the order of cdr times, oldest first - StrategyParams: supplier1:ponder;supplier2:ponder;*default:ponder + - if all have less than share return random order + - if some have a cdr count not divisible by share return them first and all ordered by cdr times, oldest first + - if all have a multiple of share return in the order of cdr times, oldest first + StrategyParams: supplier1:share;supplier2:share;*default:share ActivationTime is the date/time when the LCR entry starts to be active. diff --git a/engine/lcr.go b/engine/lcr.go index 71e48361a..05cbe0d36 100644 --- a/engine/lcr.go +++ b/engine/lcr.go @@ -337,25 +337,25 @@ func (lc *LCRCost) SortLoadDistribution() { /*for supplier, sq := range supplierQueues { log.Printf("Useful supplier qeues: %s %v", supplier, sq.conf.TimeWindow) }*/ - // if all have less than ponder return random order - // if some have a cdr count not divisible by ponder return them first and all ordered by cdr times, oldest first - // if all have a multiple of ponder return in the order of cdr times, oldest first + // if all have less than share return random order + // if some have a cdr count not divisible by share return them first and all ordered by cdr times, oldest first + // if all have a multiple of share return in the order of cdr times, oldest first // first put them in one of the above categories - havePonderlessSuppliers := false + haveSharelessSuppliers := false for supCost, sq := range supplierQueues { - ponder := lc.GetSupplierPonder(supCost.Supplier) - if ponder == -1 { + share := lc.GetSupplierShare(supCost.Supplier) + if share == -1 { supCost.Cost = -1 - havePonderlessSuppliers = true + haveSharelessSuppliers = true continue } cdrCount := len(sq.Cdrs) - if cdrCount < ponder { + if cdrCount < share { supCost.Cost = float64(LOW_PRIORITY_LIMIT + rand.Intn(RAND_LIMIT)) continue } - if cdrCount%ponder == 0 { + if cdrCount%share == 0 { supCost.Cost = float64(MED_PRIORITY_LIMIT+rand.Intn(RAND_LIMIT)) + (time.Now().Sub(sq.Cdrs[len(sq.Cdrs)-1].SetupTime).Seconds() / RAND_LIMIT) continue } else { @@ -363,7 +363,7 @@ func (lc *LCRCost) SortLoadDistribution() { continue } } - if havePonderlessSuppliers { + if haveSharelessSuppliers { var filteredSupplierCost []*LCRSupplierCost for _, supCost := range lc.SupplierCosts { if supCost.Cost != -1 { @@ -375,35 +375,35 @@ func (lc *LCRCost) SortLoadDistribution() { } // used in load distribution strategy only -// receives a long supplier id and will return the ponder found in strategy params -func (lc *LCRCost) GetSupplierPonder(supplier string) int { +// receives a long supplier id and will return the share found in strategy params +func (lc *LCRCost) GetSupplierShare(supplier string) int { // parse strategy params - ponders := make(map[string]int) + shares := make(map[string]int) params := strings.Split(lc.Entry.StrategyParams, utils.INFIELD_SEP) for _, param := range params { - ponderSlice := strings.Split(param, utils.CONCATENATED_KEY_SEP) - if len(ponderSlice) != 2 { + shareSlice := strings.Split(param, utils.CONCATENATED_KEY_SEP) + if len(shareSlice) != 2 { Logger.Warning(fmt.Sprintf("bad format in load distribution strategy param: %s", lc.Entry.StrategyParams)) continue } - p, err := strconv.Atoi(ponderSlice[1]) + p, err := strconv.Atoi(shareSlice[1]) if err != nil { Logger.Warning(fmt.Sprintf("bad format in load distribution strategy param: %s", lc.Entry.StrategyParams)) continue } - ponders[ponderSlice[0]] = p + shares[shareSlice[0]] = p } parts := strings.Split(supplier, utils.CONCATENATED_KEY_SEP) if len(parts) > 0 { supplierSubject := parts[len(parts)-1] - if ponder, found := ponders[supplierSubject]; found { - return ponder + if share, found := shares[supplierSubject]; found { + return share } - if ponder, found := ponders[utils.META_DEFAULT]; found { - return ponder + if share, found := shares[utils.META_DEFAULT]; found { + return share } } - if len(ponders) == 0 { + if len(shares) == 0 { return 1 // use random/last cdr date sorting } return -1 // exclude missing suppliers