Renamed filters prefixes

This commit is contained in:
edwardro22
2018-01-21 20:16:44 +02:00
committed by Dan Christian Bogos
parent 43bd9bbbf5
commit 4645a3b464
7 changed files with 50 additions and 50 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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() {