You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2016/11/07 19:29:56 UTC

[10/21] incubator-trafficcontrol git commit: Add TM2 config for health-to-stat ratio.

Add TM2 config for health-to-stat ratio.

Adds Traffic Monitor 2.0 config setting for health-to-stat ration.
This is only used if a 'health' poll interval exists in Traffic Ops
but no 'stat' interval, which is the case for Traffic Monitor 2.0.

If both 'health' and 'stat' exist, they will be used appropriately
and this config setting will be ignored. If only 'health' exists, it
will be used for 'stat' (which is the big query, like the only query
in Traffic Monitor 1.0), and 'health' will be the given ratio. For
example, to set the health poll at a quarter the stat poll, set the
config value to 4. So, a stat poll of 8 becomes 8/4=2 seconds. To use
the same value for both, set the config to 1.

This only exists to make it possible to poll health at a faster
rate in an existing Traffic Control deployment with no parameter
changes. Once deployed, the parameters should be set appropriately
and this config will not be used.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/75a9581d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/75a9581d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/75a9581d

Branch: refs/heads/master
Commit: 75a9581d8b00b29f3a686179d96f5a724e2b2cee
Parents: a8dabc5
Author: Robert Butts <ro...@gmail.com>
Authored: Wed Nov 2 14:42:01 2016 -0600
Committer: Dave Neuman <ne...@apache.org>
Committed: Mon Nov 7 12:29:08 2016 -0700

----------------------------------------------------------------------
 .../experimental/traffic_monitor/config/config.go       |  2 ++
 .../traffic_monitor/manager/monitorconfig.go            | 12 ++++--------
 2 files changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/75a9581d/traffic_monitor/experimental/traffic_monitor/config/config.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/config/config.go b/traffic_monitor/experimental/traffic_monitor/config/config.go
index 9e56f51..c7d53fb 100644
--- a/traffic_monitor/experimental/traffic_monitor/config/config.go
+++ b/traffic_monitor/experimental/traffic_monitor/config/config.go
@@ -36,6 +36,7 @@ type Config struct {
 	LogLocationDebug             string        `json:"log_location_debug"`
 	ServeReadTimeout             time.Duration `json:"-"`
 	ServeWriteTimeout            time.Duration `json:"-"`
+	HealthToStatRatio            uint64        `json:"health_to_stat_ratio"`
 }
 
 // DefaultConfig is the default configuration for the application, if no configuration file is given, or if a given config setting doesn't exist in the config file.
@@ -56,6 +57,7 @@ var DefaultConfig = Config{
 	LogLocationDebug:             LogLocationNull,
 	ServeReadTimeout:             10 * time.Second,
 	ServeWriteTimeout:            10 * time.Second,
+	HealthToStatRatio:            4,
 }
 
 // MarshalJSON marshals custom millisecond durations. Aliasing inspired by http://choly.ca/post/go-json-marshalling/

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/75a9581d/traffic_monitor/experimental/traffic_monitor/manager/monitorconfig.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/manager/monitorconfig.go b/traffic_monitor/experimental/traffic_monitor/manager/monitorconfig.go
index 352f8e6..4ff0cf4 100644
--- a/traffic_monitor/experimental/traffic_monitor/manager/monitorconfig.go
+++ b/traffic_monitor/experimental/traffic_monitor/manager/monitorconfig.go
@@ -119,7 +119,7 @@ func trafficOpsHealthPollIntervalToDuration(t int) time.Duration {
 }
 
 // getPollIntervals reads the Traffic Ops Client monitorConfig structure, and parses and returns the health, peer, and stat poll intervals
-func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap) (time.Duration, time.Duration, time.Duration, error) {
+func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap, cfg config.Config) (time.Duration, time.Duration, time.Duration, error) {
 	healthPollIntervalI, healthPollIntervalExists := monitorConfig.Config["health.polling.interval"]
 	if !healthPollIntervalExists {
 		return 0, 0, 0, fmt.Errorf("Traffic Ops Monitor config missing 'health.polling.interval', not setting config changes.\n")
@@ -153,12 +153,8 @@ func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap) (t
 	statPollInterval := trafficOpsHealthPollIntervalToDuration(int(statPollIntervalInt))
 
 	// Formerly, only 'health' polling existed. If TO still has old configuration and doesn't have a 'stat' parameter, this allows us to assume the 'health' poll is slow, and sets it to the stat poll (which used to be the only poll, getting all astats data) to the given presumed-slow health poll, and set the now-fast-and-small health poll to a short fraction of that.
-	// TODO make config?
-	healthIsQuarterStatIfStatNotExist := true
-	if healthIsQuarterStatIfStatNotExist {
-		if healthPollIntervalExists && !statPollIntervalExists {
-			healthPollInterval = healthPollInterval / 4
-		}
+	if healthPollIntervalExists && !statPollIntervalExists {
+		healthPollInterval = time.Duration(float64(healthPollInterval) / float64(cfg.HealthToStatRatio))
 	}
 
 	return healthPollInterval, peerPollInterval, statPollInterval, nil
@@ -184,7 +180,7 @@ func monitorConfigListen(
 		peerUrls := map[string]poller.PollConfig{}
 		caches := map[string]string{}
 
-		healthPollInterval, peerPollInterval, statPollInterval, err := getHealthPeerStatPollIntervals(monitorConfig)
+		healthPollInterval, peerPollInterval, statPollInterval, err := getHealthPeerStatPollIntervals(monitorConfig, cfg)
 		if err != nil {
 			continue
 		}