Validate connection method per endpoint, not socket

this allows e.g. to ommit the socket method in config if all endpoints
specify the method modifier.
It still is fully backward compatible.
This commit is contained in:
mkrzewic 2016-11-13 14:22:51 +01:00
parent 892aa8008b
commit 94a4d599eb
2 changed files with 20 additions and 12 deletions

View File

@ -390,17 +390,6 @@ bool FairMQChannel::ValidateChannel()
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// validate socket method
const string socketMethodNames[] = { "bind", "connect" };
const set<string> socketMethods(socketMethodNames, socketMethodNames + sizeof(socketMethodNames) / sizeof(string));
if (socketMethods.find(fMethod) == socketMethods.end())
{
ss << "INVALID";
LOG(DEBUG) << ss.str();
LOG(ERROR) << "Invalid channel method: \"" << fMethod << "\"";
exit(EXIT_FAILURE);
}
// validate socket address // validate socket address
if (fAddress == "unspecified" || fAddress == "") if (fAddress == "unspecified" || fAddress == "")
{ {
@ -421,6 +410,16 @@ bool FairMQChannel::ValidateChannel()
if (endpoint[0]=='@'||endpoint[0]=='+'||endpoint[0]=='>') { if (endpoint[0]=='@'||endpoint[0]=='+'||endpoint[0]=='>') {
address = endpoint.substr(1); address = endpoint.substr(1);
} else { } else {
// we don't have a method modifier, check if the default method is set
const string socketMethodNames[] = { "bind", "connect" };
const set<string> socketMethods(socketMethodNames, socketMethodNames + sizeof(socketMethodNames) / sizeof(string));
if (socketMethods.find(fMethod) == socketMethods.end())
{
ss << "INVALID";
LOG(DEBUG) << ss.str();
LOG(ERROR) << "Invalid endpoint connection method: \"" << fMethod << "\" for " << endpoint;
exit(EXIT_FAILURE);
}
address = endpoint; address = endpoint;
} }
// check if address is a tcp or ipc address // check if address is a tcp or ipc address

View File

@ -208,6 +208,15 @@ void FairMQDevice::InitWrapper()
// fill the uninitialized list // fill the uninitialized list
uninitializedConnectingChannels.push_back(&(*vi)); uninitializedConnectingChannels.push_back(&(*vi));
} }
else if (vi->fAddress.find_first_of("@+>") != string::npos)
{
// set channel name: name + vector index
stringstream ss;
ss << mi->first << "[" << vi - (mi->second).begin() << "]";
vi->fChannelName = ss.str();
// fill the uninitialized list
uninitializedConnectingChannels.push_back(&(*vi));
}
else else
{ {
LOG(ERROR) << "Cannot update configuration. Socket method (bind/connect) not specified."; LOG(ERROR) << "Cannot update configuration. Socket method (bind/connect) not specified.";