Skip to content

Commit e75a4d6

Browse files
dzhangalibabaqiluo-msft
authored andcommitted
[MultiDB]: repalce old APIs with New APIs incuding testing (sonic-net#537)
1 parent 6747eb5 commit e75a4d6

10 files changed

+16
-16
lines changed

lib/src/sai_redis_interfacequery.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ sai_status_t sai_api_initialize(
119119

120120
memcpy(&g_services, services, sizeof(g_services));
121121

122-
g_db = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
123-
g_dbNtf = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
122+
g_db = std::make_shared<swss::DBConnector>("ASIC_DB", 0);
123+
g_dbNtf = std::make_shared<swss::DBConnector>("ASIC_DB", 0);
124124
g_redisPipeline = std::make_shared<swss::RedisPipeline>(g_db.get()); //enable default pipeline 128
125125
g_asicState = std::make_shared<swss::ProducerTable>(g_redisPipeline.get(), ASIC_STATE_TABLE, true);
126126
g_redisGetConsumer = std::make_shared<swss::ConsumerTable>(g_db.get(), "GETRESPONSE");

saidump/saidump.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int main(int argc, char ** argv)
410410

411411
g_cmdOptions = handleCmdLine(argc, argv);
412412

413-
swss::DBConnector db(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
413+
swss::DBConnector db("ASIC_DB", 0);
414414

415415
std::string table = ASIC_STATE_TABLE;
416416

syncd/scripts/syncd_init_common.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ case "$(cat /proc/cmdline)" in
3232
;;
3333
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
3434
# check that the key exists
35-
if [[ $(redis-cli -n 6 GET "FAST_REBOOT|system") == "1" ]]; then
35+
if [[ $(sonic-db-cli STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
3636
FAST_REBOOT='yes'
3737
else
3838
FAST_REBOOT='no'

syncd/syncd.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3896,10 +3896,10 @@ int syncd_main(int argc, char **argv)
38963896
}
38973897
#endif // SAITHRIFT
38983898

3899-
dbAsic = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
3900-
std::shared_ptr<swss::DBConnector> dbNtf = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
3901-
std::shared_ptr<swss::DBConnector> dbFlexCounter = std::make_shared<swss::DBConnector>(FLEX_COUNTER_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
3902-
std::shared_ptr<swss::DBConnector> dbState = std::make_shared<swss::DBConnector>(STATE_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
3899+
dbAsic = std::make_shared<swss::DBConnector>("ASIC_DB", 0);
3900+
std::shared_ptr<swss::DBConnector> dbNtf = std::make_shared<swss::DBConnector>("ASIC_DB", 0);
3901+
std::shared_ptr<swss::DBConnector> dbFlexCounter = std::make_shared<swss::DBConnector>("FLEX_COUNTER_DB", 0);
3902+
std::shared_ptr<swss::DBConnector> dbState = std::make_shared<swss::DBConnector>("STATE_DB", 0);
39033903
std::unique_ptr<swss::Table> warmRestartTable = std::unique_ptr<swss::Table>(new swss::Table(dbState.get(), STATE_WARM_RESTART_TABLE_NAME));
39043904

39053905
g_redisClient = std::make_shared<swss::RedisClient>(dbAsic.get());

syncd/syncd_applyview.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ void redisGetAsicView(
18091809

18101810
SWSS_LOG_TIMER("get asic view from %s", tableName.c_str());
18111811

1812-
swss::DBConnector db(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
1812+
swss::DBConnector db("ASIC_DB", 0);
18131813

18141814
swss::Table table(&db, tableName);
18151815

syncd/syncd_flex_counter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ void FlexCounter::flexCounterThread(void)
16901690
{
16911691
SWSS_LOG_ENTER();
16921692

1693-
swss::DBConnector db(COUNTERS_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
1693+
swss::DBConnector db("COUNTERS_DB", 0);
16941694
swss::RedisPipeline pipeline(&db);
16951695
swss::Table countersTable(&pipeline, COUNTERS_TABLE, true);
16961696

syncd/syncd_request_shutdown.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
7575
exit(EXIT_FAILURE);
7676
}
7777

78-
swss::DBConnector db(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
78+
swss::DBConnector db("ASIC_DB", 0);
7979
swss::NotificationProducer restartQuery(&db, "RESTARTQUERY");
8080

8181
std::vector<swss::FieldValueTuple> values;

syncd/tests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void clearDB()
6363
{
6464
SWSS_LOG_ENTER();
6565

66-
swss::DBConnector db(ASIC_DB, "localhost", 6379, 0);
66+
swss::DBConnector db("ASIC_DB", 0, true);
6767
swss::RedisReply r(&db, "FLUSHALL", REDIS_REPLY_STATUS);
6868
r.checkStatusOK();
6969
}
@@ -168,7 +168,7 @@ void bulk_nhgm_consumer_worker()
168168
SWSS_LOG_ENTER();
169169

170170
std::string tableName = ASIC_STATE_TABLE;
171-
swss::DBConnector db(ASIC_DB, "localhost", 6379, 0);
171+
swss::DBConnector db("ASIC_DB", 0, true);
172172
swss::ConsumerTable c(&db, tableName);
173173
swss::Select cs;
174174
swss::Selectable *selectcs;

vslib/src/sai_vs_interfacequery.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ sai_status_t sai_api_initialize(
787787

788788
clear_local_state();
789789

790-
g_dbNtf = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
790+
g_dbNtf = std::make_shared<swss::DBConnector>("ASIC_DB", 0);
791791
g_unittestChannelNotificationConsumer = std::make_shared<swss::NotificationConsumer>(g_dbNtf.get(), SAI_VS_UNITTEST_CHANNEL);
792792

793793
g_unittestChannelRun = true;

vslib/src/tests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void test_set_readonly_attribute_via_redis()
208208

209209
// this scope contains all operations needed to perform set operation on readonly attribute
210210
{
211-
swss::DBConnector db(ASIC_DB, "localhost", 6379, 0);
211+
swss::DBConnector db("ASIC_DB", 0, true);
212212
swss::NotificationProducer vsntf(&db, SAI_VS_UNITTEST_CHANNEL);
213213

214214
std::vector<swss::FieldValueTuple> entry;
@@ -271,7 +271,7 @@ void test_set_stats_via_redis()
271271

272272
// this scope contains all operations needed to perform set stats on object
273273
{
274-
swss::DBConnector db(ASIC_DB, "localhost", 6379, 0);
274+
swss::DBConnector db("ASIC_DB", 0, true);
275275
swss::NotificationProducer vsntf(&db, SAI_VS_UNITTEST_CHANNEL);
276276

277277
std::vector<swss::FieldValueTuple> entry;

0 commit comments

Comments
 (0)