From 4645a3b464b1312691be9ebe6345386278cf40fd Mon Sep 17 00:00:00 2001 From: edwardro22 Date: Sun, 21 Jan 2018 20:16:44 +0200 Subject: [PATCH] Renamed filters prefixes --- engine/attributes.go | 4 ++-- engine/filterindexer.go | 40 ++++++++++++++++++++-------------------- engine/resources.go | 4 ++-- engine/stats.go | 4 ++-- engine/suppliers.go | 4 ++-- engine/thresholds.go | 4 ++-- utils/consts.go | 40 ++++++++++++++++++++-------------------- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/engine/attributes.go b/engine/attributes.go index 4950a8471..4db7e67d9 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -62,11 +62,11 @@ func (alS *AttributeService) matchingAttributeProfilesForEvent(ev *utils.CGREven attrIdxKey = utils.ConcatenatedKey(ev.Tenant, contextVal) matchingAPs := make(map[string]*AttributeProfile) aPrflIDs, err := matchingItemIDsForEvent(ev.Event, alS.indexedFields, - alS.dm, utils.AttributeProfilesStringIndex+attrIdxKey, MetaString) + alS.dm, utils.AttributeFilterIndexes+attrIdxKey, MetaString) if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(aPrflIDs.Slice(), utils.AttributeProfilesStringIndex) + lockIDs := utils.PrefixSliceItems(aPrflIDs.Slice(), utils.AttributeFilterIndexes) guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) defer guardian.Guardian.UnguardIDs(lockIDs...) for apID := range aPrflIDs { diff --git a/engine/filterindexer.go b/engine/filterindexer.go index b70bd4158..966ca02ee 100644 --- a/engine/filterindexer.go +++ b/engine/filterindexer.go @@ -104,24 +104,24 @@ func (rfi *ReqFilterIndexer) IndexTPFilter(tpFltr *utils.TPFilterProfile, itemID func (rfi *ReqFilterIndexer) cacheRemItemType() { switch rfi.itemType { case utils.ThresholdProfilePrefix: - cache.RemPrefixKey(utils.ThresholdStringIndex, true, utils.NonTransactional) - cache.RemPrefixKey(utils.ThresholdStringRevIndex, true, utils.NonTransactional) + cache.RemPrefixKey(utils.ThresholdFilterIndexes, true, utils.NonTransactional) + cache.RemPrefixKey(utils.ThresholdFilterRevIndexes, true, utils.NonTransactional) case utils.ResourceProfilesPrefix: - cache.RemPrefixKey(utils.ResourceProfilesStringIndex, true, utils.NonTransactional) - cache.RemPrefixKey(utils.ResourceProfilesStringRevIndex, true, utils.NonTransactional) + cache.RemPrefixKey(utils.ResourceFilterIndexes, true, utils.NonTransactional) + cache.RemPrefixKey(utils.ResourceFilterRevIndexes, true, utils.NonTransactional) case utils.StatQueueProfilePrefix: - cache.RemPrefixKey(utils.StatQueuesStringIndex, true, utils.NonTransactional) - cache.RemPrefixKey(utils.StatQueuesStringRevIndex, true, utils.NonTransactional) + cache.RemPrefixKey(utils.StatFilterIndexes, true, utils.NonTransactional) + cache.RemPrefixKey(utils.StatFilterRevIndexes, true, utils.NonTransactional) case utils.SupplierProfilePrefix: - cache.RemPrefixKey(utils.SupplierProfilesStringIndex, true, utils.NonTransactional) - cache.RemPrefixKey(utils.SupplierProfilesStringRevIndex, true, utils.NonTransactional) + cache.RemPrefixKey(utils.SupplierFilterIndexes, true, utils.NonTransactional) + cache.RemPrefixKey(utils.SupplierFilterRevIndexes, true, utils.NonTransactional) case utils.AttributeProfilePrefix: - cache.RemPrefixKey(utils.AttributeProfilesStringIndex, true, utils.NonTransactional) - cache.RemPrefixKey(utils.AttributeProfilesStringRevIndex, true, utils.NonTransactional) + cache.RemPrefixKey(utils.AttributeFilterIndexes, true, utils.NonTransactional) + cache.RemPrefixKey(utils.AttributeFilterRevIndexes, true, utils.NonTransactional) } } @@ -215,20 +215,20 @@ func GetDBIndexKey(itemType, dbKeySuffix string, reverse bool) (dbKey string) { var idxPrefix, rIdxPrefix string switch itemType { case utils.ThresholdProfilePrefix: - idxPrefix = utils.ThresholdStringIndex - rIdxPrefix = utils.ThresholdStringRevIndex + idxPrefix = utils.ThresholdFilterIndexes + rIdxPrefix = utils.ThresholdFilterRevIndexes case utils.ResourceProfilesPrefix: - idxPrefix = utils.ResourceProfilesStringIndex - rIdxPrefix = utils.ResourceProfilesStringRevIndex + idxPrefix = utils.ResourceFilterIndexes + rIdxPrefix = utils.ResourceFilterRevIndexes case utils.StatQueueProfilePrefix: - idxPrefix = utils.StatQueuesStringIndex - rIdxPrefix = utils.StatQueuesStringRevIndex + idxPrefix = utils.StatFilterIndexes + rIdxPrefix = utils.StatFilterRevIndexes case utils.SupplierProfilePrefix: - idxPrefix = utils.SupplierProfilesStringIndex - rIdxPrefix = utils.SupplierProfilesStringRevIndex + idxPrefix = utils.SupplierFilterIndexes + rIdxPrefix = utils.SupplierFilterRevIndexes case utils.AttributeProfilePrefix: - idxPrefix = utils.AttributeProfilesStringIndex - rIdxPrefix = utils.AttributeProfilesStringRevIndex + idxPrefix = utils.AttributeFilterIndexes + rIdxPrefix = utils.AttributeFilterRevIndexes } if reverse { return rIdxPrefix + dbKeySuffix diff --git a/engine/resources.go b/engine/resources.go index e8f49e256..b763ad004 100755 --- a/engine/resources.go +++ b/engine/resources.go @@ -434,11 +434,11 @@ func (rS *ResourceService) cachedResourcesForEvent(evUUID string) (rs Resources) // matchingResourcesForEvent returns ordered list of matching resources which are active by the time of the call func (rS *ResourceService) matchingResourcesForEvent(tenant string, ev map[string]interface{}) (rs Resources, err error) { matchingResources := make(map[string]*Resource) - rIDs, err := matchingItemIDsForEvent(ev, rS.indexedFields, rS.dm, utils.ResourceProfilesStringIndex+tenant, MetaString) + rIDs, err := matchingItemIDsForEvent(ev, rS.indexedFields, rS.dm, utils.ResourceFilterIndexes+tenant, MetaString) if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(rIDs.Slice(), utils.ResourceProfilesStringIndex) + lockIDs := utils.PrefixSliceItems(rIDs.Slice(), utils.ResourceFilterIndexes) guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) defer guardian.Guardian.UnguardIDs(lockIDs...) for resName := range rIDs { diff --git a/engine/stats.go b/engine/stats.go index 3461ddaed..9c13768bd 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -141,11 +141,11 @@ func (sS *StatService) StoreStatQueue(sq *StatQueue) (err error) { // matchingStatQueuesForEvent returns ordered list of matching resources which are active by the time of the call func (sS *StatService) matchingStatQueuesForEvent(ev *utils.CGREvent) (sqs StatQueues, err error) { matchingSQs := make(map[string]*StatQueue) - sqIDs, err := matchingItemIDsForEvent(ev.Event, sS.indexedFields, sS.dm, utils.StatQueuesStringIndex+ev.Tenant, MetaString) + sqIDs, err := matchingItemIDsForEvent(ev.Event, sS.indexedFields, sS.dm, utils.StatFilterIndexes+ev.Tenant, MetaString) if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(sqIDs.Slice(), utils.StatQueuesStringIndex) + lockIDs := utils.PrefixSliceItems(sqIDs.Slice(), utils.StatFilterIndexes) guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) defer guardian.Guardian.UnguardIDs(lockIDs...) for sqID := range sqIDs { diff --git a/engine/suppliers.go b/engine/suppliers.go index d4f27eb85..010d4dcec 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -115,11 +115,11 @@ func (spS *SupplierService) Shutdown() error { func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent) (sPrfls SupplierProfiles, err error) { matchingLPs := make(map[string]*SupplierProfile) sPrflIDs, err := matchingItemIDsForEvent(ev.Event, spS.indexedFields, - spS.dm, utils.SupplierProfilesStringIndex+ev.Tenant, MetaString) + spS.dm, utils.SupplierFilterIndexes+ev.Tenant, MetaString) if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(sPrflIDs.Slice(), utils.SupplierProfilesStringIndex) + lockIDs := utils.PrefixSliceItems(sPrflIDs.Slice(), utils.SupplierFilterIndexes) guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) defer guardian.Guardian.UnguardIDs(lockIDs...) for lpID := range sPrflIDs { diff --git a/engine/thresholds.go b/engine/thresholds.go index a8895bef0..df9b4cdbf 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -219,13 +219,13 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) ( if len(args.ThresholdIDs) != 0 { tIDs = args.ThresholdIDs } else { - tIDsMap, err := matchingItemIDsForEvent(args.Event, tS.indexedFields, tS.dm, utils.ThresholdStringIndex+args.Tenant, MetaString) + tIDsMap, err := matchingItemIDsForEvent(args.Event, tS.indexedFields, tS.dm, utils.ThresholdFilterIndexes+args.Tenant, MetaString) if err != nil { return nil, err } tIDs = tIDsMap.Slice() } - lockIDs := utils.PrefixSliceItems(tIDs, utils.ThresholdStringIndex) + lockIDs := utils.PrefixSliceItems(tIDs, utils.ThresholdFilterIndexes) guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) defer guardian.Guardian.UnguardIDs(lockIDs...) for _, tID := range tIDs { diff --git a/utils/consts.go b/utils/consts.go index 87c2d8be1..634426f96 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -66,16 +66,16 @@ var ( CacheFilters: FilterPrefix, CacheSupplierProfiles: SupplierProfilePrefix, CacheAttributeProfiles: AttributeProfilePrefix, - CacheResourceFilterIndexes: ResourceProfilesStringIndex, - CacheResourceFilterRevIndexes: ResourceProfilesStringRevIndex, - CacheStatFilterIndexes: StatQueuesStringIndex, - CacheStatFilterRevIndexes: StatQueuesStringRevIndex, - CacheThresholdFilterIndexes: ThresholdStringIndex, - CacheThresholdFilterRevIndexes: ThresholdStringRevIndex, - CacheSupplierFilterIndexes: SupplierProfilesStringIndex, - CacheSupplierFilterRevIndexes: SupplierProfilesStringRevIndex, - CacheAttributeFilterIndexes: AttributeProfilesStringIndex, - CacheAttributeFilterRevIndexes: AttributeProfilesStringRevIndex, + CacheResourceFilterIndexes: ResourceFilterIndexes, + CacheResourceFilterRevIndexes: ResourceFilterRevIndexes, + CacheStatFilterIndexes: StatFilterIndexes, + CacheStatFilterRevIndexes: StatFilterRevIndexes, + CacheThresholdFilterIndexes: ThresholdFilterIndexes, + CacheThresholdFilterRevIndexes: ThresholdFilterRevIndexes, + CacheSupplierFilterIndexes: SupplierFilterIndexes, + CacheSupplierFilterRevIndexes: SupplierFilterRevIndexes, + CacheAttributeFilterIndexes: AttributeFilterIndexes, + CacheAttributeFilterRevIndexes: AttributeFilterRevIndexes, } CachePrefixToInstance map[string]string // will be built on init ) @@ -703,16 +703,16 @@ const ( //Prefix for indexing const ( - ResourceProfilesStringIndex = "rsi_" - ResourceProfilesStringRevIndex = "rsr_" - StatQueuesStringIndex = "ssi_" - StatQueuesStringRevIndex = "ssr_" - ThresholdStringIndex = "tsi_" - ThresholdStringRevIndex = "tsr_" - SupplierProfilesStringIndex = "spi_" - SupplierProfilesStringRevIndex = "spr_" - AttributeProfilesStringIndex = "ali_" - AttributeProfilesStringRevIndex = "alr_" + ResourceFilterIndexes = "rfi_" + ResourceFilterRevIndexes = "rfr_" + StatFilterIndexes = "sfi_" + StatFilterRevIndexes = "sfr_" + ThresholdFilterIndexes = "tfi_" + ThresholdFilterRevIndexes = "tfr_" + SupplierFilterIndexes = "sfi_" + SupplierFilterRevIndexes = "sfr_" + AttributeFilterIndexes = "afi_" + AttributeFilterRevIndexes = "afr_" ) func buildCacheInstRevPrefixes() {