From 855be733b648d65f5736d5e66629d29525efb0b3 Mon Sep 17 00:00:00 2001 From: kcudnik Date: Tue, 10 Aug 2021 18:15:47 +0200 Subject: [PATCH] Move SelectableChannel classes to libsaimeta --- lib/inc/ServerSai.h | 6 +++--- lib/src/Makefile.am | 3 --- lib/src/ServerSai.cpp | 7 +++---- meta/Makefile.am | 5 ++++- {syncd => meta}/RedisSelectableChannel.cpp | 2 +- {syncd => meta}/RedisSelectableChannel.h | 2 +- {syncd => meta}/SelectableChannel.cpp | 2 +- {syncd => meta}/SelectableChannel.h | 2 +- {syncd => meta}/ZeroMQSelectableChannel.cpp | 2 +- {syncd => meta}/ZeroMQSelectableChannel.h | 2 +- saidiscovery/Makefile.am | 2 +- saiplayer/Makefile.am | 2 +- saisdkdump/Makefile.am | 2 +- syncd/Makefile.am | 7 ++----- syncd/Syncd.cpp | 10 +++++----- syncd/Syncd.h | 6 +++--- tests/Makefile.am | 2 +- tests/tests.cpp | 5 +++-- vslib/src/Makefile.am | 2 +- 19 files changed, 34 insertions(+), 37 deletions(-) rename {syncd => meta}/RedisSelectableChannel.cpp (98%) rename {syncd => meta}/RedisSelectableChannel.h (98%) rename {syncd => meta}/SelectableChannel.cpp (87%) rename {syncd => meta}/SelectableChannel.h (97%) rename {syncd => meta}/ZeroMQSelectableChannel.cpp (99%) rename {syncd => meta}/ZeroMQSelectableChannel.h (98%) diff --git a/lib/inc/ServerSai.h b/lib/inc/ServerSai.h index a2d83ff5fcf3..f26d35113bf6 100644 --- a/lib/inc/ServerSai.h +++ b/lib/inc/ServerSai.h @@ -2,7 +2,7 @@ #include "meta/SaiInterface.h" #include "meta/SaiAttributeList.h" -#include "syncd/SelectableChannel.h" +#include "meta/SelectableChannel.h" #include "swss/selectableevent.h" @@ -256,7 +256,7 @@ namespace sairedis void serverThreadFunction(); void processEvent( - _In_ syncd::SelectableChannel& consumer); + _In_ SelectableChannel& consumer); sai_status_t processSingleEvent( _In_ const swss::KeyOpFieldsValuesTuple &kco); @@ -375,7 +375,7 @@ namespace sairedis std::shared_ptr m_serverThread; - std::shared_ptr m_selectableChannel; + std::shared_ptr m_selectableChannel; swss::SelectableEvent m_serverThreadThreadShouldEndEvent; }; diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am index 375b80f17902..114741e0c6ed 100644 --- a/lib/src/Makefile.am +++ b/lib/src/Makefile.am @@ -10,8 +10,6 @@ lib_LTLIBRARIES = libsairedis.la noinst_LIBRARIES = libSaiRedis.a libSaiRedis_a_SOURCES = \ - ../../syncd/ZeroMQSelectableChannel.cpp \ - ../../syncd/SelectableChannel.cpp \ ClientConfig.cpp \ ServerConfig.cpp \ ClientServerSai.cpp \ @@ -105,4 +103,3 @@ tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) tests_LDADD = -lhiredis -lswsscommon -lpthread $(top_srcdir)/meta/libsaimetadata.la $(top_srcdir)/meta/libsaimeta.la libsairedis.la -lzmq TESTS = tests - diff --git a/lib/src/ServerSai.cpp b/lib/src/ServerSai.cpp index b66b17218fcb..e84bc9322a60 100644 --- a/lib/src/ServerSai.cpp +++ b/lib/src/ServerSai.cpp @@ -4,10 +4,9 @@ #include "ServerConfig.h" #include "sairediscommon.h" -#include "syncd/ZeroMQSelectableChannel.h" - #include "meta/sai_serialize.h" #include "meta/SaiAttributeList.h" +#include "meta/ZeroMQSelectableChannel.h" #include "swss/logger.h" #include "swss/select.h" @@ -90,7 +89,7 @@ sai_status_t ServerSai::initialize( auto cc = ServerConfig::loadFromFile(serverConfig); - m_selectableChannel = std::make_shared(cc->m_zmqEndpoint); + m_selectableChannel = std::make_shared(cc->m_zmqEndpoint); SWSS_LOG_NOTICE("starting server thread"); @@ -630,7 +629,7 @@ void ServerSai::serverThreadFunction() } void ServerSai::processEvent( - _In_ syncd::SelectableChannel& consumer) + _In_ SelectableChannel& consumer) { MUTEX(); SWSS_LOG_ENTER(); diff --git a/meta/Makefile.am b/meta/Makefile.am index 17c80a007def..5811cd37dd01 100644 --- a/meta/Makefile.am +++ b/meta/Makefile.am @@ -42,6 +42,9 @@ libsaimeta_la_SOURCES = \ PortRelatedSet.cpp \ MetaKeyHasher.cpp \ PerformanceIntervalTimer.cpp \ + SelectableChannel.cpp \ + RedisSelectableChannel.cpp \ + ZeroMQSelectableChannel.cpp \ Meta.cpp libsaimeta_la_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) @@ -60,6 +63,6 @@ tests_SOURCES = \ ../lib/src/SwitchConfigContainer.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -tests_LDADD = -lhiredis -lswsscommon -lpthread libsaimetadata.la libsaimeta.la +tests_LDADD = -lhiredis -lswsscommon -lpthread libsaimetadata.la libsaimeta.la -lzmq TESTS = tests diff --git a/syncd/RedisSelectableChannel.cpp b/meta/RedisSelectableChannel.cpp similarity index 98% rename from syncd/RedisSelectableChannel.cpp rename to meta/RedisSelectableChannel.cpp index 5872791ab4aa..3d7b06f2f13c 100644 --- a/syncd/RedisSelectableChannel.cpp +++ b/meta/RedisSelectableChannel.cpp @@ -2,7 +2,7 @@ #include "swss/logger.h" -using namespace syncd; +using namespace sairedis; RedisSelectableChannel::RedisSelectableChannel( _In_ std::shared_ptr dbAsic, diff --git a/syncd/RedisSelectableChannel.h b/meta/RedisSelectableChannel.h similarity index 98% rename from syncd/RedisSelectableChannel.h rename to meta/RedisSelectableChannel.h index 66a9215bf32c..a5bd951b6a5d 100644 --- a/syncd/RedisSelectableChannel.h +++ b/meta/RedisSelectableChannel.h @@ -5,7 +5,7 @@ #include "swss/consumertable.h" #include "swss/producertable.h" -namespace syncd +namespace sairedis { class RedisSelectableChannel: public SelectableChannel diff --git a/syncd/SelectableChannel.cpp b/meta/SelectableChannel.cpp similarity index 87% rename from syncd/SelectableChannel.cpp rename to meta/SelectableChannel.cpp index 42206918ba4a..b4d9c4dc07d8 100644 --- a/syncd/SelectableChannel.cpp +++ b/meta/SelectableChannel.cpp @@ -2,7 +2,7 @@ #include "swss/logger.h" -using namespace syncd; +using namespace sairedis; SelectableChannel::SelectableChannel( _In_ int pri): diff --git a/syncd/SelectableChannel.h b/meta/SelectableChannel.h similarity index 97% rename from syncd/SelectableChannel.h rename to meta/SelectableChannel.h index 3f25746a0fb1..0064e8003c96 100644 --- a/syncd/SelectableChannel.h +++ b/meta/SelectableChannel.h @@ -7,7 +7,7 @@ #include #include -namespace syncd +namespace sairedis { class SelectableChannel: public swss::Selectable diff --git a/syncd/ZeroMQSelectableChannel.cpp b/meta/ZeroMQSelectableChannel.cpp similarity index 99% rename from syncd/ZeroMQSelectableChannel.cpp rename to meta/ZeroMQSelectableChannel.cpp index ddaadb29e819..512e001702f1 100644 --- a/syncd/ZeroMQSelectableChannel.cpp +++ b/meta/ZeroMQSelectableChannel.cpp @@ -11,7 +11,7 @@ //#define ZMQ_POLL_TIMEOUT (2*60*1000) #define ZMQ_POLL_TIMEOUT (1000) -using namespace syncd; +using namespace sairedis; ZeroMQSelectableChannel::ZeroMQSelectableChannel( _In_ const std::string& endpoint): diff --git a/syncd/ZeroMQSelectableChannel.h b/meta/ZeroMQSelectableChannel.h similarity index 98% rename from syncd/ZeroMQSelectableChannel.h rename to meta/ZeroMQSelectableChannel.h index fd3f167ffaad..3ef3fe3b0f51 100644 --- a/syncd/ZeroMQSelectableChannel.h +++ b/meta/ZeroMQSelectableChannel.h @@ -9,7 +9,7 @@ #include #include -namespace syncd +namespace sairedis { class ZeroMQSelectableChannel: public SelectableChannel diff --git a/saidiscovery/Makefile.am b/saidiscovery/Makefile.am index 85c73cd66f92..5a7a60764a36 100644 --- a/saidiscovery/Makefile.am +++ b/saidiscovery/Makefile.am @@ -18,4 +18,4 @@ saidiscovery_SOURCES = saidiscovery.cpp saidiscovery_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) saidiscovery_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) -saidiscovery_LDADD = -lhiredis -lswsscommon $(top_srcdir)/syncd/libSyncd.a $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta $(CODE_COVERAGE_LIBS) +saidiscovery_LDADD = -lhiredis -lswsscommon $(top_srcdir)/syncd/libSyncd.a $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) diff --git a/saiplayer/Makefile.am b/saiplayer/Makefile.am index b44291c40820..a905f0836709 100644 --- a/saiplayer/Makefile.am +++ b/saiplayer/Makefile.am @@ -21,4 +21,4 @@ libSaiPlayer_a_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_C saiplayer_SOURCES = saiplayer_main.cpp saiplayer_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) saiplayer_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) -saiplayer_LDADD = libSaiPlayer.a ../syncd/libSyncd.a ../lib/src/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) +saiplayer_LDADD = libSaiPlayer.a $(top_srcdir)/syncd/libSyncd.a $(top_srcdir)/lib/src/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) diff --git a/saisdkdump/Makefile.am b/saisdkdump/Makefile.am index 1c4662a8fdc1..ccfad1db17cd 100644 --- a/saisdkdump/Makefile.am +++ b/saisdkdump/Makefile.am @@ -18,4 +18,4 @@ endif saisdkdump_SOURCES = saisdkdump.cpp saisdkdump_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) saisdkdump_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) -saisdkdump_LDADD = -lhiredis -lswsscommon $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta $(CODE_COVERAGE_LIBS) +saisdkdump_LDADD = -lhiredis -lswsscommon $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) diff --git a/syncd/Makefile.am b/syncd/Makefile.am index d7a21105e968..35acd1f9087d 100644 --- a/syncd/Makefile.am +++ b/syncd/Makefile.am @@ -18,9 +18,6 @@ noinst_LIBRARIES = libSyncd.a libSyncdRequestShutdown.a libSyncd_a_SOURCES = \ WatchdogScope.cpp \ SaiSwitchInterface.cpp \ - ZeroMQSelectableChannel.cpp \ - RedisSelectableChannel.cpp \ - SelectableChannel.cpp \ ZeroMQNotificationProducer.cpp \ RedisNotificationProducer.cpp \ ComparisonLogic.cpp \ @@ -66,7 +63,7 @@ libSyncd_a_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVER syncd_SOURCES = main.cpp syncd_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) syncd_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) -syncd_LDADD = libSyncd.a ../lib/src/libSaiRedis.a -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -ldl -lhiredis -lswsscommon $(SAILIB) -lpthread -lzmq $(CODE_COVERAGE_LIBS) +syncd_LDADD = libSyncd.a $(top_srcdir)/lib/src/libSaiRedis.a -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -ldl -lhiredis -lswsscommon $(SAILIB) -lpthread -lzmq $(CODE_COVERAGE_LIBS) if SAITHRIFT libSyncd_a_CXXFLAGS += -DSAITHRIFT=yes @@ -90,7 +87,7 @@ libSyncdRequestShutdown_a_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMO syncd_request_shutdown_SOURCES = syncd_request_shutdown.cpp syncd_request_shutdown_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) syncd_request_shutdown_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) -syncd_request_shutdown_LDADD = libSyncdRequestShutdown.a ../lib/src/libSaiRedis.a -lhiredis -lswsscommon -lpthread $(CODE_COVERAGE_LIBS) +syncd_request_shutdown_LDADD = libSyncdRequestShutdown.a $(top_srcdir)/lib/src/libSaiRedis.a -lhiredis -lswsscommon -lpthread $(CODE_COVERAGE_LIBS) tests_SOURCES = tests.cpp diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index c4e1a5dfadfb..1645b4d10439 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -11,8 +11,6 @@ #include "BreakConfigParser.h" #include "RedisNotificationProducer.h" #include "ZeroMQNotificationProducer.h" -#include "RedisSelectableChannel.h" -#include "ZeroMQSelectableChannel.h" #include "WatchdogScope.h" #include "sairediscommon.h" @@ -23,6 +21,8 @@ #include "swss/notificationproducer.h" #include "meta/sai_serialize.h" +#include "meta/ZeroMQSelectableChannel.h" +#include "meta/RedisSelectableChannel.h" #include "meta/PerformanceIntervalTimer.h" #include "vslib/inc/saivs.h" @@ -115,7 +115,7 @@ Syncd::Syncd( m_enableSyncMode = true; - m_selectableChannel = std::make_shared(m_contextConfig->m_zmqEndpoint); + m_selectableChannel = std::make_shared(m_contextConfig->m_zmqEndpoint); } else { @@ -125,7 +125,7 @@ Syncd::Syncd( bool modifyRedis = m_enableSyncMode ? false : true; - m_selectableChannel = std::make_shared( + m_selectableChannel = std::make_shared( m_dbAsic, ASIC_STATE_TABLE, REDIS_TABLE_GETRESPONSE, @@ -278,7 +278,7 @@ bool Syncd::isInitViewMode() const } void Syncd::processEvent( - _In_ SelectableChannel& consumer) + _In_ sairedis::SelectableChannel& consumer) { SWSS_LOG_ENTER(); diff --git a/syncd/Syncd.h b/syncd/Syncd.h index 4cea8fac5abe..5aa8a82fd47d 100644 --- a/syncd/Syncd.h +++ b/syncd/Syncd.h @@ -16,10 +16,10 @@ #include "ContextConfig.h" #include "BreakConfig.h" #include "NotificationProducerBase.h" -#include "SelectableChannel.h" #include "TimerWatchdog.h" #include "meta/SaiAttributeList.h" +#include "meta/SelectableChannel.h" #include "swss/consumertable.h" #include "swss/producertable.h" @@ -64,7 +64,7 @@ namespace syncd public: // TODO private void processEvent( - _In_ SelectableChannel& consumer); + _In_ sairedis::SelectableChannel& consumer); sai_status_t processQuadEventInInitViewMode( _In_ sai_object_type_t objectType, @@ -441,7 +441,7 @@ namespace syncd std::shared_ptr m_processor; - std::shared_ptr m_selectableChannel; + std::shared_ptr m_selectableChannel; bool m_enableSyncMode; diff --git a/tests/Makefile.am b/tests/Makefile.am index b3380ed8afb4..4629bbad6913 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,7 @@ vssyncd_SOURCES = main.cpp vssyncd_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) vssyncd_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) -vssyncd_LDADD = ../syncd/libSyncd.a ../lib/src/libSaiRedis.a -lhiredis -lswsscommon $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -ldl -lzmq $(CODE_COVERAGE_LIBS) +vssyncd_LDADD = $(top_srcdir)/syncd/libSyncd.a $(top_srcdir)/lib/src/libSaiRedis.a -lhiredis -lswsscommon $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -ldl -lzmq $(CODE_COVERAGE_LIBS) if SAITHRIFT vssyncd_LDADD += -lrpcserver -lthrift diff --git a/tests/tests.cpp b/tests/tests.cpp index 781385e41d7f..61e979d02313 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -5,16 +5,17 @@ #include #include -#include "lib/inc/ZeroMQChannel.h" #include "syncd/ZeroMQNotificationProducer.h" +#include "lib/inc/ZeroMQChannel.h" + #include "meta/sai_serialize.h" #include #include -using namespace sairedis; using namespace syncd; +using namespace sairedis; #define ASSERT_EQ(a,b) if ((a) != (b)) { SWSS_LOG_THROW("ASSERT EQ FAILED: " #a " != " #b); } diff --git a/vslib/src/Makefile.am b/vslib/src/Makefile.am index 602d01f33869..9c35000f2f23 100644 --- a/vslib/src/Makefile.am +++ b/vslib/src/Makefile.am @@ -126,6 +126,6 @@ bin_PROGRAMS = tests tests_SOURCES = tests.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -tests_LDADD = -lhiredis -lswsscommon -lpthread libsaivs.la $(top_srcdir)/meta/libsaimetadata.la $(top_srcdir)/meta/libsaimeta.la +tests_LDADD = -lhiredis -lswsscommon -lpthread libsaivs.la $(top_srcdir)/meta/libsaimetadata.la $(top_srcdir)/meta/libsaimeta.la -lzmq TESTS = tests