In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit e95764be authored by Alessio Netti's avatar Alessio Netti

Analytics: refactoring of Analyzers to Operators

- Make clean might be required
parent 33252803
......@@ -4,7 +4,7 @@ include ../config.mk
CXXFLAGS += -DBOOST_NETWORK_ENABLE_HTTPS -I../common/include -I$(DCDBDEPLOYPATH)/include -I$(DCDBDEPLOYPATH)/include/opencv4
LIBS = -L../lib -L$(DCDBDEPLOYPATH)/lib/ -ldl -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lboost_regex -lpthread -rdynamic
ANALYZERS = aggregator regressor job_aggregator testeranalyzer filesink smucngperfanalyzer
OPERATORS = aggregator regressor job_aggregator testeroperator filesink smucngperf
ifeq ($(OS),Darwin)
BACNET_PORT = bsd
......@@ -16,47 +16,47 @@ else
LIBFLAGS = -shared -Wl,-soname,
PLUGINFLAGS = -fPIC
endif
ANALYZER_LIBS = $(foreach p,$(ANALYZERS),libdcdbanalyzer_$(p).$(LIBEXT))
OPERATOR_LIBS = $(foreach p,$(OPERATORS),libdcdboperator_$(p).$(LIBEXT))
all: $(ANALYZER_LIBS)
all: $(OPERATOR_LIBS)
debug: CXXFLAGS += -DDEBUG
debug: all
clean:
rm -f $(ANALYZER_LIBS) $(shell find . -name "*.o")
rm -f $(OPERATOR_LIBS) $(shell find . -name "*.o")
rm -f ../common/src/sensornavigator.o
$(OBJS) : %.o : %.cpp
install_analyzer: $(ANALYZER_LIBS)
install_operator: $(OPERATOR_LIBS)
install $^ $(DCDBDEPLOYPATH)/lib/
install_conf: $(foreach p,$(ANALYZERS),config/$(p).conf)
install_conf: $(foreach p,$(OPERATORS),config/$(p).conf)
install -m 644 $^ $(DCDBDEPLOYPATH)/etc/
install: install_analyzer
install: install_operator
@echo "Done with installation."
@echo "====================================="
@echo "To copy the configuration files type:"
@echo " > make install_conf"
analyzers/%.o: CXXFLAGS+= $(PLUGINFLAGS)
operators/%.o: CXXFLAGS+= $(PLUGINFLAGS)
../common/src/sensornavigator.o: CXXFLAGS+= $(PLUGINFLAGS)
libdcdbanalyzer_aggregator.$(LIBEXT): analyzers/aggregator/AggregatorAnalyzer.o analyzers/aggregator/AggregatorConfigurator.o ../common/src/sensornavigator.o
libdcdboperator_aggregator.$(LIBEXT): operators/aggregator/AggregatorOperator.o operators/aggregator/AggregatorConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
libdcdbanalyzer_regressor.$(LIBEXT): analyzers/regressor/RegressorAnalyzer.o analyzers/regressor/RegressorConfigurator.o ../common/src/sensornavigator.o
libdcdboperator_regressor.$(LIBEXT): operators/regressor/RegressorOperator.o operators/regressor/RegressorConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex -lopencv_core -lopencv_ml
libdcdbanalyzer_job_aggregator.$(LIBEXT): analyzers/aggregator/AggregatorAnalyzer.o analyzers/aggregator/JobAggregatorAnalyzer.o analyzers/aggregator/JobAggregatorConfigurator.o ../common/src/sensornavigator.o
libdcdboperator_job_aggregator.$(LIBEXT): operators/aggregator/AggregatorOperator.o operators/aggregator/JobAggregatorOperator.o operators/aggregator/JobAggregatorConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
libdcdbanalyzer_testeranalyzer.$(LIBEXT): analyzers/testeranalyzer/TesterAnalyzer.o analyzers/testeranalyzer/TesterAnalyzerConfigurator.o ../common/src/sensornavigator.o
libdcdboperator_testeroperator.$(LIBEXT): operators/testeroperator/TesterOperator.o operators/testeroperator/TesterOperatorConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
libdcdbanalyzer_filesink.$(LIBEXT): analyzers/filesink/FilesinkAnalyzer.o analyzers/filesink/FilesinkConfigurator.o ../common/src/sensornavigator.o
libdcdboperator_filesink.$(LIBEXT): operators/filesink/FilesinkOperator.o operators/filesink/FilesinkConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
libdcdbanalyzer_smucngperfanalyzer.$(LIBEXT): analyzers/smucngperfanalyzer/SMUCNGPerfAnalyzer.o analyzers/smucngperfanalyzer/SMUCNGPerfConfigurator.o ../common/src/sensornavigator.o
libdcdboperator_smucngperf.$(LIBEXT): operators/smucngperf/SMUCNGPerfOperator.o operators/smucngperf/SMUCNGPerfConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
//================================================================================
// Name : AnalyticsManager.cpp
// Name : OperatorManager.cpp
// Author : Alessio Netti
// Contact : info@dcdb.it
// Copyright : Leibniz Supercomputing Centre
......@@ -25,17 +25,17 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
#include "AnalyticsManager.h"
#include "OperatorManager.h"
#include "timestamp.h"
void AnalyticsManager::clear() {
void OperatorManager::clear() {
for(const auto& p : _plugins)
p.destroy(p.configurator);
_plugins.clear();
_status = CLEAR;
}
bool AnalyticsManager::probe(const string& path, const string& globalFile) {
bool OperatorManager::probe(const string& path, const string& globalFile) {
std::string cfgPath = path;
boost::property_tree::iptree cfg;
......@@ -48,12 +48,12 @@ bool AnalyticsManager::probe(const string& path, const string& globalFile) {
return false;
}
if(cfg.find("analyzerPlugins") == cfg.not_found())
if(cfg.find("operatorPlugins") == cfg.not_found())
return false;
int pluginCtr = 0;
BOOST_FOREACH(boost::property_tree::iptree::value_type &plugin, cfg.get_child("analyzerPlugins")) {
if (boost::iequals(plugin.first, "analyzerPlugin"))
BOOST_FOREACH(boost::property_tree::iptree::value_type &plugin, cfg.get_child("operatorPlugins")) {
if (boost::iequals(plugin.first, "operatorPlugin"))
pluginCtr++;
}
......@@ -63,7 +63,7 @@ bool AnalyticsManager::probe(const string& path, const string& globalFile) {
return true;
}
bool AnalyticsManager::load(const string& path, const string& globalFile, const pluginSettings_t& pluginSettings) {
bool OperatorManager::load(const string& path, const string& globalFile, const pluginSettings_t& pluginSettings) {
//The load code is pretty much the same as in Configuration.cpp to load pusher plugins
_configPath = path;
_pluginSettings = pluginSettings;
......@@ -77,19 +77,19 @@ bool AnalyticsManager::load(const string& path, const string& globalFile, const
try {
boost::property_tree::read_info(_configPath + globalFile, cfg);
} catch (boost::property_tree::info_parser_error& e) {
LOG(error) << "Error when reading analyzer plugins from " << globalFile << ": " << e.what();
LOG(error) << "Error when reading operator plugins from " << globalFile << ": " << e.what();
return false;
}
if(cfg.find("analyzerPlugins") == cfg.not_found()) {
LOG(warning) << "No analyzerPlugins block found, skipping data analytics initialization!";
if(cfg.find("operatorPlugins") == cfg.not_found()) {
LOG(warning) << "No operatorPlugins block found, skipping data analytics initialization!";
_status = LOADED;
return true;
}
//Reading plugins
BOOST_FOREACH(boost::property_tree::iptree::value_type &plugin, cfg.get_child("analyzerPlugins")) {
if (boost::iequals(plugin.first, "analyzerPlugin")) {
BOOST_FOREACH(boost::property_tree::iptree::value_type &plugin, cfg.get_child("operatorPlugins")) {
if (boost::iequals(plugin.first, "operatorPlugin")) {
if (!plugin.second.empty()) {
string pluginConfig="", pluginPath="";
BOOST_FOREACH(boost::property_tree::iptree::value_type &val, plugin.second) {
......@@ -110,10 +110,10 @@ bool AnalyticsManager::load(const string& path, const string& globalFile, const
return true;
}
bool AnalyticsManager::loadPlugin(const string& name, const string& pluginPath, const string& config) {
LOG(info) << "Loading analyzer plugin \"" << name << "\"...";
bool OperatorManager::loadPlugin(const string& name, const string& pluginPath, const string& config) {
LOG(info) << "Loading operator plugin \"" << name << "\"...";
std::string pluginConfig; //path to config file for plugin
std::string pluginLib = "libdcdbanalyzer_" + name;
std::string pluginLib = "libdcdboperator_" + name;
#if __APPLE__
pluginLib+= ".dylib";
#else
......@@ -136,12 +136,12 @@ bool AnalyticsManager::loadPlugin(const string& name, const string& pluginPath,
// Open dl-code based on http://tldp.org/HOWTO/C++-dlopen/thesolution.html
if (FILE *file = fopen(pluginConfig.c_str(), "r")) {
fclose(file);
an_dl_t dynLib;
op_dl_t dynLib;
dynLib.id = name;
dynLib.DL = NULL;
dynLib.configurator = NULL;
// If plugin.conf exists, open libdcdbanalyzer_pluginName.so and read config
// If plugin.conf exists, open libdcdboperator_pluginName.so and read config
LOG(info) << pluginConfig << " found";
dynLib.DL = dlopen(pluginLib.c_str(), RTLD_NOW);
if(!dynLib.DL) {
......@@ -150,15 +150,15 @@ bool AnalyticsManager::loadPlugin(const string& name, const string& pluginPath,
}
dlerror();
// Set dynLib an_dl_t struct, load create and destroy symbols
dynLib.create = (an_create_t*) dlsym(dynLib.DL, "create");
// Set dynLib op_dl_t struct, load create and destroy symbols
dynLib.create = (op_create_t*) dlsym(dynLib.DL, "create");
const char* dlsym_error = dlerror();
if (dlsym_error) {
LOG(error) << "Cannot load symbol create for " << dynLib.id << ": " << dlsym_error;
return false;
}
dynLib.destroy = (an_destroy_t*) dlsym(dynLib.DL, "destroy");
dynLib.destroy = (op_destroy_t*) dlsym(dynLib.DL, "destroy");
dlsym_error = dlerror();
if (dlsym_error) {
LOG(error) << "Cannot load symbol destroy for " << dynLib.id << ": " << dlsym_error;
......@@ -167,15 +167,15 @@ bool AnalyticsManager::loadPlugin(const string& name, const string& pluginPath,
dynLib.configurator = dynLib.create();
dynLib.configurator->setGlobalSettings(_pluginSettings);
// Read the analyzer plugin configuration
// Read the operator plugin configuration
if (!(dynLib.configurator->readConfig(pluginConfig))) {
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->getAnalyzers().size() == 0) {
LOG(warning) << "Plugin \"" << dynLib.id << "\" created no analyzers!";
if(dynLib.configurator->getOperators().size() == 0) {
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;
......@@ -190,11 +190,11 @@ bool AnalyticsManager::loadPlugin(const string& name, const string& pluginPath,
return true;
}
void AnalyticsManager::unloadPlugin(const string& id) {
void OperatorManager::unloadPlugin(const string& id) {
for (auto it = _plugins.begin(); it != _plugins.end(); ++it) {
if(it->id == id || id == "") {
for (const auto& a : it->configurator->getAnalyzers())
a->stop();
for (const auto& op : it->configurator->getOperators())
op->stop();
removeTopics(*it);
......@@ -215,32 +215,32 @@ void AnalyticsManager::unloadPlugin(const string& id) {
_plugins.clear();
}
bool AnalyticsManager::init(boost::asio::io_service& io, const string& plugin) {
bool OperatorManager::init(boost::asio::io_service& io, const string& plugin) {
if(_status != LOADED) {
LOG(error) << "Cannot init, AnalyticsManager is not loaded!";
LOG(error) << "Cannot init, OperatorManager is not loaded!";
return false;
}
bool out=false;
for (const auto &p : _plugins)
//Actions always affect either one or all plugins, and always all analyzers within said 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 << "\" data analytics plugin";
for (const auto &a : p.configurator->getAnalyzers())
a->init(io);
LOG(info) << "Init \"" << p.id << "\" operator plugin";
for (const auto &op : p.configurator->getOperators())
op->init(io);
}
return out;
}
bool AnalyticsManager::reload(boost::asio::io_service& io, const string& plugin) {
bool OperatorManager::reload(boost::asio::io_service& io, const string& plugin) {
if(_status != LOADED) {
LOG(error) << "Cannot reload, AnalyticsManager is not loaded!";
LOG(error) << "Cannot reload, OperatorManager is not loaded!";
return false;
}
bool out=false;
for (const auto &p : _plugins)
if(plugin=="" || plugin==p.id) {
LOG(info) << "Reload \"" << p.id << "\" data analytics plugin";
LOG(info) << "Reload \"" << p.id << "\" operator plugin";
out = true;
//Removing obsolete MQTT topics
removeTopics(p);
......@@ -253,76 +253,76 @@ bool AnalyticsManager::reload(boost::asio::io_service& io, const string& plugin)
p.configurator->clearConfig();
return false;
} else
for (const auto &a : p.configurator->getAnalyzers())
a->init(io);
for (const auto &op : p.configurator->getOperators())
op->init(io);
}
return out;
}
void AnalyticsManager::removeTopics(an_dl_t p) {
void OperatorManager::removeTopics(op_dl_t p) {
MQTTChecker& mqttCheck = MQTTChecker::getInstance();
for(const auto& a : p.configurator->getAnalyzers()) {
mqttCheck.removeGroup(a->getName());
if (a->getStreaming()) {
for (const auto &u : a->getUnits())
for(const auto& op : p.configurator->getOperators()) {
mqttCheck.removeGroup(op->getName());
if (op->getStreaming()) {
for (const auto &u : op->getUnits())
for (const auto &o: u->getBaseOutputs()) {
mqttCheck.removeTopic(o->getMqtt());
mqttCheck.removeName(o->getName());
}
a->releaseUnits();
op->releaseUnits();
}
}
}
bool AnalyticsManager::checkTopics(an_dl_t p) {
bool OperatorManager::checkTopics(op_dl_t p) {
MQTTChecker& mqttCheck = MQTTChecker::getInstance();
bool validTopics=true;
for(const auto& a : p.configurator->getAnalyzers()) {
if (!mqttCheck.checkGroup(a->getName()))
for(const auto& op : p.configurator->getOperators()) {
if (!mqttCheck.checkGroup(op->getName()))
validTopics = false;
if (a->getStreaming()) {
for (const auto &u : a->getUnits())
if (op->getStreaming()) {
for (const auto &u : op->getUnits())
for (const auto &o: u->getBaseOutputs())
if (!mqttCheck.checkTopic(o->getMqtt()) || !mqttCheck.checkName(o->getName()))
validTopics = false;
a->releaseUnits();
op->releaseUnits();
}
}
return validTopics;
}
bool AnalyticsManager::start(const string& plugin, const string& analyzer) {
bool OperatorManager::start(const string& plugin, const string& operatorN) {
if(_status != LOADED) {
LOG(error) << "Cannot start, AnalyticsManager is not loaded!";
LOG(error) << "Cannot start, OperatorManager is not loaded!";
return false;
}
bool out=false;
for (const auto &p : _plugins)
if(plugin=="" || plugin==p.id) {
LOG(info) << "Start \"" << p.id << "\" data analytics plugin";
for (const auto &a : p.configurator->getAnalyzers())
// Only streaming analyzers can be started
if(a->getStreaming() && (analyzer=="" || analyzer==a->getName())) {
a->start();
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())) {
op->start();
out=true;
}
}
return out;
}
bool AnalyticsManager::stop(const string& plugin, const string& analyzer) {
bool OperatorManager::stop(const string& plugin, const string& operatorN) {
if(_status != LOADED) {
LOG(error) << "Cannot stop, AnalyticsManager is not loaded!";
LOG(error) << "Cannot stop, OperatorManager is not loaded!";
return false;
}
bool out=false;
for (const auto &p : _plugins)
if(plugin=="" || plugin==p.id) {
LOG(info) << "Stop \"" << p.id << "\" data analytics plugin";
for (const auto &a : p.configurator->getAnalyzers())
// Only streaming analyzers can be stopped
if(a->getStreaming() && (analyzer=="" || analyzer==a->getName())) {
a->stop();
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())) {
op->stop();
out=true;
}
}
......@@ -333,25 +333,25 @@ bool AnalyticsManager::stop(const string& plugin, const string& analyzer) {
/* Rest API endpoint methods */
/******************************************************************************/
#define stdBind(fun) std::bind(&AnalyticsManager::fun, \
#define stdBind(fun) std::bind(&OperatorManager::fun, \
this, \
std::placeholders::_1, \
std::placeholders::_2)
void AnalyticsManager::addRestEndpoints(RESTHttpsServer* restServer) {
void OperatorManager::addRestEndpoints(RESTHttpsServer* restServer) {
restServer->addEndpoint("/analytics/help", {http::verb::get, stdBind(GET_analytics_help)});
restServer->addEndpoint("/analytics/plugins", {http::verb::get, stdBind(GET_analytics_plugins)});
restServer->addEndpoint("/analytics/sensors", {http::verb::get, stdBind(GET_analytics_sensors)});
restServer->addEndpoint("/analytics/units", {http::verb::get, stdBind(GET_analytics_units)});
restServer->addEndpoint("/analytics/analyzers", {http::verb::get, stdBind(GET_analytics_analyzers)});
restServer->addEndpoint("/analytics/operators", {http::verb::get, stdBind(GET_analytics_operators)});
restServer->addEndpoint("/analytics/start", {http::verb::put, stdBind(PUT_analytics_start)});
restServer->addEndpoint("/analytics/stop", {http::verb::put, stdBind(PUT_analytics_stop)});
restServer->addEndpoint("/analytics/compute", {http::verb::put, stdBind(PUT_analytics_compute)});
restServer->addEndpoint("/analytics/analyzer", {http::verb::put, stdBind(PUT_analytics_analyzer)});
restServer->addEndpoint("/analytics/operator", {http::verb::put, stdBind(PUT_analytics_operator)});
}
void AnalyticsManager::GET_analytics_help(endpointArgs){
void OperatorManager::GET_analytics_help(endpointArgs){
if (!managerLoaded(res)) {
return;
}
......@@ -359,7 +359,7 @@ void AnalyticsManager::GET_analytics_help(endpointArgs){
res.result(http::status::ok);
}
void AnalyticsManager::GET_analytics_plugins(endpointArgs) {
void OperatorManager::GET_analytics_plugins(endpointArgs) {
if (!managerLoaded(res)) {
return;
}
......@@ -380,13 +380,13 @@ void AnalyticsManager::GET_analytics_plugins(endpointArgs) {
res.result(http::status::ok);
}
void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
void OperatorManager::GET_analytics_sensors(endpointArgs) {
if (!managerLoaded(res)) {
return;
}
const std::string plugin = getQuery("plugin", queries);
const std::string analyzer = getQuery("analyzer", queries);
const std::string oper = getQuery("operator", queries);
if (!hasPlugin(plugin, res)) {
return;
......@@ -400,34 +400,34 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
if (getQuery("json", queries) == "true") {
boost::property_tree::ptree root, sensors;
// In JSON mode, sensors are arranged hierarchically by plugin->analyzer->sensor
for (const auto& a : p.configurator->getAnalyzers()) {
if (a->getStreaming() && (analyzer == "" || analyzer == a->getName())) {
// In JSON mode, sensors are arranged hierarchically by plugin->operator->sensor
for (const auto& op : p.configurator->getOperators()) {
if (op->getStreaming() && (oper == "" || oper == op->getName())) {
found = true;
boost::property_tree::ptree group;
for (const auto& u : a->getUnits()) {
for (const auto& u : op->getUnits()) {
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("", boost::property_tree::ptree(s->getMqtt())));
}
}
a->releaseUnits();
sensors.add_child(a->getName(), group);
op->releaseUnits();
sensors.add_child(op->getName(), group);
}
}
root.add_child(p.id, sensors);
boost::property_tree::write_json(data, root, true);
} else {
for (const auto& a : p.configurator->getAnalyzers()) {
if (a->getStreaming() && (analyzer == "" || analyzer == a->getName())) {
for (const auto& op : p.configurator->getOperators()) {
if (op->getStreaming() && (oper == "" || oper == op->getName())) {
found = true;
for (const auto& u : a->getUnits()) {
for (const auto& u : op->getUnits()) {
for (const auto& s : u->getBaseOutputs()) {
data << a->getName() << "::" << s->getMqtt() << "\n";
data << op->getName() << "::" << s->getMqtt() << "\n";
}
}
a->releaseUnits();
op->releaseUnits();
}
}
}
......@@ -437,18 +437,18 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
}
}
if (!found) {
res.body() = "Plugin or analyzer not found!\n";
res.body() = "Plugin or operator not found!\n";
res.result(http::status::not_found);
}
}
void AnalyticsManager::GET_analytics_units(endpointArgs) {
void OperatorManager::GET_analytics_units(endpointArgs) {
if (!managerLoaded(res)) {
return;
}
const std::string plugin = getQuery("plugin", queries);
const std::string analyzer = getQuery("analyzer", queries);
const std::string oper = getQuery("operator", queries);
if (!hasPlugin(plugin, res)) {
return;
......@@ -462,27 +462,27 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
if (getQuery("json", queries) == "true") {
boost::property_tree::ptree root, units;
// In JSON mode, sensors are arranged hierarchically by plugin->analyzer->sensor
for (const auto& a : p.configurator->getAnalyzers())
if (a->getStreaming() && (analyzer == "" || analyzer == a->getName())) {
// In JSON mode, sensors are arranged hierarchically by plugin->operator->sensor
for (const auto& op : p.configurator->getOperators())
if (op->getStreaming() && (oper == "" || oper == op->getName())) {
found = true;
boost::property_tree::ptree group;
for (const auto& u : a->getUnits()) {
for (const auto& u : op->getUnits()) {
group.push_back(boost::property_tree::ptree::value_type("", boost::property_tree::ptree(u->getName())));
}
a->releaseUnits();
units.add_child(a->getName(), group);
op->releaseUnits();
units.add_child(op->getName(), group);
}
root.add_child(p.id, units);
boost::property_tree::write_json(data, root, true);
} else {
for (const auto& a : p.configurator->getAnalyzers()) {
if (a->getStreaming() && (analyzer == "" || analyzer == a->getName())) {
for (const auto& op : p.configurator->getOperators()) {
if (op->getStreaming() && (oper == "" || oper == op->getName())) {
found = true;
for (const auto& u : a->getUnits()) {
data << a->getName() << "::" << u->getName() << "\n";
for (const auto& u : op->getUnits()) {
data << op->getName() << "::" << u->getName() << "\n";
}
a->releaseUnits();
op->releaseUnits();
}
}
}
......@@ -492,12 +492,12 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
}
}
if (!found) {
res.body() = "Plugin or analyzer not found!\n";
res.body() = "Plugin or operator not found!\n";
res.result(http::status::not_found);
}
}
void AnalyticsManager::GET_analytics_analyzers(endpointArgs) {
void OperatorManager::GET_analytics_operators(endpointArgs) {
if (!managerLoaded(res)) {
return;
}
......@@ -513,17 +513,17 @@ void AnalyticsManager::GET_analytics_analyzers(endpointArgs) {
for (const auto& p : _plugins) {
if (p.id == plugin) {
if (getQuery("json", queries) == "true") {
boost::property_tree::ptree root, analyzers;
boost::property_tree::ptree root, operators;
// For each analyzer, we output its type as well
for (const auto& a : p.configurator->getAnalyzers()) {
analyzers.push_back(boost::property_tree::ptree::value_type(a->getName(), boost::property_tree::ptree(a->getStreaming() ? "streaming" : "on-demand")));
// For each operator, we output its type as well
for (const auto& op : p.configurator->getOperators()) {
operators.push_back(boost::property_tree::ptree::value_type(op->getName(), boost::property_tree::ptree(op->getStreaming() ? "streaming" : "on-demand")));
}
root.add_child(p.id, analyzers);
root.add_child(p.id, operators);
boost::property_tree::write_json(data, root, true);
} else {
for (const auto& a : p.configurator->getAnalyzers()) {
data << a->getName() << " " << (a->getStreaming() ? "streaming\n" : "on-demand\n");
for (const auto& op : p.configurator->getOperators()) {
data << op->getName() << " " << (op->getStreaming() ? "streaming\n" : "on-demand\n");
}
}
res.body() = data.str();
......@@ -534,51 +534,51 @@ void AnalyticsManager::GET_analytics_analyzers(endpointArgs) {
}
void AnalyticsManager::PUT_analytics_start(endpointArgs) {
void OperatorManager::PUT_analytics_start(endpointArgs) {
if (!managerLoaded(res)) {
return;
}