From eb9e2829697faa4586e4394282c03036dbb4d9a6 Mon Sep 17 00:00:00 2001 From: edwardro22 Date: Thu, 7 Sep 2017 16:19:54 +0000 Subject: [PATCH] Small fix --- cmd/cgr-migrator/cgr-migrator.go | 2 +- migrator/action.go | 2 - migrator/action_plan.go | 4 - migrator/action_trigger.go | 1 - migrator/v1Migrator_Utils.go | 22 +----- migrator/v1MongoStor.go | 25 ------- migrator/v1SqlStor.go | 123 ------------------------------- migrator/v1StorDB.go | 22 ------ utils/errors.go | 2 +- 9 files changed, 3 insertions(+), 200 deletions(-) delete mode 100644 migrator/v1MongoStor.go delete mode 100644 migrator/v1SqlStor.go delete mode 100644 migrator/v1StorDB.go diff --git a/cmd/cgr-migrator/cgr-migrator.go b/cmd/cgr-migrator/cgr-migrator.go index 2e056091e..93277d302 100755 --- a/cmd/cgr-migrator/cgr-migrator.go +++ b/cmd/cgr-migrator/cgr-migrator.go @@ -70,7 +70,7 @@ var ( dbDataEncoding = flag.String("dbdata_encoding", config.CgrConfig().DBDataEncoding, "The encoding used to store object data in strings") oldDBDataEncoding = flag.String("old_dbdata_encoding", "", "The encoding used to store object data in strings") - //nu salvez doar citesc din oldDb + //TO DO: //dryRun = flag.Bool("dry_run", false, "When true will not save loaded data to dataDb but just parse it for consistency and errors.") //verbose = flag.Bool("verbose", false, "Enable detailed verbose logging output") //slice mapstring int cate acc [0]am citit si [1]cate acc am scris diff --git a/migrator/action.go b/migrator/action.go index 44e93bd60..f594ede86 100644 --- a/migrator/action.go +++ b/migrator/action.go @@ -19,11 +19,9 @@ package migrator import ( "fmt" - // /"log" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" - //"gopkg.in/mgo.v2/bson" ) type v1Action struct { diff --git a/migrator/action_plan.go b/migrator/action_plan.go index 2ee1385c4..b1700a7ae 100644 --- a/migrator/action_plan.go +++ b/migrator/action_plan.go @@ -26,10 +26,6 @@ import ( "github.com/cgrates/cgrates/utils" ) -// const ( -// v1AccountDBPrefix = "ubl_" -// ) - type v1ActionPlan struct { Uuid string // uniquely identify the timing Id string // informative purpose only diff --git a/migrator/action_trigger.go b/migrator/action_trigger.go index 8d8df88b1..f347f835a 100644 --- a/migrator/action_trigger.go +++ b/migrator/action_trigger.go @@ -12,7 +12,6 @@ import ( type v1ActionTrigger struct { Id string // for visual identification ThresholdType string //*min_counter, *max_counter, *min_balance, *max_balance - // stats: *min_asr, *max_asr, *min_acd, *max_acd, *min_tcd, *max_tcd, *min_acc, *max_acc, *min_tcc, *max_tcc ThresholdValue float64 Recurrent bool // reset eexcuted flag each run MinSleep time.Duration // Minimum duration between two executions in case of recurrent triggers diff --git a/migrator/v1Migrator_Utils.go b/migrator/v1Migrator_Utils.go index f46bc71a0..6db21bdc8 100644 --- a/migrator/v1Migrator_Utils.go +++ b/migrator/v1Migrator_Utils.go @@ -50,24 +50,4 @@ func ConfigureV1DataStorage(db_type, host, port, name, user, pass, marshaler str return nil, err } return d, nil -} - -// func ConfigureV1Storage(db_type, host, port, name, user, pass, marshaler string) (db v1StorDB, err error) { -// func ConfigureStorStorage(db_type, host, port, name, user, pass, marshaler string, maxConn, maxIdleConn, connMaxLifetime int, cdrsIndexes []string) (db Storage, err error) { -// var d Storage -// switch db_type { -// case utils.MONGO: -// d, err = newv1MongoStorage(host, port, name, user, pass, utils.StorDB, cdrsIndexes, nil, 1) -// case utils.POSTGRES: -// d, err = NewPostgresStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime) -// case utils.MYSQL: -// d, err = NewMySQLStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime) -// default: -// err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s]", -// db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES)) -// } -// if err != nil { -// return nil, err -// } -// return d, nil -// } +} \ No newline at end of file diff --git a/migrator/v1MongoStor.go b/migrator/v1MongoStor.go deleted file mode 100644 index eadea7570..000000000 --- a/migrator/v1MongoStor.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments -Copyright (C) ITsysCOM GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see -*/ -package migrator - -// import ( -// "github.com/cgrates/cgrates/utils" -// ) -// getV1CallCost() (v1CC *v1CallCost, err error){ -// return utils.ErrNotImplemented -// } diff --git a/migrator/v1SqlStor.go b/migrator/v1SqlStor.go deleted file mode 100644 index 6642cf1a2..000000000 --- a/migrator/v1SqlStor.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments -Copyright (C) ITsysCOM GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see -*/ -package migrator - -// import ( -// "fmt" -// "time" - -// _ "github.com/go-sql-driver/mysql" -// "github.com/cgrates/cgrates/utils" -// "github.com/jinzhu/gorm" -// _ "github.com/lib/pq" -// ) - -// type v1SQLStorage struct { -// Db *sql.DB -// db *gorm.DB -// Storsql -// } - -// func NewPostgresStorage(host, port, name, user, password string, maxConn, maxIdleConn, connMaxLifetime int) (*v1SQLStorage, error) { -// connectString := fmt.Sprintf("host=%s port=%s dbname=%s user=%s password=%s sslmode=disable", host, port, name, user, password) -// db, err := gorm.Open("postgres", connectString) -// if err != nil { -// return nil, err -// } -// err = db.DB().Ping() -// if err != nil { -// return nil, err -// } -// db.DB().SetMaxIdleConns(maxIdleConn) -// db.DB().SetMaxOpenConns(maxConn) -// db.DB().SetConnMaxLifetime(time.Duration(connMaxLifetime) * time.Second) -// //db.LogMode(true) -// postgressStorage := new(PostgresStorage) -// postgressStorage.db = db -// postgressStorage.Db = db.DB() -// return &SQLStorage{db.DB(), db, postgressStorage, postgressStorage}, nil -// } - -// func NewMySQLStorage(host, port, name, user, password string, maxConn, maxIdleConn, connMaxLifetime int) (*v1SQLStorage, error) { -// connectString := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&loc=Local&parseTime=true", user, password, host, port, name) -// db, err := gorm.Open("mysql", connectString) -// if err != nil { -// return nil, err -// } -// if err = db.DB().Ping(); err != nil { -// return nil, err -// } -// db.DB().SetMaxIdleConns(maxIdleConn) -// db.DB().SetMaxOpenConns(maxConn) -// db.DB().SetConnMaxLifetime(time.Duration(connMaxLifetime) * time.Second) -// //db.LogMode(true) -// mySQLStorage := new(MySQLStorage) -// mySQLStorage.db = db -// mySQLStorage.Db = db.DB() -// return &SQLStorage{db.DB(), db, mySQLStorage, mySQLStorage}, nil -// } - -// getV1CallCost() (v1CC *v1CallCost, err error){ -// //echivalentu la ce am facut la mongo doar ca cu rows - -// var storSQL *sql.DB -// switch m.storDBType { -// case utils.MYSQL: -// storSQL = m.storDB.(*engine.SQLStorage).Db -// case utils.POSTGRES: -// storSQL = m.storDB.(*engine.PostgresStorage).Db -// default: -// return utils.NewCGRError(utils.Migrator, -// utils.MandatoryIEMissingCaps, -// utils.UnsupportedDB, -// fmt.Sprintf("unsupported database type: <%s>", m.storDBType)) -// } -// rows, err := storSQL.Query("SELECT id, tor, direction, tenant, category, account, subject, destination, cost, cost_details FROM cdrs") -// if err != nil { -// return utils.NewCGRError(utils.Migrator, -// utils.ServerErrorCaps, -// err.Error(), -// fmt.Sprintf("error: <%s> when querying storDB for cdrs", err.Error())) -// } - -// defer rows.Close() - -// for cnt := 0; rows.Next(); cnt++ { -// var id int64 -// var ccDirection, ccCategory, ccTenant, ccSubject, ccAccount, ccDestination, ccTor sql.NullString -// var ccCost sql.NullFloat64 -// var tts []byte - -// if err := rows.Scan(&id, &ccTor, &ccDirection, &ccTenant, &ccCategory, &ccAccount, &ccSubject, &ccDestination, &ccCost, &tts); err != nil { -// return utils.NewCGRError(utils.Migrator, -// utils.ServerErrorCaps, -// err.Error(), -// fmt.Sprintf("error: <%s> when scanning at count: <%d>", err.Error(), cnt)) -// } -// var v1tmsps v1TimeSpans -// if err := json.Unmarshal(tts, &v1tmsps); err != nil { -// utils.Logger.Warning( -// fmt.Sprintf(" Unmarshalling timespans at CDR with id: <%d>, error: <%s>", id, err.Error())) -// continue -// } -// return v1CC := &v1CallCost{Direction: ccDirection.String, Category: ccCategory.String, Tenant: ccTenant.String, -// Subject: ccSubject.String, Account: ccAccount.String, Destination: ccDestination.String, TOR: ccTor.String, -// Cost: ccCost.Float64, Timespans: v1tmsps} - -// } -// } diff --git a/migrator/v1StorDB.go b/migrator/v1StorDB.go deleted file mode 100644 index c83369852..000000000 --- a/migrator/v1StorDB.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments -Copyright (C) ITsysCOM GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see -*/ -package migrator - -// type v1StorDB interface { -// getV1CallCost() (v1CC *v1CallCost, err error) -// } diff --git a/utils/errors.go b/utils/errors.go index 42cf41039..a6d4b867f 100644 --- a/utils/errors.go +++ b/utils/errors.go @@ -23,7 +23,7 @@ import ( ) var ( - ErrNoMoreData = errors.New("NO_MORE_DATA") + ErrNoMoreData = errors.New("no more data") ErrNotImplemented = errors.New("NOT_IMPLEMENTED") ErrNotFound = errors.New("NOT_FOUND") ErrTimedOut = errors.New("TIMED_OUT")