From cf5d689d777f67bb5e32c70fe0e4e496bbc3de54 Mon Sep 17 00:00:00 2001 From: dzhang Date: Wed, 5 Sep 2018 11:10:45 -0700 Subject: [PATCH] moving DB --- lib/src/sai_redis_interfacequery.cpp | 4 ++-- saidump/saidump.cpp | 2 +- syncd/scripts/syncd_init_common.sh | 4 ++++ syncd/syncd.cpp | 4 ++-- syncd/syncd_applyview.cpp | 2 +- syncd/syncd_request_shutdown.cpp | 2 +- syncd/tests.cpp | 4 ++-- tests/utils.pm | 12 ++++++++++++ vslib/src/sai_vs_interfacequery.cpp | 2 +- vslib/src/tests.cpp | 2 +- 10 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/src/sai_redis_interfacequery.cpp b/lib/src/sai_redis_interfacequery.cpp index 3548b1067a..c09de279dd 100644 --- a/lib/src/sai_redis_interfacequery.cpp +++ b/lib/src/sai_redis_interfacequery.cpp @@ -115,8 +115,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, swss::DBConnector::SECONDARY_UNIXSOCKET, 0); + g_dbNtf = std::make_shared(ASIC_DB, swss::DBConnector::SECONDARY_UNIXSOCKET, 0); g_asicState = std::make_shared(g_db.get(), ASIC_STATE_TABLE); g_redisGetConsumer = std::make_shared(g_db.get(), "GETRESPONSE"); g_redisNotifications = std::make_shared(g_dbNtf.get(), "NOTIFICATIONS"); diff --git a/saidump/saidump.cpp b/saidump/saidump.cpp index 434ee558f6..7371c9cb7a 100644 --- a/saidump/saidump.cpp +++ b/saidump/saidump.cpp @@ -164,7 +164,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, DBConnector::SECONDARY_UNIXSOCKET, 0); std::string table = ASIC_STATE_TABLE; diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 28a52dbe4e..ee1e37da17 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -91,6 +91,10 @@ config_syncd_cavium() sleep 1 done + until [ $(redis-cli -p 6380 ping | grep -c PONG) -gt 0 ]; do + sleep 1 + done + if [ $FAST_REBOOT == "yes" ]; then CMD_ARGS+=" -t fast" fi diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index ab50e0d0f5..55fc9df77d 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3437,8 +3437,8 @@ int syncd_main(int argc, char **argv) } #endif // SAITHRIFT - std::shared_ptr 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 dbAsic = std::make_shared(ASIC_DB, swss::DBConnector::SECONDARY_UNIXSOCKET, 0); + std::shared_ptr dbNtf = std::make_shared(ASIC_DB, swss::DBConnector::SECONDARY_UNIXSOCKET, 0); std::shared_ptr dbFlexCounter = std::make_shared(FLEX_COUNTER_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0); g_redisClient = std::make_shared(dbAsic.get()); diff --git a/syncd/syncd_applyview.cpp b/syncd/syncd_applyview.cpp index 522a70dac0..e396316630 100644 --- a/syncd/syncd_applyview.cpp +++ b/syncd/syncd_applyview.cpp @@ -1578,7 +1578,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, swss::DBConnector::SECONDARY_UNIXSOCKET, 0); swss::Table table(&db, tableName); diff --git a/syncd/syncd_request_shutdown.cpp b/syncd/syncd_request_shutdown.cpp index 78d5d4810b..d19c8eaf33 100644 --- a/syncd/syncd_request_shutdown.cpp +++ b/syncd/syncd_request_shutdown.cpp @@ -67,7 +67,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, swss::DBConnector::SECONDARY_UNIXSOCKET, 0); swss::NotificationProducer restartQuery(&db, "RESTARTQUERY"); std::vector values; diff --git a/syncd/tests.cpp b/syncd/tests.cpp index fadf85f812..5013afe8b4 100644 --- a/syncd/tests.cpp +++ b/syncd/tests.cpp @@ -47,7 +47,7 @@ void clearDB() { SWSS_LOG_ENTER(); - swss::DBConnector db(ASIC_DB, "localhost", 6379, 0); + swss::DBConnector db(ASIC_DB, "localhost", 6380, 0); swss::RedisReply r(&db, "FLUSHALL", REDIS_REPLY_STATUS); r.checkStatusOK(); } @@ -152,7 +152,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, "localhost", 6380, 0); swss::ConsumerTable c(&db, tableName); swss::Select cs; swss::Selectable *selectcs; diff --git a/tests/utils.pm b/tests/utils.pm index 13f41fef46..bdecc3f440 100644 --- a/tests/utils.pm +++ b/tests/utils.pm @@ -43,6 +43,18 @@ sub flush_redis print color('red') . "failed to flush redis: @ret" . color('reset') . "\n"; exit 1; } + + my @ret_sec = `redis-cli -p 6380 flushall`; + + $ret_sec[0] = "failed" if not defined $ret_sec[0]; + + chomp $ret_sec[0]; + + if ($ret_sec[0] ne "OK") + { + print color('red') . "failed to flush redis port 6380: @ret" . color('reset') . "\n"; + exit 1; + } } sub start_syncd diff --git a/vslib/src/sai_vs_interfacequery.cpp b/vslib/src/sai_vs_interfacequery.cpp index 1be3a3a12f..8e3cbb0701 100644 --- a/vslib/src/sai_vs_interfacequery.cpp +++ b/vslib/src/sai_vs_interfacequery.cpp @@ -377,7 +377,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, swss::DBConnector::SECONDARY_UNIXSOCKET, 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 cb6a9e3627..37973758f6 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, "localhost", 6380, 0); swss::NotificationProducer vsntf(&db, SAI_VS_UNITTEST_CHANNEL); std::vector entry;