You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2016/10/28 21:06:47 UTC
[24/50] incubator-trafficcontrol git commit: Fix TM2 unnecessary
conversions
Fix TM2 unnecessary conversions
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/fa4d2e59
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/fa4d2e59
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/fa4d2e59
Branch: refs/heads/master
Commit: fa4d2e5968d06a8a42024d3ecfdb0e55e32ec797
Parents: b182dd8
Author: Robert Butts <ro...@gmail.com>
Authored: Fri Oct 21 15:11:40 2016 -0600
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Fri Oct 28 15:04:12 2016 -0600
----------------------------------------------------------------------
.../traffic_monitor/deliveryservice/stat.go | 18 +++++++++---------
.../traffic_monitor/manager/datarequest.go | 10 +++++-----
.../traffic_monitor/manager/healthresult.go | 10 +++++-----
.../traffic_monitor/manager/stathistory.go | 8 ++++----
4 files changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/fa4d2e59/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go b/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
index d8dd30c..ff94e42 100644
--- a/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
+++ b/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
@@ -63,7 +63,7 @@ func addAvailableData(dsStats Stats, crStates peer.Crstates, serverCachegroups m
log.Warnf("CreateStats not adding availability data for '%s': not found in DeliveryServices\n", cache)
continue
}
- cacheType, ok := serverTypes[enum.CacheName(cache)]
+ cacheType, ok := serverTypes[cache]
if !ok {
log.Warnf("CreateStats not adding availability data for '%s': not found in Server Types\n", cache)
continue
@@ -75,7 +75,7 @@ func addAvailableData(dsStats Stats, crStates peer.Crstates, serverCachegroups m
continue
}
- stat, ok := dsStats.DeliveryService[enum.DeliveryServiceName(deliveryService)]
+ stat, ok := dsStats.DeliveryService[deliveryService]
if !ok {
log.Warnf("CreateStats not adding availability data for '%s': not found in Stats\n", cache)
continue // TODO log warning? Error?
@@ -85,9 +85,9 @@ func addAvailableData(dsStats Stats, crStates peer.Crstates, serverCachegroups m
// c.IsAvailable.Value
stat.CommonStats.IsAvailable.Value = true
stat.CommonStats.CachesAvailableNum.Value++
- cacheGroupStats := stat.CacheGroups[enum.CacheGroupName(cacheGroup)]
+ cacheGroupStats := stat.CacheGroups[cacheGroup]
cacheGroupStats.IsAvailable.Value = true
- stat.CacheGroups[enum.CacheGroupName(cacheGroup)] = cacheGroupStats
+ stat.CacheGroups[cacheGroup] = cacheGroupStats
stat.TotalStats.IsAvailable.Value = true
typeStats := stat.Types[cacheType]
typeStats.IsAvailable.Value = true
@@ -95,13 +95,13 @@ func addAvailableData(dsStats Stats, crStates peer.Crstates, serverCachegroups m
}
// TODO fix nested ifs
- if results, ok := statHistory[enum.CacheName(cache)]; ok {
+ if results, ok := statHistory[cache]; ok {
if len(results) < 1 {
log.Warnf("no results %v %v\n", cache, deliveryService)
} else {
result := results[0]
if result.PrecomputedData.Reporting {
- stat.CommonStats.CachesReporting[enum.CacheName(cache)] = true
+ stat.CommonStats.CachesReporting[cache] = true
} else {
log.Debugf("no reporting %v %v\n", cache, deliveryService)
}
@@ -110,7 +110,7 @@ func addAvailableData(dsStats Stats, crStates peer.Crstates, serverCachegroups m
log.Debugf("no result for %v %v\n", cache, deliveryService)
}
- dsStats.DeliveryService[enum.DeliveryServiceName(deliveryService)] = stat // TODO Necessary? Remove?
+ dsStats.DeliveryService[deliveryService] = stat // TODO Necessary? Remove?
}
}
return dsStats, nil
@@ -391,7 +391,7 @@ func CreateStats(statHistory map[enum.CacheName][]cache.Result, toData todata.TO
log.Errorf("EMPTY CreateStats deliveryService")
continue
}
- dsStats.DeliveryService[enum.DeliveryServiceName(deliveryService)] = *dsdata.NewStat()
+ dsStats.DeliveryService[deliveryService] = *dsdata.NewStat()
}
dsStats = setStaticData(dsStats, toData.DeliveryServiceServers)
var err error
@@ -409,7 +409,7 @@ func CreateStats(statHistory map[enum.CacheName][]cache.Result, toData todata.TO
log.Warnf("server %s has no cachegroup, skipping\n", server)
continue
}
- serverType, ok := toData.ServerTypes[enum.CacheName(server)]
+ serverType, ok := toData.ServerTypes[server]
if !ok {
log.Warnf("server %s not in CRConfig, skipping\n", server)
continue
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/fa4d2e59/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 e6da58a..6a7fd9c 100644
--- a/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go
+++ b/traffic_monitor/experimental/traffic_monitor/manager/datarequest.go
@@ -613,7 +613,7 @@ func createCacheStatuses(
}
var kbps *float64
- lastStat, ok := lastStats.Caches[enum.CacheName(cacheName)]
+ lastStat, ok := lastStats.Caches[cacheName]
if !ok {
log.Warnf("cache not in last kbps cache %s\n", cacheName)
} else {
@@ -622,7 +622,7 @@ func createCacheStatuses(
}
var connections *int64
- connectionsVal, ok := conns[enum.CacheName(cacheName)]
+ connectionsVal, ok := conns[cacheName]
if !ok {
log.Warnf("cache not in connections %s\n", cacheName)
} else {
@@ -630,12 +630,12 @@ func createCacheStatuses(
}
var status *string
- statusVal, ok := localCacheStatus[enum.CacheName(cacheName)]
+ statusVal, ok := localCacheStatus[cacheName]
if !ok {
log.Warnf("cache not in statuses %s\n", cacheName)
} else {
statusString := statusVal.Status + " - "
- if localCacheStatus[enum.CacheName(cacheName)].Available {
+ if localCacheStatus[cacheName].Available {
statusString += "available"
} else {
statusString += "unavailable"
@@ -644,7 +644,7 @@ func createCacheStatuses(
}
cacheTypeStr := string(cacheType)
- statii[enum.CacheName(cacheName)] = CacheStatus{Type: &cacheTypeStr, LoadAverage: loadAverage, QueryTimeMilliseconds: queryTime, BandwidthKbps: kbps, ConnectionCount: connections, Status: status}
+ statii[cacheName] = CacheStatus{Type: &cacheTypeStr, LoadAverage: loadAverage, QueryTimeMilliseconds: queryTime, BandwidthKbps: kbps, ConnectionCount: connections, Status: status}
}
return statii
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/fa4d2e59/traffic_monitor/experimental/traffic_monitor/manager/healthresult.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/manager/healthresult.go b/traffic_monitor/experimental/traffic_monitor/manager/healthresult.go
index 5cefd06..de069b3 100644
--- a/traffic_monitor/experimental/traffic_monitor/manager/healthresult.go
+++ b/traffic_monitor/experimental/traffic_monitor/manager/healthresult.go
@@ -194,7 +194,7 @@ func processHealthResult(
log.Debugf("poll %v %v healthresultman start\n", healthResult.PollID, time.Now())
fetchCount.Inc()
var prevResult cache.Result
- healthResultHistory := healthHistory[enum.CacheName(healthResult.ID)]
+ healthResultHistory := healthHistory[healthResult.ID]
if len(healthResultHistory) != 0 {
prevResult = healthResultHistory[len(healthResultHistory)-1]
}
@@ -203,7 +203,7 @@ func processHealthResult(
health.GetVitals(&healthResult, &prevResult, &monitorConfigCopy)
}
- healthHistory[enum.CacheName(healthResult.ID)] = pruneHistory(append(healthHistory[enum.CacheName(healthResult.ID)], healthResult), cfg.MaxHealthHistory)
+ healthHistory[healthResult.ID] = pruneHistory(append(healthHistory[healthResult.ID], healthResult), cfg.MaxHealthHistory)
isAvailable, whyAvailable := health.EvalCache(healthResult, &monitorConfigCopy)
if localStates.Get().Caches[healthResult.ID].IsAvailable != isAvailable {
@@ -222,11 +222,11 @@ func processHealthResult(
lastHealthDurations := lastHealthDurationsThreadsafe.Get().Copy()
for _, healthResult := range results {
- if lastHealthStart, ok := lastHealthEndTimes[enum.CacheName(healthResult.ID)]; ok {
+ if lastHealthStart, ok := lastHealthEndTimes[healthResult.ID]; ok {
d := time.Since(lastHealthStart)
- lastHealthDurations[enum.CacheName(healthResult.ID)] = d
+ lastHealthDurations[healthResult.ID] = d
}
- lastHealthEndTimes[enum.CacheName(healthResult.ID)] = time.Now()
+ lastHealthEndTimes[healthResult.ID] = time.Now()
log.Debugf("poll %v %v finish\n", healthResult.PollID, time.Now())
healthResult.PollFinished <- healthResult.PollID
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/fa4d2e59/traffic_monitor/experimental/traffic_monitor/manager/stathistory.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/manager/stathistory.go b/traffic_monitor/experimental/traffic_monitor/manager/stathistory.go
index 24edcf7..20a9e2c 100644
--- a/traffic_monitor/experimental/traffic_monitor/manager/stathistory.go
+++ b/traffic_monitor/experimental/traffic_monitor/manager/stathistory.go
@@ -156,7 +156,7 @@ func processStatResults(
maxStats := statHistoryThreadsafe.Max()
for _, result := range results {
// TODO determine if we want to add results with errors, or just print the errors now and don't add them.
- statHistory[enum.CacheName(result.ID)] = pruneHistory(append(statHistory[enum.CacheName(result.ID)], result), maxStats)
+ statHistory[result.ID] = pruneHistory(append(statHistory[result.ID], result), maxStats)
}
statHistoryThreadsafe.Set(statHistory)
@@ -181,11 +181,11 @@ func processStatResults(
endTime := time.Now()
lastStatDurations := lastStatDurationsThreadsafe.Get().Copy()
for _, result := range results {
- if lastStatStart, ok := lastStatEndTimes[enum.CacheName(result.ID)]; ok {
+ if lastStatStart, ok := lastStatEndTimes[result.ID]; ok {
d := time.Since(lastStatStart)
- lastStatDurations[enum.CacheName(result.ID)] = d
+ lastStatDurations[result.ID] = d
}
- lastStatEndTimes[enum.CacheName(result.ID)] = endTime
+ lastStatEndTimes[result.ID] = endTime
// log.Debugf("poll %v %v statfinish\n", result.PollID, endTime)
result.PollFinished <- result.PollID