Skip to content

Commit

Permalink
Move SelectableChannel classes to libsaimeta
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 21, 2021
1 parent 016b5d9 commit 855be73
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 37 deletions.
6 changes: 3 additions & 3 deletions lib/inc/ServerSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "meta/SaiInterface.h"
#include "meta/SaiAttributeList.h"
#include "syncd/SelectableChannel.h"
#include "meta/SelectableChannel.h"

#include "swss/selectableevent.h"

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -375,7 +375,7 @@ namespace sairedis

std::shared_ptr<std::thread> m_serverThread;

std::shared_ptr<syncd::SelectableChannel> m_selectableChannel;
std::shared_ptr<SelectableChannel> m_selectableChannel;

swss::SelectableEvent m_serverThreadThreadShouldEndEvent;
};
Expand Down
3 changes: 0 additions & 3 deletions lib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

7 changes: 3 additions & 4 deletions lib/src/ServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -90,7 +89,7 @@ sai_status_t ServerSai::initialize(

auto cc = ServerConfig::loadFromFile(serverConfig);

m_selectableChannel = std::make_shared<syncd::ZeroMQSelectableChannel>(cc->m_zmqEndpoint);
m_selectableChannel = std::make_shared<ZeroMQSelectableChannel>(cc->m_zmqEndpoint);

SWSS_LOG_NOTICE("starting server thread");

Expand Down Expand Up @@ -630,7 +629,7 @@ void ServerSai::serverThreadFunction()
}

void ServerSai::processEvent(
_In_ syncd::SelectableChannel& consumer)
_In_ SelectableChannel& consumer)
{
MUTEX();
SWSS_LOG_ENTER();
Expand Down
5 changes: 4 additions & 1 deletion meta/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "swss/logger.h"

using namespace syncd;
using namespace sairedis;

RedisSelectableChannel::RedisSelectableChannel(
_In_ std::shared_ptr<swss::DBConnector> dbAsic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "swss/consumertable.h"
#include "swss/producertable.h"

namespace syncd
namespace sairedis
{
class RedisSelectableChannel:
public SelectableChannel
Expand Down
2 changes: 1 addition & 1 deletion syncd/SelectableChannel.cpp → meta/SelectableChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "swss/logger.h"

using namespace syncd;
using namespace sairedis;

SelectableChannel::SelectableChannel(
_In_ int pri):
Expand Down
2 changes: 1 addition & 1 deletion syncd/SelectableChannel.h → meta/SelectableChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>
#include <vector>

namespace syncd
namespace sairedis
{
class SelectableChannel:
public swss::Selectable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <thread>
#include <memory>

namespace syncd
namespace sairedis
{
class ZeroMQSelectableChannel:
public SelectableChannel
Expand Down
2 changes: 1 addition & 1 deletion saidiscovery/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion saiplayer/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion saisdkdump/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 2 additions & 5 deletions syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -115,7 +115,7 @@ Syncd::Syncd(

m_enableSyncMode = true;

m_selectableChannel = std::make_shared<ZeroMQSelectableChannel>(m_contextConfig->m_zmqEndpoint);
m_selectableChannel = std::make_shared<sairedis::ZeroMQSelectableChannel>(m_contextConfig->m_zmqEndpoint);
}
else
{
Expand All @@ -125,7 +125,7 @@ Syncd::Syncd(

bool modifyRedis = m_enableSyncMode ? false : true;

m_selectableChannel = std::make_shared<RedisSelectableChannel>(
m_selectableChannel = std::make_shared<sairedis::RedisSelectableChannel>(
m_dbAsic,
ASIC_STATE_TABLE,
REDIS_TABLE_GETRESPONSE,
Expand Down Expand Up @@ -278,7 +278,7 @@ bool Syncd::isInitViewMode() const
}

void Syncd::processEvent(
_In_ SelectableChannel& consumer)
_In_ sairedis::SelectableChannel& consumer)
{
SWSS_LOG_ENTER();

Expand Down
6 changes: 3 additions & 3 deletions syncd/Syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -441,7 +441,7 @@ namespace syncd

std::shared_ptr<syncd::NotificationProcessor> m_processor;

std::shared_ptr<SelectableChannel> m_selectableChannel;
std::shared_ptr<sairedis::SelectableChannel> m_selectableChannel;

bool m_enableSyncMode;

Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
#include <stdlib.h>
#include <assert.h>

#include "lib/inc/ZeroMQChannel.h"
#include "syncd/ZeroMQNotificationProducer.h"

#include "lib/inc/ZeroMQChannel.h"

#include "meta/sai_serialize.h"

#include <thread>
#include <memory>

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); }

Expand Down
2 changes: 1 addition & 1 deletion vslib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 855be73

Please sign in to comment.