gofmt -r "ContainerStatsSummary->ContainerStatsPercentiles"

This commit is contained in:
Nan Deng 2014-06-12 11:38:37 -07:00
parent f07a91c0cc
commit 71835f9bc4
3 changed files with 13 additions and 13 deletions

View File

@ -35,12 +35,12 @@ type ContainerHandler interface {
ListContainers(listType ListType) ([]string, error) ListContainers(listType ListType) ([]string, error)
ListThreads(listType ListType) ([]int, error) ListThreads(listType ListType) ([]int, error)
ListProcesses(listType ListType) ([]int, error) ListProcesses(listType ListType) ([]int, error)
StatsSummary() (*info.ContainerStatsSummary, error) StatsSummary() (*info.ContainerStatsPercentiles, error)
} }
type NoStatsSummary struct { type NoStatsSummary struct {
} }
func (self *NoStatsSummary) StatsSummary() (*info.ContainerStatsSummary, error) { func (self *NoStatsSummary) StatsSummary() (*info.ContainerStatsPercentiles, error) {
return nil, fmt.Errorf("This method (StatsSummary) should never be called") return nil, fmt.Errorf("This method (StatsSummary) should never be called")
} }

View File

@ -24,11 +24,11 @@ import (
type statsSummaryContainerHandlerWrapper struct { type statsSummaryContainerHandlerWrapper struct {
handler ContainerHandler handler ContainerHandler
currentSummary *info.ContainerStatsSummary currentSummary *info.ContainerStatsPercentiles
prevStats *info.ContainerStats prevStats *info.ContainerStats
numStats uint64 numStats uint64
sampler sampling.Sampler sampler sampling.Sampler
lock sync.Mutex lock sync.Mutex
} }
func (self *statsSummaryContainerHandlerWrapper) GetSpec() (*info.ContainerSpec, error) { func (self *statsSummaryContainerHandlerWrapper) GetSpec() (*info.ContainerSpec, error) {
@ -78,7 +78,7 @@ func (self *statsSummaryContainerHandlerWrapper) GetStats() (*info.ContainerStat
} }
self.updatePrevStats(stats) self.updatePrevStats(stats)
if self.currentSummary == nil { if self.currentSummary == nil {
self.currentSummary = new(info.ContainerStatsSummary) self.currentSummary = new(info.ContainerStatsPercentiles)
} }
self.numStats++ self.numStats++
if stats.Memory != nil { if stats.Memory != nil {
@ -101,7 +101,7 @@ func (self *statsSummaryContainerHandlerWrapper) ListProcesses(listType ListType
return self.handler.ListProcesses(listType) return self.handler.ListProcesses(listType)
} }
func (self *statsSummaryContainerHandlerWrapper) StatsSummary() (*info.ContainerStatsSummary, error) { func (self *statsSummaryContainerHandlerWrapper) StatsSummary() (*info.ContainerStatsPercentiles, error) {
self.lock.Lock() self.lock.Lock()
defer self.lock.Unlock() defer self.lock.Unlock()
samples := make([]*info.ContainerStatsSample, 0, self.sampler.Len()) samples := make([]*info.ContainerStatsSample, 0, self.sampler.Len())
@ -132,7 +132,7 @@ func AddStatsSummary(handler ContainerHandler, parameter *StatsParameter) (Conta
} }
return &statsSummaryContainerHandlerWrapper{ return &statsSummaryContainerHandlerWrapper{
handler: handler, handler: handler,
currentSummary: &info.ContainerStatsSummary{}, currentSummary: &info.ContainerStatsPercentiles{},
sampler: sampler, sampler: sampler,
}, nil }, nil
} }

View File

@ -62,7 +62,7 @@ type ContainerInfo struct {
// Historical statistics gathered from the container. // Historical statistics gathered from the container.
Stats []*ContainerStats `json:"stats,omitempty"` Stats []*ContainerStats `json:"stats,omitempty"`
StatsSummary *ContainerStatsSummary `json:"stats_summary,omitempty"` StatsSummary *ContainerStatsPercentiles `json:"stats_summary,omitempty"`
} }
func (self *ContainerInfo) StatsAfter(ref time.Time) []*ContainerStats { func (self *ContainerInfo) StatsAfter(ref time.Time) []*ContainerStats {
@ -177,7 +177,7 @@ type percentile struct {
Value uint64 `json:"value"` Value uint64 `json:"value"`
} }
type ContainerStatsSummary struct { type ContainerStatsPercentiles struct {
// TODO(dengnan): More things? // TODO(dengnan): More things?
MaxMemoryUsage uint64 `json:"max_memory_usage,omitempty"` MaxMemoryUsage uint64 `json:"max_memory_usage,omitempty"`
Samples []*ContainerStatsSample `json:"samples,omitempty"` Samples []*ContainerStatsSample `json:"samples,omitempty"`
@ -263,7 +263,7 @@ func intZipuint64(as []int, bs []uint64) []percentile {
return ret return ret
} }
func (self *ContainerStatsSummary) FillPercentiles(cpuPercentages, memoryPercentages []int) { func (self *ContainerStatsPercentiles) FillPercentiles(cpuPercentages, memoryPercentages []int) {
if len(self.Samples) == 0 { if len(self.Samples) == 0 {
return return
} }