mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Updated analyzers
This commit is contained in:
committed by
Dan Christian Bogos
parent
6476c036b1
commit
173392b030
@@ -59,7 +59,7 @@ func (aS *AnalyzerService) SetFilterS(fS *engine.FilterS) {
|
||||
}
|
||||
|
||||
func (aS *AnalyzerService) initDB() (err error) {
|
||||
if aS.cfg.AnalyzerSCfg().DBPath == utils.EmptyString {
|
||||
if aS.cfg.AnalyzerSCfg().IndexType == utils.MetaInternal {
|
||||
aS.db, err = bleve.NewMemOnly(bleve.NewIndexMapping())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ func TestAnalyzersListenAndServe(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(1)
|
||||
time.Sleep(time.Nanosecond)
|
||||
runtime.Gosched()
|
||||
anz.db.Close()
|
||||
}()
|
||||
@@ -445,6 +445,7 @@ func TestAnalyzerSLogTrafficInternalDB(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
|
||||
cfg.AnalyzerSCfg().DBPath = utils.EmptyString
|
||||
cfg.AnalyzerSCfg().IndexType = utils.MetaInternal
|
||||
cfg.AnalyzerSCfg().TTL = 30 * time.Minute
|
||||
anz, err := NewAnalyzerService(cfg)
|
||||
if err != nil {
|
||||
|
||||
@@ -1078,7 +1078,12 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
if !utils.AnzIndexType.Has(cfg.analyzerSCfg.IndexType) {
|
||||
return fmt.Errorf("<%s> unsuported index type: %q", utils.AnalyzerS, cfg.analyzerSCfg.IndexType)
|
||||
}
|
||||
// TTL and CleanupInterval should always be bigger than zero in order to not keep unnecessary logs in index
|
||||
if cfg.analyzerSCfg.IndexType != utils.MetaInternal {
|
||||
if _, err := os.Stat(cfg.analyzerSCfg.DBPath); err != nil && os.IsNotExist(err) {
|
||||
return fmt.Errorf("<%s> nonexistent DB folder: %q", utils.AnalyzerS, cfg.analyzerSCfg.DBPath)
|
||||
}
|
||||
}
|
||||
// TTL and CleanupInterval should always be biger than zero in order to not keep unecesary logs in index
|
||||
if cfg.analyzerSCfg.TTL <= 0 {
|
||||
return fmt.Errorf("<%s> the TTL needs to be bigger than 0", utils.AnalyzerS)
|
||||
}
|
||||
|
||||
@@ -1692,9 +1692,14 @@ func TestConfigSanityAnalyzer(t *testing.T) {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
|
||||
cfg.analyzerSCfg.IndexType = utils.MetaScorch
|
||||
cfg.analyzerSCfg.DBPath = "/inexistent/Path"
|
||||
expected = "<AnalyzerS> nonexistent DB folder: \"/inexistent/Path\""
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.analyzerSCfg.DBPath = "/"
|
||||
|
||||
cfg.analyzerSCfg.IndexType = utils.MetaScorch
|
||||
expected = "<AnalyzerS> the TTL needs to be bigger than 0"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
|
||||
@@ -2604,15 +2604,13 @@ const (
|
||||
ExecCgr = "exec"
|
||||
)
|
||||
|
||||
var (
|
||||
// AnzIndexType are the analyzers possible index types
|
||||
AnzIndexType = StringSet{
|
||||
MetaScorch: {},
|
||||
MetaBoltdb: {},
|
||||
MetaLeveldb: {},
|
||||
MetaMoss: {},
|
||||
}
|
||||
)
|
||||
var AnzIndexType = StringSet{ // AnzIndexType are the analyzers possible index types
|
||||
MetaScorch: {},
|
||||
MetaBoltdb: {},
|
||||
MetaLeveldb: {},
|
||||
MetaMoss: {},
|
||||
MetaInternal: {},
|
||||
}
|
||||
|
||||
// StringTmplType a string set used, by agentRequest and eventRequest to determine if the returned template type is string
|
||||
var StringTmplType = StringSet{
|
||||
|
||||
Reference in New Issue
Block a user