X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=adapter%2Fstats_api.go;h=d15dee892732f1685f9ba73dca79a9f430c807e0;hb=d0b973030fe07dc7875da72f5ebe42d8bd9544b1;hp=15c3789823bea33394a9d5fad18f97cf06ab74b2;hpb=4459b648e9fb53c34abbf52a00e63ad384fb9ee2;p=govpp.git diff --git a/adapter/stats_api.go b/adapter/stats_api.go index 15c3789..d15dee8 100644 --- a/adapter/stats_api.go +++ b/adapter/stats_api.go @@ -60,6 +60,7 @@ const ( CombinedCounterVector StatType = 3 ErrorIndex StatType = 4 NameVector StatType = 5 + Empty StatType = 6 ) func (d StatType) String() string { @@ -74,6 +75,8 @@ func (d StatType) String() string { return "ErrorIndex" case NameVector: return "NameVector" + case Empty: + return "Empty" } return fmt.Sprintf("UnknownStatType(%d)", d) } @@ -126,8 +129,8 @@ type Stat interface { // ScalarStat represents stat for ScalarIndex. type ScalarStat float64 -// ErrorStat represents stat for ErrorIndex. -type ErrorStat Counter +// ErrorStat represents stat for ErrorIndex. The array represents workers. +type ErrorStat []Counter // SimpleCounterStat represents stat for SimpleCounterVector. // The outer array represents workers and the inner array represents interface/node/.. indexes. @@ -144,17 +147,29 @@ type CombinedCounterStat [][]CombinedCounter // NameStat represents stat for NameVector. type NameStat []Name +// EmptyStat represents removed counter directory +type EmptyStat string + func (ScalarStat) isStat() {} func (ErrorStat) isStat() {} func (SimpleCounterStat) isStat() {} func (CombinedCounterStat) isStat() {} func (NameStat) isStat() {} +func (EmptyStat) isStat() {} func (s ScalarStat) IsZero() bool { return s == 0 } func (s ErrorStat) IsZero() bool { - return s == 0 + if s == nil { + return true + } + for _, ss := range s { + if ss != 0 { + return false + } + } + return true } func (s SimpleCounterStat) IsZero() bool { if s == nil { @@ -196,6 +211,9 @@ func (s NameStat) IsZero() bool { } return true } +func (s EmptyStat) IsZero() bool { + return true +} // ReduceSimpleCounterStatIndex returns reduced SimpleCounterStat s for index i. func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64 {