BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
Implements Exporter interface and provides SensorData prevents SensorData loss. More...
#include <QueuingExporter.h>
Public Types | |
typedef Poco::SharedPtr < QueuingExporter > | Ptr |
Public Member Functions | |
bool | ship (const SensorData &data) override |
void | setStrategy (const QueuingStrategy::Ptr strategy) |
void | setSaveThreshold (const int dataCount) |
void | setSaveTimeout (const Poco::Timespan &timeout) |
void | setStrategyPriority (const int percent) |
Protected Member Functions | |
void | acquire (std::vector< SensorData > &data, size_t count, const Poco::Timespan &timeout) |
void | ack () |
void | reset () |
bool | empty () const |
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) | |
Additional Inherited Members | |
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) |
Implements Exporter interface and provides SensorData prevents SensorData loss.
QueuingExporter serves as interface for any particular exporter. It prevents SensorData loss by buffering them and cooperating with a QueuingStrategy. By inheritance of this class, the particular exporter can work with the data via acquire(), ack() and reset() methods.
As long as this class implements the Exporter interface, it can be used with any particular class which implements the Distributor interface. Despite the particular Distributor could provide its own data buffering, it is not needed for any particular Exporter that inherits from QueuingExporter. QueuingExporter always reports successful export and provides both the persistent and via the QueuingStrategy also non-persistent buffering.
QueuingExporter has its own buffer, which serves as a temporary SensorData backup. When a situation that could lead to significant loss of the data occurs, or when the data loss is probable, the data from buffer are pushed to the QueuingStrategy.
|
protected |
When this method is called, all the previously acquired data are permanently deleted.
|
protected |
Acquires the data from the queue and from the QueuingStrategy.
data | Vector to be filled with the acquired data. This method does not clear the vector, but just adds the data to the end of it. |
count | The count of data to be acquired. This number gives the maximum count, if there are less data available, the vector is filled just by them (if no data are available, the vector stays as it was given). |
timeout | If there are no data available, this method waits for the new data income, but for a maximum of this timeout. |
|
protected |
|
protected |
After calling this method, no data are longer considered as acquired.
void QueuingExporter::setSaveThreshold | ( | const int | dataCount | ) |
When the number of enqueued SensorData is greater than or equal to saveThreshold, the data are pushed to the QueuingStrategy.
If the push to the QueuingStrategy is not successful, the oldest data in the buffer, that are not acquired, are erased. After this erase, the amount of data in the buffer is equal to saveThreshold - 1.
dataCount |
void QueuingExporter::setSaveTimeout | ( | const Poco::Timespan & | timeout | ) |
When the given timeout is elapsed since the last successful export, enqueued data are pushed to the QueuingStrategy.
timeout |
void QueuingExporter::setStrategyPriority | ( | const int | percent | ) |
Provided SensorData are mix from the queue and the QueuingStrategy. The strategyPriority gives the ratio of the provided data between the enqueued data and the data from the QueuingStrategy.
percent |
|
overridevirtual |