mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 00:28:44 +05:00
Fixed index health code
This commit is contained in:
committed by
Dan Christian Bogos
parent
bc02ec03f3
commit
4cd784ca05
@@ -740,7 +740,7 @@ func (dm *DataManager) GetThresholdProfile(tenant, id string, cacheRead, cacheWr
|
||||
}
|
||||
if err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
if err == utils.ErrNotFound && cacheWrite {
|
||||
if err == utils.ErrNotFound && cacheWrite && dm.dataDB.GetStorageType() != utils.INTERNAL {
|
||||
Cache.Set(utils.CacheThresholdProfiles, tntID, nil, nil,
|
||||
cacheCommit(transactionID), transactionID)
|
||||
|
||||
@@ -2105,7 +2105,7 @@ func (dm *DataManager) GetChargerProfile(tenant, id string, cacheRead, cacheWrit
|
||||
}
|
||||
if err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
if err == utils.ErrNotFound && cacheWrite {
|
||||
if err == utils.ErrNotFound && cacheWrite && dm.dataDB.GetStorageType() != utils.INTERNAL{
|
||||
Cache.Set(utils.CacheChargerProfiles, tntID, nil, nil,
|
||||
cacheCommit(transactionID), transactionID)
|
||||
|
||||
|
||||
@@ -447,10 +447,11 @@ func getFilterAsIndexSet(dm *DataManager, fltrIdxCache *ltcache.Cache, idxItmTyp
|
||||
}
|
||||
|
||||
// updateFilterIHMisingIndx updates the reply with the missing indexes for a specific object( obj->filter->index relation)
|
||||
func updateFilterIHMisingIndx(dm *DataManager, fltrCache, fltrIdxCache *ltcache.Cache, filterIDs []string, indxType, tnt, tntCtx, itmID string, rply *FilterIHReply) (_ *FilterIHReply, err error) {
|
||||
func updateFilterIHMisingIndx(dm *DataManager, fltrCache, fltrIdxCache *ltcache.Cache, filterIDs []string,
|
||||
indxType, tnt, tntCtx, itmID string, missingFltrs utils.StringSet, rply *FilterIHReply) (_ *FilterIHReply, err error) {
|
||||
if len(filterIDs) == 0 { // no filter so check the *none:*any:*any index
|
||||
var rcvIndx utils.StringMap
|
||||
if rcvIndx, err = getIHFltrIdxFromCache(dm, nil, indxType, tntCtx, utils.META_NONE, utils.META_ANY, utils.META_ANY); err != nil {
|
||||
if rcvIndx, err = getIHFltrIdxFromCache(dm, fltrIdxCache, indxType, tntCtx, utils.META_NONE, utils.META_ANY, utils.META_ANY); err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
return
|
||||
}
|
||||
@@ -469,8 +470,10 @@ func updateFilterIHMisingIndx(dm *DataManager, fltrCache, fltrIdxCache *ltcache.
|
||||
if err != utils.ErrNotFound {
|
||||
return
|
||||
}
|
||||
fltrID = utils.ConcatenatedKey(tnt, fltrID)
|
||||
rply.MissingFilters[fltrID] = append(rply.MissingFilters[fltrID], itmID)
|
||||
if tntIdxFltr := utils.ConcatenatedKey(fltrID, itmID); !missingFltrs.Has(tntIdxFltr) { // tntIdxFltr = tnt:idx:id verification to not set the same ID
|
||||
missingFltrs.Add(tntIdxFltr)
|
||||
rply.MissingFilters[fltrID] = append(rply.MissingFilters[fltrID], itmID)
|
||||
}
|
||||
continue
|
||||
}
|
||||
var indexes map[string]utils.StringMap
|
||||
@@ -500,6 +503,7 @@ func GetFltrIdxHealth(dm *DataManager, fltrCache, fltrIdxCache, objCache *ltcach
|
||||
if ids, err = dm.dataDB.GetKeysForPrefix(objPrfx); err != nil {
|
||||
return
|
||||
}
|
||||
missingFltrs := utils.StringSet{} // for checking multiple filters that are missing(to not append the same ID in case)
|
||||
for _, id := range ids { // get all the objects from DB
|
||||
id = strings.TrimPrefix(id, objPrfx)
|
||||
tntID := utils.NewTenantID(id)
|
||||
@@ -509,12 +513,14 @@ func GetFltrIdxHealth(dm *DataManager, fltrCache, fltrIdxCache, objCache *ltcach
|
||||
}
|
||||
|
||||
if obj.contexts == nil { // update the reply
|
||||
if rply, err = updateFilterIHMisingIndx(dm, fltrCache, fltrIdxCache, obj.filterIDs, indxType, tntID.Tenant, tntID.Tenant, tntID.ID, rply); err != nil {
|
||||
if rply, err = updateFilterIHMisingIndx(dm, fltrCache, fltrIdxCache, obj.filterIDs, indxType,
|
||||
tntID.Tenant, tntID.Tenant, tntID.ID, missingFltrs, rply); err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
for _, ctx := range *obj.contexts {
|
||||
if rply, err = updateFilterIHMisingIndx(dm, fltrCache, fltrIdxCache, obj.filterIDs, indxType, tntID.Tenant, utils.ConcatenatedKey(tntID.Tenant, ctx), tntID.ID, rply); err != nil {
|
||||
if rply, err = updateFilterIHMisingIndx(dm, fltrCache, fltrIdxCache, obj.filterIDs, indxType,
|
||||
tntID.Tenant, utils.ConcatenatedKey(tntID.Tenant, ctx), tntID.ID, missingFltrs, rply); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -527,6 +533,7 @@ func GetFltrIdxHealth(dm *DataManager, fltrCache, fltrIdxCache, objCache *ltcach
|
||||
if indexKeys, err = dm.dataDB.GetKeysForPrefix(idxPrfx); err != nil {
|
||||
return
|
||||
}
|
||||
missingObj := utils.StringSet{}
|
||||
for _, dataID := range indexKeys { // get all the indexes
|
||||
dataID = strings.TrimPrefix(dataID, idxPrfx)
|
||||
|
||||
@@ -559,11 +566,12 @@ func GetFltrIdxHealth(dm *DataManager, fltrCache, fltrIdxCache, objCache *ltcach
|
||||
if err != utils.ErrNotFound {
|
||||
return
|
||||
}
|
||||
rply.MissingObjects = append(rply.MissingObjects, utils.ConcatenatedKey(tnt, itmID))
|
||||
missingObj.Add(utils.ConcatenatedKey(tnt, itmID))
|
||||
//rply.MissingObjects = append(rply.MissingObjects, utils.ConcatenatedKey(tnt, itmID))
|
||||
err = nil
|
||||
continue
|
||||
}
|
||||
if ctx != nil ||
|
||||
if ctx != nil &&
|
||||
(obj.contexts == nil || !utils.IsSliceMember(*obj.contexts, *ctx)) { // check the contexts if present
|
||||
key := utils.ConcatenatedKey(tntCtx, idxKey)
|
||||
rply.MissingIndexes[key] = append(rply.MissingIndexes[key], itmID)
|
||||
@@ -600,6 +608,6 @@ func GetFltrIdxHealth(dm *DataManager, fltrCache, fltrIdxCache, objCache *ltcach
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rply.MissingObjects = missingObj.AsSlice()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user