diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index f3bc4ff42..02948476b 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -77,7 +77,7 @@ func (apierV1 *ApierV1) SetThresholdProfile(thp *engine.ThresholdProfile, reply if missing := utils.MissingStructFields(thp, []string{"Tenant", "ID"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } - if err := apierV1.DataManager.DataDB().SetThresholdProfile(thp); err != nil { + if err := apierV1.DataManager.SetThresholdProfile(thp); err != nil { return utils.APIErrorHandler(err) } cache.RemKey(utils.ThresholdProfilePrefix+utils.ConcatenatedKey(thp.Tenant, thp.ID), true, "") // ToDo: Remove here with autoreload diff --git a/engine/datamanager.go b/engine/datamanager.go index 4511088b1..27da8697f 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -166,5 +166,8 @@ func (dm *DataManager) GetThresholdProfile(tenant, id string, skipCache bool, tr } cache.Set(key, th, cacheCommit(transactionID), transactionID) return - +} + +func (dm *DataManager) SetThresholdProfile(th *ThresholdProfile) (err error) { + return dm.DataDB().SetThresholdProfileDrv(th) } diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go index 8205fcb12..be22259cb 100644 --- a/engine/onstor_it_test.go +++ b/engine/onstor_it_test.go @@ -2066,7 +2066,7 @@ func testOnStorITCRUDThresholdProfile(t *testing.T) { false, utils.NonTransactional); rcvErr != utils.ErrNotFound { t.Error(rcvErr) } - if err := onStor.DataDB().SetThresholdProfile(th); err != nil { + if err := onStor.SetThresholdProfile(th); err != nil { t.Error(err) } if rcv, err := onStor.GetThresholdProfile(th.Tenant, th.ID, true, utils.NonTransactional); err != nil { diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 99f90bdf5..f8e7ac535 100755 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -121,7 +121,7 @@ type DataDB interface { SetStoredStatQueue(sq *StoredStatQueue) (err error) RemStoredStatQueue(tenant, id string) (err error) GetThresholdProfileDrv(tenant string, ID string) (tp *ThresholdProfile, err error) - SetThresholdProfile(tp *ThresholdProfile) (err error) + SetThresholdProfileDrv(tp *ThresholdProfile) (err error) RemThresholdProfile(tenant, id, transactionID string) (err error) GetThresholdDrv(string, string) (*Threshold, error) SetThresholdDrv(*Threshold) error diff --git a/engine/storage_map.go b/engine/storage_map.go index 80a777965..20ab8b342 100755 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -1591,8 +1591,8 @@ func (ms *MapStorage) GetThresholdProfileDrv(tenant, ID string) (tp *ThresholdPr return } -// SetThresholdProfile stores a ThresholdProfile into DataDB -func (ms *MapStorage) SetThresholdProfile(tp *ThresholdProfile) (err error) { +// SetThresholdProfileDrv stores a ThresholdProfile into DataDB +func (ms *MapStorage) SetThresholdProfileDrv(tp *ThresholdProfile) (err error) { ms.mu.Lock() defer ms.mu.Unlock() result, err := ms.ms.Marshal(tp) diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index c5fa46f12..0a871923f 100755 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -2176,8 +2176,8 @@ func (ms *MongoStorage) GetThresholdProfileDrv(tenant, ID string) (tp *Threshold return } -// SetThresholdProfile stores a ThresholdProfile into DataDB -func (ms *MongoStorage) SetThresholdProfile(tp *ThresholdProfile) (err error) { +// SetThresholdProfileDrv stores a ThresholdProfile into DataDB +func (ms *MongoStorage) SetThresholdProfileDrv(tp *ThresholdProfile) (err error) { session, col := ms.conn(colTps) defer session.Close() _, err = col.UpsertId(bson.M{"tenant": tp.Tenant, "id": tp.ID}, tp) diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 4283f55d4..7ddb6da2b 100755 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -1684,7 +1684,7 @@ func (rs *RedisStorage) RemStoredStatQueue(tenant, id string) (err error) { return } -// GetThresholdProfile retrieves a ThresholdProfile from dataDB +// GetThresholdProfileDrv retrieves a ThresholdProfile from dataDB func (rs *RedisStorage) GetThresholdProfileDrv(tenant, ID string) (tp *ThresholdProfile, err error) { key := utils.ThresholdProfilePrefix + utils.ConcatenatedKey(tenant, ID) var values []byte @@ -1705,8 +1705,8 @@ func (rs *RedisStorage) GetThresholdProfileDrv(tenant, ID string) (tp *Threshold return } -// SetThresholdProfile stores a ThresholdProfile into DataDB -func (rs *RedisStorage) SetThresholdProfile(tp *ThresholdProfile) (err error) { +// SetThresholdProfileDrv stores a ThresholdProfile into DataDB +func (rs *RedisStorage) SetThresholdProfileDrv(tp *ThresholdProfile) (err error) { var result []byte result, err = rs.ms.Marshal(tp) if err != nil { diff --git a/engine/tp_reader.go b/engine/tp_reader.go index cca681fe1..c92837a3b 100755 --- a/engine/tp_reader.go +++ b/engine/tp_reader.go @@ -2086,7 +2086,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err if err != nil { return err } - if err = tpr.dm.DataDB().SetThresholdProfile(th); err != nil { + if err = tpr.dm.SetThresholdProfile(th); err != nil { return err } if verbose {