Commit 6516c02f authored by Alessio Netti's avatar Alessio Netti
Browse files

Fixes after merge of master branch

- Changes mostly affect the REST API
parent 3b74a90b
......@@ -343,7 +343,7 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
for (const auto& s : u->getBaseOutputs()) {
// Explicitly adding nodes to the ptree as to prevent BOOST from performing
// parsing on the node names
group.push_back(boost::property_tree::ptree::value_type(s->getName(), boost::property_tree::ptree(s->getMqtt())));
group.push_back(boost::property_tree::ptree::value_type("", boost::property_tree::ptree(s->getMqtt())));
}
}
sensors.add_child(a->getName(), group);
......@@ -357,7 +357,7 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
found = true;
for (const auto& u : a->getUnits()) {
for (const auto& s : u->getBaseOutputs()) {
data << a->getName() << "." << s->getName() << " " << s->getMqtt() << "\n";
data << a->getName() << "::" << s->getMqtt() << "\n";
}
}
}
......@@ -400,7 +400,7 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
found = true;
boost::property_tree::ptree group;
for (const auto& u : a->getUnits()) {
group.push_back(boost::property_tree::ptree::value_type(u->getName(), boost::property_tree::ptree()));
group.push_back(boost::property_tree::ptree::value_type("", boost::property_tree::ptree(u->getName())));
}
units.add_child(a->getName(), group);
}
......@@ -411,7 +411,7 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
if (a->getStreaming() && (analyzer == "" || analyzer == a->getName())) {
found = true;
for (const auto& u : a->getUnits()) {
data << a->getName() << "." << u->getName() << "\n";
data << a->getName() << "::" << u->getName() << "\n";
}
}
}
......@@ -535,7 +535,7 @@ void AnalyticsManager::PUT_analytics_compute(endpointArgs) {
const std::string plugin = getQuery("plugin", queries);
const std::string analyzer = getQuery("analyzer", queries);
std::string unit = getQuery("unit", queries);
std::string unit = MQTTChecker::nameToTopic(getQuery("unit", queries));
if (plugin == "" || analyzer == "") {
res.body() = "Request malformed: plugin or analyzer query missing\n";
......
......@@ -34,7 +34,7 @@ void CARestAPI::GET_help(endpointArgs) {
}
void CARestAPI::GET_average(endpointArgs) {
const std::string sensor = getQuery("sensor", queries);
const std::string sensor = MQTTChecker::nameToTopic(getQuery("sensor", queries));
const std::string interval = getQuery("interval", queries);
if (sensor == "") {
......@@ -58,7 +58,6 @@ void CARestAPI::GET_average(endpointArgs) {
//try getting the latest value
try {
//TODO: switch from SID input to sensor name input
int64_t val = _sensorCache->getSensor(sensor, (uint64_t) time * 1000000000);
res.body() = "collectagent::" + sensor + " Average of last " +
......
......@@ -11,6 +11,7 @@
#include "RESTHttpsServer.h"
#include "analyticscontroller.h"
#include "mqttchecker.h"
class CARestAPI : public RESTHttpsServer {
public:
......
......@@ -11,7 +11,7 @@
#include <unistd.h>
#include "timestamp.h"
MQTTPusher::MQTTPusher(int brokerPort, const std::string& brokerHost, const std::string& sensorPattern, int qosLevel,
MQTTPusher::MQTTPusher(int brokerPort, const std::string& brokerHost, const bool autoPublish, int qosLevel,
pusherPluginStorage_t& plugins, an_pluginVector_t& aPlugins, int maxNumberOfMessages, unsigned int maxInflightMsgNum, unsigned int maxQueuedMsgNum) :
_qosLevel(qosLevel),
_brokerPort(brokerPort),
......
......@@ -24,7 +24,7 @@ enum msgCap_t {DISABLED = 1, ENABLED = 2, MINIMUM = 3};
*/
class MQTTPusher {
public:
MQTTPusher(int brokerPort, const std::string& brokerHost, const std::string& sensorPattern, int qosLevel,
MQTTPusher(int brokerPort, const std::string& brokerHost, const bool autoPublish, int qosLevel,
pusherPluginStorage_t& plugins, an_pluginVector_t& aPlugins, int maxNumberOfMessages, unsigned int maxInflightMsgNum, unsigned int maxQueuedMsgNum);
virtual ~MQTTPusher();
......@@ -88,7 +88,7 @@ private:
int _qosLevel;
int _brokerPort;
std::string _brokerHost;
std::string _sensorPattern;
bool _autoPublish;
pusherPluginStorage_t& _plugins;
an_pluginVector_t& _analyticsPlugins;
struct mosquitto* _mosq;
......
......@@ -84,7 +84,7 @@ void RestAPI::GET_sensors(endpointArgs) {
for(const auto& g : p.configurator->getSensorGroups()) {
boost::property_tree::ptree group;
for(const auto& s : g->getSensors()) {
group.put(s->getName(), s->getMqtt());
group.push_back(boost::property_tree::ptree::value_type("", boost::property_tree::ptree(s->getMqtt())));
}
sensors.add_child(g->getGroupName(), group);
}
......@@ -93,7 +93,7 @@ void RestAPI::GET_sensors(endpointArgs) {
} else {
for(const auto& g : p.configurator->getSensorGroups()) {
for(const auto& s : g->getSensors()) {
data << g->getGroupName() << "." << s->getName() << " " << s->getMqtt() << "\n";
data << g->getGroupName() << "::" << s->getMqtt() << "\n";
}
}
}
......@@ -106,7 +106,7 @@ void RestAPI::GET_sensors(endpointArgs) {
void RestAPI::GET_average(endpointArgs) {
const std::string plugin = getQuery("plugin", queries);
const std::string sensor = getQuery("sensor", queries);
const std::string sensor = MQTTChecker::nameToTopic(getQuery("sensor", queries));
const std::string interval = getQuery("interval", queries);
if (plugin == "" || sensor == "") {
......
......@@ -266,7 +266,7 @@ int main(int argc, char** argv) {
// Preparing the SensorNavigator
if(_analyticsManager->probe(argv[argc-1], "dcdbpusher.conf")) {
std::shared_ptr <SensorNavigator> navigator = std::make_shared<SensorNavigator>();
vector <std::string> names, topics;
vector <std::string> topics;
for (const auto &p : _pluginManager->getPlugins())
for (const auto &g : p.configurator->getSensorGroups())
for (const auto &s : g->getSensors())
......@@ -345,7 +345,7 @@ int main(int argc, char** argv) {
}
//MQTTPusher and Https server get their own threads
_mqttPusher = new MQTTPusher(globalSettings.brokerPort, globalSettings.brokerHost, pluginSettings.sensorPattern, globalSettings.qosLevel,
_mqttPusher = new MQTTPusher(globalSettings.brokerPort, globalSettings.brokerHost, pluginSettings.autoPublish, globalSettings.qosLevel,
_pluginManager->getPlugins(), _analyticsManager->getPlugins(), globalSettings.maxMsgNum, globalSettings.maxInflightMsgNum, globalSettings.maxQueuedMsgNum);
_httpsServer = new RestAPI(restAPISettings, _pluginManager, _mqttPusher, _analyticsManager, io);
_configuration->readRestAPIUsers(_httpsServer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment