diff --git a/cfgmgr/buffermgrd.cpp b/cfgmgr/buffermgrd.cpp index ac59b87bd85c..9bce96f19c44 100644 --- a/cfgmgr/buffermgrd.cpp +++ b/cfgmgr/buffermgrd.cpp @@ -78,8 +78,8 @@ int main(int argc, char **argv) CFG_PORT_CABLE_LEN_TABLE_NAME, }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector stateDb("STATE_DB", 0); BufferMgr buffmgr(&cfgDb, &stateDb, pg_lookup_file, cfg_buffer_tables); diff --git a/cfgmgr/intfmgrd.cpp b/cfgmgr/intfmgrd.cpp index 891373dcc7dc..d184b66e4a5a 100644 --- a/cfgmgr/intfmgrd.cpp +++ b/cfgmgr/intfmgrd.cpp @@ -48,9 +48,9 @@ int main(int argc, char **argv) CFG_VLAN_SUB_INTF_TABLE_NAME, }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); IntfMgr intfmgr(&cfgDb, &appDb, &stateDb, cfg_intf_tables); diff --git a/cfgmgr/nbrmgrd.cpp b/cfgmgr/nbrmgrd.cpp index fc2ed2158d38..d9b68290368f 100644 --- a/cfgmgr/nbrmgrd.cpp +++ b/cfgmgr/nbrmgrd.cpp @@ -49,9 +49,9 @@ int main(int argc, char **argv) CFG_NEIGH_TABLE_NAME, }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); NbrMgr nbrmgr(&cfgDb, &appDb, &stateDb, cfg_nbr_tables); diff --git a/cfgmgr/portmgrd.cpp b/cfgmgr/portmgrd.cpp index d96ac4e9620f..b0f0c887ddf2 100644 --- a/cfgmgr/portmgrd.cpp +++ b/cfgmgr/portmgrd.cpp @@ -44,9 +44,9 @@ int main(int argc, char **argv) CFG_PORT_TABLE_NAME, }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); PortMgr portmgr(&cfgDb, &appDb, &stateDb, cfg_port_tables); diff --git a/cfgmgr/sflowmgrd.cpp b/cfgmgr/sflowmgrd.cpp index 343f0ead0acf..0436ad5f0042 100644 --- a/cfgmgr/sflowmgrd.cpp +++ b/cfgmgr/sflowmgrd.cpp @@ -46,8 +46,8 @@ int main(int argc, char **argv) CFG_PORT_TABLE_NAME }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); SflowMgr sflowmgr(&cfgDb, &appDb, cfg_sflow_tables); diff --git a/cfgmgr/teammgrd.cpp b/cfgmgr/teammgrd.cpp index bac429e0a335..6217a0a21a2f 100644 --- a/cfgmgr/teammgrd.cpp +++ b/cfgmgr/teammgrd.cpp @@ -26,9 +26,9 @@ int main(int argc, char **argv) try { - DBConnector conf_db(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector app_db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector conf_db("CONFIG_DB", 0); + DBConnector app_db("APPL_DB", 0); + DBConnector state_db("STATE_DB", 0); WarmStart::initialize("teammgrd", "teamd"); WarmStart::checkWarmStart("teammgrd", "teamd"); diff --git a/cfgmgr/vlanmgrd.cpp b/cfgmgr/vlanmgrd.cpp index a2bafe02848e..88e4745758ba 100644 --- a/cfgmgr/vlanmgrd.cpp +++ b/cfgmgr/vlanmgrd.cpp @@ -53,9 +53,9 @@ int main(int argc, char **argv) CFG_VLAN_MEMBER_TABLE_NAME, }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); WarmStart::initialize("vlanmgrd", "swss"); WarmStart::checkWarmStart("vlanmgrd", "swss"); diff --git a/cfgmgr/vrfmgrd.cpp b/cfgmgr/vrfmgrd.cpp index dc01641002be..6a347896b330 100644 --- a/cfgmgr/vrfmgrd.cpp +++ b/cfgmgr/vrfmgrd.cpp @@ -45,9 +45,9 @@ int main(int argc, char **argv) CFG_VNET_TABLE_NAME, }; - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); VrfMgr vrfmgr(&cfgDb, &appDb, &stateDb, cfg_vrf_tables); diff --git a/cfgmgr/vxlanmgrd.cpp b/cfgmgr/vxlanmgrd.cpp index 3acd88bdfe87..8e86cfbe4976 100644 --- a/cfgmgr/vxlanmgrd.cpp +++ b/cfgmgr/vxlanmgrd.cpp @@ -45,9 +45,9 @@ int main(int argc, char **argv) try { - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); vector cfg_vnet_tables = { CFG_VNET_TABLE_NAME, diff --git a/fpmsyncd/fpmsyncd.cpp b/fpmsyncd/fpmsyncd.cpp index 8040a7ecb47e..59427bf1fa6e 100644 --- a/fpmsyncd/fpmsyncd.cpp +++ b/fpmsyncd/fpmsyncd.cpp @@ -47,11 +47,11 @@ static bool eoiuFlagsSet(Table &bgpStateTable) int main(int argc, char **argv) { swss::Logger::linkToDbNative("fpmsyncd"); - DBConnector db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector db("APPL_DB", 0); RedisPipeline pipeline(&db); RouteSync sync(&pipeline); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector stateDb("STATE_DB", 0); Table bgpStateTable(&stateDb, STATE_BGP_TABLE_NAME); NetDispatcher::getInstance().registerMessageHandler(RTM_NEWROUTE, &sync); diff --git a/neighsyncd/neighsyncd.cpp b/neighsyncd/neighsyncd.cpp index ad3f9bc06512..c14380fb3ac5 100644 --- a/neighsyncd/neighsyncd.cpp +++ b/neighsyncd/neighsyncd.cpp @@ -15,9 +15,9 @@ int main(int argc, char **argv) { Logger::linkToDbNative("neighsyncd"); - 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 stateDb("STATE_DB", 0); NeighSync sync(&pipelineAppDB, &stateDb); diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index fbafdecb37a3..b12644efd213 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -22,7 +22,7 @@ bool AclOrch::m_bCollectCounters = true; sai_uint32_t AclRule::m_minPriority = 0; sai_uint32_t AclRule::m_maxPriority = 0; -swss::DBConnector AclOrch::m_db(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); +swss::DBConnector AclOrch::m_db("COUNTERS_DB", 0); swss::Table AclOrch::m_countersTable(&m_db, "COUNTERS"); extern sai_acl_api_t* sai_acl_api; diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index ee1de1899d40..5465d6a6bd08 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -36,10 +36,10 @@ type_map BufferOrch::m_buffer_type_maps = { BufferOrch::BufferOrch(DBConnector *db, vector &tableNames) : Orch(db, tableNames), - m_flexCounterDb(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)), m_flexCounterTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_TABLE)), m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)), - m_countersDb(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_countersDb(new DBConnector("COUNTERS_DB", 0)), m_countersDbRedisClient(m_countersDb.get()) { SWSS_LOG_ENTER(); diff --git a/orchagent/countercheckorch.cpp b/orchagent/countercheckorch.cpp index 68edb69e2042..097a3a93ffd6 100644 --- a/orchagent/countercheckorch.cpp +++ b/orchagent/countercheckorch.cpp @@ -24,7 +24,7 @@ CounterCheckOrch& CounterCheckOrch::getInstance(DBConnector *db) CounterCheckOrch::CounterCheckOrch(DBConnector *db, vector &tableNames): Orch(db, tableNames), - m_countersDb(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_countersDb(new DBConnector("COUNTERS_DB", 0)), m_countersTable(new Table(m_countersDb.get(), COUNTERS_TABLE)) { SWSS_LOG_ENTER(); diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index 03dcea26dd48..537d6370638d 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -151,7 +151,7 @@ const map crmUsedCntsTableMap = CrmOrch::CrmOrch(DBConnector *db, string tableName): Orch(db, tableName), - m_countersDb(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_countersDb(new DBConnector("COUNTERS_DB", 0)), m_countersCrmTable(new Table(m_countersDb.get(), COUNTERS_CRM_TABLE)), m_timer(new SelectableTimer(timespec { .tv_sec = CRM_POLLING_INTERVAL_DEFAULT, .tv_nsec = 0 })) { diff --git a/orchagent/debugcounterorch.cpp b/orchagent/debugcounterorch.cpp index 8c989e6aa025..b70c6625c6ea 100644 --- a/orchagent/debugcounterorch.cpp +++ b/orchagent/debugcounterorch.cpp @@ -26,9 +26,9 @@ static const unordered_map flex_counter_type_lookup = { DebugCounterOrch::DebugCounterOrch(DBConnector *db, const vector& table_names, int poll_interval) : Orch(db, table_names), flex_counter_manager(DEBUG_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, poll_interval), - m_stateDb(new DBConnector(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_stateDb(new DBConnector("STATE_DB", 0)), m_debugCapabilitiesTable(new Table(m_stateDb.get(), STATE_DEBUG_COUNTER_CAPABILITIES_NAME)), - m_countersDb(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_countersDb(new DBConnector("COUNTERS_DB", 0)), m_counterNameToPortStatMap(new Table(m_countersDb.get(), COUNTERS_DEBUG_NAME_PORT_STAT_MAP)), m_counterNameToSwitchStatMap(new Table(m_countersDb.get(), COUNTERS_DEBUG_NAME_SWITCH_STAT_MAP)) { @@ -585,4 +585,4 @@ bool DebugCounterOrch::isDropReasonValid(const string& drop_reason) const } return true; -} \ No newline at end of file +} diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index 2c0ff988df81..9a54ba98f1bd 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -32,7 +32,7 @@ FdbOrch::FdbOrch(TableConnector applDbConnector, TableConnector stateDbConnector Orch::addExecutor(flushNotifier); /* Add FDB notifications support from ASIC */ - DBConnector *notificationsDb = new DBConnector(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector *notificationsDb = new DBConnector("ASIC_DB", 0); m_fdbNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS"); auto fdbNotifier = new Notifier(m_fdbNotificationConsumer, this, "FDB_NOTIFICATIONS"); Orch::addExecutor(fdbNotifier); diff --git a/orchagent/flex_counter/flex_counter_manager.cpp b/orchagent/flex_counter/flex_counter_manager.cpp index 0b0eddd8c43b..323bd309c40e 100644 --- a/orchagent/flex_counter/flex_counter_manager.cpp +++ b/orchagent/flex_counter/flex_counter_manager.cpp @@ -45,7 +45,7 @@ FlexCounterManager::FlexCounterManager( stats_mode(stats_mode), polling_interval(polling_interval), enabled(false), - flex_counter_db(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + flex_counter_db(new DBConnector("FLEX_COUNTER_DB", 0)), flex_counter_group_table(new ProducerTable(flex_counter_db.get(), FLEX_COUNTER_GROUP_TABLE)), flex_counter_table(new ProducerTable(flex_counter_db.get(), FLEX_COUNTER_TABLE)) { @@ -222,4 +222,4 @@ string FlexCounterManager::serializeCounterStats( } return stats_string; -} \ No newline at end of file +} diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index c94c1b189116..571b69c50fd8 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -33,7 +33,7 @@ unordered_map flexCounterGroupMap = FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector &tableNames): Orch(db, tableNames), - m_flexCounterDb(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)), m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)) { SWSS_LOG_ENTER(); diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index f54022412957..ddf22404559b 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -55,9 +55,9 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) : SWSS_LOG_ENTER(); /* Initialize DB connectors */ - m_counter_db = shared_ptr(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)); - m_flex_db = shared_ptr(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)); - m_asic_db = shared_ptr(new DBConnector(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)); + m_counter_db = shared_ptr(new DBConnector("COUNTERS_DB", 0)); + m_flex_db = shared_ptr(new DBConnector("FLEX_COUNTER_DB", 0)); + m_asic_db = shared_ptr(new DBConnector("ASIC_DB", 0)); /* Initialize COUNTER_DB tables */ m_rifNameTable = unique_ptr(new Table(m_counter_db.get(), COUNTERS_RIF_NAME_MAP)); m_rifTypeTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_RIF_TYPE_MAP)); diff --git a/orchagent/main.cpp b/orchagent/main.cpp index a0bb8af5245a..a5591b9d0040 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -291,9 +291,9 @@ int main(int argc, char **argv) SWSS_LOG_NOTICE("Created underlay router interface ID %" PRIx64, gUnderlayIfId); /* Initialize orchestration components */ - DBConnector appl_db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector config_db(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector appl_db("APPL_DB", 0); + DBConnector config_db("CONFIG_DB", 0); + DBConnector state_db("STATE_DB", 0); auto orchDaemon = make_shared(&appl_db, &config_db, &state_db); diff --git a/orchagent/orchagent_restart_check.cpp b/orchagent/orchagent_restart_check.cpp index aaf0901427a1..f91f701a53b0 100644 --- a/orchagent/orchagent_restart_check.cpp +++ b/orchagent/orchagent_restart_check.cpp @@ -105,7 +105,7 @@ int main(int argc, char **argv) } } - swss::DBConnector db(APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + swss::DBConnector db("APPL_DB", 0); // Send warm restart query via "RESTARTCHECK" notification channel swss::NotificationProducer restartQuery(&db, "RESTARTCHECK"); // Will listen for the reply on "RESTARTCHECKREPLY" channel diff --git a/orchagent/pfcwdorch.cpp b/orchagent/pfcwdorch.cpp index d6635b49b38f..d9de320527d7 100644 --- a/orchagent/pfcwdorch.cpp +++ b/orchagent/pfcwdorch.cpp @@ -36,7 +36,7 @@ extern PortsOrch *gPortsOrch; template PfcWdOrch::PfcWdOrch(DBConnector *db, vector &tableNames): Orch(db, tableNames), - m_countersDb(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_countersDb(new DBConnector("COUNTERS_DB", 0)), m_countersTable(new Table(m_countersDb.get(), COUNTERS_TABLE)) { SWSS_LOG_ENTER(); @@ -652,14 +652,14 @@ PfcWdSwOrch::PfcWdSwOrch( const vector &queueAttrIds, int pollInterval): PfcWdOrch(db, tableNames), - m_flexCounterDb(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)), m_flexCounterTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_TABLE)), m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)), c_portStatIds(portStatIds), c_queueStatIds(queueStatIds), c_queueAttrIds(queueAttrIds), m_pollInterval(pollInterval), - m_applDb(make_shared(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)), + m_applDb(make_shared("APPL_DB", 0)), m_applTable(make_shared
(m_applDb.get(), APP_PFC_WD_TABLE_NAME "_INSTORM")), m_applDbRedisClient(m_applDb.get()) { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 586a81f755bb..30e93430cab0 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -156,7 +156,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) SWSS_LOG_ENTER(); /* Initialize counter table */ - m_counter_db = shared_ptr(new DBConnector(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)); + m_counter_db = shared_ptr(new DBConnector("COUNTERS_DB", 0)); m_counterTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_PORT_NAME_MAP)); /* Initialize port table */ @@ -173,7 +173,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) m_pgPortTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_PG_PORT_MAP)); m_pgIndexTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_PG_INDEX_MAP)); - m_flex_db = shared_ptr(new DBConnector(FLEX_COUNTER_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)); + m_flex_db = shared_ptr(new DBConnector("FLEX_COUNTER_DB", 0)); m_flexCounterTable = unique_ptr(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_TABLE)); m_flexCounterGroupTable = unique_ptr(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_GROUP_TABLE)); @@ -315,7 +315,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) removeDefaultBridgePorts(); /* Add port oper status notification support */ - DBConnector *notificationsDb = new DBConnector(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector *notificationsDb = new DBConnector("ASIC_DB", 0); m_portStatusNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS"); auto portStatusNotificatier = new Notifier(m_portStatusNotificationConsumer, this, "PORT_STATUS_NOTIFICATIONS"); Orch::addExecutor(portStatusNotificatier); diff --git a/orchagent/routeresync.cpp b/orchagent/routeresync.cpp index 871d1c34e848..477226374b70 100644 --- a/orchagent/routeresync.cpp +++ b/orchagent/routeresync.cpp @@ -19,7 +19,7 @@ int main(int argc, char **argv) SWSS_LOG_ENTER(); - DBConnector db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector db("APPL_DB", 0); ProducerStateTable r(&db, APP_ROUTE_TABLE_NAME); if (argc != 2) diff --git a/orchagent/watermarkorch.cpp b/orchagent/watermarkorch.cpp index 0b8c20e91197..7860ef7cc158 100644 --- a/orchagent/watermarkorch.cpp +++ b/orchagent/watermarkorch.cpp @@ -23,8 +23,8 @@ WatermarkOrch::WatermarkOrch(DBConnector *db, const vector &tables): { SWSS_LOG_ENTER(); - m_countersDb = make_shared(COUNTERS_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - m_appDb = make_shared(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + m_countersDb = make_shared("COUNTERS_DB", 0); + m_appDb = make_shared("APPL_DB", 0); m_countersTable = make_shared
(m_countersDb.get(), COUNTERS_TABLE); m_periodicWatermarkTable = make_shared
(m_countersDb.get(), PERIODIC_WATERMARKS_TABLE); m_persistentWatermarkTable = make_shared
(m_countersDb.get(), PERSISTENT_WATERMARKS_TABLE); diff --git a/portsyncd/portsyncd.cpp b/portsyncd/portsyncd.cpp index 7efec9d58a8e..8d618c80cb21 100644 --- a/portsyncd/portsyncd.cpp +++ b/portsyncd/portsyncd.cpp @@ -65,9 +65,9 @@ int main(int argc, char **argv) } } - DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector appl_db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appl_db("APPL_DB", 0); + DBConnector state_db("STATE_DB", 0); ProducerStateTable p(&appl_db, APP_PORT_TABLE_NAME); SubscriberStateTable portCfg(&cfgDb, CFG_PORT_TABLE_NAME); diff --git a/swssconfig/swssconfig.cpp b/swssconfig/swssconfig.cpp index 02fdaaaa1362..058b83a56b9c 100644 --- a/swssconfig/swssconfig.cpp +++ b/swssconfig/swssconfig.cpp @@ -15,8 +15,6 @@ using namespace std; using namespace swss; using json = nlohmann::json; -int db_port = 6379; -const char* const hostname = "localhost"; const char* const op_name = "OP"; const char* const name_delimiter = ":"; const int el_count = 2; @@ -43,7 +41,7 @@ void dump_db_item(KeyOpFieldsValuesTuple &db_item) bool write_db_data(vector &db_items) { - DBConnector db(APPL_DB, hostname, db_port, 0); + DBConnector db("APPL_DB", 0, true); for (auto &db_item : db_items) { dump_db_item(db_item); diff --git a/swssconfig/swssplayer.cpp b/swssconfig/swssplayer.cpp index a4c0ce5355f4..d999ace999f1 100644 --- a/swssconfig/swssplayer.cpp +++ b/swssconfig/swssplayer.cpp @@ -9,11 +9,8 @@ using namespace std; using namespace swss; -constexpr int DB_PORT = 6379; -constexpr char* DB_HOSTNAME = "localhost"; - static int line_index = 0; -static DBConnector db(APPL_DB, DB_HOSTNAME, DB_PORT, 0); +static DBConnector db("APPL_DB", 0, true); void usage() { diff --git a/teamsyncd/teamsyncd.cpp b/teamsyncd/teamsyncd.cpp index faf3e24f5787..ef368ca691a8 100644 --- a/teamsyncd/teamsyncd.cpp +++ b/teamsyncd/teamsyncd.cpp @@ -12,8 +12,8 @@ using namespace swss; int main(int argc, char **argv) { swss::Logger::linkToDbNative(TEAMSYNCD_APP_NAME); - DBConnector db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector db("APPL_DB", 0); + DBConnector stateDb("STATE_DB", 0); Select s; TeamSync sync(&db, &stateDb, &s); diff --git a/tests/mock_tests/aclorch_ut.cpp b/tests/mock_tests/aclorch_ut.cpp index c6541dbded51..19d52cafbf97 100644 --- a/tests/mock_tests/aclorch_ut.cpp +++ b/tests/mock_tests/aclorch_ut.cpp @@ -98,7 +98,7 @@ namespace aclorch_test AclTest() { - m_config_db = make_shared(CONFIG_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + m_config_db = make_shared("CONFIG_DB", 0); } void SetUp() override @@ -235,9 +235,9 @@ namespace aclorch_test AclOrchTest() { // FIXME: move out from constructor - m_app_db = make_shared(APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); - m_config_db = make_shared(CONFIG_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); - m_state_db = make_shared(STATE_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + m_app_db = make_shared("APPL_DB", 0); + m_config_db = make_shared("CONFIG_DB", 0); + m_state_db = make_shared("STATE_DB", 0); } static map gProfileMap; diff --git a/tests/mock_tests/database_config.json b/tests/mock_tests/database_config.json new file mode 100644 index 000000000000..b86ae11bba98 --- /dev/null +++ b/tests/mock_tests/database_config.json @@ -0,0 +1,57 @@ +{ + "INSTANCES": { + "redis":{ + "hostname" : "127.0.0.1", + "port" : 6379, + "unix_socket_path" : "/var/run/redis/redis.sock" + } + }, + "DATABASES" : { + "APPL_DB" : { + "id" : 0, + "separator": ":", + "instance" : "redis" + }, + "ASIC_DB" : { + "id" : 1, + "separator": ":", + "instance" : "redis" + }, + "COUNTERS_DB" : { + "id" : 2, + "separator": ":", + "instance" : "redis" + }, + "LOGLEVEL_DB" : { + "id" : 3, + "separator": ":", + "instance" : "redis" + }, + "CONFIG_DB" : { + "id" : 4, + "separator": "|", + "instance" : "redis" + }, + "PFC_WD_DB" : { + "id" : 5, + "separator": ":", + "instance" : "redis" + }, + "FLEX_COUNTER_DB" : { + "id" : 5, + "separator": ":", + "instance" : "redis" + }, + "STATE_DB" : { + "id" : 6, + "separator": "|", + "instance" : "redis" + }, + "SNMP_OVERLAY_DB" : { + "id" : 7, + "separator": "|", + "instance" : "redis" + } + }, + "VERSION" : "1.0" +} diff --git a/tests/mock_tests/mock_dbconnector.cpp b/tests/mock_tests/mock_dbconnector.cpp index 6a021e036add..df9b25e179ae 100644 --- a/tests/mock_tests/mock_dbconnector.cpp +++ b/tests/mock_tests/mock_dbconnector.cpp @@ -38,6 +38,28 @@ namespace swss m_conn->fd = socket(AF_UNIX, SOCK_DGRAM, 0); } + DBConnector::DBConnector(const std::string& dbName, unsigned int timeout, bool isTcpConn) + { + if (swss::SonicDBConfig::isInit() == false) + swss::SonicDBConfig::initialize("./database_config.json"); + m_dbId = swss::SonicDBConfig::getDbId(dbName); + if (isTcpConn) + { + m_conn = (redisContext *)calloc(1, sizeof(redisContext)); + m_conn->connection_type = REDIS_CONN_TCP; + m_conn->tcp.host = strdup(swss::SonicDBConfig::getDbHostname(dbName).c_str()); + m_conn->tcp.port = swss::SonicDBConfig::getDbPort(dbName); + m_conn->fd = socket(AF_UNIX, SOCK_DGRAM, 0); + } + else + { + m_conn = (redisContext *)calloc(1, sizeof(redisContext)); + m_conn->connection_type = REDIS_CONN_UNIX; + m_conn->unix_sock.path = strdup(swss::SonicDBConfig::getDbSock(dbName).c_str()); + m_conn->fd = socket(AF_UNIX, SOCK_DGRAM, 0); + } + } + int DBConnector::getDbId() const { return m_dbId; diff --git a/tests/mock_tests/portsorch_ut.cpp b/tests/mock_tests/portsorch_ut.cpp index 40cfbd3ecc92..40b0db6c3bb3 100644 --- a/tests/mock_tests/portsorch_ut.cpp +++ b/tests/mock_tests/portsorch_ut.cpp @@ -19,11 +19,11 @@ namespace portsorch_test { // FIXME: move out from constructor m_app_db = make_shared( - APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + "APPL_DB", 0); m_config_db = make_shared( - CONFIG_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + "CONFIG_DB", 0); m_state_db = make_shared( - STATE_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + "STATE_DB", 0); } virtual void SetUp() override