Skip to content

Commit

Permalink
[MultiDB] Use database name instead of database ID (sonic-net#1303)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rajendra-dendukuri authored Jun 9, 2020
1 parent 4cc1d1f commit 2deb6e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
5 changes: 5 additions & 0 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> &ts);

Expand Down
4 changes: 2 additions & 2 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void PfcWdOrch<DropHandler, ForwardHandler>::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())
Expand Down Expand Up @@ -761,7 +761,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::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())
Expand Down

0 comments on commit 2deb6e0

Please sign in to comment.