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

Commit 0b344fc2 authored by Alessio Netti's avatar Alessio Netti
Browse files

Unified configuration backend

- The GlobalConfiguration class includes all shared logic to read and
parse configuration attributes for the collectagent and dcdbpusher
- The class is further expanded to add application-specific
configuration parameters and blocks
parent eb186235
......@@ -41,7 +41,7 @@ Additional parameters specific to this framework are the following:
| Value | Explanation |
|:----- |:----------- |
| global | Wrapper structure for the global values.
| analytics | Wrapper structure for the data analytics-specific values.
| hierarchy | Space-separated sequence of regular expressions used to infer the local (DCDBPusher) or global (DCDBCollectAgent) sensor hierarchy. This parameter should be wrapped in quotes to ensure proper parsing. See the Sensor Tree [section](#sensorTree) for more details.
| analyzerPlugins | Block containing the specification of all data analytics plugin to be instantiated.
| plugin _name_ | The plugin name is used to build the corresponding lib-name (e.g. average --> libdcdbanalyzer_average.1.0)
......
......@@ -10,7 +10,7 @@
#include "QueryEngine.h"
#include "AnalyzerInterface.h"
#include "pluginsettings.h"
#include "globalconfiguration.h"
/**
* Interface to configurators for data analyzer plugins
......
......@@ -439,6 +439,7 @@ protected:
* @param config A boost property (sub-)tree containing the sensor values
* @return True if successful, false otherwise
*/
//TODO: add template functionality (if useful at all here)
bool readSensorBase(SBase& sBase, CFG_VAL config) {
sBase.setCacheInterval(_cacheInterval);
......
......@@ -5,6 +5,7 @@ CXXFLAGS = -O2 -g --std=c++11 -Wall -Wno-unused-function -Wno-unused-local-typed
OBJS = ../common/src/logging.o \
../analytics/AnalyticsManager.o \
../common/src/sensornavigator.o \
../common/src/globalconfiguration.o \
analyticscontroller.o \
sensorcache.o \
collectagent.o \
......
......@@ -26,7 +26,7 @@ restResponse_t AnalyticsController::REST(const vector<string>& pathStrs, const v
return _manager->REST(pathStrs, queries, method, _io);
}
bool AnalyticsController::initialize(globalCA_t& settings, const string& configPath) {
bool AnalyticsController::initialize(Configuration& settings, const string& configPath) {
_settings = settings;
_configPath = configPath;
_navigator = make_shared<SensorNavigator>();
......@@ -47,7 +47,7 @@ bool AnalyticsController::initialize(globalCA_t& settings, const string& configP
// Building the sensor navigator
try {
_navigator->buildTree(_settings.hierarchy, &names, &topics);
_navigator->buildTree(_settings.analyticsSettings.hierarchy, &names, &topics);
} catch (const std::invalid_argument &e) {
LOG(error) << e.what();
LOG(error) << "Failed to build sensor hierarchy tree!";
......
......@@ -75,11 +75,11 @@ public:
* and then create an AnalyticsManager object, which will take care of instantiating and
* preparing plugins.
*
* @param settings Settings structure containing user-specified configuration parameters
* @param settings Settings class containing user-specified configuration parameters
* @param configPath Path to the configuration files for the data analytics framework
* @return True if successful, false otherwise
*/
bool initialize(globalCA_t& settings, const string& configPath);
bool initialize(Configuration& settings, const string& configPath);
/**
* @brief Sets the cache to be used for sensors
......@@ -178,7 +178,7 @@ private:
// Internal data analytics manager object
shared_ptr<AnalyticsManager> _manager;
// Misc configuration attributes
globalCA_t _settings;
Configuration _settings;
string _configPath;
// Readings counter
uint64_t _readingCtr;
......
......@@ -156,7 +156,6 @@ struct httpHandler_t {
std::string response = "";
std::ostringstream data;
std::string auth_value = "";
bool json = false;
std::vector<std::string> pathStrs;
std::vector<std::pair<std::string, std::string>> queries;
......@@ -195,15 +194,17 @@ struct httpHandler_t {
}
}
//finished string processing
for (auto& p : queries) {
//authkey is required in every case
//if (p.first == "authkey") {
// auth_value = p.second;
//} else
if (p.first == "json")
if (stoi(p.second) > 0)
json = true;
}
//bool json = false;
//for (auto& p : queries) {
// authkey is required in every case
//if (p.first == "authkey") {
// auth_value = p.second;
//} else
//if (p.first == "json")
// if (stoi(p.second) > 0)
// json = true;
//}
if (pathStrs.size() < 1) {
LOGH(warning) << "Received malformed request: No first path part";
......@@ -430,26 +431,24 @@ int mqttCallback(SimpleMQTTMessage *msg)
* Print usage information
*/
void usage() {
Configuration config("");
globalCA_t& defaults = config.getGlobal();
Configuration config("", "collectagent.conf");
/*
1 2 3 4 5 6 7 8
012345678901234567890123456789012345678901234567890123456789012345678901234567890
*/
cout << "Usage:" << endl;
cout << " collectagent [-d] [-s] [-x] [-a<string>] [-m<host>] [-r<host>] [-c<host>] [-u<username>] [-p<password>] [-t<ttl>] [-v<verbosity>] <path/to/configfiles/>" << endl;
cout << " collectagent [-d] [-s] [-x] [-a<string>] [-m<host>] [-c<host>] [-u<username>] [-p<password>] [-t<ttl>] [-v<verbosity>] <path/to/configfiles/>" << endl;
cout << " collectagent -h" << endl;
cout << endl;
cout << "Options:" << endl;
cout << " -a <string> Auto-publish pattern [default: none]" << endl;
cout << " -m<host> MQTT listen address [default: " << defaults.mqttListenAddress << "]" << endl;
cout << " -r<host> REST API listen address [default: " << defaults.restListenAddress << "]" << endl;
cout << " -c<host> Cassandra host [default: " << defaults.cassandraSettings.address << "]" << endl;
cout << " -m<host> MQTT listen address [default: " << config.mqttListenAddress << "]" << endl;
cout << " -c<host> Cassandra host [default: " << config.cassandraSettings.address << "]" << endl;
cout << " -u<username> Cassandra username [default: none]" << endl;
cout << " -p<password> Cassandra password [default: none]" << endl;
cout << " -t<ttl> Cassandra insert TTL [default: " << defaults.cassandraSettings.ttl << "]" << endl;
cout << " -v<level> Set verbosity of output [default: " << defaults.logLevelCmd << "]" << endl
cout << " -t<ttl> Cassandra insert TTL [default: " << config.cassandraSettings.ttl << "]" << endl;
cout << " -v<level> Set verbosity of output [default: " << config.logLevelCmd << "]" << endl
<< " Can be a number between 5 (all) and 0 (fatal)." << endl;
cout << endl;
cout << " -d Daemonize" << endl;
......@@ -461,7 +460,6 @@ void usage() {
int main(int argc, char* const argv[]) {
cout << "CollectAgent " << VERSION << " (libdcdb " << DCDB::Version::getVersion() << ")" << endl << endl;
bool validateConfig = false;
try{
......@@ -493,38 +491,40 @@ int main(int argc, char* const argv[]) {
initLogging();
auto cmdSink = setupCmdLogger();
Configuration config(argv[argc - 1]);
if( !config.readGlobal() ) {
Configuration config(argv[argc - 1], "collectagent.conf");
if( !config.readConfig() ) {
LOG(fatal) << "Failed to read global configuration!";
exit(EXIT_FAILURE);
}
globalCA_t& settings = config.getGlobal();
// References to shorten access to config parameters
Configuration& settings = config;
cassandra_t& cassandraSettings = config.cassandraSettings;
pluginSettings_t& pluginSettings = config.pluginSettings;
restAPISettings_t& restAPISettings = config.restAPISettings;
analyticsSettings_t& analyticsSettings = config.analyticsSettings;
/* Parse command line */
std::string listenHost, cassandraHost, restApiHost;
std::string listenPort, cassandraPort, restApiPort;
std::string listenHost, cassandraHost;
std::string listenPort, cassandraPort;
optind = 1;
while ((ret=getopt(argc, argv, opts))!=-1) {
switch(ret) {
case 'a':
settings.pluginSettings.sensorPattern = optarg;
pluginSettings.sensorPattern = optarg;
break;
case 'm':
settings.mqttListenAddress = optarg;
break;
case 'r':
settings.restListenAddress = optarg;
break;
case 'c':
settings.cassandraSettings.address = optarg;
cassandraSettings.address = optarg;
break;
case 'u':
settings.cassandraSettings.username = optarg;
cassandraSettings.username = optarg;
break;
case 'p': {
settings.cassandraSettings.password = optarg;
cassandraSettings.password = optarg;
// What does this do? Mask the password?
size_t pwdLen = strlen(optarg);
memset(optarg, 'x', (pwdLen >= 3) ? 3 : pwdLen);
......@@ -534,7 +534,7 @@ int main(int argc, char* const argv[]) {
break;
}
case 't':
settings.cassandraSettings.ttl = stoul(optarg);
cassandraSettings.ttl = stoul(optarg);
break;
case 'v':
settings.logLevelCmd = translateLogLevel(stoi(optarg));
......@@ -547,7 +547,7 @@ int main(int argc, char* const argv[]) {
settings.statistics = 1;
break;
case 'x':
validateConfig = true;
settings.validateConfig = true;
break;
case 'h':
default:
......@@ -556,7 +556,7 @@ int main(int argc, char* const argv[]) {
}
}
auto fileSink = setupFileLogger(settings.pluginSettings.tempdir, std::string("collectagent"));
auto fileSink = setupFileLogger(pluginSettings.tempdir, std::string("collectagent"));
//severity level may be overwritten (per option or config-file) --> set it according to globalSettings
fileSink->set_filter(boost::log::trivial::severity >= settings.logLevelFile);
cmdSink->set_filter(boost::log::trivial::severity >= settings.logLevelCmd);
......@@ -589,7 +589,7 @@ int main(int argc, char* const argv[]) {
listenPort = LISTENPORT;
}
cassandraHost = string(settings.cassandraSettings.address);
cassandraHost = string(cassandraSettings.address);
pos = cassandraHost.find(":");
if (pos != string::npos) {
cassandraPort = cassandraHost.substr(pos+1);
......@@ -597,25 +597,16 @@ int main(int argc, char* const argv[]) {
} else {
cassandraPort = CASSANDRAPORT;
}
restApiHost = string(settings.restListenAddress);
pos = restApiHost.find(":");
if (pos != string::npos) {
restApiPort = restApiHost.substr(pos+1);
restApiHost.erase(pos);
} else {
restApiPort = RESTAPIPORT;
}
// Setting the size of the sensor cache
// Conversion from milliseconds to nanoseconds
mySensorCache.setMaxHistory(uint64_t(settings.pluginSettings.cacheInterval) * 1000000);
mySensorCache.setMaxHistory(uint64_t(pluginSettings.cacheInterval) * 1000000);
//Allocate and initialize connection to Cassandra.
dcdbConn = new DCDB::Connection(cassandraHost, atoi(cassandraPort.c_str()), settings.cassandraSettings.username, settings.cassandraSettings.password);
dcdbConn->setNumThreadsIo(settings.cassandraSettings.numThreadsIo);
dcdbConn->setQueueSizeIo(settings.cassandraSettings.queueSizeIo);
uint32_t params[3] = {settings.cassandraSettings.coreConnPerHost, settings.cassandraSettings.maxConnPerHost, settings.cassandraSettings.maxConcRequests};
dcdbConn = new DCDB::Connection(cassandraHost, atoi(cassandraPort.c_str()), cassandraSettings.username, cassandraSettings.password);
dcdbConn->setNumThreadsIo(cassandraSettings.numThreadsIo);
dcdbConn->setQueueSizeIo(cassandraSettings.queueSizeIo);
uint32_t params[3] = {cassandraSettings.coreConnPerHost, cassandraSettings.maxConnPerHost, cassandraSettings.maxConcRequests};
dcdbConn->setBackendParams(params);
......@@ -639,9 +630,9 @@ int main(int argc, char* const argv[]) {
/*
* Set TTL for data store inserts if TTL > 0.
*/
if (settings.cassandraSettings.ttl > 0)
mySensorDataStore->setTTL(settings.cassandraSettings.ttl);
mySensorDataStore->setDebugLog(settings.cassandraSettings.debugLog);
if (cassandraSettings.ttl > 0)
mySensorDataStore->setTTL(cassandraSettings.ttl);
mySensorDataStore->setDebugLog(cassandraSettings.debugLog);
analyticsController = new AnalyticsController(mySensorConfig, mySensorDataStore);
analyticsController->setCache(&mySensorCache);
......@@ -649,40 +640,50 @@ int main(int argc, char* const argv[]) {
return EXIT_FAILURE;
queryEngine.setQueryCallback(sensorQueryCallback);
LOG_LEVEL vLogLevel = validateConfig ? LOG_LEVEL::info : LOG_LEVEL::debug;
LOG_LEVEL vLogLevel = settings.validateConfig ? LOG_LEVEL::info : LOG_LEVEL::debug;
LOG_VAR(vLogLevel) << "----- Configuration -----";
//print global settings in either case
LOG(info) << "Global Settings:";
LOG(info) << " MQTT-listenAddress: " << settings.mqttListenAddress;
LOG(info) << " CacheInterval: " << int(settings.pluginSettings.cacheInterval/1000) << " [s]";
LOG(info) << " CacheInterval: " << int(pluginSettings.cacheInterval/1000) << " [s]";
LOG(info) << " CleaningInterval: " << settings.cleaningInterval << " [s]";
LOG(info) << " MessageThreads: " << settings.messageThreads;
LOG(info) << " MessageSlots: " << settings.messageSlots;
LOG(info) << " Daemonize: " << (settings.daemonize ? "Enabled" : "Disabled");
LOG(info) << " Statistics: " << (settings.statistics ? "Enabled" : "Disabled");
LOG(info) << " Write-Dir: " << settings.pluginSettings.tempdir;
LOG(info) << " Hierarchy: " << (settings.hierarchy!="" ? settings.hierarchy : "none");
LOG(info) << (validateConfig ? " Only validating config files." : " ValidateConfig: Disabled");
LOG(info) << " MQTT-prefix: " << pluginSettings.mqttPrefix;
LOG(info) << " Write-Dir: " << pluginSettings.tempdir;
LOG(info) << (settings.validateConfig ? " Only validating config files." : " ValidateConfig: Disabled");
LOG(info) << "Analytics Settings:";
LOG(info) << " Hierarchy: " << (analyticsSettings.hierarchy!="" ? analyticsSettings.hierarchy : "none");
LOG(info) << "Cassandra Driver Settings:";
LOG(info) << " Address: " << settings.cassandraSettings.address;
LOG(info) << " TTL: " << settings.cassandraSettings.ttl;
LOG(info) << " NumThreadsIO: " << settings.cassandraSettings.numThreadsIo;
LOG(info) << " QueueSizeIO: " << settings.cassandraSettings.queueSizeIo;
LOG(info) << " CoreConnPerHost: " << settings.cassandraSettings.coreConnPerHost;
LOG(info) << " MaxConnPerHost: " << settings.cassandraSettings.maxConnPerHost;
LOG(info) << " MaxConcRequests: " << settings.cassandraSettings.maxConcRequests;
LOG(info) << " DebugLog: " << (settings.cassandraSettings.debugLog ? "Enabled" : "Disabled");
LOG(info) << " Address: " << cassandraSettings.address;
LOG(info) << " TTL: " << cassandraSettings.ttl;
LOG(info) << " NumThreadsIO: " << cassandraSettings.numThreadsIo;
LOG(info) << " QueueSizeIO: " << cassandraSettings.queueSizeIo;
LOG(info) << " CoreConnPerHost: " << cassandraSettings.coreConnPerHost;
LOG(info) << " MaxConnPerHost: " << cassandraSettings.maxConnPerHost;
LOG(info) << " MaxConcRequests: " << cassandraSettings.maxConcRequests;
LOG(info) << " DebugLog: " << (cassandraSettings.debugLog ? "Enabled" : "Disabled");
#ifdef SimpleMQTTVerbose
LOG(info) << " Username: " << settings.cassandraSettings.username;
LOG(info) << " Password: " << settings.cassandraSettings.password;
LOG(info) << " Username: " << cassandraSettings.username;
LOG(info) << " Password: " << cassandraSettings.password;
#else
LOG(info) << " Username and password not printed.";
#endif
LOG(info) << "RestAPI Settings:";
LOG(info) << " REST Server: " << settings.restListenAddress;
LOG(info) << " REST Server: " << restAPISettings.restHost << ":" << restAPISettings.restPort;
#ifdef SimpleMQTTVerbose
LOG(info) << " Certificate: " << restAPISettings.certificate;
LOG(info) << " Private key file: " << restAPISettings.privateKey;
LOG(info) << " DH params from: " << restAPISettings.dhFile;
#else
LOG(info) << " Certificate, private key and DH-param file not printed.";
#endif
LOG_VAR(vLogLevel) << "----- Analytics Configuration -----";
for(auto& p : analyticsController->getManager()->getPlugins()) {
......@@ -691,7 +692,7 @@ int main(int argc, char* const argv[]) {
}
LOG_VAR(vLogLevel) << "----- End Configuration -----";
if (validateConfig)
if (settings.validateConfig)
return EXIT_SUCCESS;
else
analyticsController->start();
......@@ -715,7 +716,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(restApiHost).port(restApiPort));
httpServer_t httpServer(httpOptions.address(restAPISettings.restHost).port(restAPISettings.restPort));
httpThread = std::thread([&httpServer] { httpServer.run(); });
LOG(info) << "HTTP Server running...";
......
......@@ -4,146 +4,49 @@
#include "configuration.h"
using namespace std;
Configuration::Configuration(const std::string& cfgFilePath) :
_cfgFilePath(cfgFilePath) {
if (_cfgFilePath[_cfgFilePath.length()-1] != '/') {
_cfgFilePath.append("/");
}
//set default values for global variables
_global.daemonize = false;
_global.statistics = false;
_global.mqttListenAddress = string(LISTENHOST) + ":" + string(LISTENPORT);
_global.restListenAddress = string(RESTAPIHOST) + ":" + string(RESTAPIPORT);
_global.messageThreads = 128;
_global.messageSlots = 16;
_global.threads = 24;
_global.cleaningInterval = 86400;
_global.logLevelFile = boost::log::trivial::trace;
_global.logLevelCmd = boost::log::trivial::info;
_global.pluginSettings.cacheInterval = 900000;
_global.pluginSettings.tempdir = "./";
_global.pluginSettings.sensorPattern = "";
_global.pluginSettings.mqttPrefix = "";
_global.cassandraSettings.address = string(CASSANDRAHOST) + ":" + string(CASSANDRAPORT);
_global.cassandraSettings.username = "";
_global.cassandraSettings.password = "";
_global.cassandraSettings.ttl = 0;
_global.cassandraSettings.numThreadsIo = 1;
_global.cassandraSettings.queueSizeIo = 4096;
_global.cassandraSettings.coreConnPerHost = 1;
_global.cassandraSettings.maxConnPerHost = 2;
_global.cassandraSettings.maxConcRequests = 100;
_global.cassandraSettings.debugLog = false;
}
Configuration::~Configuration() {}
bool Configuration::readGlobal() {
//open file
std::string globalConfig = _cfgFilePath;
globalConfig.append("collectagent.conf");
boost::property_tree::iptree cfg;
//parse to property_tree
try {
boost::property_tree::read_info(globalConfig, cfg);
} catch (boost::property_tree::info_parser_error& e) {
LOG(error) << "Error when reading collectagent.conf: " << e.what();
bool Configuration::readAdditionalValues(boost::property_tree::iptree::value_type &global) {
// ----- READING ADDITIONAL GLOBAL SETTINGS -----
if (boost::iequals(global.first, "mqttListenAddress")) {
mqttListenAddress = global.second.data();
} else if (boost::iequals(global.first, "cleaningInterval")) {
cleaningInterval = stoul(global.second.data());
} else if (boost::iequals(global.first, "messageThreads")) {
messageThreads = stoul(global.second.data());
} else if (boost::iequals(global.first, "messageSlots")) {
messageSlots = stoul(global.second.data());
} else {
return false;
}
return true;
}
//read global struct
BOOST_FOREACH(boost::property_tree::iptree::value_type &global, cfg.get_child("global")) {
if (boost::iequals(global.first, "mqttListenAddress")) {
_global.mqttListenAddress = global.second.data();
} else if (boost::iequals(global.first, "hierarchy")) {
_global.hierarchy = global.second.data();
} else if (boost::iequals(global.first, "cleaningInterval")) {
_global.cleaningInterval = stoul(global.second.data());
} else if (boost::iequals(global.first, "messageThreads")) {
_global.messageThreads = stoul(global.second.data());
} else if (boost::iequals(global.first, "messageSlots")) {
_global.messageSlots = stoul(global.second.data());
} else if (boost::iequals(global.first, "cacheInterval")) {
_global.pluginSettings.cacheInterval = stoul(global.second.data()) * 1000;
} else if (boost::iequals(global.first, "verbosity")) {
_global.logLevelFile = translateLogLevel(stoi(global.second.data()));
} else if (boost::iequals(global.first, "threads")) {
_global.threads = stoi(global.second.data());
} else if (boost::iequals(global.first, "tempDir")) {
_global.pluginSettings.tempdir = global.second.data();
if (_global.pluginSettings.tempdir[_global.pluginSettings.tempdir.length()-1] != '/') {
_global.pluginSettings.tempdir.append("/");
void Configuration::readAdditionalBlocks(boost::property_tree::iptree& cfg) {
// ----- READING CASSANDRA SETTINGS -----
if(cfg.find("cassandra") != cfg.not_found()) {
BOOST_FOREACH(boost::property_tree::iptree::value_type & global, cfg.get_child("cassandra")) {
if (boost::iequals(global.first, "address")) {
cassandraSettings.address = global.second.data();
} else if (boost::iequals(global.first, "username")) {
cassandraSettings.username = global.second.data();
} else if (boost::iequals(global.first, "password")) {
cassandraSettings.password = global.second.data();
} else if (boost::iequals(global.first, "ttl")) {
cassandraSettings.ttl = stoul(global.second.data());
} else if (boost::iequals(global.first, "numThreadsIo")) {
cassandraSettings.numThreadsIo = stoul(global.second.data());
} else if (boost::iequals(global.first, "queueSizeIo")) {
cassandraSettings.queueSizeIo = stoul(global.second.data());
} else if (boost::iequals(global.first, "coreConnPerHost")) {
cassandraSettings.coreConnPerHost = stoul(global.second.data());
} else if (boost::iequals(global.first, "maxConnPerHost")) {
cassandraSettings.maxConnPerHost = stoul(global.second.data());
} else if (boost::iequals(global.first, "maxConcRequests")) {
cassandraSettings.maxConcRequests = stoul(global.second.data());
} else if (boost::iequals(global.first, "debugLog")) {
cassandraSettings.debugLog = to_bool(global.second.data());
} else {
LOG(warning) << " Value \"" << global.first << "\" not recognized. Omitting";
}
} else if (boost::iequals(global.first, "mqttprefix")) {
_global.pluginSettings.mqttPrefix = global.second.data();
if (_global.pluginSettings.mqttPrefix[_global.pluginSettings.mqttPrefix.length()-1] != '/') {
_global.pluginSettings.mqttPrefix.append("/");
}
} else if (boost::iequals(global.first, "sensorpattern")) {
_global.pluginSettings.sensorPattern = global.second.data();
} else if (boost::iequals(global.first, "daemonize")) {
_global.daemonize = to_bool(global.second.data());
} else if (boost::iequals(global.first, "statistics")) {
_global.statistics = to_bool(global.second.data());
} else {
LOG(warning) << " Value \"" << global.first << "\" not recognized. Omitting";
}
}
//read cassandra struct
BOOST_FOREACH(boost::property_tree::iptree::value_type &global, cfg.get_child("cassandra")) {
if (boost::iequals(global.first, "address")) {
_global.cassandraSettings.address = global.second.data();
} else if (boost::iequals(global.first, "username")) {
_global.cassandraSettings.username = global.second.data();
} else if (boost::iequals(global.first, "password")) {
_global.cassandraSettings.password = global.second.data();
} else if (boost::iequals(global.first, "ttl")) {
_global.cassandraSettings.ttl = stoul(global.second.data());
} else if (boost::iequals(global.first, "numThreadsIo")) {
_global.cassandraSettings.numThreadsIo = stoul(global.second.data());
} else if (boost::iequals(global.first, "queueSizeIo")) {
_global.cassandraSettings.queueSizeIo = stoul(global.second.data());
} else if (boost::iequals(global.first, "coreConnPerHost")) {
_global.cassandraSettings.coreConnPerHost = stoul(global.second.data());
} else if (boost::iequals(global.first, "maxConnPerHost")) {
_global.cassandraSettings.maxConnPerHost = stoul(global.second.data());
} else if (boost::iequals(global.first, "maxConcRequests")) {
_global.cassandraSettings.maxConcRequests = stoul(global.second.data());
} else if (boost::iequals(global.first, "debugLog")) {
_global.cassandraSettings.debugLog = to_bool(global.second.data());
} else {
LOG(warning) << " Value \"" << global.first << "\" not recognized. Omitting";
}
}
//read restAPI struct
BOOST_FOREACH(boost::property_tree::iptree::value_type &global, cfg.get_child("restAPI")) {
if (boost::iequals(global.first, "address")) {
_global.restListenAddress = global.second.data();
//} else if (boost::iequals(global.first, "certificate")) {
// _global.restAPISettings.certificate = global.second.data();
//} else if (boost::iequals(global.first, "privateKey")) {
// _global.restAPISettings.privateKey = global.second.data();
//} else if (boost::iequals(global.first, "dhFile")) {
// _global.restAPISettings.dhFile = global.second.data();
//} else if (boost::iequals(global.first, "authkey")) {
// //Avoid unnecessary "Value not recognized" message
} else {
LOG(warning) << " Value \"" << global.first << "\" not recognized. Omitting";
}
}
return true;
}
globalCA_t& Configuration::getGlobal() {
return _global;
}
......@@ -5,16 +5,11 @@
#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_
#include <boost/property_tree/ptree.hpp>
#include <string>
#include <unistd.h>
#include <boost/foreach.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/algorithm/string.hpp>
#include "logging.h"
#include "pluginsettings.h"
#include "globalconfiguration.h"
#define LISTENHOST "localhost"
#define LISTENPORT "1883"
......@@ -23,69 +18,55 @@
#define RESTAPIHOST "0.0.0.0"
#define RESTAPIPORT "8080"
typedef struct {
std::string address;
std::string username;
std::string password;
uint32_t ttl;
uint32_t numThreadsIo;
uint32_t queueSizeIo;
uint32_t coreConnPerHost;
uint32_t maxConnPerHost;