Commit f8703fc3 authored by Micha Müller's avatar Micha Müller

Batch of compiler fixes

parent fd8c374a
This diff is collapsed.
......@@ -135,6 +135,48 @@ public:
*/
bool stop(const string& plugin="", const string& analyzer="");
/**
* @brief Supply a REST command to the manager
*
* Commands must be plugin-specific. Those will be forwarded to said plugins, if of GET type, and
* the result will be collected. If PUT type, one or more actions will be performed on the plugin
* (e.g. start or stop). Some generic commands are available as well (see cheatsheet).
*
* @param pathStrs resource path to be accessed
* @param queries vector of queries
* @param method Either GET or PUT
* @param io BOOST IO Service, required to reload plugins
* @return Response as a <data, response> pair
*/
restResponse_t REST(const vector<string>& pathStrs, const vector<pair<string,string>>& queries, const string& method, boost::asio::io_service& io);
// String used as a response for the REST GET /help command
const string restCheatSheet = "dcdbpusher analytics RESTful API cheatsheet:\n"
" -GET: /analytics/plugins List of currently loaded plugins (Discovery)\n"
" /analytics/[plugin]/analyzers\n"
" List of running analyzers in the specified\n"
" data analytics plugin\n"
" /analytics/[plugin]/[analyzer]/sensors\n"
" List of currently running sensors which belong\n"
" to the specified data analytics plugin (Discovery)\n"
" /analytics/[plugin]/[analyzer]/units\n"
" List of units to which sensors are associated in the\n"
" specified data analytics plugin (Discovery)\n"
" -PUT: /analytics/[plugin]/[analyzer]/[start|stop|reload]\n"
" Start/stop the analyzers of the plugin or\n"
" reload the plugin configuration\n"
" /analytics/[plugin]/[analyzer]/compute\n"
" Perform computation of the given analyzer\n"
" in real-time. A \"unit\" query, specifying\n"
" the target unit must be included\n"
" /analytics/[plugin]/[analyzer]/[action]\n"
" Perform plugin-specific actions\n"
" (refer to documentation)\n"
"\n"
"All resources have to be prepended by host:port and need at\n"
"least the query ?authkey=[token] at the end. Multiple queries\n"
"need to be separated by semicolons(';')\n";
/**
* @brief Get the vector of currently loaded plugins
*
......
......@@ -147,6 +147,23 @@ public:
*/
virtual restResponse_t REST(const string& action, const unordered_map<string, string>& queries) = 0;
/**
* For LEGACY SUPPORT only.
* TODO switch to new Rest API design with the method above
*
* @brief Perform a REST-triggered PUT action
*
* This method must be implemented in derived classes. It will perform an action (if any)
* on the analyzer according to the input action string. Any thrown
* exceptions will be reported in the response string.
*
* @param action Name of the action to be performed
* @param queries Vector of queries (key-value pairs)
*
* @return Response to the request as a <response, data> pair
*/
virtual restResponse_t REST(const string& action, const vector<pair<string,string>>& queries) = 0;
/**
* @brief Starts this analyzer
*
......
......@@ -225,6 +225,24 @@ public:
throw invalid_argument("Unknown plugin action " + action + " requested!");
}
/**
* For LEGACY SUPPORT only.
* TODO switch to new Rest API design with the method above
*
* @brief Perform a REST-triggered PUT action
*
* This is a dummy implementation that can be overridden in user plugins. Any thrown
* exceptions will be reported in the response string.
*
* @param action Name of the action to be performed
* @param queries Vector of queries (key-value pairs)
*
* @return Response to the request as a <response, data> pair
*/
virtual restResponse_t REST(const string& action, const vector<pair<string,string>>& queries) override {
throw invalid_argument("Unknown plugin action " + action + " requested!");
}
/**
* @brief Performs an on-demand compute task
*
......
......@@ -501,7 +501,7 @@ int main(int argc, char* const argv[]) {
Configuration& settings = config;
cassandra_t& cassandraSettings = config.cassandraSettings;
pluginSettings_t& pluginSettings = config.pluginSettings;
restAPISettings_t& restAPISettings = config.restAPISettings;
serverSettings_t& restAPISettings = config.restAPISettings;
analyticsSettings_t& analyticsSettings = config.analyticsSettings;
optind = 1;
......@@ -661,7 +661,7 @@ int main(int argc, char* const argv[]) {
#endif
LOG(info) << "RestAPI Settings:";
LOG(info) << " REST Server: " << restAPISettings.restHost << ":" << restAPISettings.restPort;
LOG(info) << " REST Server: " << restAPISettings.host << ":" << restAPISettings.port;
#ifdef SimpleMQTTVerbose
LOG(info) << " Certificate: " << restAPISettings.certificate;
LOG(info) << " Private key file: " << restAPISettings.privateKey;
......@@ -701,7 +701,7 @@ int main(int argc, char* const argv[]) {
httpOptions.reuse_address(true);
httpOptions.thread_pool(std::make_shared<boost::network::utils::thread_pool>());
httpServer_t httpServer(httpOptions.address(restAPISettings.restHost).port(restAPISettings.restPort));
httpServer_t httpServer(httpOptions.address(restAPISettings.host).port(restAPISettings.port));
httpThread = std::thread([&httpServer] { httpServer.run(); });
LOG(info) << "HTTP Server running...";
......
......@@ -51,8 +51,8 @@ public:
* @param cfgFileName Name of the file containing the config
*/
Configuration(const std::string& cfgFilePath, const std::string& cfgFileName) : GlobalConfiguration(cfgFilePath, cfgFileName) {
restAPISettings.restPort = string(RESTAPIPORT);
restAPISettings.restHost = string(RESTAPIHOST);
restAPISettings.port = string(RESTAPIPORT);
restAPISettings.host = string(RESTAPIHOST);
}
Configuration() {}
......
......@@ -10,7 +10,6 @@
#include <boost/foreach.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/algorithm/string.hpp>
#include "RestAPI.h"
#include "logging.h"
// Wrapper class for plugin-specific settings
......
......@@ -13,6 +13,7 @@
#include <boost/log/trivial.hpp>
#include "includes/PluginDefinitions.h"
#include "mqttchecker.h"
#include "RestAPI.h"
#define BROKERPORT 1883
#define BROKERHOST "127.0.0.1"
......
......@@ -13,6 +13,7 @@
#include <boost/asio.hpp>
#include "includes/PluginDefinitions.h"
#include "globalconfiguration.h"
#include "../analytics/AnalyticsManager.h"
#include "mqttchecker.h"
#include "MQTTPusher.h"
......
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