Skip to content

Refactor FlexCounter class#1020

Merged
liat-grozovik merged 1 commit intosonic-net:masterfrom
Junchao-Mellanox:refactor-flex-counter
Jul 6, 2022
Merged

Refactor FlexCounter class#1020
liat-grozovik merged 1 commit intosonic-net:masterfrom
Junchao-Mellanox:refactor-flex-counter

Conversation

@Junchao-Mellanox
Copy link
Contributor

@Junchao-Mellanox Junchao-Mellanox commented Jun 22, 2022

FlexCounter class is a representation of flex counter group which supports querying multiple types of statistic/attributes. It supports multiple statistic/attribute types such as port counter, port debug counter, queue counter, queue attribute and so on. For each statistic/attribute type, it defines several member functions:

  • setXXXCounterList: e.g. setPortCounterList, setPortDebugCounterList
  • removeXXX: e.g. removePort, removeQueue
  • collectXXXCounters: e.g. collectPortCounters, collectQueueCounters
  • collectXXXAttr: e.g. collectQueueAttrs, collectPriorityGroupAttrs
  • so on

For different statistic/attribute types, these functions have very similar logic. This design document describes a proposal about how to refactor FlexCounter class by moving duplicate/similar logic to a single place.

PR:

PR title state context
[sonic-sairedis] [FlexCounter] Refactor FlexCounter class GitHub issue/pull request detail GitHub pull request check contexts

@liat-grozovik liat-grozovik requested a review from kcudnik June 24, 2022 16:37
@liat-grozovik liat-grozovik merged commit d84ba9f into sonic-net:master Jul 6, 2022
qiluo-msft pushed a commit to sonic-net/sonic-sairedis that referenced this pull request Jul 28, 2022
HLD: sonic-net/SONiC#1020

**Why I did it?**
FlexCounter class is a representation of flex counter group which supports querying multiple types of statistic/attributes. It supports multiple statistic/attribute types such as port counter, port debug counter, queue counter, queue attribute and so on. For each statistic/attribute type, it defines several member functions:

- setXXXCounterList: e.g. setPortCounterList, setPortDebugCounterList
- removeXXX: e.g. removePort, removeQueue
- collectXXXCounters: e.g. collectPortCounters, collectQueueCounters
- collectXXXAttr: e.g. collectQueueAttrs, collectPriorityGroupAttrs
- so on
- 
For different statistic/attribute types, these functions have very similar logic. This PR moved similar logic to single place to avoid redundant code.

**How I test it?**

Almost full unit test coverage of newly added code.
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
HLD: sonic-net/SONiC#1020

**Why I did it?**
FlexCounter class is a representation of flex counter group which supports querying multiple types of statistic/attributes. It supports multiple statistic/attribute types such as port counter, port debug counter, queue counter, queue attribute and so on. For each statistic/attribute type, it defines several member functions:

- setXXXCounterList: e.g. setPortCounterList, setPortDebugCounterList
- removeXXX: e.g. removePort, removeQueue
- collectXXXCounters: e.g. collectPortCounters, collectQueueCounters
- collectXXXAttr: e.g. collectQueueAttrs, collectPriorityGroupAttrs
- so on
- 
For different statistic/attribute types, these functions have very similar logic. This PR moved similar logic to single place to avoid redundant code.

**How I test it?**

Almost full unit test coverage of newly added code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants