From 0e97bb501570a2200ac6a3b9a91a9400228abcea Mon Sep 17 00:00:00 2001 From: TeoV Date: Mon, 25 Nov 2019 11:33:39 +0200 Subject: [PATCH] Move TPReader.Init() outside of ReloadCache --- apier/v1/apier.go | 9 ++++++++- apier/v2/apier.go | 2 ++ cmd/cgr-loader/cgr-loader.go | 2 ++ .../samples/remote_replication/internal/cgrates.json | 6 ++++++ .../samples/remote_replication/internal_gob/cgrates.json | 7 +++++++ data/conf/samples/tutmysql/cgrates.json | 2 ++ engine/tpreader.go | 2 -- 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/apier/v1/apier.go b/apier/v1/apier.go index c270ab1a6..8a13e68ed 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -354,6 +354,8 @@ func (apiv1 *ApierV1) LoadTariffPlanFromStorDb(attrs AttrLoadTpFromStorDb, reply return utils.NewErrServerError(err) } } + // release the reader with it's structures + dbReader.Init() *reply = utils.OK return nil } @@ -885,6 +887,8 @@ func (apiv1 *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder, return utils.NewErrServerError(err) } } + // release the reader with it's structures + loader.Init() *reply = utils.OK return nil } @@ -948,6 +952,8 @@ func (apiv1 *ApierV1) RemoveTPFromFolder(attrs utils.AttrLoadTpFromFolder, reply return utils.NewErrServerError(err) } } + // release the reader with it's structures + loader.Init() *reply = utils.OK return nil } @@ -997,7 +1003,8 @@ func (apiv1 *ApierV1) RemoveTPFromStorDB(attrs AttrLoadTpFromStorDb, reply *stri return utils.NewErrServerError(err) } } - + // release the reader with it's structures + dbReader.Init() *reply = utils.OK return nil } diff --git a/apier/v2/apier.go b/apier/v2/apier.go index 9fd3911ee..ae70f5d29 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -150,6 +150,8 @@ func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder, return utils.NewErrServerError(err) } } + // release the reader with it's structures + loader.Init() loadHistList, err := self.DataManager.DataDB().GetLoadHistory(1, true, utils.NonTransactional) if err != nil { return err diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go index ff868064c..aa1137fb3 100755 --- a/cmd/cgr-loader/cgr-loader.go +++ b/cmd/cgr-loader/cgr-loader.go @@ -378,6 +378,8 @@ func main() { log.Fatal("Could not reload scheduler: ", err) } } + // release the reader with it's structures + tpReader.Init() } else { if err := tpReader.RemoveFromDatabase(*verbose, *disableReverse); err != nil { log.Fatal("Could not delete from database: ", err) diff --git a/data/conf/samples/remote_replication/internal/cgrates.json b/data/conf/samples/remote_replication/internal/cgrates.json index 80193f5be..053e43a72 100644 --- a/data/conf/samples/remote_replication/internal/cgrates.json +++ b/data/conf/samples/remote_replication/internal/cgrates.json @@ -81,4 +81,10 @@ }, +"apier": { + "scheduler_conns": [ + {"address": "*internal"}, + ], +}, + } diff --git a/data/conf/samples/remote_replication/internal_gob/cgrates.json b/data/conf/samples/remote_replication/internal_gob/cgrates.json index 8b3bc5da5..83206296d 100644 --- a/data/conf/samples/remote_replication/internal_gob/cgrates.json +++ b/data/conf/samples/remote_replication/internal_gob/cgrates.json @@ -81,4 +81,11 @@ }, +"apier": { + "scheduler_conns": [ + {"address": "*internal"}, + ], +}, + + } diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json index 1b256579f..82db90759 100644 --- a/data/conf/samples/tutmysql/cgrates.json +++ b/data/conf/samples/tutmysql/cgrates.json @@ -154,4 +154,6 @@ {"address": "*internal"}, ], }, + + } diff --git a/engine/tpreader.go b/engine/tpreader.go index 9aed84144..46a6c7626 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -2512,8 +2512,6 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, argDispatcher *ut Cache.Set(utils.CacheLoadIDs, key, val, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) } - // release the reader with it's structures - tpr.Init() return }