 |
Fledge
An open source edge computing platform for industrial users
|
4 #include <north_plugin.h>
5 #include <reading_set.h>
9 #include <condition_variable>
10 #include <perfmonitors.h>
13 #define FLUSH_STATS_INTERVAL 5
15 #define STATS_UPDATE_FAIL_THRESHOLD 3
18 #define FAILURE_BACKOFF_THRESHOLD 10 // Number of consequetive failures to trigger backoff
19 #define MIN_SEND_BACKOFF 50 // Min backoff in milliseconds
20 #define MAX_SEND_BACKOFF 60000 // Max backoff in milliseconds
30 void updatePlugin(
NorthPlugin *plugin) { m_plugin = plugin; };
34 bool isRunning() {
return !m_shutdown; };
39 void updateStatistics(uint32_t increment);
40 bool createStats(
const std::string &key,
unsigned int value);
48 volatile bool m_shutdown;
49 std::thread *m_thread;
53 std::mutex m_pauseMutex;
54 std::condition_variable m_pauseCV;
57 std::thread *m_statsThread;
58 std::mutex m_flushStatsMtx;
60 std::condition_variable m_statsCv;
61 std::mutex m_statsMtx;
62 std::map<std::string, unsigned int>
63 m_statsPendingEntries;
64 int m_statsUpdateFails;
66 std::unordered_set<std::string>
67 m_statsDbEntriesCache;
68 unsigned int m_repeatedFailure;
69 unsigned int m_sendBackoffTime;
70 std::mutex m_backoffMutex;
71 std::condition_variable m_backoffCV;
Definition: data_sender.h:25
void pause()
Cause the data sender process to pause sending data until a corresponding release call is made.
Definition: data_send.cpp:286
DataSender(NorthPlugin *plugin, DataLoad *loader, NorthService *north)
Constructor for the data sending class.
Definition: data_send.cpp:42
void flushStatistics()
Flush statistics to storage service.
Definition: data_send.cpp:356
void release()
Release the paused data sender thread.
Definition: data_send.cpp:300
Class that represents a north plugin.
Definition: north_plugin.h:33
~DataSender()
Destructor for the data sender class.
Definition: data_send.cpp:72
Reading set class.
Definition: reading_set.h:26
void configChange()
Notify the data sender that there has been a configuration change.
Definition: data_send.cpp:532
A class used in the North service to load data from the buffer.
Definition: data_load.h:24
bool isDryRun()
Check status of dryrun flag.
Definition: data_send.cpp:521
Fledge Logger class used to log to syslog.
Definition: logger.h:42
The NorthService class.
Definition: north_service.h:42
void sendThread()
The sending thread entry point.
Definition: data_send.cpp:96