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 2017/01/23 19:11:17 UTC

[1/3] incubator-trafficcontrol git commit: Add TM2 enum usage explanation comment

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master fb42fb6bc -> a54db70d9


Add TM2 enum usage explanation comment


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

Branch: refs/heads/master
Commit: fc5d61a7014220e6100f2c3407aa64aeab0da6c4
Parents: edb7e63
Author: Robert Butts <ro...@gmail.com>
Authored: Thu Jan 19 12:10:19 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Mon Jan 23 12:10:59 2017 -0700

----------------------------------------------------------------------
 traffic_monitor/experimental/traffic_monitor/enum/enum.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/fc5d61a7/traffic_monitor/experimental/traffic_monitor/enum/enum.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/enum/enum.go b/traffic_monitor/experimental/traffic_monitor/enum/enum.go
index ce838ac..853236a 100644
--- a/traffic_monitor/experimental/traffic_monitor/enum/enum.go
+++ b/traffic_monitor/experimental/traffic_monitor/enum/enum.go
@@ -1,5 +1,12 @@
 // Package enum contains enumerations and strongly typed names.
-// The names are an experiment with strong typing of string types. The primary goal is to make code more self-documenting, especially map keys. If peole don't like it, we can get rid of it.
+//
+// These enums should be treated as enumerables, and MUST NOT be cast as anything else (integer, strings, etc). Enums MUST NOT be compared to strings or integers via casting. Enumerable data SHOULD be stored as the enumeration, not as a string or number. The *only* reason they are internally represented as strings, is to make them implicitly serialize to human-readable JSON. They should not be treated as strings. Casting or storing strings or numbers defeats the purpose of enum safety and conveniences.
+//
+// When storing enumumerable data in memory, it SHOULD be converted to and stored as an enum via the corresponding `FromString` function, checked whether the conversion failed and Invalid values handled, and valid data stored as the enum. This guarantees stored data is valid, and catches invalid input as soon as possible.
+//
+// When adding new enum types, enums should be internally stored as strings, so they implicitly serialize as human-readable JSON, unless the performance or memory of integers is necessary (it almost certainly isn't). Enums should always have the "invalid" value as the empty string (or 0), so default-initialized enums are invalid.
+// Enums should always have a FromString() conversion function, to convert input data to enums. Conversion functions should usually be case-insensitive, and may ignore underscores or hyphens, depending on the use case.
+//
 package enum
 
 /*


[3/3] incubator-trafficcontrol git commit: This closes #195

Posted by ne...@apache.org.
This closes #195


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

Branch: refs/heads/master
Commit: a54db70d9c8d076f0b884b5474c13663f7ac645b
Parents: fc5d61a
Author: David Neuman <da...@gmail.com>
Authored: Mon Jan 23 12:11:12 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Mon Jan 23 12:11:12 2017 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------



[2/3] incubator-trafficcontrol git commit: Add TM2 cache capacity to GUI

Posted by ne...@apache.org.
Add TM2 cache capacity to GUI


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

Branch: refs/heads/master
Commit: edb7e63387a1536756e041358a4e272c6e3b626d
Parents: fb42fb6
Author: Robert Butts <ro...@gmail.com>
Authored: Wed Jan 18 08:45:20 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Mon Jan 23 12:10:59 2017 -0700

----------------------------------------------------------------------
 .../traffic_monitor/manager/datarequest.go      | 21 +++++++++++++++-----
 .../traffic_monitor/static/index.html           |  5 ++++-
 2 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/edb7e633/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go b/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go
index e4a35ed..c4385f3 100644
--- a/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go
+++ b/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go
@@ -77,6 +77,7 @@ type CacheStatus struct {
 	// HealthSpanMilliseconds is the length of time between completing the most recent two health queries. This can be used as a rough gauge of the end-to-end query processing time.
 	HealthSpanMilliseconds *int64   `json:"health_span_ms,omitempty"`
 	BandwidthKbps          *float64 `json:"bandwidth_kbps,omitempty"`
+	BandwidthCapacityKbps  *float64 `json:"bandwidth_capacity_kbps,omitempty"`
 	ConnectionCount        *int64   `json:"connection_count,omitempty"`
 }
 
@@ -656,8 +657,8 @@ func srvAPIVersion(staticAppData StaticAppData) []byte {
 func srvAPITrafficOpsURI(opsConfig OpsConfigThreadsafe) []byte {
 	return []byte(opsConfig.Get().Url)
 }
-func srvAPICacheStates(toData todata.TODataThreadsafe, statInfoHistory threadsafe.ResultInfoHistory, statResultHistory threadsafe.ResultStatHistory, healthHistory threadsafe.ResultHistory, lastHealthDurations DurationMapThreadsafe, localStates peer.CRStatesThreadsafe, lastStats threadsafe.LastStats, localCacheStatus threadsafe.CacheAvailableStatus) ([]byte, error) {
-	return json.Marshal(createCacheStatuses(toData.Get().ServerTypes, statInfoHistory.Get(), statResultHistory.Get(), healthHistory.Get(), lastHealthDurations.Get(), localStates.Get().Caches, lastStats.Get(), localCacheStatus))
+func srvAPICacheStates(toData todata.TODataThreadsafe, statInfoHistory threadsafe.ResultInfoHistory, statResultHistory threadsafe.ResultStatHistory, healthHistory threadsafe.ResultHistory, lastHealthDurations DurationMapThreadsafe, localStates peer.CRStatesThreadsafe, lastStats threadsafe.LastStats, localCacheStatus threadsafe.CacheAvailableStatus, statMaxKbpses threadsafe.CacheKbpses) ([]byte, error) {
+	return json.Marshal(createCacheStatuses(toData.Get().ServerTypes, statInfoHistory.Get(), statResultHistory.Get(), healthHistory.Get(), lastHealthDurations.Get(), localStates.Get().Caches, lastStats.Get(), localCacheStatus, statMaxKbpses))
 }
 
 func srvAPIBandwidthKbps(toData todata.TODataThreadsafe, lastStats threadsafe.LastStats) []byte {
@@ -779,7 +780,7 @@ func MakeDispatchMap(
 			return srvAPITrafficOpsURI(opsConfig)
 		}, ContentTypeJSON)),
 		"/api/cache-statuses": wrap(WrapErr(errorCount, func() ([]byte, error) {
-			return srvAPICacheStates(toData, statInfoHistory, statResultHistory, healthHistory, lastHealthDurations, localStates, lastStats, localCacheStatus)
+			return srvAPICacheStates(toData, statInfoHistory, statResultHistory, healthHistory, lastHealthDurations, localStates, lastStats, localCacheStatus, statMaxKbpses)
 		}, ContentTypeJSON)),
 		"/api/bandwidth-kbps": wrap(WrapBytes(func() []byte {
 			return srvAPIBandwidthKbps(toData, lastStats)
@@ -897,10 +898,12 @@ func createCacheStatuses(
 	cacheStates map[enum.CacheName]peer.IsAvailable,
 	lastStats ds.LastStats,
 	localCacheStatusThreadsafe threadsafe.CacheAvailableStatus,
+	statMaxKbpses threadsafe.CacheKbpses,
 ) map[enum.CacheName]CacheStatus {
 	conns := createCacheConnections(statResultHistory)
 	statii := map[enum.CacheName]CacheStatus{}
 	localCacheStatus := localCacheStatusThreadsafe.Get()
+	maxKbpses := statMaxKbpses.Get()
 
 	for cacheName, cacheType := range cacheTypes {
 		infoHistory, ok := statInfoHistory[cacheName]
@@ -944,14 +947,21 @@ func createCacheStatuses(
 		}
 
 		var kbps *float64
-		lastStat, ok := lastStats.Caches[cacheName]
-		if !ok {
+		if lastStat, ok := lastStats.Caches[cacheName]; !ok {
 			log.Warnf("cache not in last kbps cache %s\n", cacheName)
 		} else {
 			kbpsVal := lastStat.Bytes.PerSec / float64(ds.BytesPerKilobit)
 			kbps = &kbpsVal
 		}
 
+		var maxKbps *float64
+		if v, ok := maxKbpses[cacheName]; !ok {
+			log.Warnf("cache not in max kbps cache %s\n", cacheName)
+		} else {
+			fv := float64(v)
+			maxKbps = &fv
+		}
+
 		var connections *int64
 		connectionsVal, ok := conns[cacheName]
 		if !ok {
@@ -989,6 +999,7 @@ func createCacheStatuses(
 			StatSpanMilliseconds:   &statSpan,
 			HealthSpanMilliseconds: &healthSpan,
 			BandwidthKbps:          kbps,
+			BandwidthCapacityKbps:  maxKbps,
 			ConnectionCount:        connections,
 			Status:                 status,
 		}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/edb7e633/traffic_monitor/experimental/traffic_monitor/static/index.html
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/static/index.html b/traffic_monitor/experimental/traffic_monitor/static/index.html
index be9129f..b3d6227 100644
--- a/traffic_monitor/experimental/traffic_monitor/static/index.html
+++ b/traffic_monitor/experimental/traffic_monitor/static/index.html
@@ -321,7 +321,10 @@ under the License.
 						 document.getElementById("cache-states-" + server + "-stat-span").textContent = jdata[server].stat_span_ms;
 					 }
 					 if (jdata[server].hasOwnProperty("bandwidth_kbps")) {
-						 document.getElementById("cache-states-" + server + "-bandwidth").textContent = (jdata[server].bandwidth_kbps / kilobitsInMegabit).toFixed(2);
+						 var kbps = (jdata[server].bandwidth_kbps / kilobitsInMegabit).toFixed(2);
+						 var max = numberStrWithCommas((jdata[server].bandwidth_capacity_kbps / kilobitsInMegabit).toFixed(0));
+						 document.getElementById("cache-states-" + server + "-bandwidth").textContent = '' + kbps + ' / ' + max;
+
 					 } else {
 						 document.getElementById("cache-states-" + server + "-bandwidth").textContent = "N/A";
 					 }