mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Allow cache to be created for operational data on internal dataDB
This commit is contained in:
committed by
Dan Christian Bogos
parent
ec145d778e
commit
9b08994b5e
@@ -264,8 +264,7 @@ func (apierSv1 *APIerSv1) LoadDestination(ctx *context.Context, attrs *AttrLoadD
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone, apierSv1.Config.ApierCfg().CachesConns,
|
||||
apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -296,8 +295,7 @@ func (apierSv1 *APIerSv1) LoadRatingPlan(ctx *context.Context, attrs *AttrLoadRa
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -320,8 +318,7 @@ func (apierSv1 *APIerSv1) LoadRatingProfile(ctx *context.Context, attrs *utils.T
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -355,8 +352,7 @@ func (apierSv1 *APIerSv1) LoadSharedGroup(ctx *context.Context, attrs *AttrLoadS
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -382,8 +378,7 @@ func (apierSv1 *APIerSv1) LoadTariffPlanFromStorDb(ctx *context.Context, attrs *
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -970,8 +965,7 @@ func (apierSv1 *APIerSv1) LoadAccountActions(ctx *context.Context, attrs *utils.
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -1014,8 +1008,7 @@ func (apierSv1 *APIerSv1) LoadTariffPlanFromFolder(ctx *context.Context, attrs *
|
||||
// create the TpReader
|
||||
loader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(),
|
||||
csvStorage, "", apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -1091,8 +1084,7 @@ func (apierSv1 *APIerSv1) RemoveTPFromFolder(ctx *context.Context, attrs *utils.
|
||||
// create the TpReader
|
||||
loader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(),
|
||||
csvStorage, "", apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -1150,8 +1142,7 @@ func (apierSv1 *APIerSv1) RemoveTPFromStorDB(ctx *context.Context, attrs *AttrLo
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apierSv1.DataManager.DataDB(), apierSv1.StorDb,
|
||||
attrs.TPid, apierSv1.Config.GeneralCfg().DefaultTimezone,
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns,
|
||||
apierSv1.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apierSv1.Config.ApierCfg().CachesConns, apierSv1.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ func (apiv2 *APIerSv2) LoadRatingProfile(ctx *context.Context, attrs *AttrLoadRa
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apiv2.DataManager.DataDB(), apiv2.StorDb,
|
||||
attrs.TPid, apiv2.Config.GeneralCfg().DefaultTimezone,
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns,
|
||||
apiv2.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -86,8 +85,7 @@ func (apiv2 *APIerSv2) LoadAccountActions(ctx *context.Context, attrs *AttrLoadA
|
||||
}
|
||||
dbReader, err := engine.NewTpReader(apiv2.DataManager.DataDB(), apiv2.StorDb,
|
||||
attrs.TPid, apiv2.Config.GeneralCfg().DefaultTimezone,
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns,
|
||||
apiv2.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -127,8 +125,7 @@ func (apiv2 *APIerSv2) LoadTariffPlanFromFolder(ctx *context.Context, attrs *uti
|
||||
|
||||
loader, err := engine.NewTpReader(apiv2.DataManager.DataDB(),
|
||||
csvStorage, "", apiv2.Config.GeneralCfg().DefaultTimezone,
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns,
|
||||
apiv2.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ func main() {
|
||||
if tpReader, err = engine.NewTpReader(dataDB, loader,
|
||||
ldrCfg.LoaderCgrCfg().TpID, ldrCfg.GeneralCfg().DefaultTimezone,
|
||||
ldrCfg.LoaderCgrCfg().CachesConns,
|
||||
ldrCfg.LoaderCgrCfg().SchedulerConns, false); err != nil {
|
||||
ldrCfg.LoaderCgrCfg().SchedulerConns); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err = tpReader.LoadAll(); err != nil {
|
||||
|
||||
@@ -479,8 +479,8 @@ func (cfg *CGRConfig) loadDataDBCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
// in case of internalDB we need to disable the cache
|
||||
// so we enforce it here
|
||||
if cfg.dataDbCfg.Type == utils.MetaInternal {
|
||||
// overwrite only DataDBPartitions and leave other unmodified ( e.g. *diameter_messages, *closed_sessions, etc... )
|
||||
for key := range utils.DataDBPartitions {
|
||||
// overwrite only StatelessDataDBPartitions and leave other unmodified ( e.g. *diameter_messages, *closed_sessions, etc... )
|
||||
for key := range utils.StatelessDataDBPartitions {
|
||||
if _, has := cfg.cacheCfg.Partitions[key]; has {
|
||||
cfg.cacheCfg.Partitions[key] = &CacheParamCfg{}
|
||||
}
|
||||
|
||||
@@ -1111,8 +1111,8 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
// DataDB sanity checks
|
||||
if cfg.dataDbCfg.Type == utils.MetaInternal {
|
||||
for key, config := range cfg.cacheCfg.Partitions {
|
||||
if utils.DataDBPartitions.Has(key) && config.Limit != 0 {
|
||||
return fmt.Errorf("<%s> %s needs to be 0 when DataBD is *internal, received : %d", utils.CacheS, key, config.Limit)
|
||||
if utils.StatelessDataDBPartitions.Has(key) && config.Limit != 0 {
|
||||
return fmt.Errorf("<%s> %s needs to be 0 when DataBD is *internal and with no persistence, received : %d", utils.CacheS, key, config.Limit)
|
||||
}
|
||||
}
|
||||
if (cfg.dataDbCfg.Opts.InternalDBDumpInterval != 0 ||
|
||||
|
||||
@@ -62,11 +62,10 @@ type TpReader struct {
|
||||
acntActionPlans map[string][]string
|
||||
cacheConns []string
|
||||
schedulerConns []string
|
||||
isInternalDB bool // do not reload cache if we use intarnalDB
|
||||
}
|
||||
|
||||
func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string,
|
||||
cacheConns, schedulerConns []string, isInternalDB bool) (*TpReader, error) {
|
||||
cacheConns, schedulerConns []string) (*TpReader, error) {
|
||||
|
||||
tpr := &TpReader{
|
||||
tpid: tpid,
|
||||
@@ -75,7 +74,6 @@ func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string,
|
||||
lr: lr,
|
||||
cacheConns: cacheConns,
|
||||
schedulerConns: schedulerConns,
|
||||
isInternalDB: isInternalDB,
|
||||
}
|
||||
tpr.Init()
|
||||
//add default timing tag (in case of no timings file)
|
||||
@@ -2389,9 +2387,6 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disableReverse bool) (err error
|
||||
}
|
||||
|
||||
func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]any, tenant string) (err error) {
|
||||
if tpr.isInternalDB {
|
||||
return
|
||||
}
|
||||
if len(tpr.cacheConns) == 0 {
|
||||
log.Print("Disabled automatic reload")
|
||||
return
|
||||
|
||||
@@ -36,6 +36,18 @@ var (
|
||||
CacheCDRIDs, CacheRPCConnections, CacheUCH, CacheSTIR, CacheEventCharges, MetaAPIBan, MetaSentryPeer,
|
||||
CacheRatingProfilesTmp, CacheCapsEvents, CacheReplicationHosts})
|
||||
|
||||
// DataDBPartitions excluding Resources, Thresholds, Trends, Rankings, IPs, Stats
|
||||
StatelessDataDBPartitions = NewStringSet([]string{
|
||||
CacheDestinations, CacheReverseDestinations, CacheRatingPlans,
|
||||
CacheRatingProfiles, CacheDispatcherProfiles, CacheDispatcherHosts,
|
||||
CacheChargerProfiles, CacheActions, CacheActionTriggers, CacheSharedGroups,
|
||||
CacheTimings, CacheFilters, CacheRouteProfiles, CacheAttributeProfiles,
|
||||
CacheRouteFilterIndexes, CacheAttributeFilterIndexes,
|
||||
CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheLoadIDs,
|
||||
CacheReverseFilterIndexes, CacheActionPlans, CacheAccountActionPlans,
|
||||
CacheAccounts, CacheVersions,
|
||||
})
|
||||
|
||||
DataDBPartitions = NewStringSet([]string{
|
||||
CacheDestinations, CacheReverseDestinations, CacheRatingPlans,
|
||||
CacheRatingProfiles, CacheDispatcherProfiles, CacheDispatcherHosts,
|
||||
|
||||
Reference in New Issue
Block a user