From 915ede86c980cd884c0c48b5d77efbef3ce31179 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 7 May 2021 12:58:40 +0300 Subject: [PATCH] Updated cache reload --- apier/v1/remote_it_test.go | 2 +- engine/caches.go | 6 ++-- utils/apitpdata.go | 60 +++++++++++++++++++------------------- utils/apitpdata_test.go | 60 +++++++++++++++++++------------------- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index 95ee337a4..4496b6d06 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -713,7 +713,7 @@ func testInternalReplicationSetThreshold(t *testing.T) { }, } if err := internalRPC.Call(utils.APIerSv1SetThresholdProfile, tPrfl, &result); err != nil { - t.Error(err) + t.Fatal(err) } else if result != utils.OK { t.Error("Unexpected reply returned", result) } diff --git a/engine/caches.go b/engine/caches.go index c0cfc5354..28618e58f 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -371,7 +371,7 @@ func (chS *CacheS) V1LoadCache(attrs utils.AttrReloadCacheWithAPIOpts, reply *st func (chS *CacheS) cacheDataFromDB(attrs utils.AttrReloadCacheWithAPIOpts, reply *string, mustBeCached bool) (err error) { for key, ids := range attrs.ArgsCache { if prfx, has := utils.ArgCacheToPrefix[key]; has { - if err = chS.dm.CacheDataFromDB(prfx, ids, true); err != nil { + if err = chS.dm.CacheDataFromDB(prfx, ids, mustBeCached); err != nil { return } } @@ -382,6 +382,7 @@ func (chS *CacheS) cacheDataFromDB(attrs utils.AttrReloadCacheWithAPIOpts, reply if err != utils.ErrNotFound { // we can receive cache reload from LoaderS and we store the LoadID only after all Items was processed return } + err = nil loadIDs = make(map[string]int64) } for key, val := range populateCacheLoadIDs(loadIDs, attrs.ArgsCache) { @@ -397,8 +398,7 @@ func populateCacheLoadIDs(loadIDs map[string]int64, attrs map[string][]string) ( cacheLoadIDs = make(map[string]int64) //based on IDs of each type populate cacheLoadIDs and add into cache for key, ids := range attrs { - if inst, has := utils.ArgCacheToInstance[key]; has && - (ids == nil || len(ids) != 0) { + if inst, has := utils.ArgCacheToInstance[key]; has && len(ids) != 0 { cacheLoadIDs[inst] = loadIDs[inst] } } diff --git a/utils/apitpdata.go b/utils/apitpdata.go index b07237452..3ecb88efd 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -1297,36 +1297,36 @@ type ArgsGetCacheItemWithAPIOpts struct { func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithAPIOpts { return &AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ - DestinationIDs: nil, - ReverseDestinationIDs: nil, - RatingPlanIDs: nil, - RatingProfileIDs: nil, - ActionIDs: nil, - ActionPlanIDs: nil, - AccountActionPlanIDs: nil, - ActionTriggerIDs: nil, - SharedGroupIDs: nil, - ResourceProfileIDs: nil, - ResourceIDs: nil, - StatsQueueIDs: nil, - StatsQueueProfileIDs: nil, - ThresholdIDs: nil, - ThresholdProfileIDs: nil, - FilterIDs: nil, - RouteProfileIDs: nil, - AttributeProfileIDs: nil, - ChargerProfileIDs: nil, - DispatcherProfileIDs: nil, - DispatcherHostIDs: nil, - TimingIDs: nil, - AttributeFilterIndexIDs: nil, - ResourceFilterIndexIDs: nil, - StatFilterIndexIDs: nil, - ThresholdFilterIndexIDs: nil, - RouteFilterIndexIDs: nil, - ChargerFilterIndexIDs: nil, - DispatcherFilterIndexIDs: nil, - FilterIndexIDs: nil, + DestinationIDs: {MetaAny}, + ReverseDestinationIDs: {MetaAny}, + RatingPlanIDs: {MetaAny}, + RatingProfileIDs: {MetaAny}, + ActionIDs: {MetaAny}, + ActionPlanIDs: {MetaAny}, + AccountActionPlanIDs: {MetaAny}, + ActionTriggerIDs: {MetaAny}, + SharedGroupIDs: {MetaAny}, + ResourceProfileIDs: {MetaAny}, + ResourceIDs: {MetaAny}, + StatsQueueIDs: {MetaAny}, + StatsQueueProfileIDs: {MetaAny}, + ThresholdIDs: {MetaAny}, + ThresholdProfileIDs: {MetaAny}, + FilterIDs: {MetaAny}, + RouteProfileIDs: {MetaAny}, + AttributeProfileIDs: {MetaAny}, + ChargerProfileIDs: {MetaAny}, + DispatcherProfileIDs: {MetaAny}, + DispatcherHostIDs: {MetaAny}, + TimingIDs: {MetaAny}, + AttributeFilterIndexIDs: {MetaAny}, + ResourceFilterIndexIDs: {MetaAny}, + StatFilterIndexIDs: {MetaAny}, + ThresholdFilterIndexIDs: {MetaAny}, + RouteFilterIndexIDs: {MetaAny}, + ChargerFilterIndexIDs: {MetaAny}, + DispatcherFilterIndexIDs: {MetaAny}, + FilterIndexIDs: {MetaAny}, }, } } diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go index 7de34e44d..e829ffe26 100644 --- a/utils/apitpdata_test.go +++ b/utils/apitpdata_test.go @@ -1014,36 +1014,36 @@ func TestCDRsFilterPrepare(t *testing.T) { func TestNewAttrReloadCacheWithOpts(t *testing.T) { newAttrReloadCache := &AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ - DestinationIDs: nil, - ReverseDestinationIDs: nil, - RatingPlanIDs: nil, - RatingProfileIDs: nil, - ActionIDs: nil, - ActionPlanIDs: nil, - AccountActionPlanIDs: nil, - ActionTriggerIDs: nil, - SharedGroupIDs: nil, - ResourceProfileIDs: nil, - ResourceIDs: nil, - StatsQueueIDs: nil, - StatsQueueProfileIDs: nil, - ThresholdIDs: nil, - ThresholdProfileIDs: nil, - FilterIDs: nil, - RouteProfileIDs: nil, - AttributeProfileIDs: nil, - ChargerProfileIDs: nil, - DispatcherProfileIDs: nil, - DispatcherHostIDs: nil, - TimingIDs: nil, - AttributeFilterIndexIDs: nil, - ResourceFilterIndexIDs: nil, - StatFilterIndexIDs: nil, - ThresholdFilterIndexIDs: nil, - RouteFilterIndexIDs: nil, - ChargerFilterIndexIDs: nil, - DispatcherFilterIndexIDs: nil, - FilterIndexIDs: nil, + DestinationIDs: {MetaAny}, + ReverseDestinationIDs: {MetaAny}, + RatingPlanIDs: {MetaAny}, + RatingProfileIDs: {MetaAny}, + ActionIDs: {MetaAny}, + ActionPlanIDs: {MetaAny}, + AccountActionPlanIDs: {MetaAny}, + ActionTriggerIDs: {MetaAny}, + SharedGroupIDs: {MetaAny}, + ResourceProfileIDs: {MetaAny}, + ResourceIDs: {MetaAny}, + StatsQueueIDs: {MetaAny}, + StatsQueueProfileIDs: {MetaAny}, + ThresholdIDs: {MetaAny}, + ThresholdProfileIDs: {MetaAny}, + FilterIDs: {MetaAny}, + RouteProfileIDs: {MetaAny}, + AttributeProfileIDs: {MetaAny}, + ChargerProfileIDs: {MetaAny}, + DispatcherProfileIDs: {MetaAny}, + DispatcherHostIDs: {MetaAny}, + TimingIDs: {MetaAny}, + AttributeFilterIndexIDs: {MetaAny}, + ResourceFilterIndexIDs: {MetaAny}, + StatFilterIndexIDs: {MetaAny}, + ThresholdFilterIndexIDs: {MetaAny}, + RouteFilterIndexIDs: {MetaAny}, + ChargerFilterIndexIDs: {MetaAny}, + DispatcherFilterIndexIDs: {MetaAny}, + FilterIndexIDs: {MetaAny}, }, } eMap := NewAttrReloadCacheWithOpts()