BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Member Functions | Protected Member Functions | Protected Attributes
BeeeOn::AbstractGWSConnector Class Reference

Most GWSConnector implementations would solve the issue of sending prioritization and asynchronous queuing of outgoing messages. The AbstractGWSConnector aims on this issue. More...

#include <AbstractGWSConnector.h>

Inheritance diagram for BeeeOn::AbstractGWSConnector:
BeeeOn::GWSConnector BeeeOn::Loggable BeeeOn::GWSConnectorImpl

Public Member Functions

void setOutputsCount (int count)
 
void setPriorityAssigner (GWSPriorityAssigner::Ptr assigner)
 
void setupQueues ()
 Setup queues based on configuration. This must be called before the connector is started.
 
void send (const GWMessage::Ptr message) override
 Put the message into a queue and notify sender to check queues for updates.
 
- Public Member Functions inherited from BeeeOn::GWSConnector
void addListener (GWSListener::Ptr listener)
 Register a GWSListener instance that would receive events related to the communication.
 
void clearListeners ()
 Remove all registered listeners.
 
void setEventsExecutor (AsyncExecutor::Ptr executor)
 Configure an AsyncExecutor instance that would be used for GWSListener events delivery.
 

Protected Member Functions

size_t selectOutput () const
 
void updateOutputs (size_t i)
 
bool outputValid (size_t i) const
 
GWMessage::Ptr peekOutput (size_t i) const
 
void popOutput (size_t i)
 Pop the first (oldest) message in the queue of the given index.
 
- Protected Member Functions inherited from BeeeOn::GWSConnector
template<typename Event , typename Method >
void fireEvent (const Event &e, const Method &m)
 
void fireReceived (const GWMessage::Ptr message)
 
- Protected Member Functions inherited from BeeeOn::Loggable
void setupLogger (Poco::Logger *logger=0) const
 
Poco::Logger & logger () const
 
 Loggable (const ClassInfo &info)
 
 Loggable (const std::type_info &info)
 

Protected Attributes

Poco::Event m_outputsUpdated
 
Poco::Mutex m_outputLock
 

Additional Inherited Members

- Public Types inherited from BeeeOn::GWSConnector
typedef Poco::SharedPtr
< GWSConnector
Ptr
 
- Static Protected Member Functions inherited from BeeeOn::Loggable
static Poco::Logger & forMethod (const char *name)
 
static Poco::Logger & forClass (const ClassInfo &info)
 
static Poco::Logger & forClass (const std::type_info &info)
 
template<typename T >
static Poco::Logger & forInstance (const T *i)
 
static void configureSimple (Poco::Logger &logger, const std::string &level)
 
static void logException (Poco::Logger &logger, const Poco::Message::Priority priority, const Poco::Exception &e, const char *file, size_t line)
 

Detailed Description

Most GWSConnector implementations would solve the issue of sending prioritization and asynchronous queuing of outgoing messages. The AbstractGWSConnector aims on this issue.

AbstractGWSConnector implements a queuing mechanism for outgoing messages. Each message is appended to a queue based on its priority. The queue number 0 is the most urgent queue.

Each queue contains a statistic of count of messages sent from the queue. A message for output is selected based on the following algorithm:

  1. take queue[i] (initially i := 0) with status[i]
  2. sum all status[j] for j > i
  3. if the status[i] <= sum(status[all j]), use queue i
  4. i := i + 1, try again

Empty or unused queues are skipped. Summarization... The first queue must always send more messages then all the other queues. If the first queue sends more messages then available in other queues (the first queue has been satisfied), the following queue is used with the same algorithm.

Member Function Documentation

bool AbstractGWSConnector::outputValid ( size_t  i) const
protected
Returns
true if the queue of the given index is valid (existing queue)
GWMessage::Ptr AbstractGWSConnector::peekOutput ( size_t  i) const
protected
Returns
first message in the queue of the given index
size_t AbstractGWSConnector::selectOutput ( ) const
protected
Returns
index of output queue to send from.
void AbstractGWSConnector::updateOutputs ( size_t  i)
protected

Update status of output queues. The given index denotes queue that has been used to send a message.


The documentation for this class was generated from the following files: