diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 0e69431ac..1f03d090b 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -1005,6 +1005,19 @@ func (self *ApierV1) ReloadCache(attrs utils.AttrReloadCache, reply *string) (er if err = self.DataManager.CacheDataFromDB(utils.ThresholdProfilePrefix, dataIDs, true); err != nil { return } + // Filters + dataIDs = make([]string, 0) + if attrs.FilterIDs == nil { + dataIDs = nil // Reload all + } else if len(*attrs.FilterIDs) > 0 { + dataIDs = make([]string, len(*attrs.FilterIDs)) + for idx, dId := range *attrs.FilterIDs { + dataIDs[idx] = dId + } + } + if err = self.DataManager.CacheDataFromDB(utils.FilterPrefix, dataIDs, true); err != nil { + return + } *reply = utils.OK return nil @@ -1014,7 +1027,7 @@ func (self *ApierV1) LoadCache(args utils.AttrReloadCache, reply *string) (err e if args.FlushAll { cache.Flush() } - var dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs []string + var dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs []string if args.DestinationIDs == nil { dstIDs = nil } else { @@ -1110,8 +1123,13 @@ func (self *ApierV1) LoadCache(args utils.AttrReloadCache, reply *string) (err e } else { thpIDs = *args.ThresholdProfileIDs } + if args.FilterIDs == nil { + fltrIDs = nil + } else { + fltrIDs = *args.FilterIDs + } - if err := self.DataManager.LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs); err != nil { + if err := self.DataManager.LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs); err != nil { return utils.NewErrServerError(err) } *reply = utils.OK @@ -1251,6 +1269,13 @@ func (self *ApierV1) FlushCache(args utils.AttrReloadCache, reply *string) (err cache.RemKey(utils.ThresholdProfilePrefix+key, true, utils.NonTransactional) } } + if args.FilterIDs == nil { + cache.RemPrefixKey(utils.FilterPrefix, true, utils.NonTransactional) + } else if len(*args.FilterIDs) != 0 { + for _, key := range *args.FilterIDs { + cache.RemKey(utils.FilterPrefix+key, true, utils.NonTransactional) + } + } *reply = utils.OK return @@ -1276,6 +1301,7 @@ func (self *ApierV1) GetCacheStats(attrs utils.AttrCacheStats, reply *utils.Cach cs.StatQueueProfiles = cache.CountEntries(utils.StatQueueProfilePrefix) cs.Thresholds = cache.CountEntries(utils.ThresholdPrefix) cs.ThresholdProfiles = cache.CountEntries(utils.ThresholdProfilePrefix) + cs.Filters = cache.CountEntries(utils.FilterPrefix) if self.CdrStatsSrv != nil { var queueIds []string @@ -1646,6 +1672,25 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } + if args.FilterIDs != nil { + var ids []string + if len(*args.FilterIDs) != 0 { + for _, id := range *args.FilterIDs { + if _, hasIt := cache.Get(utils.FilterPrefix + id); hasIt { + ids = append(ids, id) + } + } + } else { + for _, id := range cache.GetEntryKeys(utils.FilterPrefix) { + ids = append(ids, id[len(utils.FilterPrefix):]) + } + } + ids = args.Paginator.PaginateStringSlice(ids) + if len(ids) != 0 { + reply.FilterIDs = &ids + } + } + return } @@ -1712,17 +1757,16 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder, utils.ACTION_TRIGGER_PREFIX, utils.SHARED_GROUP_PREFIX, utils.DERIVEDCHARGERS_PREFIX, - utils.LCR_PREFIX} { - loadedIDs, _ := loader.GetLoadedIds(prfx) - if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil { - return utils.NewErrServerError(err) - } - } - for _, prfx := range []string{ + utils.LCR_PREFIX, utils.ALIASES_PREFIX, utils.REVERSE_ALIASES_PREFIX, utils.ResourceProfilesPrefix, - utils.ResourcesPrefix} { + utils.ResourcesPrefix, + utils.StatQueuePrefix, + utils.StatQueueProfilePrefix, + utils.ThresholdPrefix, + utils.ThresholdProfilePrefix, + utils.FilterPrefix} { loadedIDs, _ := loader.GetLoadedIds(prfx) if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil { return utils.NewErrServerError(err) diff --git a/apier/v1/smgenericv1_it_test.go b/apier/v1/smgenericv1_it_test.go index 4a79433df..919790b98 100644 --- a/apier/v1/smgenericv1_it_test.go +++ b/apier/v1/smgenericv1_it_test.go @@ -102,7 +102,8 @@ func TestSMGV1CacheStats(t *testing.T) { var rcvStats *utils.CacheStats expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 9, Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1, - LcrProfiles: 5, CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 0, StatQueueProfiles: 0, Thresholds: 6, ThresholdProfiles: 6} + LcrProfiles: 5, CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 0, + StatQueueProfiles: 0, Thresholds: 6, ThresholdProfiles: 6, Filters: 0} var args utils.AttrCacheStats if err := smgV1Rpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil { t.Error("Got error on ApierV1.GetCacheStats: ", err.Error()) diff --git a/apier/v2/apier.go b/apier/v2/apier.go index 54df6a9f6..60c31f26c 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -175,16 +175,16 @@ func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder, utils.ACTION_TRIGGER_PREFIX, utils.SHARED_GROUP_PREFIX, utils.DERIVEDCHARGERS_PREFIX, - utils.LCR_PREFIX} { - loadedIDs, _ := loader.GetLoadedIds(prfx) - if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil { - return utils.NewErrServerError(err) - } - } - for _, prfx := range []string{ + utils.LCR_PREFIX, utils.ALIASES_PREFIX, utils.REVERSE_ALIASES_PREFIX, - utils.ResourceProfilesPrefix} { + utils.ResourceProfilesPrefix, + utils.ResourcesPrefix, + utils.StatQueuePrefix, + utils.StatQueueProfilePrefix, + utils.ThresholdPrefix, + utils.ThresholdProfilePrefix, + utils.FilterPrefix} { loadedIDs, _ := loader.GetLoadedIds(prfx) if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil { return utils.NewErrServerError(err) diff --git a/cmd/cgr-engine/rater.go b/cmd/cgr-engine/rater.go index 798c6c792..7994eb181 100755 --- a/cmd/cgr-engine/rater.go +++ b/cmd/cgr-engine/rater.go @@ -43,7 +43,7 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheDoneC waitTasks = append(waitTasks, cacheTaskChan) go func() { defer close(cacheTaskChan) - var dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs []string + var dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs []string if cCfg, has := cfg.CacheConfig[utils.CacheDestinations]; !has || !cCfg.Precache { dstIDs = make([]string, 0) // Don't cache any } @@ -101,9 +101,12 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheDoneC if cCfg, has := cfg.CacheConfig[utils.CacheThresholdProfiles]; !has || !cCfg.Precache { thpIDs = make([]string, 0) } + if cCfg, has := cfg.CacheConfig[utils.CacheFilters]; !has || !cCfg.Precache { + fltrIDs = make([]string, 0) + } // ToDo: Add here timings - if err := dm.LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs); err != nil { + if err := dm.LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs); err != nil { utils.Logger.Crit(fmt.Sprintf(" Cache rating error: %s", err.Error())) exitChan <- true return diff --git a/cmd/cgr-tester/cgr-tester.go b/cmd/cgr-tester/cgr-tester.go index 86bfc97a4..30dbb0acd 100644 --- a/cmd/cgr-tester/cgr-tester.go +++ b/cmd/cgr-tester/cgr-tester.go @@ -67,7 +67,7 @@ func durInternalRater(cd *engine.CallDescriptor) (time.Duration, error) { } defer dm.DataDB().Close() engine.SetDataStorage(dm) - if err := dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil); err != nil { + if err := dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil); err != nil { return nilDuration, fmt.Errorf("Cache rating error: %s", err.Error()) } log.Printf("Runnning %d cycles...", *runs) diff --git a/data/conf/samples/apier/apier.json b/data/conf/samples/apier/apier.json index e2b9f5868..ae60d8a81 100644 --- a/data/conf/samples/apier/apier.json +++ b/data/conf/samples/apier/apier.json @@ -31,6 +31,7 @@ "statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, "thresholds": {"limit": 10000, "ttl":"0s", "precache": true}, "threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, + "filters": {"limit": 10000, "ttl":"0s", "precache": true}, }, "listen": { diff --git a/data/conf/samples/tutmongo/cgrates.json b/data/conf/samples/tutmongo/cgrates.json index 17fbaa227..640c89286 100644 --- a/data/conf/samples/tutmongo/cgrates.json +++ b/data/conf/samples/tutmongo/cgrates.json @@ -48,6 +48,7 @@ "statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, "thresholds": {"limit": 10000, "ttl":"0s", "precache": true}, "threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, + "filters": {"limit": 10000, "ttl":"0s", "precache": true}, }, diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json index e9d24f866..3468f3e06 100644 --- a/data/conf/samples/tutmysql/cgrates.json +++ b/data/conf/samples/tutmysql/cgrates.json @@ -41,6 +41,7 @@ "statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, "thresholds": {"limit": 10000, "ttl":"0s", "precache": true}, "threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, + "filters": {"limit": 10000, "ttl":"0s", "precache": true}, }, diff --git a/engine/datamanager.go b/engine/datamanager.go index 7dfeb173c..20c1f44b8 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -38,7 +38,7 @@ func (dm *DataManager) DataDB() DataDB { return dm.dataDB } -func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aaPlIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rpIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs []string) (err error) { +func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aaPlIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rpIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs []string) (err error) { if dm.DataDB().GetStorageType() == utils.MAPSTOR { if dm.cacheCfg == nil { return @@ -49,7 +49,7 @@ func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX, utils.LCR_PREFIX, utils.CDR_STATS_PREFIX, utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACTION_TRIGGER_PREFIX, utils.SHARED_GROUP_PREFIX, utils.ALIASES_PREFIX, utils.REVERSE_ALIASES_PREFIX, utils.StatQueuePrefix, utils.StatQueueProfilePrefix, - utils.ThresholdPrefix, utils.ThresholdProfilePrefix}, k) && cacheCfg.Precache { + utils.ThresholdPrefix, utils.ThresholdProfilePrefix, utils.FilterPrefix}, k) && cacheCfg.Precache { if err := dm.PreloadCacheForPrefix(k); err != nil && err != utils.ErrInvalidKey { return err } @@ -77,6 +77,7 @@ func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, utils.StatQueueProfilePrefix: stqpIDs, utils.ThresholdPrefix: thIDs, utils.ThresholdProfilePrefix: thpIDs, + utils.FilterPrefix: fltrIDs, } { if err = dm.CacheDataFromDB(key, ids, false); err != nil { return @@ -132,7 +133,8 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b utils.StatQueuePrefix, utils.StatQueueProfilePrefix, utils.ThresholdPrefix, - utils.ThresholdProfilePrefix}, prfx) { + utils.ThresholdProfilePrefix, + utils.FilterPrefix}, prfx) { return utils.NewCGRError(utils.MONGO, utils.MandatoryIEMissingCaps, utils.UnsupportedCachePrefix, @@ -285,9 +287,6 @@ func (dm *DataManager) GetFilter(tenant, id string, skipCache bool, transactionI } return nil, err } - if err = fltr.Compile(); err != nil { - return - } cache.Set(key, fltr, cacheCommit(transactionID), transactionID) return } diff --git a/engine/libtest.go b/engine/libtest.go index 6999c008f..66df14ab5 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -41,7 +41,7 @@ func InitDataDb(cfg *config.CGRConfig) error { if err := dm.DataDB().Flush(""); err != nil { return err } - dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) // Write version before starting if err := SetDBVersions(dm.dataDB); err != nil { return err diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index ba1e5b472..0c87ea1ab 100755 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -346,9 +346,11 @@ func init() { if err := csvr.LoadAliases(); err != nil { log.Print("error in LoadAliases:", err) } + if err := csvr.LoadFilters(); err != nil { + log.Print("error in LoadFilter:", err) + } if err := csvr.LoadResourceProfiles(); err != nil { log.Print("error in LoadResourceProfiles:", err) - } if err := csvr.LoadStats(); err != nil { log.Print("error in LoadStats:", err) @@ -356,12 +358,9 @@ func init() { if err := csvr.LoadThresholds(); err != nil { log.Print("error in LoadThresholds:", err) } - if err := csvr.LoadFilters(); err != nil { - log.Print("error in LoadFilter:", err) - } csvr.WriteToDatabase(false, false, false) cache.Flush() - dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) } func TestLoadDestinations(t *testing.T) { diff --git a/engine/storage_csv.go b/engine/storage_csv.go index 344dd6634..d84438f5c 100755 --- a/engine/storage_csv.go +++ b/engine/storage_csv.go @@ -694,7 +694,7 @@ func (csvs *CSVStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) return nil, err } if filterCfg, err := csvLoad(TpFilter{}, record); err != nil { - log.Print("error loading TPThreshold: ", err) + log.Print("error loading TPFilter: ", err) return nil, err } else { fIlterCfg := filterCfg.(TpFilter) diff --git a/engine/storage_map.go b/engine/storage_map.go index dcac6794f..538a4079e 100755 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -1363,6 +1363,14 @@ func (ms *MapStorage) GetFilterDrv(tenant, id string) (r *Filter, err error) { return nil, utils.ErrNotFound } err = ms.ms.Unmarshal(values, &r) + if err != nil { + return nil, err + } + for _, fltr := range r.RequestFilters { + if err := fltr.CompileValues(); err != nil { + return nil, err + } + } return } diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index cfe254616..f8f9ef092 100755 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -1952,6 +1952,11 @@ func (ms *MongoStorage) GetFilterDrv(tenant, id string) (r *Filter, err error) { } return nil, err } + for _, fltr := range r.RequestFilters { + if err = fltr.CompileValues(); err != nil { + return + } + } return } diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 4062bc95e..a8953cc1d 100755 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -1510,6 +1510,11 @@ func (rs *RedisStorage) GetFilterDrv(tenant, id string) (r *Filter, err error) { if err = rs.ms.Unmarshal(values, &r); err != nil { return } + for _, fltr := range r.RequestFilters { + if err = fltr.CompileValues(); err != nil { + return + } + } return } diff --git a/engine/storage_test.go b/engine/storage_test.go index 6ace59c5a..000accc23 100644 --- a/engine/storage_test.go +++ b/engine/storage_test.go @@ -102,7 +102,7 @@ func TestStorageCacheRefresh(t *testing.T) { dm.DataDB().GetDestination("T11", false, utils.NonTransactional) dm.DataDB().SetDestination(&Destination{"T11", []string{"1"}}, utils.NonTransactional) t.Log("Test cache refresh") - err := dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + err := dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if err != nil { t.Error("Error cache rating: ", err) } diff --git a/general_tests/acntacts_test.go b/general_tests/acntacts_test.go index d089bd83c..ea8cafa04 100644 --- a/general_tests/acntacts_test.go +++ b/general_tests/acntacts_test.go @@ -65,7 +65,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,,false,false,10` csvr.WriteToDatabase(false, false, false) cache.Flush() - dbAcntActs.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dbAcntActs.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) expectAcnt := &engine.Account{ID: "cgrates.org:1"} if acnt, err := dbAcntActs.DataDB().GetAccount("cgrates.org:1"); err != nil { diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go index 82847734b..763f0dd20 100644 --- a/general_tests/auth_test.go +++ b/general_tests/auth_test.go @@ -77,7 +77,7 @@ RP_ANY,DR_ANY_1CNT,*any,10` } cache.Flush() - dbAuth.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dbAuth.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) diff --git a/general_tests/costs1_test.go b/general_tests/costs1_test.go index 5ac89d5f0..3990197d3 100644 --- a/general_tests/costs1_test.go +++ b/general_tests/costs1_test.go @@ -74,7 +74,7 @@ RP_SMS1,DR_SMS_1,ALWAYS,10` } csvr.WriteToDatabase(false, false, false) cache.Flush() - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 3 { t.Error("Wrong number of cached rating plans found", cachedRPlans) diff --git a/general_tests/datachrg1_test.go b/general_tests/datachrg1_test.go index 5dee13e63..5f818c7a2 100644 --- a/general_tests/datachrg1_test.go +++ b/general_tests/datachrg1_test.go @@ -61,7 +61,7 @@ RP_DATA1,DR_DATA_2,TM2,10` } csvr.WriteToDatabase(false, false, false) cache.Flush() - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 1 { t.Error("Wrong number of cached rating plans found", cachedRPlans) diff --git a/general_tests/ddazmbl1_test.go b/general_tests/ddazmbl1_test.go index 74358bff1..01935f450 100644 --- a/general_tests/ddazmbl1_test.go +++ b/general_tests/ddazmbl1_test.go @@ -112,7 +112,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` t.Error("No account saved") } cache.Flush() - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) diff --git a/general_tests/ddazmbl2_test.go b/general_tests/ddazmbl2_test.go index 9aff38ae7..910e6325f 100644 --- a/general_tests/ddazmbl2_test.go +++ b/general_tests/ddazmbl2_test.go @@ -112,7 +112,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` t.Error("No account saved") } cache.Flush() - dataDB2.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB2.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) diff --git a/general_tests/ddazmbl3_test.go b/general_tests/ddazmbl3_test.go index 4c42b7aaf..4230688cf 100644 --- a/general_tests/ddazmbl3_test.go +++ b/general_tests/ddazmbl3_test.go @@ -110,7 +110,7 @@ RP_UK,DR_UK_Mobile_BIG5,ALWAYS,10` t.Error("No account saved") } cache.Flush() - dataDB3.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB3.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) diff --git a/general_tests/smschrg1_test.go b/general_tests/smschrg1_test.go index b4a7422c9..0c0eca418 100644 --- a/general_tests/smschrg1_test.go +++ b/general_tests/smschrg1_test.go @@ -59,7 +59,7 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) { } csvr.WriteToDatabase(false, false, false) cache.Flush() - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 1 { t.Error("Wrong number of cached rating plans found", cachedRPlans) diff --git a/general_tests/tutorial_it_test.go b/general_tests/tutorial_it_test.go index 943e11d9a..a579ac611 100644 --- a/general_tests/tutorial_it_test.go +++ b/general_tests/tutorial_it_test.go @@ -104,7 +104,7 @@ func TestTutITCacheStats(t *testing.T) { var rcvStats *utils.CacheStats expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 9, Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1, LcrProfiles: 5, - CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 0, StatQueueProfiles: 0, Thresholds: 6, ThresholdProfiles: 6} + CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 0, StatQueueProfiles: 0, Thresholds: 6, ThresholdProfiles: 6, Filters: 0} var args utils.AttrCacheStats if err := tutLocalRpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil { t.Error("Got error on ApierV1.GetCacheStats: ", err.Error()) diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 71b515922..e8bf330ac 100755 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -674,6 +674,7 @@ type ArgsCache struct { StatsQueueProfileIDs *[]string ThresholdIDs *[]string ThresholdProfileIDs *[]string + FilterIDs *[]string } // Data used to do remote cache reloads via api @@ -714,6 +715,7 @@ type CacheStats struct { StatQueueProfiles int Thresholds int ThresholdProfiles int + Filters int } type AttrExpFileCdrs struct { diff --git a/utils/consts.go b/utils/consts.go index 0e3520b2e..dc47059a0 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -474,6 +474,7 @@ const ( ResourceS = "ResourceS" CacheThresholdProfiles = "threshold_profiles" CacheThresholds = "thresholds" + CacheFilters = "filters" AccountUpdate = "AccountUpdate" BalanceUpdate = "BalanceUpdate" StatUpdate = "StatUpdate"