From 54f4bdee0581a77ad21e5f3b9374db4b67cff7a5 Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 31 Jan 2017 12:48:01 +0100 Subject: [PATCH] Config changes: httpposter_attempts -> poster_attempts, failed_requests_dir -> failed_posts_dir --- apier/v1/apier.go | 4 +-- config/config.go | 12 +++---- config/config_defaults.go | 38 +++++++++++------------ config/config_json_test.go | 4 +-- config/config_test.go | 8 ++--- config/libconfig_json.go | 4 +-- data/conf/cgrates/cgrates.json | 38 +++++++++++------------ engine/action.go | 4 +-- engine/cdrs.go | 2 +- general_tests/cdrs_replication_it_test.go | 6 ++-- packages/jessie/rules | 2 +- packages/redhat_fedora/cgrates.spec | 2 +- packages/squeeze/rules | 2 +- 13 files changed, 63 insertions(+), 63 deletions(-) diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 8b656370c..6f58b9345 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -1677,7 +1677,7 @@ type ArgsReplyFailedPosts struct { } func (v1 *ApierV1) ReplayFailedPosts(args ArgsReplyFailedPosts, reply *string) (err error) { - failedReqsInDir := v1.Config.FailedRequestsDir + failedReqsInDir := v1.Config.FailedPostsDir if args.FailedRequestsInDir != nil && *args.FailedRequestsInDir != "" { failedReqsInDir = *args.FailedRequestsInDir } @@ -1722,7 +1722,7 @@ func (v1 *ApierV1) ReplayFailedPosts(args ArgsReplyFailedPosts, reply *string) ( } _, err = utils.NewHTTPPoster(v1.Config.HttpSkipTlsVerify, v1.Config.ReplyTimeout).Post(ffn.Address, utils.PosterTransportContentTypes[ffn.Transport], fileContent, - v1.Config.HttpPosterAttempts, path.Join(failedReqsOutDir, file.Name())) + v1.Config.PosterAttempts, path.Join(failedReqsOutDir, file.Name())) if err != nil { // Got error from HTTPPoster could be that content was not written, we need to write it ourselves fileOutPath := path.Join(failedReqsOutDir, ffn.AsString()) _, err := guardian.Guardian.Guard(func() (interface{}, error) { diff --git a/config/config.go b/config/config.go index 622a52d07..46cf755be 100644 --- a/config/config.go +++ b/config/config.go @@ -220,8 +220,8 @@ type CGRConfig struct { RoundingDecimals int // Number of decimals to round end prices at HttpSkipTlsVerify bool // If enabled Http Client will accept any TLS certificate TpExportPath string // Path towards export folder for offline Tariff Plans - HttpPosterAttempts int - FailedRequestsDir string // Directory path where we store failed http requests + PosterAttempts int + FailedPostsDir string // Directory path where we store failed http requests MaxCallDuration time.Duration // The maximum call duration (used by responder when querying DerivedCharging) // ToDo: export it in configuration file LockingTimeout time.Duration // locking mechanism timeout to avoid deadlocks LogLevel int // system wide log level, nothing higher than this will be logged @@ -754,11 +754,11 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error { if jsnGeneralCfg.Tpexport_dir != nil { self.TpExportPath = *jsnGeneralCfg.Tpexport_dir } - if jsnGeneralCfg.Httpposter_attempts != nil { - self.HttpPosterAttempts = *jsnGeneralCfg.Httpposter_attempts + if jsnGeneralCfg.Poster_attempts != nil { + self.PosterAttempts = *jsnGeneralCfg.Poster_attempts } - if jsnGeneralCfg.Failed_requests_dir != nil { - self.FailedRequestsDir = *jsnGeneralCfg.Failed_requests_dir + if jsnGeneralCfg.Failed_posts_dir != nil { + self.FailedPostsDir = *jsnGeneralCfg.Failed_posts_dir } if jsnGeneralCfg.Default_timezone != nil { self.DefaultTimezone = *jsnGeneralCfg.Default_timezone diff --git a/config/config_defaults.go b/config/config_defaults.go index a5b30ddfd..ba3ccb150 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -27,25 +27,25 @@ const CGRATES_CFG_JSON = ` // This is what you get when you load CGRateS with an empty configuration file. "general": { - "instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated - "log_level": 6, // control the level of messages logged (0-emerg to 7-debug) - "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate - "rounding_decimals": 5, // system level precision for floats - "dbdata_encoding": "msgpack", // encoding used to store object data in strings: - "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans - "httpposter_attempts": 3, // number of http attempts before considering request failed (eg: *call_url) - "failed_requests_dir": "/var/spool/cgrates/failed_requests", // directory path where we store failed requests - "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> - "default_category": "call", // default category to consider when missing from requests - "default_tenant": "cgrates.org", // default tenant to consider when missing from requests - "default_timezone": "Local", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> - "connect_attempts": 3, // initial server connect attempts - "reconnects": -1, // number of retries in case of connection lost - "connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature - "reply_timeout": "2s", // consider connection down for replies taking longer than this value - "response_cache_ttl": "0s", // the life span of a cached response - "internal_ttl": "2m", // maximum duration to wait for internal connections before giving up - "locking_timeout": "5s", // timeout internal locks to avoid deadlocks + "instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated + "log_level": 6, // control the level of messages logged (0-emerg to 7-debug) + "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate + "rounding_decimals": 5, // system level precision for floats + "dbdata_encoding": "msgpack", // encoding used to store object data in strings: + "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans + "poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR replication) + "failed_posts_dir": "/var/spool/cgrates/failed_posts", // directory path where we store failed requests + "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> + "default_category": "call", // default category to consider when missing from requests + "default_tenant": "cgrates.org", // default tenant to consider when missing from requests + "default_timezone": "Local", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> + "connect_attempts": 3, // initial server connect attempts + "reconnects": -1, // number of retries in case of connection lost + "connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature + "reply_timeout": "2s", // consider connection down for replies taking longer than this value + "response_cache_ttl": "0s", // the life span of a cached response + "internal_ttl": "2m", // maximum duration to wait for internal connections before giving up + "locking_timeout": "5s", // timeout internal locks to avoid deadlocks }, diff --git a/config/config_json_test.go b/config/config_json_test.go index c9b7482d0..2cea6d44e 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -44,8 +44,8 @@ func TestDfGeneralJsonCfg(t *testing.T) { Rounding_decimals: utils.IntPointer(5), Dbdata_encoding: utils.StringPointer("msgpack"), Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"), - Httpposter_attempts: utils.IntPointer(3), - Failed_requests_dir: utils.StringPointer("/var/spool/cgrates/failed_requests"), + Poster_attempts: utils.IntPointer(3), + Failed_posts_dir: utils.StringPointer("/var/spool/cgrates/failed_posts"), Default_request_type: utils.StringPointer(utils.META_RATED), Default_category: utils.StringPointer("call"), Default_tenant: utils.StringPointer("cgrates.org"), diff --git a/config/config_test.go b/config/config_test.go index 433900100..5bff139c5 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -151,11 +151,11 @@ func TestCgrCfgJSONDefaultsGeneral(t *testing.T) { if cgrCfg.TpExportPath != "/var/spool/cgrates/tpe" { t.Error(cgrCfg.TpExportPath) } - if cgrCfg.HttpPosterAttempts != 3 { - t.Error(cgrCfg.HttpPosterAttempts) + if cgrCfg.PosterAttempts != 3 { + t.Error(cgrCfg.PosterAttempts) } - if cgrCfg.FailedRequestsDir != "/var/spool/cgrates/failed_requests" { - t.Error(cgrCfg.FailedRequestsDir) + if cgrCfg.FailedPostsDir != "/var/spool/cgrates/failed_posts" { + t.Error(cgrCfg.FailedPostsDir) } if cgrCfg.DefaultReqType != "*rated" { t.Error(cgrCfg.DefaultReqType) diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 412857773..31cb010b3 100644 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -25,8 +25,8 @@ type GeneralJsonCfg struct { Rounding_decimals *int Dbdata_encoding *string Tpexport_dir *string - Httpposter_attempts *int - Failed_requests_dir *string + Poster_attempts *int + Failed_posts_dir *string Default_request_type *string Default_category *string Default_tenant *string diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 298c7368b..e4660bce0 100644 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -7,25 +7,25 @@ // This is what you get when you load CGRateS with an empty configuration file. // "general": { -// "instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated -// "log_level": 6, // control the level of messages logged (0-emerg to 7-debug) -// "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate -// "rounding_decimals": 5, // system level precision for floats -// "dbdata_encoding": "msgpack", // encoding used to store object data in strings: -// "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans -// "httpposter_attempts": 3, // number of http attempts before considering request failed (eg: *call_url) -// "failed_requests_dir": "/var/spool/cgrates/failed_requests", // directory path where we store failed requests -// "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> -// "default_category": "call", // default category to consider when missing from requests -// "default_tenant": "cgrates.org", // default tenant to consider when missing from requests -// "default_timezone": "Local", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> -// "connect_attempts": 3, // initial server connect attempts -// "reconnects": -1, // number of retries in case of connection lost -// "connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature -// "reply_timeout": "2s", // consider connection down for replies taking longer than this value -// "response_cache_ttl": "0s", // the life span of a cached response -// "internal_ttl": "2m", // maximum duration to wait for internal connections before giving up -// "locking_timeout": "5s", // timeout internal locks to avoid deadlocks +// "instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated +// "log_level": 6, // control the level of messages logged (0-emerg to 7-debug) +// "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate +// "rounding_decimals": 5, // system level precision for floats +// "dbdata_encoding": "msgpack", // encoding used to store object data in strings: +// "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans +// "poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR replication) +// "failed_posts_dir": "/var/spool/cgrates/failed_posts", // directory path where we store failed requests +// "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> +// "default_category": "call", // default category to consider when missing from requests +// "default_tenant": "cgrates.org", // default tenant to consider when missing from requests +// "default_timezone": "Local", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> +// "connect_attempts": 3, // initial server connect attempts +// "reconnects": -1, // number of retries in case of connection lost +// "connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature +// "reply_timeout": "2s", // consider connection down for replies taking longer than this value +// "response_cache_ttl": "0s", // the life span of a cached response +// "internal_ttl": "2m", // maximum duration to wait for internal connections before giving up +// "locking_timeout": "5s", // timeout internal locks to avoid deadlocks // }, diff --git a/engine/action.go b/engine/action.go index a07486949..3a249afa3 100644 --- a/engine/action.go +++ b/engine/action.go @@ -418,7 +418,7 @@ func callUrl(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) error RequestID: utils.GenUUID(), FileSuffix: utils.JSNSuffix} _, err = utils.NewHTTPPoster(config.CgrConfig().HttpSkipTlsVerify, config.CgrConfig().ReplyTimeout).Post(a.ExtraParameters, utils.CONTENT_JSON, jsn, - config.CgrConfig().HttpPosterAttempts, path.Join(cfg.FailedRequestsDir, ffn.AsString())) + config.CgrConfig().PosterAttempts, path.Join(cfg.FailedPostsDir, ffn.AsString())) return err } @@ -441,7 +441,7 @@ func callUrlAsync(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) RequestID: utils.GenUUID(), FileSuffix: utils.JSNSuffix} go utils.NewHTTPPoster(config.CgrConfig().HttpSkipTlsVerify, config.CgrConfig().ReplyTimeout).Post(a.ExtraParameters, utils.CONTENT_JSON, jsn, - config.CgrConfig().HttpPosterAttempts, path.Join(cfg.FailedRequestsDir, ffn.AsString())) + config.CgrConfig().PosterAttempts, path.Join(cfg.FailedPostsDir, ffn.AsString())) return nil } diff --git a/engine/cdrs.go b/engine/cdrs.go index 8a5042469..ceccf0b69 100644 --- a/engine/cdrs.go +++ b/engine/cdrs.go @@ -499,7 +499,7 @@ func (self *CdrServer) replicateCdr(cdr *CDR) error { } go func(body interface{}, rplCfg *config.CDRReplicationCfg, content string, errChan chan error) { fallbackPath := path.Join( - self.cgrCfg.FailedRequestsDir, + self.cgrCfg.FailedPostsDir, rplCfg.FallbackFileName()) if _, err := self.httpPoster.Post(rplCfg.Address, utils.PosterTransportContentTypes[rplCfg.Transport], body, rplCfg.Attempts, fallbackPath); err != nil { utils.Logger.Err(fmt.Sprintf( diff --git a/general_tests/cdrs_replication_it_test.go b/general_tests/cdrs_replication_it_test.go index 3b8576922..e421b5881 100644 --- a/general_tests/cdrs_replication_it_test.go +++ b/general_tests/cdrs_replication_it_test.go @@ -146,16 +146,16 @@ func TestCdrsFileFailover(t *testing.T) { break } } - filesInDir, _ := ioutil.ReadDir(cdrsMasterCfg.FailedRequestsDir) + filesInDir, _ := ioutil.ReadDir(cdrsMasterCfg.FailedPostsDir) if len(filesInDir) == 0 { - t.Fatalf("No files in directory: %s", cdrsMasterCfg.FailedRequestsDir) + t.Fatalf("No files in directory: %s", cdrsMasterCfg.FailedPostsDir) } var fileName string for _, file := range filesInDir { // First file in directory is the one we need, harder to find it's name out of config fileName = file.Name() break } - filePath := path.Join(cdrsMasterCfg.FailedRequestsDir, fileName) + filePath := path.Join(cdrsMasterCfg.FailedPostsDir, fileName) if readBytes, err := ioutil.ReadFile(filePath); err != nil { t.Error(err) } else if !reflect.DeepEqual(failoverContent, readBytes) { // Checking just the prefix should do since some content is dynamic diff --git a/packages/jessie/rules b/packages/jessie/rules index 20bca83f2..bd4600dca 100755 --- a/packages/jessie/rules +++ b/packages/jessie/rules @@ -38,7 +38,7 @@ binary-arch: clean mkdir -p $(PKGDIR)/var/spool/cgrates/cdre/csv mkdir -p $(PKGDIR)/var/spool/cgrates/cdre/fwv mkdir -p $(PKGDIR)/var/spool/cgrates/tpe - mkdir -p $(PKGDIR)/var/spool/cgrates/failed_requests + mkdir -p $(PKGDIR)/var/spool/cgrates/failed_posts mkdir -p $(PKGDIR)/var/lib/cgrates/history mkdir -p $(PKGDIR)/var/lib/cgrates/cache_dump dh_strip diff --git a/packages/redhat_fedora/cgrates.spec b/packages/redhat_fedora/cgrates.spec index ddf7a85e4..315ad34bd 100644 --- a/packages/redhat_fedora/cgrates.spec +++ b/packages/redhat_fedora/cgrates.spec @@ -93,7 +93,7 @@ mkdir -p $RPM_BUILD_ROOT%{_spooldir}/cdrc/out mkdir -p $RPM_BUILD_ROOT%{_spooldir}/cdre/csv mkdir -p $RPM_BUILD_ROOT%{_spooldir}/cdre/fwv mkdir -p $RPM_BUILD_ROOT%{_spooldir}/tpe -mkdir -p $RPM_BUILD_ROOT%{_spooldir}/failed_requests +mkdir -p $RPM_BUILD_ROOT%{_spooldir}/failed_posts_ mkdir -p $RPM_BUILD_ROOT%{_libdir}/history mkdir -p $RPM_BUILD_ROOT%{_libdir}/cache_dump install -D -m 0644 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.options $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name} diff --git a/packages/squeeze/rules b/packages/squeeze/rules index 1831bcd3f..1770d7e62 100755 --- a/packages/squeeze/rules +++ b/packages/squeeze/rules @@ -37,7 +37,7 @@ binary-arch: clean mkdir -p $(PKGDIR)/var/spool/cgrates/cdre/csv mkdir -p $(PKGDIR)/var/spool/cgrates/cdre/fwv mkdir -p $(PKGDIR)/var/spool/cgrates/tpe - mkdir -p $(PKGDIR)/var/spool/cgrates/failed_requests + mkdir -p $(PKGDIR)/var/spool/cgrates/failed_posts mkdir -p $(PKGDIR)/var/lib/cgrates/history mkdir -p $(PKGDIR)/var/lib/cgrates/cache_dump dh_strip