From 2deb6e09ebca497b94a230d8ea81ed7e5d870bdf Mon Sep 17 00:00:00 2001 From: rajendra-dendukuri <47423477+rajendra-dendukuri@users.noreply.github.com> Date: Tue, 9 Jun 2020 02:13:55 -0400 Subject: [PATCH] [MultiDB] Use database name instead of database ID (#1303) Remove references to hardcoded DB ID in swss as in a MultiDB, the DB Name should always be used to accurately identify the connector's database role. --- orchagent/orch.cpp | 2 +- orchagent/orch.h | 5 +++++ orchagent/pfcwdorch.cpp | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 6dcbc6c3d656..56d96e0367f6 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -557,7 +557,7 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin void Orch::addConsumer(DBConnector *db, string tableName, int pri) { - if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB) + if (db->getDbName() == "CONFIG_DB" || db->getDbName() == "STATE_DB") { addExecutor(new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this, tableName)); } diff --git a/orchagent/orch.h b/orchagent/orch.h index 5622d984cb2a..456885491a1e 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -136,6 +136,11 @@ class Consumer : public Executor { return getConsumerTable()->getDbConnector()->getDbId(); } + std::string getDbName() const + { + return getConsumerTable()->getDbConnector()->getDbName(); + } + std::string dumpTuple(const swss::KeyOpFieldsValuesTuple &tuple); void dumpPendingTasks(std::vector &ts); diff --git a/orchagent/pfcwdorch.cpp b/orchagent/pfcwdorch.cpp index 53625966c04f..dec47d30f8c0 100644 --- a/orchagent/pfcwdorch.cpp +++ b/orchagent/pfcwdorch.cpp @@ -59,7 +59,7 @@ void PfcWdOrch::doTask(Consumer& consumer) return; } - if ((consumer.getDbId() == CONFIG_DB) && (consumer.getTableName() == CFG_PFC_WD_TABLE_NAME)) + if ((consumer.getDbName() == "CONFIG_DB") && (consumer.getTableName() == CFG_PFC_WD_TABLE_NAME)) { auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) @@ -761,7 +761,7 @@ void PfcWdSwOrch::doTask(Consumer& consumer) return; } - if ((consumer.getDbId() == APPL_DB) && (consumer.getTableName() == APP_PFC_WD_TABLE_NAME)) + if ((consumer.getDbName() == "APPL_DB") && (consumer.getTableName() == APP_PFC_WD_TABLE_NAME)) { auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end())