Recognize stat_dir_type_empty 24/31624/2
authorVladimir Lavor <vlavor@cisco.com>
Thu, 11 Mar 2021 14:27:02 +0000 (15:27 +0100)
committerOndrej Fabry <ofabry@cisco.com>
Tue, 20 Apr 2021 16:51:29 +0000 (16:51 +0000)
Do not to handle empty stats directory as unknown.
Empty dir's value is always treated as zero.

Change-Id: I40a3829675c5b7c9da80ceaa7e2d0a87fe02dc7c
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
adapter/stats_api.go
adapter/statsclient/statseg_v2.go

index 4b398f5..d15dee8 100644 (file)
@@ -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)
 }
@@ -144,11 +147,15 @@ 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
@@ -204,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 {
index 68411f9..08467c1 100644 (file)
@@ -202,6 +202,7 @@ func (ss *statSegmentV2) CopyEntryData(statSegDir unsafe.Pointer) adapter.Stat {
                return adapter.NameStat(data)
 
        case statDirEmpty:
+               return adapter.EmptyStat("<none>")
                // no-op
 
        default: