Commit 23d04c54 authored by Alessio Netti's avatar Alessio Netti

Analytics: operator plugins now report their version when loaded

- Plus other logging consistency changes
parent eec37385
......@@ -111,7 +111,7 @@ bool OperatorManager::load(const string& path, const string& globalFile, const p
}
bool OperatorManager::loadPlugin(const string& name, const string& pluginPath, const string& config) {
LOG(info) << "Loading operator plugin \"" << name << "\"...";
LOG(info) << "Loading operator plugin " << name << "...";
std::string pluginConfig; //path to config file for plugin
std::string pluginLib = "libdcdboperator_" + name;
#if __APPLE__
......@@ -171,20 +171,20 @@ bool OperatorManager::loadPlugin(const string& name, const string& pluginPath, c
dynLib.configurator->setGlobalSettings(_pluginSettings);
// Read the operator plugin configuration
if (!(dynLib.configurator->readConfig(pluginConfig))) {
LOG(error) << "Plugin \"" << dynLib.id << "\" could not read configuration!";
LOG(error) << "Plugin " << dynLib.id << " could not read configuration!";
return false;
}
// Returning an empty vector may indicate problems with the config file
if(dynLib.configurator->getOperators().size() == 0) {
LOG(warning) << "Plugin \"" << dynLib.id << "\" created no operators!";
LOG(warning) << "Plugin " << dynLib.id << " created no operators!";
} else if(!checkTopics(dynLib)) {
LOG(error) << "Problematic MQTT topics or sensor names, please check your config files!";
return false;
}
//save dl-struct
_plugins.push_back(dynLib);
LOG(info) << "Plugin \"" << dynLib.id << "\" loaded!";
LOG(info) << "Plugin " << dynLib.id << " " << dynLib.configurator->getVersion() << " loaded!";
} else {
LOG(info) << pluginConfig << " not found. Omitting";
return false;
......@@ -230,7 +230,7 @@ bool OperatorManager::init(boost::asio::io_service& io, const string& plugin) {
//Actions always affect either one or all plugins, and always all operators within said plugin
if(plugin=="" || plugin==p.id) {
out = true;
LOG(info) << "Init \"" << p.id << "\" operator plugin";
LOG(info) << "Init " << p.id << " operator plugin";
for (const auto &op : p.configurator->getOperators())
op->init(io);
}
......@@ -245,7 +245,7 @@ bool OperatorManager::reload(boost::asio::io_service& io, const string& plugin)
bool out=false;
for (const auto &p : _plugins)
if(plugin=="" || plugin==p.id) {
LOG(info) << "Reload \"" << p.id << "\" operator plugin";
LOG(info) << "Reload " << p.id << " operator plugin";
out = true;
//Removing obsolete MQTT topics
removeTopics(p);
......@@ -304,7 +304,7 @@ bool OperatorManager::start(const string& plugin, const string& operatorN) {
bool out=false;
for (const auto &p : _plugins)
if(plugin=="" || plugin==p.id) {
LOG(info) << "Start \"" << p.id << "\" operator plugin";
LOG(info) << "Start " << p.id << " operator plugin";
for (const auto &op : p.configurator->getOperators())
// Only streaming operators can be started
if(op->getStreaming() && (operatorN=="" || operatorN==op->getName())) {
......@@ -323,7 +323,7 @@ bool OperatorManager::stop(const string& plugin, const string& operatorN) {
bool out=false;
for (const auto &p : _plugins)
if(plugin=="" || plugin==p.id) {
LOG(info) << "Stop \"" << p.id << "\" operator plugin";
LOG(info) << "Stop " << p.id << " operator plugin";
for (const auto &op : p.configurator->getOperators())
// Only streaming operators can be stopped
if(op->getStreaming() && (operatorN=="" || operatorN==op->getName())) {
......
......@@ -30,6 +30,7 @@
#include <string>
#include <vector>
#include "version.h"
#include "QueryEngine.h"
#include "OperatorInterface.h"
......@@ -115,6 +116,15 @@ public:
*/
virtual void printConfig(LOG_LEVEL ll) = 0;
/**
* @brief Get current DCDB version.
*
* @return Version number as string.
*/
std::string getVersion() {
return std::string(VERSION);
}
protected:
// Logger object
......
......@@ -73,7 +73,7 @@ bool Configuration::readPlugins(PluginManager &pluginManager) {
std::string pluginConfig = ""; // path to config file for plugin
std::string pluginPath = ""; // path to plugin
LOG(info) << "Read plugin " << pluginName << "...";
//LOG(info) << "Read plugin " << pluginName << "...";
BOOST_FOREACH (boost::property_tree::iptree::value_type &val, plugin.second) {
if (boost::iequals(val.first, "path")) {
......
......@@ -182,6 +182,7 @@ bool PluginManager::initPlugin(boost::asio::io_service &io,
for (const auto &p : _plugins) {
if (p.id == id || id == "") {
LOG(info) << "Init " << p.id << " plugin";
for (const auto &g : p.configurator->getSensorGroups()) {
found = true;
g->init(io);
......@@ -191,8 +192,6 @@ bool PluginManager::initPlugin(boost::asio::io_service &io,
if (!found) {
LOG(warning) << "Could not find plugin " << id << " to initialize!";
} else {
LOG(info) << "Initialized plugin " << id;
}
return found;
}
......@@ -202,6 +201,7 @@ bool PluginManager::startPlugin(const string &id) {
for (const auto &p : _plugins) {
if (p.id == id || id == "") {
LOG(info) << "Start " << p.id << " plugin";
for (const auto &g : p.configurator->getSensorGroups()) {
found = true;
g->start();
......@@ -211,8 +211,6 @@ bool PluginManager::startPlugin(const string &id) {
if (!found) {
LOG(warning) << "Could not find plugin " << id << " to start!";
} else {
LOG(info) << "Started plugin " << id;
}
return found;
}
......@@ -222,21 +220,21 @@ bool PluginManager::stopPlugin(const string &id) {
for (const auto &p : _plugins) {
if (p.id == id || id == "") {
LOG(info) << "Stop " << p.id << " plugin";
// Issuing stop command
for (const auto &g : p.configurator->getSensorGroups()) {
found = true;
g->stop();
}
// Waiting for sensor group termination
for (const auto &g : p.configurator->getSensorGroups())
g->wait();
for (const auto &g : p.configurator->getSensorGroups()) {
g->wait();
}
}
}
if (!found) {
LOG(warning) << "Could not find plugin " << id << " to stop!";
} else {
LOG(info) << "Stopped plugin " << id;
}
return found;
}
......
......@@ -139,11 +139,11 @@ void sigHandler(int sig) {
retCode = !_httpsServer ? EXIT_SUCCESS : _httpsServer->getReturnCode();
}
LOG(info) << "Stopping sensors...";
//Stop data analytics plugins and operators
_operatorManager->stop();
//Stop all sensors
LOG(info) << "Stopping sensors...";
_pluginManager->stopPlugin();
//Stop io service by killing keepAliveWork
......
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