10.12., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 1b644a40 authored by Michael Ott's avatar Michael Ott

Fix printing of default values in printSyntax() and assignment

parent bb76c3ef
...@@ -523,7 +523,6 @@ int mqttCallback(SimpleMQTTMessage *msg) ...@@ -523,7 +523,6 @@ int mqttCallback(SimpleMQTTMessage *msg)
* Print usage information * Print usage information
*/ */
void usage() { void usage() {
Configuration config("", "collectagent.conf");
/* /*
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
012345678901234567890123456789012345678901234567890123456789012345678901234567890 012345678901234567890123456789012345678901234567890123456789012345678901234567890
...@@ -534,12 +533,12 @@ void usage() { ...@@ -534,12 +533,12 @@ void usage() {
cout << endl; cout << endl;
cout << "Options:" << endl; cout << "Options:" << endl;
cout << " -m<host> MQTT listen address [default: " << config.mqttListenHost << ":" << config.mqttListenPort << "]" << endl; cout << " -m<host> MQTT listen address [default: " << DEFAULT_LISTENHOST << ":" << DEFAULT_LISTENPORT << "]" << endl;
cout << " -c<host> Cassandra host [default: " << config.cassandraSettings.host << ":" << config.cassandraSettings.port << "]" << endl; cout << " -c<host> Cassandra host [default: " << DEFAULT_CASSANDRAHOST << ":" << DEFAULT_CASSANDRAPORT << "]" << endl;
cout << " -u<username> Cassandra username [default: none]" << endl; cout << " -u<username> Cassandra username [default: none]" << endl;
cout << " -p<password> Cassandra password [default: none]" << endl; cout << " -p<password> Cassandra password [default: none]" << endl;
cout << " -t<ttl> Cassandra insert TTL [default: " << config.cassandraSettings.ttl << "]" << endl; cout << " -t<ttl> Cassandra insert TTL [default: " << DEFAULT_CASSANDRATTL << "]" << endl;
cout << " -v<level> Set verbosity of output [default: " << config.logLevelCmd << "]" << endl cout << " -v<level> Set verbosity of output [default: " << DEFAULT_LOGLEVEL << "]" << endl
<< " Can be a number between 5 (all) and 0 (fatal)." << endl; << " Can be a number between 5 (all) and 0 (fatal)." << endl;
cout << endl; cout << endl;
cout << " -d Daemonize" << endl; cout << " -d Daemonize" << endl;
...@@ -602,12 +601,12 @@ int main(int argc, char* const argv[]) { ...@@ -602,12 +601,12 @@ int main(int argc, char* const argv[]) {
case 'm': case 'm':
settings.mqttListenHost = parseNetworkHost(optarg); settings.mqttListenHost = parseNetworkHost(optarg);
settings.mqttListenPort = parseNetworkPort(optarg); settings.mqttListenPort = parseNetworkPort(optarg);
if(settings.mqttListenPort=="") settings.mqttListenPort = string(LISTENPORT); if(settings.mqttListenPort=="") settings.mqttListenPort = string(DEFAULT_LISTENPORT);
break; break;
case 'c': case 'c':
cassandraSettings.host = parseNetworkHost(optarg); cassandraSettings.host = parseNetworkHost(optarg);
cassandraSettings.port = parseNetworkPort(optarg); cassandraSettings.port = parseNetworkPort(optarg);
if(cassandraSettings.port=="") cassandraSettings.port = string(CASSANDRAPORT); if(cassandraSettings.port=="") cassandraSettings.port = string(DEFAULT_CASSANDRAPORT);
break; break;
case 'u': case 'u':
cassandraSettings.username = optarg; cassandraSettings.username = optarg;
......
...@@ -32,7 +32,7 @@ bool Configuration::readAdditionalValues(boost::property_tree::iptree::value_typ ...@@ -32,7 +32,7 @@ bool Configuration::readAdditionalValues(boost::property_tree::iptree::value_typ
if (boost::iequals(global.first, "mqttListenAddress")) { if (boost::iequals(global.first, "mqttListenAddress")) {
mqttListenHost = parseNetworkHost(global.second.data()); mqttListenHost = parseNetworkHost(global.second.data());
mqttListenPort = parseNetworkPort(global.second.data()); mqttListenPort = parseNetworkPort(global.second.data());
if(mqttListenPort=="") mqttListenPort = string(LISTENPORT); if(mqttListenPort=="") mqttListenPort = string(DEFAULT_LISTENPORT);
} else if (boost::iequals(global.first, "cleaningInterval")) { } else if (boost::iequals(global.first, "cleaningInterval")) {
cleaningInterval = stoul(global.second.data()); cleaningInterval = stoul(global.second.data());
} else if (boost::iequals(global.first, "messageThreads")) { } else if (boost::iequals(global.first, "messageThreads")) {
...@@ -52,7 +52,7 @@ void Configuration::readAdditionalBlocks(boost::property_tree::iptree& cfg) { ...@@ -52,7 +52,7 @@ void Configuration::readAdditionalBlocks(boost::property_tree::iptree& cfg) {
if (boost::iequals(global.first, "address")) { if (boost::iequals(global.first, "address")) {
cassandraSettings.host = parseNetworkHost(global.second.data()); cassandraSettings.host = parseNetworkHost(global.second.data());
cassandraSettings.port = parseNetworkPort(global.second.data()); cassandraSettings.port = parseNetworkPort(global.second.data());
if(cassandraSettings.port=="") cassandraSettings.port = string(CASSANDRAPORT); if(cassandraSettings.port=="") cassandraSettings.port = string(DEFAULT_CASSANDRAPORT);
} else if (boost::iequals(global.first, "username")) { } else if (boost::iequals(global.first, "username")) {
cassandraSettings.username = global.second.data(); cassandraSettings.username = global.second.data();
} else if (boost::iequals(global.first, "password")) { } else if (boost::iequals(global.first, "password")) {
......
...@@ -37,12 +37,10 @@ ...@@ -37,12 +37,10 @@
#include "metadatastore.h" #include "metadatastore.h"
#include <dcdb/sensorconfig.h> #include <dcdb/sensorconfig.h>
#define LISTENHOST "localhost" #define DEFAULT_LISTENHOST "localhost"
#define LISTENPORT "1883" #define DEFAULT_LISTENPORT "1883"
#define CASSANDRAHOST "127.0.0.1" #define DEFAULT_RESTAPIHOST "0.0.0.0"
#define CASSANDRAPORT "9042" #define DEFAULT_RESTAPIPORT "8080"
#define RESTAPIHOST "0.0.0.0"
#define RESTAPIPORT "8080"
using namespace std; using namespace std;
...@@ -54,11 +52,11 @@ using namespace std; ...@@ -54,11 +52,11 @@ using namespace std;
class cassandra_t { class cassandra_t {
public: public:
cassandra_t() {} cassandra_t() {}
std::string host = string(CASSANDRAHOST); std::string host = string(DEFAULT_CASSANDRAHOST);
std::string port = string(CASSANDRAPORT); std::string port = string(DEFAULT_CASSANDRAPORT);
std::string username = ""; std::string username = "";
std::string password = ""; std::string password = "";
uint32_t ttl = 0; uint32_t ttl = DEFAULT_CASSANDRATTL;
uint32_t numThreadsIo = 1; uint32_t numThreadsIo = 1;
uint32_t queueSizeIo = 4096; uint32_t queueSizeIo = 4096;
uint32_t coreConnPerHost = 1; uint32_t coreConnPerHost = 1;
...@@ -81,8 +79,8 @@ public: ...@@ -81,8 +79,8 @@ public:
* @param cfgFileName Name of the file containing the config * @param cfgFileName Name of the file containing the config
*/ */
Configuration(const std::string& cfgFilePath, const std::string& cfgFileName) : GlobalConfiguration(cfgFilePath, cfgFileName) { Configuration(const std::string& cfgFilePath, const std::string& cfgFileName) : GlobalConfiguration(cfgFilePath, cfgFileName) {
restAPISettings.port = string(RESTAPIPORT); restAPISettings.port = string(DEFAULT_RESTAPIPORT);
restAPISettings.host = string(RESTAPIHOST); restAPISettings.host = string(DEFAULT_RESTAPIHOST);
} }
Configuration() {} Configuration() {}
...@@ -105,8 +103,8 @@ public: ...@@ -105,8 +103,8 @@ public:
static SensorMetadata publicSensorToMetadata(const DCDB::PublicSensor& ps); static SensorMetadata publicSensorToMetadata(const DCDB::PublicSensor& ps);
// Additional configuration parameters to be parsed within the global block // Additional configuration parameters to be parsed within the global block
std::string mqttListenHost = string(LISTENHOST); std::string mqttListenHost = string(DEFAULT_LISTENHOST);
std::string mqttListenPort = string(LISTENPORT); std::string mqttListenPort = string(DEFAULT_LISTENPORT);
uint64_t cleaningInterval = 86400; uint64_t cleaningInterval = 86400;
uint64_t messageThreads = 128; uint64_t messageThreads = 128;
uint64_t messageSlots = 16; uint64_t messageSlots = 16;
......
...@@ -43,6 +43,14 @@ ...@@ -43,6 +43,14 @@
#include "logging.h" #include "logging.h"
#include "mqttchecker.h" #include "mqttchecker.h"
#define DEFAULT_LOGLEVEL 3
#define DEFAULT_THREADS 8
#define DEFAULT_TEMPDIR "./"
#define DEFAULT_CASSANDRAHOST "127.0.0.1"
#define DEFAULT_CASSANDRAPORT "9042"
#define DEFAULT_CASSANDRATTL 0
class RESTHttpsServer; class RESTHttpsServer;
/** /**
...@@ -54,7 +62,7 @@ class pluginSettings_t { ...@@ -54,7 +62,7 @@ class pluginSettings_t {
public: public:
pluginSettings_t() {} pluginSettings_t() {}
std::string mqttPrefix = ""; std::string mqttPrefix = "";
std::string tempdir = "./"; std::string tempdir = DEFAULT_TEMPDIR;
bool autoPublish = false; bool autoPublish = false;
unsigned int cacheInterval = 900000; unsigned int cacheInterval = 900000;
}; };
...@@ -185,9 +193,9 @@ public: ...@@ -185,9 +193,9 @@ public:
bool validateConfig = false; bool validateConfig = false;
bool daemonize = false; bool daemonize = false;
bool statistics = false; bool statistics = false;
uint64_t threads = 24; uint64_t threads = DEFAULT_THREADS;
int logLevelFile = -1; int logLevelFile = -1;
int logLevelCmd = 3; int logLevelCmd = DEFAULT_LOGLEVEL;
analyticsSettings_t analyticsSettings; analyticsSettings_t analyticsSettings;
serverSettings_t restAPISettings; serverSettings_t restAPISettings;
pluginSettings_t pluginSettings; pluginSettings_t pluginSettings;
......
...@@ -35,7 +35,7 @@ bool Configuration::readAdditionalValues(boost::property_tree::iptree::value_typ ...@@ -35,7 +35,7 @@ bool Configuration::readAdditionalValues(boost::property_tree::iptree::value_typ
// ----- READING ADDITIONAL GLOBAL SETTINGS ----- // ----- READING ADDITIONAL GLOBAL SETTINGS -----
if (boost::iequals(global.first, "mqttBroker")) { if (boost::iequals(global.first, "mqttBroker")) {
brokerHost = parseNetworkHost(global.second.data()); brokerHost = parseNetworkHost(global.second.data());
brokerPort = parseNetworkPort(global.second.data()) == "" ? BROKERPORT : stoi(parseNetworkPort(global.second.data())); brokerPort = parseNetworkPort(global.second.data()) == "" ? DEFAULT_BROKERPORT : stoi(parseNetworkPort(global.second.data()));
} else if (boost::iequals(global.first, "qosLevel")) { } else if (boost::iequals(global.first, "qosLevel")) {
qosLevel = stoi(global.second.data()); qosLevel = stoi(global.second.data());
if (qosLevel > 2 || qosLevel < 0) if (qosLevel > 2 || qosLevel < 0)
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include "PluginManager.h" #include "PluginManager.h"
#define BROKERPORT 1883 #define DEFAULT_BROKERPORT 1883
#define BROKERHOST "127.0.0.1" #define DEFAULT_BROKERHOST "127.0.0.1"
/** /**
* @brief Class responsible for reading dcdb-pusher specific configuration. * @brief Class responsible for reading dcdb-pusher specific configuration.
...@@ -70,8 +70,8 @@ class Configuration : public GlobalConfiguration { ...@@ -70,8 +70,8 @@ class Configuration : public GlobalConfiguration {
int qosLevel = 1; int qosLevel = 1;
unsigned int maxInflightMsgNum = 20; unsigned int maxInflightMsgNum = 20;
unsigned int maxQueuedMsgNum = 0; unsigned int maxQueuedMsgNum = 0;
int brokerPort = BROKERPORT; int brokerPort = DEFAULT_BROKERPORT;
std::string brokerHost = BROKERHOST; std::string brokerHost = DEFAULT_BROKERHOST;
int maxMsgNum = 0; int maxMsgNum = 0;
protected: protected:
......
...@@ -151,17 +151,16 @@ void printSyntax() { ...@@ -151,17 +151,16 @@ void printSyntax() {
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
012345678901234567890123456789012345678901234567890123456789012345678901234567890 012345678901234567890123456789012345678901234567890123456789012345678901234567890
*/ */
_configuration = new Configuration("", "dcdbpusher.conf");
cout << "Usage:" << endl; cout << "Usage:" << endl;
cout << " dcdbpusher [-d] [-x] [-a] [-b<host>] [-m<string>] [-w<path>] [-v<level>] <config>" << endl; cout << " dcdbpusher [-d] [-x] [-a] [-b<host>] [-m<string>] [-w<path>] [-v<level>] <config>" << endl;
cout << " dcdbpusher -h" << endl; cout << " dcdbpusher -h" << endl;
cout << endl; cout << endl;
cout << "Options:" << endl; cout << "Options:" << endl;
cout << " -b <host> MQTT broker [default: " << _configuration->brokerHost << ":" << _configuration->brokerPort << "]" << endl; cout << " -b <host> MQTT broker [default: " << DEFAULT_BROKERHOST << ":" << DEFAULT_BROKERPORT << "]" << endl;
cout << " -m <string> MQTT topic prefix [default: none]" << endl; cout << " -m <string> MQTT topic prefix [default: none]" << endl;
cout << " -w <path> Writable temp dir [default: .]" << endl; cout << " -w <path> Writable temp dir [default: " << DEFAULT_TEMPDIR << "]" << endl;
cout << " -v <level> Set verbosity of output [default: " << _configuration->logLevelCmd << "]" << endl cout << " -v <level> Set verbosity of output [default: " << DEFAULT_LOGLEVEL << "]" << endl
<< " Can be a number between 5 (all) and 0 (fatal)." << endl; << " Can be a number between 5 (all) and 0 (fatal)." << endl;
cout << endl; cout << endl;
cout << " -d Daemonize" << endl; cout << " -d Daemonize" << endl;
...@@ -169,9 +168,6 @@ void printSyntax() { ...@@ -169,9 +168,6 @@ void printSyntax() {
cout << " -a Enable sensor auto-publish" << endl; cout << " -a Enable sensor auto-publish" << endl;
cout << " -h This help page" << endl; cout << " -h This help page" << endl;
cout << endl; cout << endl;
delete _configuration;
_configuration = nullptr;
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
...@@ -236,7 +232,7 @@ int main(int argc, char **argv) { ...@@ -236,7 +232,7 @@ int main(int argc, char **argv) {
break; break;
case 'b': case 'b':
globalSettings.brokerHost = parseNetworkHost(optarg); globalSettings.brokerHost = parseNetworkHost(optarg);
globalSettings.brokerPort = parseNetworkPort(optarg) == "" ? BROKERPORT : stoi(parseNetworkPort(optarg)); globalSettings.brokerPort = parseNetworkPort(optarg) == "" ? DEFAULT_BROKERPORT : stoi(parseNetworkPort(optarg));
break; break;
case 'm': case 'm':
pluginSettings.mqttPrefix = optarg; pluginSettings.mqttPrefix = optarg;
......
...@@ -32,10 +32,8 @@ ...@@ -32,10 +32,8 @@
#include <set> #include <set>
#define GRAFANAHOST "127.0.0.1" #define DEFAULT_GRAFANAHOST "127.0.0.1"
#define GRAFANAPORT "8081" #define DEFAULT_GRAFANAPORT "8081"
#define CASSANDRAHOST "127.0.0.1"
#define CASSANDRAPORT "9042"
/** /**
* Struct defining the Cassandra settings. * Struct defining the Cassandra settings.
...@@ -68,7 +66,7 @@ public: ...@@ -68,7 +66,7 @@ public:
hierarchySettings_t hierarchySettings; hierarchySettings_t hierarchySettings;
// Additional configuration parameter to be parsed within the global block // Additional configuration parameter to be parsed within the global block
std::string tempdir = "."; std::string tempdir = DEFAULT_TEMPDIR;
/** /**
* Create new Configuration. Sets global config file to read from to cfgFile. * Create new Configuration. Sets global config file to read from to cfgFile.
...@@ -78,10 +76,10 @@ public: ...@@ -78,10 +76,10 @@ public:
*/ */
Configuration(const std::string& cfgFilePath, const std::string& cfgFileName) : GlobalConfiguration(cfgFilePath, cfgFileName) { Configuration(const std::string& cfgFilePath, const std::string& cfgFileName) : GlobalConfiguration(cfgFilePath, cfgFileName) {
restAPISettings.host = std::string(GRAFANAHOST); restAPISettings.host = std::string(DEFAULT_GRAFANAHOST);
restAPISettings.port = std::string(GRAFANAPORT); restAPISettings.port = std::string(DEFAULT_GRAFANAPORT);
cassandraSettings.host = std::string(CASSANDRAHOST); cassandraSettings.host = std::string(DEFAULT_CASSANDRAHOST);
cassandraSettings.port = std::string(CASSANDRAPORT); cassandraSettings.port = std::string(DEFAULT_CASSANDRAPORT);
} }
virtual ~Configuration() {} virtual ~Configuration() {}
......
...@@ -47,7 +47,6 @@ boost::shared_ptr<boost::asio::io_service::work> keepAliveWork; ...@@ -47,7 +47,6 @@ boost::shared_ptr<boost::asio::io_service::work> keepAliveWork;
void printSyntax() void printSyntax()
{ {
_configuration = new Configuration("", "grafana.conf");
/* /*
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
012345678901234567890123456789012345678901234567890123456789012345678901234567890 012345678901234567890123456789012345678901234567890123456789012345678901234567890
...@@ -58,18 +57,15 @@ void printSyntax() ...@@ -58,18 +57,15 @@ void printSyntax()
std::cout << std::endl; std::cout << std::endl;
std::cout << "Options:" << std::endl; std::cout << "Options:" << std::endl;
std::cout << " -c <host:port> Cassandra host and port. [default: " << _configuration->cassandraSettings.host << ":" << _configuration->cassandraSettings.port << "]" << endl; std::cout << " -c <host:port> Cassandra host and port. [default: " << DEFAULT_CASSANDRAHOST << ":" << DEFAULT_CASSANDRAPORT << "]" << endl;
std::cout << " -t <number> Thread count. [default: " << _configuration->threads << "]" << std::endl; std::cout << " -t <number> Thread count. [default: " << DEFAULT_THREADS << "]" << std::endl;
std::cout << " -v <level> Set verbosity of output. [default: " << _configuration->logLevelCmd << "]" << std::endl std::cout << " -v <level> Set verbosity of output. [default: " << DEFAULT_LOGLEVEL << "]" << std::endl
<< " Can be a number between 5 (all) and 0 (fatal)." << std::endl; << " Can be a number between 5 (all) and 0 (fatal)." << std::endl;
std::cout << " -w <path> Writable temp dir. [default: " << _configuration->tempdir << "]" << endl; std::cout << " -w <path> Writable temp dir. [default: " << DEFAULT_TEMPDIR << "]" << endl;
std::cout << std::endl; std::cout << std::endl;
std::cout << " -d Daemonize." << std::endl; std::cout << " -d Daemonize." << std::endl;
std::cout << " -h This help page." << std::endl; std::cout << " -h This help page." << std::endl;
std::cout << std::endl; std::cout << std::endl;
delete _configuration;
_configuration = nullptr;
} }
void sigHandler(int sig) { void sigHandler(int sig) {
...@@ -156,7 +152,7 @@ int main(int argc, char *argv[]) ...@@ -156,7 +152,7 @@ int main(int argc, char *argv[])
{ {
case 'c': case 'c':
cassandraSettings.host = parseNetworkHost(optarg); cassandraSettings.host = parseNetworkHost(optarg);
cassandraSettings.port = parseNetworkPort(optarg) == "" ? CASSANDRAPORT : parseNetworkPort(optarg); cassandraSettings.port = parseNetworkPort(optarg) == "" ? DEFAULT_CASSANDRAPORT : parseNetworkPort(optarg);
break; break;
case 't': case 't':
globalSettings.threads = stoul(optarg); globalSettings.threads = stoul(optarg);
......
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