FairMQParser: Disable deprecated parsing for singular JSON keys

This commit is contained in:
Alexey Rybalchenko 2017-08-29 10:15:04 +02:00 committed by Mohammad Al-Turany
parent 4c7f119ce8
commit 3ab7ee5f02

View File

@ -107,30 +107,30 @@ void PrintDeviceList(const boost::property_tree::ptree& tree, const std::string&
} }
} }
if (p.first == "device") // if (p.first == "device")
{ // {
//get id attribute to choose the device // //get id attribute to choose the device
if (formatFlag == "xml") // if (formatFlag == "xml")
{ // {
deviceIdKey = p.second.get<string>("<xmlattr>.id"); // deviceIdKey = p.second.get<string>("<xmlattr>.id");
LOG(TRACE) << "Found config for '" << deviceIdKey << "' in XML input"; // LOG(TRACE) << "Found config for '" << deviceIdKey << "' in XML input";
} // }
if (formatFlag == "json") // if (formatFlag == "json")
{ // {
string key = p.second.get<string>("key", ""); // string key = p.second.get<string>("key", "");
if (key != "") // if (key != "")
{ // {
deviceIdKey = key; // deviceIdKey = key;
LOG(TRACE) << "Found config for device key '" << deviceIdKey << "' in JSON input"; // LOG(TRACE) << "Found config for device key '" << deviceIdKey << "' in JSON input";
} // }
else // else
{ // {
deviceIdKey = p.second.get<string>("id"); // deviceIdKey = p.second.get<string>("id");
LOG(TRACE) << "Found config for device id '" << deviceIdKey << "' in JSON input"; // LOG(TRACE) << "Found config for device id '" << deviceIdKey << "' in JSON input";
} // }
} // }
} // }
} }
} }
@ -173,40 +173,40 @@ void DeviceParser(const boost::property_tree::ptree& tree, FairMQMap& channelMap
} }
} }
if (p.first == "device") // if (p.first == "device")
{ // {
if (formatFlag == "xml") // if (formatFlag == "xml")
{ // {
deviceIdKey = p.second.get<string>("<xmlattr>.id"); // deviceIdKey = p.second.get<string>("<xmlattr>.id");
} // }
if (formatFlag == "json") // if (formatFlag == "json")
{ // {
// check if key is provided, otherwise use id // // check if key is provided, otherwise use id
string key = p.second.get<string>("key", ""); // string key = p.second.get<string>("key", "");
if (key != "") // if (key != "")
{ // {
deviceIdKey = key; // deviceIdKey = key;
// LOG(DEBUG) << "Found config for device key '" << deviceIdKey << "' in JSON input"; // // LOG(DEBUG) << "Found config for device key '" << deviceIdKey << "' in JSON input";
} // }
else // else
{ // {
deviceIdKey = p.second.get<string>("id"); // deviceIdKey = p.second.get<string>("id");
// LOG(DEBUG) << "Found config for device id '" << deviceIdKey << "' in JSON input"; // // LOG(DEBUG) << "Found config for device id '" << deviceIdKey << "' in JSON input";
} // }
} // }
// if not correct device id, do not fill MQMap // // if not correct device id, do not fill MQMap
if (deviceId != deviceIdKey) // if (deviceId != deviceIdKey)
{ // {
continue; // continue;
} // }
LOG(DEBUG) << "Found with following channels:"; // LOG(DEBUG) << "Found with following channels:";
ChannelParser(p.second, channelMap, formatFlag); // ChannelParser(p.second, channelMap, formatFlag);
} // }
} }
} }
@ -270,68 +270,68 @@ void ChannelParser(const boost::property_tree::ptree& tree, FairMQMap& channelMa
} }
} }
if (p.first == "channel") // if (p.first == "channel")
{ // {
// try to get common properties to use for all subChannels // // try to get common properties to use for all subChannels
FairMQChannel commonChannel; // FairMQChannel commonChannel;
int numSockets = 0; // int numSockets = 0;
// get name attribute to form key // // get name attribute to form key
if (formatFlag == "xml") // if (formatFlag == "xml")
{ // {
channelKey = p.second.get<string>("<xmlattr>.name"); // channelKey = p.second.get<string>("<xmlattr>.name");
} // }
if (formatFlag == "json") // if (formatFlag == "json")
{ // {
channelKey = p.second.get<string>("name"); // channelKey = p.second.get<string>("name");
numSockets = p.second.get<int>("numSockets", 0); // numSockets = p.second.get<int>("numSockets", 0);
// try to get common properties to use for all subChannels // // try to get common properties to use for all subChannels
commonChannel.UpdateType(p.second.get<string>("type", commonChannel.GetType())); // commonChannel.UpdateType(p.second.get<string>("type", commonChannel.GetType()));
commonChannel.UpdateMethod(p.second.get<string>("method", commonChannel.GetMethod())); // commonChannel.UpdateMethod(p.second.get<string>("method", commonChannel.GetMethod()));
commonChannel.UpdateAddress(p.second.get<string>("address", commonChannel.GetAddress())); // commonChannel.UpdateAddress(p.second.get<string>("address", commonChannel.GetAddress()));
commonChannel.UpdateTransport(p.second.get<string>("transport", commonChannel.GetTransport())); // commonChannel.UpdateTransport(p.second.get<string>("transport", commonChannel.GetTransport()));
commonChannel.UpdateSndBufSize(p.second.get<int>("sndBufSize", commonChannel.GetSndBufSize())); // commonChannel.UpdateSndBufSize(p.second.get<int>("sndBufSize", commonChannel.GetSndBufSize()));
commonChannel.UpdateRcvBufSize(p.second.get<int>("rcvBufSize", commonChannel.GetRcvBufSize())); // commonChannel.UpdateRcvBufSize(p.second.get<int>("rcvBufSize", commonChannel.GetRcvBufSize()));
commonChannel.UpdateSndKernelSize(p.second.get<int>("sndKernelSize", commonChannel.GetSndKernelSize())); // commonChannel.UpdateSndKernelSize(p.second.get<int>("sndKernelSize", commonChannel.GetSndKernelSize()));
commonChannel.UpdateRcvKernelSize(p.second.get<int>("rcvKernelSize", commonChannel.GetRcvKernelSize())); // commonChannel.UpdateRcvKernelSize(p.second.get<int>("rcvKernelSize", commonChannel.GetRcvKernelSize()));
commonChannel.UpdateRateLogging(p.second.get<int>("rateLogging", commonChannel.GetRateLogging())); // commonChannel.UpdateRateLogging(p.second.get<int>("rateLogging", commonChannel.GetRateLogging()));
} // }
// temporary FairMQChannel container // // temporary FairMQChannel container
vector<FairMQChannel> channelList; // vector<FairMQChannel> channelList;
if (numSockets > 0) // if (numSockets > 0)
{ // {
LOG(DEBUG) << "" << channelKey << ":"; // LOG(DEBUG) << "" << channelKey << ":";
LOG(DEBUG) << "\tnumSockets of " << numSockets << " specified,"; // LOG(DEBUG) << "\tnumSockets of " << numSockets << " specified,";
LOG(DEBUG) << "\tapplying common settings to each:"; // LOG(DEBUG) << "\tapplying common settings to each:";
LOG(DEBUG) << "\ttype = " << commonChannel.GetType(); // LOG(DEBUG) << "\ttype = " << commonChannel.GetType();
LOG(DEBUG) << "\tmethod = " << commonChannel.GetMethod(); // LOG(DEBUG) << "\tmethod = " << commonChannel.GetMethod();
LOG(DEBUG) << "\taddress = " << commonChannel.GetAddress(); // LOG(DEBUG) << "\taddress = " << commonChannel.GetAddress();
LOG(DEBUG) << "\ttransport = " << commonChannel.GetTransport(); // LOG(DEBUG) << "\ttransport = " << commonChannel.GetTransport();
LOG(DEBUG) << "\tsndBufSize = " << commonChannel.GetSndBufSize(); // LOG(DEBUG) << "\tsndBufSize = " << commonChannel.GetSndBufSize();
LOG(DEBUG) << "\trcvBufSize = " << commonChannel.GetRcvBufSize(); // LOG(DEBUG) << "\trcvBufSize = " << commonChannel.GetRcvBufSize();
LOG(DEBUG) << "\tsndKernelSize = " << commonChannel.GetSndKernelSize(); // LOG(DEBUG) << "\tsndKernelSize = " << commonChannel.GetSndKernelSize();
LOG(DEBUG) << "\trcvKernelSize = " << commonChannel.GetRcvKernelSize(); // LOG(DEBUG) << "\trcvKernelSize = " << commonChannel.GetRcvKernelSize();
LOG(DEBUG) << "\trateLogging = " << commonChannel.GetRateLogging(); // LOG(DEBUG) << "\trateLogging = " << commonChannel.GetRateLogging();
for (int i = 0; i < numSockets; ++i) // for (int i = 0; i < numSockets; ++i)
{ // {
FairMQChannel channel(commonChannel); // FairMQChannel channel(commonChannel);
channelList.push_back(channel); // channelList.push_back(channel);
} // }
} // }
else // else
{ // {
SocketParser(p.second.get_child(""), channelList, channelKey, commonChannel); // SocketParser(p.second.get_child(""), channelList, channelKey, commonChannel);
} // }
channelMap.insert(make_pair(channelKey, move(channelList))); // channelMap.insert(make_pair(channelKey, move(channelList)));
} // }
} }
} }
@ -376,36 +376,36 @@ void SocketParser(const boost::property_tree::ptree& tree, vector<FairMQChannel>
} }
} }
if (p.first == "socket") // if (p.first == "socket")
{ // {
// create new channel and apply setting from the common channel // // create new channel and apply setting from the common channel
FairMQChannel channel(commonChannel); // FairMQChannel channel(commonChannel);
// if the socket field specifies or overrides something from the common channel, apply those settings // // if the socket field specifies or overrides something from the common channel, apply those settings
channel.UpdateType(p.second.get<string>("type", channel.GetType())); // channel.UpdateType(p.second.get<string>("type", channel.GetType()));
channel.UpdateMethod(p.second.get<string>("method", channel.GetMethod())); // channel.UpdateMethod(p.second.get<string>("method", channel.GetMethod()));
channel.UpdateAddress(p.second.get<string>("address", channel.GetAddress())); // channel.UpdateAddress(p.second.get<string>("address", channel.GetAddress()));
channel.UpdateTransport(p.second.get<string>("transport", channel.GetTransport())); // channel.UpdateTransport(p.second.get<string>("transport", channel.GetTransport()));
channel.UpdateSndBufSize(p.second.get<int>("sndBufSize", channel.GetSndBufSize())); // channel.UpdateSndBufSize(p.second.get<int>("sndBufSize", channel.GetSndBufSize()));
channel.UpdateRcvBufSize(p.second.get<int>("rcvBufSize", channel.GetRcvBufSize())); // channel.UpdateRcvBufSize(p.second.get<int>("rcvBufSize", channel.GetRcvBufSize()));
channel.UpdateSndKernelSize(p.second.get<int>("sndKernelSize", channel.GetSndKernelSize())); // channel.UpdateSndKernelSize(p.second.get<int>("sndKernelSize", channel.GetSndKernelSize()));
channel.UpdateRcvKernelSize(p.second.get<int>("rcvKernelSize", channel.GetRcvKernelSize())); // channel.UpdateRcvKernelSize(p.second.get<int>("rcvKernelSize", channel.GetRcvKernelSize()));
channel.UpdateRateLogging(p.second.get<int>("rateLogging", channel.GetRateLogging())); // channel.UpdateRateLogging(p.second.get<int>("rateLogging", channel.GetRateLogging()));
LOG(DEBUG) << "" << channelName << "[" << socketCounter << "]:"; // LOG(DEBUG) << "" << channelName << "[" << socketCounter << "]:";
LOG(DEBUG) << "\ttype = " << channel.GetType(); // LOG(DEBUG) << "\ttype = " << channel.GetType();
LOG(DEBUG) << "\tmethod = " << channel.GetMethod(); // LOG(DEBUG) << "\tmethod = " << channel.GetMethod();
LOG(DEBUG) << "\taddress = " << channel.GetAddress(); // LOG(DEBUG) << "\taddress = " << channel.GetAddress();
LOG(DEBUG) << "\ttransport = " << channel.GetTransport(); // LOG(DEBUG) << "\ttransport = " << channel.GetTransport();
LOG(DEBUG) << "\tsndBufSize = " << channel.GetSndBufSize(); // LOG(DEBUG) << "\tsndBufSize = " << channel.GetSndBufSize();
LOG(DEBUG) << "\trcvBufSize = " << channel.GetRcvBufSize(); // LOG(DEBUG) << "\trcvBufSize = " << channel.GetRcvBufSize();
LOG(DEBUG) << "\tsndKernelSize = " << channel.GetSndKernelSize(); // LOG(DEBUG) << "\tsndKernelSize = " << channel.GetSndKernelSize();
LOG(DEBUG) << "\trcvKernelSize = " << channel.GetRcvKernelSize(); // LOG(DEBUG) << "\trcvKernelSize = " << channel.GetRcvKernelSize();
LOG(DEBUG) << "\trateLogging = " << channel.GetRateLogging(); // LOG(DEBUG) << "\trateLogging = " << channel.GetRateLogging();
channelList.push_back(channel); // channelList.push_back(channel);
++socketCounter; // ++socketCounter;
} // }
} // end socket loop } // end socket loop
if (socketCounter) if (socketCounter)