Skip to content

Commit 2deb6e0

Browse files
[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.
1 parent 4cc1d1f commit 2deb6e0

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

orchagent/orch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin
557557

558558
void Orch::addConsumer(DBConnector *db, string tableName, int pri)
559559
{
560-
if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB)
560+
if (db->getDbName() == "CONFIG_DB" || db->getDbName() == "STATE_DB")
561561
{
562562
addExecutor(new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this, tableName));
563563
}

orchagent/orch.h

+5
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ class Consumer : public Executor {
136136
return getConsumerTable()->getDbConnector()->getDbId();
137137
}
138138

139+
std::string getDbName() const
140+
{
141+
return getConsumerTable()->getDbConnector()->getDbName();
142+
}
143+
139144
std::string dumpTuple(const swss::KeyOpFieldsValuesTuple &tuple);
140145
void dumpPendingTasks(std::vector<std::string> &ts);
141146

orchagent/pfcwdorch.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void PfcWdOrch<DropHandler, ForwardHandler>::doTask(Consumer& consumer)
5959
return;
6060
}
6161

62-
if ((consumer.getDbId() == CONFIG_DB) && (consumer.getTableName() == CFG_PFC_WD_TABLE_NAME))
62+
if ((consumer.getDbName() == "CONFIG_DB") && (consumer.getTableName() == CFG_PFC_WD_TABLE_NAME))
6363
{
6464
auto it = consumer.m_toSync.begin();
6565
while (it != consumer.m_toSync.end())
@@ -761,7 +761,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::doTask(Consumer& consumer)
761761
return;
762762
}
763763

764-
if ((consumer.getDbId() == APPL_DB) && (consumer.getTableName() == APP_PFC_WD_TABLE_NAME))
764+
if ((consumer.getDbName() == "APPL_DB") && (consumer.getTableName() == APP_PFC_WD_TABLE_NAME))
765765
{
766766
auto it = consumer.m_toSync.begin();
767767
while (it != consumer.m_toSync.end())

0 commit comments

Comments
 (0)