Skip to content

Commit

Permalink
[MultiDB]:sonic-swss replace old API with new APIs (sonic-net#3292)
Browse files Browse the repository at this point in the history
Replace DBConnector old APIs with new APIs to enable Multi DB

I implemented similar changes in sonic-net#1138
  • Loading branch information
Pan-XT authored Nov 1, 2024
1 parent 9dd2848 commit 368e1d6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions fdbsyncd/fdbsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ int main(int argc, char **argv)
{
Logger::linkToDbNative("fdbsyncd");

DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector appDb("APPL_DB", 0);
RedisPipeline pipelineAppDB(&appDb);
DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector config_db(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector stateDb("STATE_DB", 0);
DBConnector config_db("CONFIG_DB", 0);

FdbSync sync(&pipelineAppDB, &stateDb, &config_db);

Expand Down
2 changes: 1 addition & 1 deletion gearsyncd/gearparserbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GearParserBase::init()
{
m_writeToDb = false;
m_rootInit = false;
m_applDb = std::unique_ptr<swss::DBConnector>{new swss::DBConnector(APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0)};
m_applDb = std::unique_ptr<swss::DBConnector>{new swss::DBConnector("APPL_DB", 0)};
m_producerStateTable = std::unique_ptr<swss::ProducerStateTable>{new swss::ProducerStateTable(m_applDb.get(), APP_GEARBOX_TABLE_NAME)};
}

Expand Down
4 changes: 2 additions & 2 deletions gearsyncd/gearsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ int main(int argc, char **argv)
}
}

DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector applDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector cfgDb("CONFIG_DB", 0);
DBConnector applDb("APPL_DB", 0);
ProducerStateTable producerStateTable(&applDb, APP_GEARBOX_TABLE_NAME);

WarmStart::initialize("gearsyncd", "swss");
Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9094,7 +9094,7 @@ bool PortsOrch::addSystemPorts()
vector<string> keys;
vector<FieldValueTuple> spFv;

DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector appDb("APPL_DB", 0);
Table appSystemPortTable(&appDb, APP_SYSTEM_PORT_TABLE_NAME);

//Retrieve system port configurations from APP DB
Expand Down
4 changes: 2 additions & 2 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector<TableConnector>& connectors, Tabl
Orch(connectors),
m_switchTable(switchTable.first, switchTable.second),
m_db(db),
m_stateDb(new DBConnector(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)),
m_stateDb(new DBConnector("STATE_DB", 0)),
m_asicSensorsTable(new Table(m_stateDb.get(), ASIC_TEMPERATURE_INFO_TABLE_NAME)),
m_sensorsPollerTimer (new SelectableTimer((timespec { .tv_sec = DEFAULT_ASIC_SENSORS_POLLER_INTERVAL, .tv_nsec = 0 }))),
m_stateDbForNotification(new DBConnector(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)),
m_stateDbForNotification(new DBConnector("STATE_DB", 0)),
m_asicSdkHealthEventTable(new Table(m_stateDbForNotification.get(), STATE_ASIC_SDK_HEALTH_EVENT_TABLE_NAME))
{
m_restartCheckNotificationConsumer = new NotificationConsumer(db, "RESTARTCHECK");
Expand Down

0 comments on commit 368e1d6

Please sign in to comment.