From e75a4d64792c6834bd2a00628ce11ad29a65be7b Mon Sep 17 00:00:00 2001 From: Dong Zhang <41927498+dzhangalibaba@users.noreply.github.com> Date: Wed, 11 Dec 2019 11:33:32 -0800 Subject: [PATCH] [MultiDB]: repalce old APIs with New APIs incuding testing (#537) --- lib/src/sai_redis_interfacequery.cpp | 4 ++-- saidump/saidump.cpp | 2 +- syncd/scripts/syncd_init_common.sh | 2 +- syncd/syncd.cpp | 8 ++++---- syncd/syncd_applyview.cpp | 2 +- syncd/syncd_flex_counter.cpp | 2 +- syncd/syncd_request_shutdown.cpp | 2 +- syncd/tests.cpp | 4 ++-- vslib/src/sai_vs_interfacequery.cpp | 2 +- vslib/src/tests.cpp | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/src/sai_redis_interfacequery.cpp b/lib/src/sai_redis_interfacequery.cpp index 799f87755572..c5fa789e7231 100644 --- a/lib/src/sai_redis_interfacequery.cpp +++ b/lib/src/sai_redis_interfacequery.cpp @@ -119,8 +119,8 @@ sai_status_t sai_api_initialize( memcpy(&g_services, services, sizeof(g_services)); - g_db = std::make_shared(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); - g_dbNtf = std::make_shared(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + g_db = std::make_shared("ASIC_DB", 0); + g_dbNtf = std::make_shared("ASIC_DB", 0); g_redisPipeline = std::make_shared(g_db.get()); //enable default pipeline 128 g_asicState = std::make_shared(g_redisPipeline.get(), ASIC_STATE_TABLE, true); g_redisGetConsumer = std::make_shared(g_db.get(), "GETRESPONSE"); diff --git a/saidump/saidump.cpp b/saidump/saidump.cpp index cb2d83378d7b..463f45ba2a3c 100644 --- a/saidump/saidump.cpp +++ b/saidump/saidump.cpp @@ -410,7 +410,7 @@ int main(int argc, char ** argv) g_cmdOptions = handleCmdLine(argc, argv); - swss::DBConnector db(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + swss::DBConnector db("ASIC_DB", 0); std::string table = ASIC_STATE_TABLE; diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 7fb3436eb5a3..e4a97966c5e2 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -32,7 +32,7 @@ case "$(cat /proc/cmdline)" in ;; *SONIC_BOOT_TYPE=fast*|*fast-reboot*) # check that the key exists - if [[ $(redis-cli -n 6 GET "FAST_REBOOT|system") == "1" ]]; then + if [[ $(sonic-db-cli STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then FAST_REBOOT='yes' else FAST_REBOOT='no' diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 09efb08e20c1..4bdb5a4e2381 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3896,10 +3896,10 @@ int syncd_main(int argc, char **argv) } #endif // SAITHRIFT - dbAsic = std::make_shared(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); - std::shared_ptr dbNtf = std::make_shared(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); - std::shared_ptr dbFlexCounter = std::make_shared(FLEX_COUNTER_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); - std::shared_ptr dbState = std::make_shared(STATE_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + dbAsic = std::make_shared("ASIC_DB", 0); + std::shared_ptr dbNtf = std::make_shared("ASIC_DB", 0); + std::shared_ptr dbFlexCounter = std::make_shared("FLEX_COUNTER_DB", 0); + std::shared_ptr dbState = std::make_shared("STATE_DB", 0); std::unique_ptr warmRestartTable = std::unique_ptr(new swss::Table(dbState.get(), STATE_WARM_RESTART_TABLE_NAME)); g_redisClient = std::make_shared(dbAsic.get()); diff --git a/syncd/syncd_applyview.cpp b/syncd/syncd_applyview.cpp index e2acbc16ce1e..28f174fbb186 100644 --- a/syncd/syncd_applyview.cpp +++ b/syncd/syncd_applyview.cpp @@ -1809,7 +1809,7 @@ void redisGetAsicView( SWSS_LOG_TIMER("get asic view from %s", tableName.c_str()); - swss::DBConnector db(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + swss::DBConnector db("ASIC_DB", 0); swss::Table table(&db, tableName); diff --git a/syncd/syncd_flex_counter.cpp b/syncd/syncd_flex_counter.cpp index 8bd467afcfe2..43b456f1b900 100644 --- a/syncd/syncd_flex_counter.cpp +++ b/syncd/syncd_flex_counter.cpp @@ -1690,7 +1690,7 @@ void FlexCounter::flexCounterThread(void) { SWSS_LOG_ENTER(); - swss::DBConnector db(COUNTERS_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + swss::DBConnector db("COUNTERS_DB", 0); swss::RedisPipeline pipeline(&db); swss::Table countersTable(&pipeline, COUNTERS_TABLE, true); diff --git a/syncd/syncd_request_shutdown.cpp b/syncd/syncd_request_shutdown.cpp index 3e6c7e4f079c..8156dd15a7ba 100644 --- a/syncd/syncd_request_shutdown.cpp +++ b/syncd/syncd_request_shutdown.cpp @@ -75,7 +75,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - swss::DBConnector db(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + swss::DBConnector db("ASIC_DB", 0); swss::NotificationProducer restartQuery(&db, "RESTARTQUERY"); std::vector values; diff --git a/syncd/tests.cpp b/syncd/tests.cpp index 34b97d4924c1..90db35f26862 100644 --- a/syncd/tests.cpp +++ b/syncd/tests.cpp @@ -63,7 +63,7 @@ void clearDB() { SWSS_LOG_ENTER(); - swss::DBConnector db(ASIC_DB, "localhost", 6379, 0); + swss::DBConnector db("ASIC_DB", 0, true); swss::RedisReply r(&db, "FLUSHALL", REDIS_REPLY_STATUS); r.checkStatusOK(); } @@ -168,7 +168,7 @@ void bulk_nhgm_consumer_worker() SWSS_LOG_ENTER(); std::string tableName = ASIC_STATE_TABLE; - swss::DBConnector db(ASIC_DB, "localhost", 6379, 0); + swss::DBConnector db("ASIC_DB", 0, true); swss::ConsumerTable c(&db, tableName); swss::Select cs; swss::Selectable *selectcs; diff --git a/vslib/src/sai_vs_interfacequery.cpp b/vslib/src/sai_vs_interfacequery.cpp index c217e31bbfe0..26215053d24b 100644 --- a/vslib/src/sai_vs_interfacequery.cpp +++ b/vslib/src/sai_vs_interfacequery.cpp @@ -787,7 +787,7 @@ sai_status_t sai_api_initialize( clear_local_state(); - g_dbNtf = std::make_shared(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); + g_dbNtf = std::make_shared("ASIC_DB", 0); g_unittestChannelNotificationConsumer = std::make_shared(g_dbNtf.get(), SAI_VS_UNITTEST_CHANNEL); g_unittestChannelRun = true; diff --git a/vslib/src/tests.cpp b/vslib/src/tests.cpp index 07efe66e6470..61b18e7189fe 100644 --- a/vslib/src/tests.cpp +++ b/vslib/src/tests.cpp @@ -208,7 +208,7 @@ void test_set_readonly_attribute_via_redis() // this scope contains all operations needed to perform set operation on readonly attribute { - swss::DBConnector db(ASIC_DB, "localhost", 6379, 0); + swss::DBConnector db("ASIC_DB", 0, true); swss::NotificationProducer vsntf(&db, SAI_VS_UNITTEST_CHANNEL); std::vector entry; @@ -271,7 +271,7 @@ void test_set_stats_via_redis() // this scope contains all operations needed to perform set stats on object { - swss::DBConnector db(ASIC_DB, "localhost", 6379, 0); + swss::DBConnector db("ASIC_DB", 0, true); swss::NotificationProducer vsntf(&db, SAI_VS_UNITTEST_CHANNEL); std::vector entry;