forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ZeroMQ communication channel between sairedis and syncd (sonic-ne…
…t#659) * [sairedis] Use separate db connector for VID index generator * [sairedis] Add Channel class * [sairedis] Start using Channel class in RedisChannel * [sairedis] Add zmq configuration to ContextConfig * [sairedis] Change reddis channel class to base channel class * [syncd] Fix aspell * [sairedis] Disable zeromq by default * [sairedis] Add ZeroMQChannel class * Update aspell * [syncd] Add NotificationProducerBase class * [syncd] Add RedisNotificationProducer class * [syncd] Start using RediisNotificationProducer class * [syncd] Add ZeroMQNotificationProducer class * [syncd] Start uisng ZeroMQNotificationProducer class * [sairedis] Start using ZeroMQChannel clas * [saiplayer] Use lib zmq in saiplayer Makefile * [tests] Add libzmq to makefile * [sairedis] Force sync mode when zmq enabled * [syncd] Force sync mode when zmq enabled * [syncd] Add libzmq to makefile * [syncd] Add SelectableChannel class * [syncd] Add RedisSelectableChannel class * [syncd] Start using SelectableChannel base * [saidump] Add libzmq to makefile * [syncd] Add ZeroMQSelectableChannel class * [syncd] Start using ZeroMQSelectableChannel * [sairedis] Remove unused includes from Channel class * [sairedis] Fix ZeroMQChannel error checks * [syncd] Use zmq_poll in separate thread to ignore edge trigger poll * [sairedis] Fix aspell * [tests] Update aspell dict * [tests] Add zmq channel unittests * [syncd] Fix ZeroMQNotificationProducer connect error code * Update aspell * [syncd] Increase ZeroMQSelectableChannel timeout to 2min * Update aspell * Modify libzmq order in Makefiles * [syncd] Fix merge issues
- Loading branch information
Showing
39 changed files
with
1,495 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#pragma once | ||
|
||
#include "swss/producertable.h" | ||
#include "swss/consumertable.h" | ||
#include "swss/notificationconsumer.h" | ||
#include "swss/selectableevent.h" | ||
#include "swss/sal.h" | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
} | ||
|
||
#include <memory> | ||
#include <functional> | ||
|
||
namespace sairedis | ||
{ | ||
class Channel | ||
{ | ||
public: | ||
|
||
typedef std::function<void(const std::string&,const std::string&, const std::vector<swss::FieldValueTuple>&)> Callback; | ||
|
||
public: | ||
|
||
Channel( | ||
_In_ Callback callback); | ||
|
||
virtual ~Channel(); | ||
|
||
public: | ||
|
||
virtual void setBuffered( | ||
_In_ bool buffered) = 0; | ||
|
||
virtual void flush() = 0; | ||
|
||
virtual void set( | ||
_In_ const std::string& key, | ||
_In_ const std::vector<swss::FieldValueTuple>& values, | ||
_In_ const std::string& command) = 0; | ||
|
||
virtual void del( | ||
_In_ const std::string& key, | ||
_In_ const std::string& command) = 0; | ||
|
||
virtual sai_status_t wait( | ||
_In_ const std::string& command, | ||
_Out_ swss::KeyOpFieldsValuesTuple& kco) = 0; | ||
|
||
protected: | ||
|
||
virtual void notificationThreadFunction() = 0; | ||
|
||
protected: | ||
|
||
Callback m_callback; | ||
|
||
protected: // notification | ||
|
||
/** | ||
* @brief Indicates whether notification thread should be running. | ||
*/ | ||
volatile bool m_runNotificationThread; | ||
|
||
/** | ||
* @brief Event used to nice end notifications thread. | ||
*/ | ||
swss::SelectableEvent m_notificationThreadShouldEndEvent; | ||
|
||
/** | ||
* @brief Notification thread | ||
*/ | ||
std::shared_ptr<std::thread> m_notificationThread; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#pragma once | ||
|
||
#include "Channel.h" | ||
|
||
#include "swss/producertable.h" | ||
#include "swss/consumertable.h" | ||
#include "swss/notificationconsumer.h" | ||
#include "swss/selectableevent.h" | ||
|
||
#include <memory> | ||
#include <functional> | ||
|
||
namespace sairedis | ||
{ | ||
class ZeroMQChannel: | ||
public Channel | ||
{ | ||
public: | ||
|
||
ZeroMQChannel( | ||
_In_ const std::string& endpoint, | ||
_In_ const std::string& ntfEndpoint, | ||
_In_ Channel::Callback callback); | ||
|
||
virtual ~ZeroMQChannel(); | ||
|
||
public: | ||
|
||
virtual void setBuffered( | ||
_In_ bool buffered) override; | ||
|
||
virtual void flush() override; | ||
|
||
virtual void set( | ||
_In_ const std::string& key, | ||
_In_ const std::vector<swss::FieldValueTuple>& values, | ||
_In_ const std::string& command) override; | ||
|
||
virtual void del( | ||
_In_ const std::string& key, | ||
_In_ const std::string& command) override; | ||
|
||
virtual sai_status_t wait( | ||
_In_ const std::string& command, | ||
_Out_ swss::KeyOpFieldsValuesTuple& kco) override; | ||
|
||
protected: | ||
|
||
virtual void notificationThreadFunction() override; | ||
|
||
private: | ||
|
||
std::string m_endpoint; | ||
|
||
std::string m_ntfEndpoint; | ||
|
||
std::vector<uint8_t> m_buffer; | ||
|
||
void* m_context; | ||
|
||
void* m_socket; | ||
|
||
void* m_ntfContext; | ||
|
||
void* m_ntfSocket; | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "Channel.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
using namespace sairedis; | ||
|
||
Channel::Channel( | ||
_In_ Callback callback): | ||
m_callback(callback) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
// empty | ||
} | ||
|
||
Channel::~Channel() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
// empty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.