diff --git a/mclagsyncd/mclaglink.cpp b/mclagsyncd/mclaglink.cpp index 857f95f410..3daf0cb746 100644 --- a/mclagsyncd/mclaglink.cpp +++ b/mclagsyncd/mclaglink.cpp @@ -38,7 +38,7 @@ using namespace std; void MclagLink::getOidToPortNameMap(std::unordered_map & port_map) { std::unordered_map::iterator it; - auto hash = p_redisClient_to_counters->hgetall("COUNTERS_PORT_NAME_MAP"); + auto hash = p_counters_db->hgetall("COUNTERS_PORT_NAME_MAP"); for (it = hash.begin(); it != hash.end(); ++it) port_map.insert(pair(it->second, it->first)); @@ -53,14 +53,14 @@ void MclagLink::getBridgePortIdToAttrPortIdMap(std::map::iterator attr_port_id; - auto keys = p_redisClient_to_asic->keys("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:*"); + auto keys = p_asic_db->keys("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:*"); for (auto& key : keys) { pos1 = key.find("oid:", 0); bridge_port_id = key.substr(pos1); - auto hash = p_redisClient_to_asic->hgetall(key); + auto hash = p_asic_db->hgetall(key); attr_port_id = hash.find("SAI_BRIDGE_PORT_ATTR_PORT_ID"); if (attr_port_id == hash.end()) { @@ -81,7 +81,7 @@ void MclagLink::getVidByBvid(std::string &bvid, std::string &vlanid) std::string pre = "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:"; std::string key = pre + bvid; - auto hash = p_redisClient_to_asic->hgetall(key.c_str()); + auto hash = p_asic_db->hgetall(key.c_str()); attr_vlan_id = hash.find("SAI_VLAN_ATTR_VLAN_ID"); if (attr_vlan_id == hash.end()) @@ -109,7 +109,7 @@ void MclagLink::getFdbSet(std::set *fdb_set) std::map::iterator brPortId_to_attrPortId_it; std::unordered_map::iterator oid_to_portName_it; - auto keys = p_redisClient_to_asic->keys("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*"); + auto keys = p_asic_db->keys("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*"); for (auto& key : keys) { @@ -136,7 +136,7 @@ void MclagLink::getFdbSet(std::set *fdb_set) mac = key.substr(pos1, pos2 - pos1 + 1); /*get type*/ - auto hash = p_redisClient_to_asic->hgetall(key); + auto hash = p_asic_db->hgetall(key); type_it = hash.find("SAI_FDB_ENTRY_ATTR_TYPE"); if (type_it == hash.end()) { diff --git a/mclagsyncd/mclaglink.h b/mclagsyncd/mclaglink.h index c33eec98b6..e1b6ae5678 100644 --- a/mclagsyncd/mclaglink.h +++ b/mclagsyncd/mclaglink.h @@ -102,8 +102,8 @@ class MclagLink : public Selectable { ProducerStateTable *p_acl_table_tbl; ProducerStateTable *p_acl_rule_tbl; DBConnector *p_appl_db; - RedisClient *p_redisClient_to_asic;/*redis client access to ASIC_DB*/ - RedisClient *p_redisClient_to_counters;/*redis client access to COUNTERS_DB*/ + DBConnector *p_asic_db; /*redis client access to ASIC_DB*/ + DBConnector *p_counters_db; /*redis client access to COUNTERS_DB*/ std::set *p_old_fdb; MclagLink(uint16_t port = MCLAG_DEFAULT_PORT); diff --git a/mclagsyncd/mclagsyncd.cpp b/mclagsyncd/mclagsyncd.cpp index 5f45750ca7..df65896b0c 100644 --- a/mclagsyncd/mclagsyncd.cpp +++ b/mclagsyncd/mclagsyncd.cpp @@ -41,8 +41,6 @@ int main(int argc, char **argv) ProducerStateTable fdb_tbl(&appl_db, APP_FDB_TABLE_NAME); ProducerStateTable acl_table_tbl(&appl_db, APP_ACL_TABLE_TABLE_NAME); ProducerStateTable acl_rule_tbl(&appl_db, APP_ACL_RULE_TABLE_NAME); - RedisClient redisClient_to_asicDb(&asic_db); - RedisClient redisClient_to_countersDb(&counters_db); map isolate; RedisPipeline pipeline(&appl_db); set old_fdb; @@ -62,8 +60,8 @@ int main(int argc, char **argv) mclag.p_acl_table_tbl = &acl_table_tbl; mclag.p_acl_rule_tbl = &acl_rule_tbl; mclag.p_appl_db = &appl_db; - mclag.p_redisClient_to_asic = &redisClient_to_asicDb; - mclag.p_redisClient_to_counters = &redisClient_to_countersDb; + mclag.p_asic_db = &asic_db; + mclag.p_counters_db = &counters_db; mclag.p_old_fdb = &old_fdb; cout << "Waiting for connection..." << endl; diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 602864d8bd..ebfd913f56 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -39,8 +39,7 @@ BufferOrch::BufferOrch(DBConnector *db, vector &tableNames) : m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)), m_flexCounterTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_TABLE)), m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)), - m_countersDb(new DBConnector("COUNTERS_DB", 0)), - m_countersDbRedisClient(m_countersDb.get()) + m_countersDb(new DBConnector("COUNTERS_DB", 0)) { SWSS_LOG_ENTER(); initTableHandlers(); @@ -358,7 +357,7 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer) // Specifically, we push the buffer pool name to oid mapping upon the creation of the oid // In pg and queue case, this mapping installment is deferred to FlexCounterOrch at a reception of field // "FLEX_COUNTER_STATUS" - m_countersDbRedisClient.hset(COUNTERS_BUFFER_POOL_NAME_MAP, object_name, sai_serialize_object_id(sai_object)); + m_countersDb->hset(COUNTERS_BUFFER_POOL_NAME_MAP, object_name, sai_serialize_object_id(sai_object)); } } else if (op == DEL_COMMAND) @@ -372,7 +371,7 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer) SWSS_LOG_NOTICE("Removed buffer pool %s with type %s", object_name.c_str(), map_type_name.c_str()); auto it_to_delete = (m_buffer_type_maps[map_type_name])->find(object_name); (m_buffer_type_maps[map_type_name])->erase(it_to_delete); - m_countersDbRedisClient.hdel(COUNTERS_BUFFER_POOL_NAME_MAP, object_name); + m_countersDb->hdel(COUNTERS_BUFFER_POOL_NAME_MAP, object_name); } else { diff --git a/orchagent/bufferorch.h b/orchagent/bufferorch.h index bbc3448376..547889481f 100644 --- a/orchagent/bufferorch.h +++ b/orchagent/bufferorch.h @@ -64,7 +64,6 @@ class BufferOrch : public Orch unique_ptr m_flexCounterTable; unique_ptr m_countersDb; - RedisClient m_countersDbRedisClient; bool m_isBufferPoolWatermarkCounterIdListGenerated = false; }; diff --git a/orchagent/countercheckorch.cpp b/orchagent/countercheckorch.cpp index 097a3a93ff..fe2865fc78 100644 --- a/orchagent/countercheckorch.cpp +++ b/orchagent/countercheckorch.cpp @@ -193,13 +193,12 @@ QueueMcCounters CounterCheckOrch::getQueueMcCounters( vector fieldValues; QueueMcCounters counters; - RedisClient redisClient(m_countersDb.get()); for (uint8_t prio = 0; prio < port.m_queue_ids.size(); prio++) { sai_object_id_t queueId = port.m_queue_ids[prio]; auto queueIdStr = sai_serialize_object_id(queueId); - auto queueType = redisClient.hget(COUNTERS_QUEUE_TYPE_MAP, queueIdStr); + auto queueType = m_countersDb->hget(COUNTERS_QUEUE_TYPE_MAP, queueIdStr); if (queueType.get() == nullptr || *queueType != "SAI_QUEUE_TYPE_MULTICAST" || !m_countersTable->get(queueIdStr, fieldValues)) { diff --git a/orchagent/pfcwdorch.cpp b/orchagent/pfcwdorch.cpp index dec47d30f8..af27fb7b87 100644 --- a/orchagent/pfcwdorch.cpp +++ b/orchagent/pfcwdorch.cpp @@ -364,9 +364,8 @@ void PfcWdSwOrch::disableBigRedSwitchMode() } auto queueId = entry.first; - RedisClient redisClient(this->getCountersDb().get()); string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + sai_serialize_object_id(queueId); - redisClient.hdel(countersKey, "BIG_RED_SWITCH_MODE"); + this->getCountersDb()->hdel(countersKey, "BIG_RED_SWITCH_MODE"); } m_brsEntryMap.clear(); @@ -633,9 +632,8 @@ void PfcWdSwOrch::unregisterFromWdDb(const Port& po m_entryMap.erase(queueId); // Clean up - RedisClient redisClient(this->getCountersDb().get()); string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + sai_serialize_object_id(queueId); - redisClient.hdel(countersKey, {"PFC_WD_DETECTION_TIME", "PFC_WD_RESTORATION_TIME", "PFC_WD_ACTION", "PFC_WD_STATUS"}); + this->getCountersDb()->hdel(countersKey, {"PFC_WD_DETECTION_TIME", "PFC_WD_RESTORATION_TIME", "PFC_WD_ACTION", "PFC_WD_STATUS"}); } } @@ -657,8 +655,7 @@ PfcWdSwOrch::PfcWdSwOrch( c_queueAttrIds(queueAttrIds), m_pollInterval(pollInterval), m_applDb(make_shared("APPL_DB", 0)), - m_applTable(make_shared(m_applDb.get(), APP_PFC_WD_TABLE_NAME "_INSTORM")), - m_applDbRedisClient(m_applDb.get()) + m_applTable(make_shared
(m_applDb.get(), APP_PFC_WD_TABLE_NAME "_INSTORM")) { SWSS_LOG_ENTER(); @@ -934,7 +931,7 @@ bool PfcWdSwOrch::startWdActionOnQueue(const string entry->second.handler->initCounters(); // Log storm event to APPL_DB for warm-reboot purpose string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias; - m_applDbRedisClient.hset(key, to_string(entry->second.index), PFC_WD_IN_STORM); + m_applDb->hset(key, to_string(entry->second.index), PFC_WD_IN_STORM); } } else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_DROP) @@ -956,7 +953,7 @@ bool PfcWdSwOrch::startWdActionOnQueue(const string entry->second.handler->initCounters(); // Log storm event to APPL_DB for warm-reboot purpose string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias; - m_applDbRedisClient.hset(key, to_string(entry->second.index), PFC_WD_IN_STORM); + m_applDb->hset(key, to_string(entry->second.index), PFC_WD_IN_STORM); } } else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_FORWARD) @@ -978,7 +975,7 @@ bool PfcWdSwOrch::startWdActionOnQueue(const string entry->second.handler->initCounters(); // Log storm event to APPL_DB for warm-reboot purpose string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias; - m_applDbRedisClient.hset(key, to_string(entry->second.index), PFC_WD_IN_STORM); + m_applDb->hset(key, to_string(entry->second.index), PFC_WD_IN_STORM); } } else @@ -1002,7 +999,7 @@ bool PfcWdSwOrch::startWdActionOnQueue(const string entry->second.handler = nullptr; // Remove storm status in APPL_DB for warm-reboot purpose string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias; - m_applDbRedisClient.hdel(key, to_string(entry->second.index)); + m_applDb->hdel(key, to_string(entry->second.index)); } } else @@ -1019,8 +1016,6 @@ bool PfcWdSwOrch::bake() { // clean all *_last and *_LEFT fields in COUNTERS_TABLE // to allow warm-reboot pfc detect & restore state machine to enter the same init state as cold-reboot - RedisClient redisClient(this->getCountersDb().get()); - vector cKeys; this->getCountersTable()->getKeys(cKeys); for (const auto &key : cKeys) @@ -1037,7 +1032,7 @@ bool PfcWdSwOrch::bake() } if (!wLasts.empty()) { - redisClient.hdel( + this->getCountersDb()->hdel( this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + key, diff --git a/orchagent/pfcwdorch.h b/orchagent/pfcwdorch.h index c051bc69ac..a86132fe49 100644 --- a/orchagent/pfcwdorch.h +++ b/orchagent/pfcwdorch.h @@ -135,8 +135,6 @@ class PfcWdSwOrch: public PfcWdOrch shared_ptr m_applDb = nullptr; // Track queues in storm shared_ptr
m_applTable = nullptr; - // used for hset and hdel - RedisClient m_applDbRedisClient; }; #endif diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index ce86371da6..5ceed76760 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1894,8 +1894,7 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id) port_stat_manager.clearCounterIdList(p.m_port_id); /* remove port name map from counter table */ - RedisClient redisClient(m_counter_db.get()); - redisClient.hdel(COUNTERS_PORT_NAME_MAP, alias); + m_counter_db->hdel(COUNTERS_PORT_NAME_MAP, alias); m_portList[alias].m_init = false; SWSS_LOG_NOTICE("De-Initialized port %s", alias.c_str());