Skip to content

Commit

Permalink
fix logic
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
  • Loading branch information
Mykola Faryma committed Mar 18, 2019
1 parent 0fcd994 commit 5a119d2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
24 changes: 15 additions & 9 deletions orchagent/watermarkorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,27 @@ void WatermarkOrch::handleWmConfigUpdate(const std::string &key, const std::vect

void WatermarkOrch::handleFcConfigUpdate(const std::string &key, const std::vector<FieldValueTuple> &fvt)
{

if (key == "QUEUE_WATERMARK" || key == "PG_WATERMARK")
{
for (std::pair<std::basic_string<char>, std::basic_string<char> > i: fvt)
{
if (i.first == "FLEX_COUNTER_STATUS" && i.second == "enable" && m_isTimerEnabled == false)
{
m_telemetryTimer->start();
m_isTimerEnabled = true;
}
else if (i.first == "FLEX_COUNTER_STATUS" && i.second == "disable" && m_isTimerEnabled == true)
if (i.first == "FLEX_COUNTER_STATUS")
{
/* no need to stop timer here - it won't be reset after end of this interval */
m_isTimerEnabled = false;
if (key == "QUEUE_WATERMARK")
{
m_qWmEnabled = (i.second == "enable");
}
else if (key == "PG_WATERMARK")
{
m_pgWmEnabled = (i.second == "enable");
}
}
}
if (isTimerEnabled())
{
m_telemetryTimer->start();
}
}
}

Expand Down Expand Up @@ -203,7 +209,7 @@ void WatermarkOrch::doTask(SelectableTimer &timer)
{
/* Timer is only running when the watermark polling is on *
* if it is disabled we will not restart the timer at the end of current interval */
if (m_isTimerEnabled)
if (isTimerEnabled())
{
m_telemetryTimer->reset();
}
Expand Down
8 changes: 7 additions & 1 deletion orchagent/watermarkorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ class WatermarkOrch : public Orch
return m_countersDb;
}

bool isTimerEnabled()
{
return m_qWmEnabled || m_pgWmEnabled;
}

private:
bool m_isTimerEnabled = false;
bool m_qWmEnabled = false;
bool m_pgWmEnabled = false;

shared_ptr<DBConnector> m_countersDb = nullptr;
shared_ptr<DBConnector> m_appDb = nullptr;
Expand Down

0 comments on commit 5a119d2

Please sign in to comment.