Configuration and DDS example/tools updates

- Update DDS example command UI and extract it from example.
 - Unify address handling via DDS properties for dynamic deployment.
 - Update DDS docs with the new approach.
 - Allow `--config-key` to be used to access common config in JSON.
 - Allow common channel properties to be specified for all sockets.
 - Update MQ examples and Tuto3 with new config options.
 - Add start scripts to MQ examples for easier use.
This commit is contained in:
Alexey Rybalchenko
2016-03-31 14:41:05 +02:00
parent 151d3b5de8
commit b9883d3b13
21 changed files with 1082 additions and 701 deletions

View File

@@ -61,23 +61,23 @@ int FairMQProgOptions::ParseAll(const int argc, char** argv, bool allowUnregiste
}
}
// set log level before printing (default is 0 = DEBUG level)
std::string verbose = GetValue<std::string>("verbose");
bool color = GetValue<bool>("log-color");
if (!color)
{
reinit_logger(false);
}
//SET_LOG_LEVEL(DEBUG);
if (fSeverityMap.count(verbose))
{
set_global_log_level(log_op::operation::GREATER_EQ_THAN, fSeverityMap.at(verbose));
}
else
{
LOG(ERROR) << " verbosity level '" << verbose << "' unknown, it will be set to DEBUG";
set_global_log_level(log_op::operation::GREATER_EQ_THAN, fSeverityMap.at("DEBUG"));
}
// // set log level before printing (default is 0 = DEBUG level)
// std::string verbose = GetValue<std::string>("verbose");
// bool color = GetValue<bool>("log-color");
// if (!color)
// {
// reinit_logger(false);
// }
// //SET_LOG_LEVEL(DEBUG);
// if (fSeverityMap.count(verbose))
// {
// set_global_log_level(log_op::operation::GREATER_EQ_THAN, fSeverityMap.at(verbose));
// }
// else
// {
// LOG(ERROR) << " verbosity level '" << verbose << "' unknown, it will be set to DEBUG";
// set_global_log_level(log_op::operation::GREATER_EQ_THAN, fSeverityMap.at("DEBUG"));
// }
PrintOptions();
@@ -108,28 +108,42 @@ int FairMQProgOptions::ParseAll(const int argc, char** argv, bool allowUnregiste
}
else
{
if(fVarMap.count("mq-config"))
if (fVarMap.count("mq-config"))
{
LOG(DEBUG)<<"mq-config command line called : default xml/json parser will be used";
LOG(DEBUG) << "mq-config command line called : default xml/json parser will be used";
std::string file = fVarMap["mq-config"].as<std::string>();
std::string id = fVarMap["id"].as<std::string>();
std::string id;
if (fVarMap.count("config-key"))
{
id = fVarMap["config-key"].as<std::string>();
}
else
{
id = fVarMap["id"].as<std::string>();
}
std::string file_extension = boost::filesystem::extension(file);
std::transform(file_extension.begin(), file_extension.end(), file_extension.begin(), ::tolower);
if(file_extension==".json")
if (file_extension == ".json")
{
UserParser<FairMQParser::JSON>(file, id);
}
else
if(file_extension==".xml")
{
if (file_extension == ".xml")
{
UserParser<FairMQParser::XML>(file, id);
}
else
{
LOG(ERROR) <<"mq-config command line called but file extension '"
<<file_extension
LOG(ERROR) << "mq-config command line called but file extension '"
<< file_extension
<< "' not recognized. Program will now exit";
return 1;
}
}
}
}
@@ -159,21 +173,30 @@ void FairMQProgOptions::InitOptionDescription()
if (fUseConfigFile)
{
fMQOptionsInCmd.add_options()
("id", po::value<string>(), "Device ID (required argument).")
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads.")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').");
("id", po::value<string>(), "Device ID (required argument).")
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads.")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
("deployment", po::value<string>()->default_value("static"), "Deployment ('static'/'dds').")
("network-interface", po::value<string>()->default_value("eth0"), "Network interface to bind on (e.g. eth0, ib0, wlan0, en0, lo...).")
;
fMQOptionsInCfg.add_options()
("id", po::value<string>()->required(), "Device ID (required argument).")
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads.")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').");
("id", po::value<string>()->required(), "Device ID (required argument).")
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads.")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
("deployment", po::value<string>()->default_value("static"), "Deployment ('static'/'dds').")
("network-interface", po::value<string>()->default_value("eth0"), "Network interface to bind on (e.g. eth0, ib0, wlan0, en0, lo...).")
;
}
else
{
fMQOptionsInCmd.add_options()
("id", po::value<string>()->required(), "Device ID (required argument)")
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').");
("id", po::value<string>()->required(), "Device ID (required argument)")
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
("deployment", po::value<string>()->default_value("static"), "Deployment ('static'/'dds').")
("network-interface", po::value<string>()->default_value("eth0"), "Network interface to bind on (e.g. eth0, ib0, wlan0, en0, lo...).")
;
}
fMQParserOptions.add_options()
@@ -182,6 +205,7 @@ void FairMQProgOptions::InitOptionDescription()
("config-json-string", po::value<vector<string>>()->multitoken(), "JSON input as command line string.")
("config-json-file", po::value<string>(), "JSON input as file.")
("mq-config", po::value<string>(), "JSON/XML input as file. The configuration object will check xml or json file extention and will call the json or xml parser accordingly")
("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file")
;
AddToCmdLineOptions(fGenericDesc);
@@ -190,7 +214,7 @@ void FairMQProgOptions::InitOptionDescription()
if (fUseConfigFile)
{
AddToCfgFileOptions(fMQOptionsInCfg,false);
AddToCfgFileOptions(fMQParserOptions,false);
AddToCfgFileOptions(fMQOptionsInCfg, false);
AddToCfgFileOptions(fMQParserOptions, false);
}
}