Skip to content

Commit

Permalink
delay counters by 60 sec
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak committed Nov 12, 2024
1 parent 1536dfb commit 97e081f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
Binary file added cfgmgr/fabricmgrd
Binary file not shown.
20 changes: 20 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ extern CoppOrch *gCoppOrch;
extern FlowCounterRouteOrch *gFlowCounterRouteOrch;
extern sai_object_id_t gSwitchId;

#define FLEX_COUNTER_DELAY_SEC 60

#define BUFFER_POOL_WATERMARK_KEY "BUFFER_POOL_WATERMARK"
#define PORT_KEY "PORT"
#define PORT_BUFFER_DROP_KEY "PORT_BUFFER_DROP"
Expand Down Expand Up @@ -71,6 +73,10 @@ FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector<string> &tableNames):
m_deviceMetadataConfigTable(db, CFG_DEVICE_METADATA_TABLE_NAME)
{
SWSS_LOG_ENTER();
m_delayTimer = new SelectableTimer(timespec{.tv_sec = FLEX_COUNTER_DELAY_SEC, .tv_nsec = 0});
auto executor = new ExecutableTimer(m_delayTimer, this, "FLEX_COUNTER_DELAY");
Orch::addExecutor(executor);
m_delayTimer->start();
}

FlexCounterOrch::~FlexCounterOrch(void)
Expand All @@ -82,6 +88,11 @@ void FlexCounterOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!m_delayTimerExpired)
{
return;
}

VxlanTunnelOrch* vxlan_tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();
if (gPortsOrch && !gPortsOrch->allPortsReady())
{
Expand Down Expand Up @@ -239,6 +250,15 @@ void FlexCounterOrch::doTask(Consumer &consumer)
}
}

void FlexCounterOrch::doTask(SelectableTimer &timer)
{
SWSS_LOG_ENTER();

SWSS_LOG_NOTICE("Processing counters");
m_delayTimer->stop();
m_delayTimerExpired = true;
}

bool FlexCounterOrch::getPortCountersState() const
{
return m_port_counter_enabled;
Expand Down
4 changes: 4 additions & 0 deletions orchagent/flexcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "orch.h"
#include "port.h"
#include "producertable.h"
#include "selectabletimer.h"
#include "table.h"

extern "C" {
Expand Down Expand Up @@ -40,6 +41,7 @@ class FlexCounterOrch: public Orch
{
public:
void doTask(Consumer &consumer);
void doTask(SelectableTimer &timer);
FlexCounterOrch(swss::DBConnector *db, std::vector<std::string> &tableNames);
virtual ~FlexCounterOrch(void);
bool getPortCountersState() const;
Expand All @@ -63,9 +65,11 @@ class FlexCounterOrch: public Orch
bool m_pg_watermark_enabled = false;
bool m_hostif_trap_counter_enabled = false;
bool m_route_flow_counter_enabled = false;
bool m_delayTimerExpired = false;
Table m_bufferQueueConfigTable;
Table m_bufferPgConfigTable;
Table m_deviceMetadataConfigTable;
SelectableTimer* m_delayTimer;
};

#endif
4 changes: 4 additions & 0 deletions orchagent/p4orch/tests/fake_flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ void FlexCounterOrch::doTask(Consumer &consumer)
{
}

void FlexCounterOrch::doTask(SelectableTimer &timer)
{
}

bool FlexCounterOrch::getPortCountersState() const
{
return true;
Expand Down
1 change: 1 addition & 0 deletions tests/mock_tests/flexcounter_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ namespace flexcounter_test
CFG_FLEX_COUNTER_TABLE_NAME
};
auto* flexCounterOrch = new FlexCounterOrch(m_config_db.get(), flex_counter_tables);
flexCounterOrch->m_delayTimerExpired = true;
gDirectory.set(flexCounterOrch);

vector<string> buffer_tables = { APP_BUFFER_POOL_TABLE_NAME,
Expand Down
1 change: 1 addition & 0 deletions tests/mock_tests/flowcounterrouteorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ namespace flowcounterrouteorch_test
CFG_FLEX_COUNTER_TABLE_NAME
};
auto* flexCounterOrch = new FlexCounterOrch(m_config_db.get(), flex_counter_tables);
flexCounterOrch->m_delayTimerExpired = true;
gDirectory.set(flexCounterOrch);

ASSERT_EQ(gPortsOrch, nullptr);
Expand Down

0 comments on commit 97e081f

Please sign in to comment.