From 368e1d62674ff511b241f10ea8e0933398a357bd Mon Sep 17 00:00:00 2001 From: PanXuntao <46553235+Pan-XT@users.noreply.github.com> Date: Fri, 1 Nov 2024 23:37:07 +0800 Subject: [PATCH] [MultiDB]:sonic-swss replace old API with new APIs (#3292) Replace DBConnector old APIs with new APIs to enable Multi DB I implemented similar changes in #1138 --- fdbsyncd/fdbsyncd.cpp | 6 +++--- gearsyncd/gearparserbase.cpp | 2 +- gearsyncd/gearsyncd.cpp | 4 ++-- orchagent/portsorch.cpp | 2 +- orchagent/switchorch.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fdbsyncd/fdbsyncd.cpp b/fdbsyncd/fdbsyncd.cpp index 4f9405cbfd..70bff7b79f 100644 --- a/fdbsyncd/fdbsyncd.cpp +++ b/fdbsyncd/fdbsyncd.cpp @@ -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); diff --git a/gearsyncd/gearparserbase.cpp b/gearsyncd/gearparserbase.cpp index c6cae36253..e86e34e10c 100644 --- a/gearsyncd/gearparserbase.cpp +++ b/gearsyncd/gearparserbase.cpp @@ -24,7 +24,7 @@ GearParserBase::init() { m_writeToDb = false; m_rootInit = false; - m_applDb = std::unique_ptr{new swss::DBConnector(APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0)}; + m_applDb = std::unique_ptr{new swss::DBConnector("APPL_DB", 0)}; m_producerStateTable = std::unique_ptr{new swss::ProducerStateTable(m_applDb.get(), APP_GEARBOX_TABLE_NAME)}; } diff --git a/gearsyncd/gearsyncd.cpp b/gearsyncd/gearsyncd.cpp index f79b079d82..55b6eca0a3 100644 --- a/gearsyncd/gearsyncd.cpp +++ b/gearsyncd/gearsyncd.cpp @@ -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"); diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index ba5336b063..7c3be48d20 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -9094,7 +9094,7 @@ bool PortsOrch::addSystemPorts() vector keys; vector 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 diff --git a/orchagent/switchorch.cpp b/orchagent/switchorch.cpp index b8e0090259..64442c96af 100644 --- a/orchagent/switchorch.cpp +++ b/orchagent/switchorch.cpp @@ -120,10 +120,10 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector& 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");