Updated cache reload

This commit is contained in:
Trial97
2021-05-07 12:58:40 +03:00
committed by Dan Christian Bogos
parent c73556091f
commit 915ede86c9
4 changed files with 64 additions and 64 deletions

View File

@@ -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)
}

View File

@@ -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]
}
}

View File

@@ -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},
},
}
}

View File

@@ -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()