Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

MQTTPusher.h 1.65 KB
Newer Older
1
2
3
4
/*
 * MQTTPusher.h
 *
 *  Created on: 13.12.2017
5
 *      Author: Michael Ott (original), Micha Mueller
6
7
8
9
10
 */

#ifndef MQTTPUSHER_H_
#define MQTTPUSHER_H_

11
#define DCDB_MAP "/DCDB_MAP/"
12
#define PUSHER_IDLETIME 1000000000
13

14
#include <mosquitto.h>
15
#include "includes/PluginDefinitions.h"
16
17
18
#include "includes/SensorBase.h"
#include "analytics/AnalyticsManager.h"
#include <map>
19

Alessio Netti's avatar
Alessio Netti committed
20
21
enum msgCap_t {DISABLED = 1, ENABLED = 2, MINIMUM = 3};

Micha Mueller's avatar
Micha Mueller committed
22
/**
Micha Mueller's avatar
Micha Mueller committed
23
 * Class responsible for collecting values from the sensors and pushing them to the database.
Micha Mueller's avatar
Micha Mueller committed
24
 */
25
26
class MQTTPusher {
public:
27
	MQTTPusher(int brokerPort, const std::string& brokerHost, const std::string& sensorPattern, int qosLevel,
Alessio Netti's avatar
Alessio Netti committed
28
			   pluginVector_t& plugins, an_pluginVector_t& aPlugins, int maxNumberOfMessages, unsigned int maxInflightMsgNum, unsigned int maxQueuedMsgNum);
29
30
31
	virtual ~MQTTPusher();

	void push();
32
	bool sendMappings();
33

34
35
36
37
38
39
40
41
	void start() {
		_keepRunning = true;
	}

	void stop() {
		_keepRunning = false;
	}

42
43
44
45
46
	void halt() {
		_doHalt = true;
	}

	void cont() {
Alessio Netti's avatar
Alessio Netti committed
47
		computeMsgRate();
48
49
50
51
52
53
54
		_doHalt = false;
	}

	bool isHalted() const {
		return _halted;
	}

55
private:
56
	int sendReadings(SensorBase& s, reading_t* reads, std::size_t& totalCount);
Alessio Netti's avatar
Alessio Netti committed
57
	void computeMsgRate();
58

Alessio Netti's avatar
Alessio Netti committed
59
	int _qosLevel;
60
61
	int _brokerPort;
	std::string _brokerHost;
62
	std::string _sensorPattern;
63
	pluginVector_t& _plugins;
64
	an_pluginVector_t& _analyticsPlugins;
65
66
	struct mosquitto* _mosq;
	bool _connected;
67
	bool _keepRunning;
Alessio Netti's avatar
Alessio Netti committed
68
	msgCap_t _msgCap;
69
70
	bool _doHalt;
	bool _halted;
Alessio Netti's avatar
Alessio Netti committed
71
	int _maxNumberOfMessages;
72
73
	unsigned int _maxInflightMsgNum;
	unsigned int _maxQueuedMsgNum;
74
75

	boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
76
77
78
};

#endif /* MQTTPUSHER_H_ */