Add LoadID when Set/Remove from APIer

This commit is contained in:
TeoV
2019-03-26 16:56:22 +02:00
committed by Dan Christian Bogos
parent 8e06267ca3
commit dc1876a038
10 changed files with 69 additions and 12 deletions

View File

@@ -70,6 +70,11 @@ func (apierV1 *ApierV1) SetChargerProfile(arg *ChargerWrapper, reply *string) er
if err := apierV1.DataManager.SetChargerProfile(arg.ChargerProfile, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheChargerProfiles: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ChargerProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheChargerProfiles,

View File

@@ -75,6 +75,11 @@ func (apierV1 *ApierV1) SetDispatcherProfile(args *DispatcherWrapper, reply *str
if err := apierV1.DataManager.SetDispatcherProfile(args.DispatcherProfile, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheDispatcherProfiles: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheDispatcherProfiles,
@@ -96,6 +101,11 @@ func (apierV1 *ApierV1) RemoveDispatcherProfile(arg *utils.TenantIDWrapper, repl
arg.ID, utils.NonTransactional, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheFilters: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheDispatcherProfiles,

View File

@@ -36,6 +36,11 @@ func (apierV1 *ApierV1) SetFilter(arg *FilterWrapper, reply *string) error {
if err := apierV1.DataManager.SetFilter(arg.Filter); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheFilters: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Filter
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheFilters,
@@ -93,6 +98,11 @@ func (apierV1 *ApierV1) RemoveFilter(arg utils.TenantIDWrapper, reply *string) e
}
return err
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheFilters: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Filter
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheFilters,

View File

@@ -120,6 +120,12 @@ func (apierV1 *ApierV1) SetResourceProfile(arg *ResourceWrapper, reply *string)
if err := apierV1.DataManager.SetResourceProfile(arg.ResourceProfile, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for thresholdProfile and store it in database
loadID := utils.UUIDSha1Prefix()
loadIDs := map[string]string{utils.CacheResourceProfiles: loadID}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ResourceProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheResourceProfiles,
@@ -134,6 +140,10 @@ func (apierV1 *ApierV1) SetResourceProfile(arg *ResourceWrapper, reply *string)
Usages: make(map[string]*engine.ResourceUsage)}); err != nil {
return utils.APIErrorHandler(err)
}
loadIDs2 := map[string]string{utils.CacheResources: loadID}
if err := apierV1.DataManager.SetLoadIDs(loadIDs2); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Resource
argCache = engine.ArgsGetCacheItem{
CacheID: utils.CacheResources,

View File

@@ -68,6 +68,11 @@ func (apierV1 *ApierV1) SetStatQueueProfile(arg *StatQueueWrapper, reply *string
if err := apierV1.DataManager.SetStatQueueProfile(arg.StatQueueProfile, true); err != nil {
return utils.APIErrorHandler(err)
}
loadID := utils.UUIDSha1Prefix()
loadIDs := map[string]string{utils.CacheStatQueueProfiles: loadID}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for StatQueueProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheStatQueueProfiles,
@@ -88,6 +93,10 @@ func (apierV1 *ApierV1) SetStatQueueProfile(arg *StatQueueWrapper, reply *string
if err := apierV1.DataManager.SetStatQueue(&engine.StatQueue{Tenant: arg.Tenant, ID: arg.ID, SQMetrics: metrics}); err != nil {
return utils.APIErrorHandler(err)
}
loadIDs2 := map[string]string{utils.CacheStatQueues: loadID}
if err := apierV1.DataManager.SetLoadIDs(loadIDs2); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for StatQueues
argCache = engine.ArgsGetCacheItem{
CacheID: utils.CacheStatQueues,

View File

@@ -70,6 +70,11 @@ func (apierV1 *ApierV1) SetSupplierProfile(args *SupplierWrapper, reply *string)
if err := apierV1.DataManager.SetSupplierProfile(args.SupplierProfile, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheSupplierProfiles: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for SupplierProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheSupplierProfiles,
@@ -90,6 +95,11 @@ func (apierV1 *ApierV1) RemoveSupplierProfile(args *utils.TenantIDWrapper, reply
if err := apierV1.DataManager.RemoveSupplierProfile(args.Tenant, args.ID, utils.NonTransactional, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheChargerProfiles: utils.UUIDSha1Prefix()}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for SupplierProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheSupplierProfiles,

View File

@@ -102,6 +102,12 @@ func (apierV1 *ApierV1) SetThresholdProfile(args *ThresholdWrapper, reply *strin
if err := apierV1.DataManager.SetThresholdProfile(args.ThresholdProfile, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for thresholdProfile and store it in database
loadID := utils.UUIDSha1Prefix()
loadIDs := map[string]string{utils.CacheThresholdProfiles: loadID}
if err := apierV1.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ThresholdProfile
argCache := engine.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
@@ -113,6 +119,10 @@ func (apierV1 *ApierV1) SetThresholdProfile(args *ThresholdWrapper, reply *strin
if err := apierV1.DataManager.SetThreshold(&engine.Threshold{Tenant: args.Tenant, ID: args.ID}); err != nil {
return err
}
loadIDs2 := map[string]string{utils.CacheThresholds: loadID}
if err := apierV1.DataManager.SetLoadIDs(loadIDs2); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Threshold
argCache = engine.ArgsGetCacheItem{
CacheID: utils.CacheThresholds,

View File

@@ -41,6 +41,11 @@ func (apierV2 *ApierV2) SetAttributeProfile(extAlsPrfWrp *AttributeWrapper, repl
if err := apierV2.DataManager.SetAttributeProfile(alsPrf, true); err != nil {
return utils.APIErrorHandler(err)
}
//generate a loadID for attributeProfile and store it in database
loadIDs := map[string]string{utils.CacheAttributeProfiles: utils.UUIDSha1Prefix()}
if err := apierV2.DataManager.SetLoadIDs(loadIDs); err != nil {
return utils.APIErrorHandler(err)
}
args := engine.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: alsPrf.TenantID(),

View File

@@ -58,11 +58,5 @@
"enabled": true, // starts User service: <true|false>.
},
"apier": {
"caches_conns":[ // connections to CacheS for reloads
{"address": "127.0.0.1:3012", "transport": "*json"},
],
},
}

View File

@@ -47,10 +47,4 @@
],
},
"apier": {
"caches_conns":[ // connections to CacheS for reloads
{"address": "127.0.0.1:22012", "transport": "*json"},
],
},
}