-
Notifications
You must be signed in to change notification settings - Fork 692
[flexcounter]: add support to change port/queue counter poll interval #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #include <unordered_map> | ||
| #include "flexcounterorch.h" | ||
| #include "portsorch.h" | ||
| #include "select.h" | ||
| #include "notifier.h" | ||
| #include "redisclient.h" | ||
| #include "sai_serialize.h" | ||
|
|
||
| extern sai_port_api_t *sai_port_api; | ||
|
|
||
| extern PortsOrch *gPortsOrch; | ||
|
|
||
| unordered_map<string, string> flexCounterGroupMap = | ||
| { | ||
| {"PORT", PORT_STAT_COUNTER_FLEX_COUNTER_GROUP}, | ||
| {"QUEUE", QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP}, | ||
| }; | ||
|
|
||
| FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector<string> &tableNames): | ||
| Orch(db, tableNames), | ||
| m_flexCounterDb(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), | ||
| m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)) | ||
| { | ||
| SWSS_LOG_ENTER(); | ||
| } | ||
|
|
||
| FlexCounterOrch::~FlexCounterOrch(void) | ||
| { | ||
| SWSS_LOG_ENTER(); | ||
| } | ||
|
|
||
| void FlexCounterOrch::doTask(Consumer &consumer) | ||
| { | ||
| SWSS_LOG_ENTER(); | ||
|
|
||
| if (!gPortsOrch->isInitDone()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| auto it = consumer.m_toSync.begin(); | ||
| while (it != consumer.m_toSync.end()) | ||
| { | ||
| KeyOpFieldsValuesTuple t = it->second; | ||
|
|
||
| string key = kfvKey(t); | ||
| string op = kfvOp(t); | ||
| auto data = kfvFieldsValues(t); | ||
|
|
||
| if (!flexCounterGroupMap.count(key)) | ||
| { | ||
| SWSS_LOG_NOTICE("Invalid flex counter group input, %s", key.c_str()); | ||
| consumer.m_toSync.erase(it++); | ||
| continue; | ||
| } | ||
|
|
||
| if (op == SET_COMMAND) | ||
| { | ||
| for (auto valuePair:data) | ||
| { | ||
| const auto &field = fvField(valuePair); | ||
| const auto &value = fvValue(valuePair); | ||
|
|
||
| if (field == POLL_INTERVAL_FIELD) | ||
| { | ||
| vector<FieldValueTuple> fieldValues; | ||
| fieldValues.emplace_back(POLL_INTERVAL_FIELD, value); | ||
| m_flexCounterGroupTable->set(flexCounterGroupMap[key], fieldValues); | ||
| } | ||
| /* In future add the support to disable/enable counter query here.*/ | ||
| } | ||
| } | ||
|
|
||
| consumer.m_toSync.erase(it++); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #ifndef FLEXCOUNTER_ORCH_H | ||
| #define FLEXCOUNTER_ORCH_H | ||
|
|
||
| #include "orch.h" | ||
| #include "port.h" | ||
| #include "producertable.h" | ||
|
|
||
| extern "C" { | ||
| #include "sai.h" | ||
| } | ||
|
|
||
| class FlexCounterOrch: public Orch | ||
| { | ||
| public: | ||
| void doTask(Consumer &consumer); | ||
| FlexCounterOrch(DBConnector *db, vector<string> &tableNames); | ||
| virtual ~FlexCounterOrch(void); | ||
|
|
||
| private: | ||
| shared_ptr<DBConnector> m_flexCounterDb = nullptr; | ||
| shared_ptr<ProducerTable> m_flexCounterGroupTable = nullptr; | ||
| }; | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IFAIK if nothing is set, the default value of 1 second is used.
Then I think we also have to set the default back if the entry is deleted from DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entry only has set_command and no del command. We can always use set command to change the interval value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok