diff --git a/apier/v1/apier.go b/apier/v1/apier.go index ec9830442..6d536fe3d 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -989,7 +989,7 @@ func (v1 *ApierV1) CallCache(cacheOpt string, args engine.ArgsGetCacheItem) (err return err } case utils.MetaRemove: - if err = v1.CacheS.Call(utils.CacheSv1RemoveItem, args, &reply); err != nil { + if err = v1.CacheS.Call(utils.CacheSv1RemoveItem, &args, &reply); err != nil { return err } case utils.MetaClear: diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go index a327d5a6d..ef4b6c34d 100644 --- a/apier/v1/attributes.go +++ b/apier/v1/attributes.go @@ -85,9 +85,11 @@ func (apierV1 *ApierV1) SetAttributeProfile(alsWrp *AttributeWrapper, reply *str if err := apierV1.DataManager.SetAttributeProfile(alsWrp.AttributeProfile, true); err != nil { return utils.APIErrorHandler(err) } - loadId := map[string]string{utils.AttributeProfilePrefix: utils.UUIDSha1Prefix()} - //generez un nou id pentru load_ids - //fac update in datadb + //generate a loadID for attributeProfile and store it in database + loadIDs := map[string]string{utils.CacheAttributeProfiles: utils.UUIDSha1Prefix()} + if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil { + return utils.APIErrorHandler(err) + } args := engine.ArgsGetCacheItem{ CacheID: utils.CacheAttributeProfiles, ItemID: alsWrp.TenantID(), diff --git a/apier/v1/caches_it_test.go b/apier/v1/caches_it_test.go index 2fa52ffe0..3afea28f4 100644 --- a/apier/v1/caches_it_test.go +++ b/apier/v1/caches_it_test.go @@ -132,7 +132,7 @@ func testCacheSAfterLoadFromFolder(t *testing.T) { if err := chcRPC.Call(utils.CacheSv1GetCacheStats, nil, &rcvStats); err != nil { t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error()) } else if !reflect.DeepEqual(expStats, rcvStats) { - t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats)) + t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats)) } reply := "" // Simple test that command is executed without errors @@ -155,11 +155,12 @@ func testCacheSAfterLoadFromFolder(t *testing.T) { expStats[utils.CacheSupplierProfiles].Items = 2 expStats[utils.CacheThresholdProfiles].Items = 1 expStats[utils.CacheThresholds].Items = 1 + expStats[utils.CacheLoadIDs].Items = 20 if err := chcRPC.Call(utils.CacheSv1GetCacheStats, nil, &rcvStats); err != nil { t.Error(err) } else if !reflect.DeepEqual(expStats, rcvStats) { - t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats)) + t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats)) } } @@ -207,6 +208,7 @@ func testCacheSReload(t *testing.T) { expStats[utils.CacheSupplierProfiles].Items = 2 expStats[utils.CacheThresholdProfiles].Items = 1 expStats[utils.CacheThresholds].Items = 1 + expStats[utils.CacheLoadIDs].Items = 20 if err := chcRPC.Call(utils.CacheSv1GetCacheStats, nil, &rcvStats); err != nil { t.Error(err) @@ -370,6 +372,7 @@ func testCacheSPrecacheStatus(t *testing.T) { utils.CacheSupplierFilterIndexes: utils.MetaReady, utils.CacheChargerFilterIndexes: utils.MetaReady, utils.CacheDispatcherFilterIndexes: utils.MetaReady, + utils.CacheLoadIDs: utils.MetaReady, } if err := chcRPC.Call(utils.CacheSv1PrecacheStatus, nil, &reply); err != nil { diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 8eb5a12f3..b561a9484 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -1063,8 +1063,6 @@ func startRpc(server *utils.Server, internalRaterChan, internalDispatcherSChan <- dispatcherS case analyzerS := <-internalAnalyzerSChan: internalAnalyzerSChan <- analyzerS - case cacheS := <-internalCacheSChan: - internalCacheSChan <- cacheS } go server.ServeJSON(cfg.ListenCfg().RPCJSONListen) @@ -1334,8 +1332,9 @@ func main() { // init cache cacheS := engine.NewCacheS(cfg, dm) + cacheSv1 := v1.NewCacheSv1(cacheS) if !cfg.DispatcherSCfg().Enabled { - server.RpcRegister(v1.NewCacheSv1(cacheS)) // before pre-caching so we can check status via API + server.RpcRegister(cacheSv1) // before pre-caching so we can check status via API } go func() { if err := cacheS.Precache(); err != nil { @@ -1366,7 +1365,8 @@ func main() { internalDispatcherSChan := make(chan *dispatchers.DispatcherService, 1) internalAnalyzerSChan := make(chan rpcclient.RpcClientConnection, 1) internalCacheSChan := make(chan rpcclient.RpcClientConnection, 1) - + //Add cacheSv1 into channel + internalCacheSChan <- cacheSv1 // Start ServiceManager srvManager := servmanager.NewServiceManager(cfg, dm, exitChan, cacheS) diff --git a/config/config_defaults.go b/config/config_defaults.go index 8d6a882c5..aa50fe6c0 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -755,7 +755,7 @@ const CGRATES_CFG_JSON = ` "apier": { "caches_conns":[ // connections to CacheS for reloads - {"address": "127.0.0.1:2012", "transport": "*json"}, + {"address": "*internal"}, ], }, diff --git a/config/config_json_test.go b/config/config_json_test.go index ac16737c4..ad63da712 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -161,6 +161,9 @@ func TestCacheJsonCfg(t *testing.T) { Ttl: utils.StringPointer("2s"), Static_ttl: utils.BoolPointer(false)}, utils.CacheClosedSessions: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("10s"), Static_ttl: utils.BoolPointer(false)}, + utils.CacheLoadIDs: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), + Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), + Precache: utils.BoolPointer(false)}, } if gCfg, err := dfCgrJsonCfg.CacheJsonCfg(); err != nil { @@ -1501,8 +1504,7 @@ func TestDfApierCfg(t *testing.T) { eCfg := &ApierJsonCfg{ Caches_conns: &[]*HaPoolJsonCfg{ { - Address: utils.StringPointer("127.0.0.1:2012"), - Transport: utils.StringPointer(utils.MetaJSONrpc), + Address: utils.StringPointer(utils.MetaInternal), }, }, } diff --git a/config/config_test.go b/config/config_test.go index f549f28b5..b5cce0f1a 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -711,6 +711,8 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) { TTL: time.Duration(2 * time.Second), StaticTTL: false}, utils.CacheClosedSessions: &CacheParamCfg{Limit: -1, TTL: time.Duration(10 * time.Second), StaticTTL: false}, + utils.CacheLoadIDs: &CacheParamCfg{Limit: -1, + TTL: time.Duration(0), StaticTTL: false, Precache: false}, } if !reflect.DeepEqual(eCacheCfg, cgrCfg.CacheCfg()) { @@ -1709,7 +1711,7 @@ func TestNewCGRConfigFromPathNotFound(t *testing.T) { func TestCgrCfgJSONDefaultApierCfg(t *testing.T) { aCfg := &ApierCfg{ CachesConns: []*HaPoolConfig{ - {Address: "127.0.0.1:2012", Transport: "*json"}, + {Address: utils.MetaInternal}, }, } if !reflect.DeepEqual(cgrCfg.apier, aCfg) { diff --git a/engine/caches.go b/engine/caches.go index fc53e6d71..1a5d5e041 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -323,6 +323,17 @@ func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCache, reply *string) (er return } + //get loadIDs from database for all types + loadIDs, err := chS.dm.GetItemLoadIDs(utils.EmptyString, false) + if err != nil { + return err + } + cacheLoadIDs := populateCacheLoadIDs(loadIDs, attrs) + for key, val := range cacheLoadIDs { + Cache.Set(utils.CacheLoadIDs, key, val, nil, + cacheCommit(utils.NonTransactional), utils.NonTransactional) + } + *reply = utils.OK return nil } @@ -363,6 +374,16 @@ func (chS *CacheS) V1LoadCache(args utils.AttrReloadCache, reply *string) (err e ); err != nil { return utils.NewErrServerError(err) } + //get loadIDs for all types + loadIDs, err := chS.dm.GetItemLoadIDs(utils.EmptyString, false) + if err != nil { + return err + } + cacheLoadIDs := populateCacheLoadIDs(loadIDs, args) + for key, val := range cacheLoadIDs { + Cache.Set(utils.CacheLoadIDs, key, val, nil, + cacheCommit(utils.NonTransactional), utils.NonTransactional) + } *reply = utils.OK return nil } @@ -405,7 +426,83 @@ func (chS *CacheS) V1FlushCache(args utils.AttrReloadCache, reply *string) (err flushCache(utils.CacheDispatcherProfiles, args.DispatcherProfileIDs) flushCache(utils.CacheDispatcherHosts, args.DispatcherHostIDs) flushCache(utils.CacheDispatcherRoutes, args.DispatcherRoutesIDs) - + //get loadIDs for all types + loadIDs, err := chS.dm.GetItemLoadIDs(utils.EmptyString, false) + if err != nil { + return err + } + cacheLoadIDs := populateCacheLoadIDs(loadIDs, args) + for key, val := range cacheLoadIDs { + Cache.Set(utils.CacheLoadIDs, key, val, nil, + cacheCommit(utils.NonTransactional), utils.NonTransactional) + } *reply = utils.OK return } + +//populateCacheLoadIDs populate cacheLoadIDs based on attrs +func populateCacheLoadIDs(loadIDs map[string]string, attrs utils.AttrReloadCache) (cacheLoadIDs map[string]string) { + cacheLoadIDs = make(map[string]string) + //based on IDs of each type populate cacheLoadIDs and add into cache + if attrs.DestinationIDs == nil || len(*attrs.DestinationIDs) != 0 { + cacheLoadIDs[utils.CacheDestinations] = loadIDs[utils.CacheDestinations] + } + if attrs.ReverseDestinationIDs == nil || len(*attrs.ReverseDestinationIDs) != 0 { + cacheLoadIDs[utils.CacheReverseDestinations] = loadIDs[utils.CacheReverseDestinations] + } + if attrs.RatingPlanIDs == nil || len(*attrs.RatingPlanIDs) != 0 { + cacheLoadIDs[utils.CacheRatingPlans] = loadIDs[utils.CacheRatingPlans] + } + if attrs.RatingProfileIDs == nil || len(*attrs.RatingProfileIDs) != 0 { + cacheLoadIDs[utils.CacheRatingProfiles] = loadIDs[utils.CacheRatingProfiles] + } + if attrs.ActionIDs == nil || len(*attrs.ActionIDs) != 0 { + cacheLoadIDs[utils.CacheActions] = loadIDs[utils.CacheActions] + } + if attrs.ActionPlanIDs == nil || len(*attrs.ActionPlanIDs) != 0 { + cacheLoadIDs[utils.CacheActionPlans] = loadIDs[utils.CacheActionPlans] + } + if attrs.AccountActionPlanIDs == nil || len(*attrs.AccountActionPlanIDs) != 0 { + cacheLoadIDs[utils.CacheAccountActionPlans] = loadIDs[utils.CacheAccountActionPlans] + } + if attrs.ActionTriggerIDs == nil || len(*attrs.ActionTriggerIDs) != 0 { + cacheLoadIDs[utils.CacheActionTriggers] = loadIDs[utils.CacheActionTriggers] + } + if attrs.SharedGroupIDs == nil || len(*attrs.SharedGroupIDs) != 0 { + cacheLoadIDs[utils.CacheSharedGroups] = loadIDs[utils.CacheSharedGroups] + } + if attrs.ResourceProfileIDs == nil || len(*attrs.ResourceProfileIDs) != 0 { + cacheLoadIDs[utils.CacheResourceProfiles] = loadIDs[utils.CacheResourceProfiles] + } + if attrs.ResourceIDs == nil || len(*attrs.ResourceIDs) != 0 { + cacheLoadIDs[utils.CacheResources] = loadIDs[utils.CacheResources] + } + if attrs.StatsQueueProfileIDs == nil || len(*attrs.StatsQueueProfileIDs) != 0 { + cacheLoadIDs[utils.CacheStatQueueProfiles] = loadIDs[utils.CacheStatQueueProfiles] + } + if attrs.StatsQueueIDs == nil || len(*attrs.StatsQueueIDs) != 0 { + cacheLoadIDs[utils.CacheStatQueues] = loadIDs[utils.CacheStatQueues] + } + if attrs.ThresholdProfileIDs == nil || len(*attrs.ThresholdProfileIDs) != 0 { + cacheLoadIDs[utils.CacheThresholdProfiles] = loadIDs[utils.CacheThresholdProfiles] + } + if attrs.ThresholdIDs == nil || len(*attrs.ThresholdIDs) != 0 { + cacheLoadIDs[utils.CacheThresholds] = loadIDs[utils.CacheThresholds] + } + if attrs.FilterIDs == nil || len(*attrs.FilterIDs) != 0 { + cacheLoadIDs[utils.CacheFilters] = loadIDs[utils.CacheFilters] + } + if attrs.SupplierProfileIDs == nil || len(*attrs.SupplierProfileIDs) != 0 { + cacheLoadIDs[utils.CacheSupplierProfiles] = loadIDs[utils.CacheSupplierProfiles] + } + if attrs.AttributeProfileIDs == nil || len(*attrs.AttributeProfileIDs) != 0 { + cacheLoadIDs[utils.CacheAttributeProfiles] = loadIDs[utils.CacheAttributeProfiles] + } + if attrs.ChargerProfileIDs == nil || len(*attrs.ChargerProfileIDs) != 0 { + cacheLoadIDs[utils.CacheChargerProfiles] = loadIDs[utils.CacheChargerProfiles] + } + if attrs.DispatcherProfileIDs == nil || len(*attrs.DispatcherProfileIDs) != 0 { + cacheLoadIDs[utils.CacheDispatcherProfiles] = loadIDs[utils.CacheDispatcherProfiles] + } + return +} diff --git a/engine/datamanager.go b/engine/datamanager.go index e0122d403..46380b32d 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -291,6 +291,8 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b err = dm.MatchFilterIndexFromKey(utils.CacheChargerFilterIndexes, dataID) case utils.DispatcherFilterIndexes: err = dm.MatchFilterIndexFromKey(utils.CacheDispatcherFilterIndexes, dataID) + case utils.LoadIDPrefix: + _, err = dm.GetItemLoadIDs(utils.EmptyString, true) } if err != nil { if err == utils.ErrNotFound { @@ -1348,3 +1350,27 @@ func (dm *DataManager) RemoveDispatcherHost(tenant, id string, } return } + +func (dm *DataManager) GetItemLoadIDs(itemIDPrefix string, cacheWrite bool) (loadIDs map[string]string, err error) { + loadIDs, err = dm.DataDB().GetItemLoadIDsDrv(itemIDPrefix) + if err != nil { + if err == utils.ErrNotFound && cacheWrite { + for key, _ := range loadIDs { + Cache.Set(utils.CacheLoadIDs, key, nil, nil, + cacheCommit(utils.NonTransactional), utils.NonTransactional) + } + } + return nil, err + } + if cacheWrite { + for key, val := range loadIDs { + Cache.Set(utils.CacheLoadIDs, key, val, nil, + cacheCommit(utils.NonTransactional), utils.NonTransactional) + } + } + return +} + +func (dm *DataManager) SetLoadIDs(loadIDs map[string]string) error { + return dm.DataDB().SetLoadIDsDrv(loadIDs) +} diff --git a/engine/libtest.go b/engine/libtest.go index a6dd44f01..152ff2be4 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -373,5 +373,9 @@ func GetDefaultEmptyCacheStats() map[string]*ltcache.CacheStats { Items: 0, Groups: 0, }, + utils.CacheLoadIDs: { + Items: 0, + Groups: 0, + }, } } diff --git a/engine/tpreader.go b/engine/tpreader.go index 24eea432a..adbd61b6b 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -1409,6 +1409,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err // return // } } + //generate a loadID + loadID := utils.UUIDSha1Prefix() + loadIDs := make(map[string]string) if verbose { log.Print("Destinations:") } @@ -1421,6 +1424,12 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", d.Id, " : ", d.Prefixes) } } + if len(tpr.destinations) != 0 { + loadIDs[utils.CacheDestinations] = loadID + } + if len(tpr.revDests) != 0 { + loadIDs[utils.CacheReverseDestinations] = loadID + } if verbose { log.Print("Reverse Destinations:") for id, vals := range tpr.revDests { @@ -1437,6 +1446,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", rp.Id) } } + if len(tpr.ratingPlans) != 0 { + loadIDs[utils.CacheRatingPlans] = loadID + } if verbose { log.Print("Rating Profiles:") } @@ -1449,6 +1461,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", rp.Id) } } + if len(tpr.ratingProfiles) != 0 { + loadIDs[utils.CacheRatingProfiles] = loadID + } if verbose { log.Print("Action Plans:") } @@ -1490,6 +1505,12 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Println("\t", k) } } + if len(tpr.actionPlans) != 0 { + loadIDs[utils.CacheActionPlans] = loadID + } + if len(tpr.acntActionPlans) != 0 { + loadIDs[utils.CacheAccountActionPlans] = loadID + } if verbose { log.Print("Account Action Plans:") for id, vals := range tpr.acntActionPlans { @@ -1508,6 +1529,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Println("\t", k) } } + if len(tpr.actionsTriggers) != 0 { + loadIDs[utils.CacheActionTriggers] = loadID + } if verbose { log.Print("Shared Groups:") } @@ -1520,6 +1544,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Println("\t", k) } } + if len(tpr.sharedGroups) != 0 { + loadIDs[utils.CacheSharedGroups] = loadID + } if verbose { log.Print("Actions:") } @@ -1532,6 +1559,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Println("\t", k) } } + if len(tpr.actions) != 0 { + loadIDs[utils.CacheActions] = loadID + } if verbose { log.Print("Account Actions:") } @@ -1559,6 +1589,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", th.TenantID()) } } + if len(tpr.filters) != 0 { + loadIDs[utils.CacheFilters] = loadID + } if verbose { log.Print("ResourceProfiles:") } @@ -1574,6 +1607,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", rsp.TenantID()) } } + if len(tpr.resProfiles) != 0 { + loadIDs[utils.CacheResourceProfiles] = loadID + } if verbose { log.Print("Resources:") } @@ -1585,6 +1621,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", rTid.TenantID()) } } + if len(tpr.resources) != 0 { + loadIDs[utils.CacheResources] = loadID + } if verbose { log.Print("StatQueueProfiles:") } @@ -1600,6 +1639,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", st.TenantID()) } } + if len(tpr.sqProfiles) != 0 { + loadIDs[utils.CacheStatQueueProfiles] = loadID + } if verbose { log.Print("StatQueues:") } @@ -1622,6 +1664,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", sqTntID.TenantID()) } } + if len(tpr.statQueues) != 0 { + loadIDs[utils.CacheStatQueues] = loadID + } if verbose { log.Print("ThresholdProfiles:") } @@ -1637,6 +1682,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", th.TenantID()) } } + if len(tpr.thProfiles) != 0 { + loadIDs[utils.CacheThresholdProfiles] = loadID + } if verbose { log.Print("Thresholds:") } @@ -1648,7 +1696,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", thd.TenantID()) } } - + if len(tpr.thresholds) != 0 { + loadIDs[utils.CacheThresholds] = loadID + } if verbose { log.Print("SupplierProfiles:") } @@ -1664,7 +1714,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", th.TenantID()) } } - + if len(tpr.sppProfiles) != 0 { + loadIDs[utils.CacheSupplierProfiles] = loadID + } if verbose { log.Print("AttributeProfiles:") } @@ -1680,7 +1732,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", th.TenantID()) } } - + if len(tpr.attributeProfiles) != 0 { + loadIDs[utils.CacheAttributeProfiles] = loadID + } if verbose { log.Print("ChargerProfiles:") } @@ -1697,7 +1751,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", th.TenantID()) } } - + if len(tpr.chargerProfiles) != 0 { + loadIDs[utils.CacheChargerProfiles] = loadID + } if verbose { log.Print("DispatcherProfiles:") } @@ -1713,7 +1769,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", th.TenantID()) } } - + if len(tpr.dispatcherProfiles) != 0 { + loadIDs[utils.CacheDispatcherProfiles] = loadID + } if verbose { log.Print("DispatcherHosts:") } @@ -1738,6 +1796,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("\t", t.ID) } } + if len(tpr.timings) != 0 { + loadIDs[utils.CacheTimings] = loadID + } if !disable_reverse { if len(tpr.destinations) > 0 { if verbose { @@ -1756,6 +1817,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err } } } + if err = tpr.dm.SetLoadIDs(loadIDs); err != nil { + return err + } return } @@ -2377,6 +2441,16 @@ func (tpr *TpReader) ReloadCache(flush, verbose bool) (err error) { } } + //get loadIDs for all types + loadIDs, err := tpr.dm.GetItemLoadIDs(utils.EmptyString, false) + if err != nil { + return err + } + cacheLoadIDs := populateCacheLoadIDs(loadIDs, cacheArgs) + for key, val := range cacheLoadIDs { + Cache.Set(utils.CacheLoadIDs, key, val, nil, + cacheCommit(utils.NonTransactional), utils.NonTransactional) + } // release the reader with it's structures tpr.Init() return diff --git a/utils/consts.go b/utils/consts.go index 3f4919a40..fb6076f1c 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -80,6 +80,7 @@ var ( CacheAttributeFilterIndexes: AttributeFilterIndexes, CacheChargerFilterIndexes: ChargerFilterIndexes, CacheDispatcherFilterIndexes: DispatcherFilterIndexes, + CacheLoadIDs: LoadIDPrefix, } CachePrefixToInstance map[string]string // will be built on init PrefixToIndexCache = map[string]string{ @@ -254,6 +255,7 @@ const ( DispatcherHostPrefix = "dph_" ThresholdProfilePrefix = "thp_" StatQueuePrefix = "stq_" + LoadIDPrefix = "lid_" LOADINST_KEY = "load_history" SESSION_MANAGER_SOURCE = "SMR" MEDIATOR_SOURCE = "MED"