From 4bcc4ad8d9d0570a37cf0cb2c93e320feaee1472 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Tue, 16 Aug 2016 14:26:01 -0700 Subject: [PATCH] portsorch: Writing the port name map into the counter table --- orchagent/portsorch.cpp | 13 +++++++++++++ orchagent/portsorch.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 6951a5a5318..d0d8b85e27a 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -8,6 +8,7 @@ #include "net/if.h" #include "logger.h" +#include "schema.h" extern sai_switch_api_t *sai_switch_api; extern sai_port_api_t *sai_port_api; @@ -23,6 +24,10 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : { SWSS_LOG_ENTER(); + /* Initialize Counter Table */ + DBConnector *counter_db = new DBConnector(COUNTERS_DB, "localhost", 6379, 0); + m_counterTable = new Table(counter_db, COUNTERS_PORT_NAME_MAP); + int i, j; sai_status_t status; sai_attribute_t attr; @@ -244,6 +249,14 @@ void PortsOrch::doPortTask(Consumer &consumer) { /* Add port to port list */ m_portList[alias] = p; + /* Add port name map to counter table */ + std::stringstream ss; + ss << hex << p.m_port_id; + FieldValueTuple tuple(p.m_alias, ss.str()); + vector vector; + vector.push_back(tuple); + m_counterTable->set("", vector); + SWSS_LOG_NOTICE("Port is initialized alias:%s\n", alias.c_str()); } diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index e9d94576a2e..6804afb5bd2 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -19,6 +19,8 @@ class PortsOrch : public Orch void setPort(string alias, Port port); private: + Table *m_counterTable; + bool m_initDone = false; sai_object_id_t m_cpuPort;