mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
fix giving config servers with/without port
This commit is contained in:
parent
1a4ad3f915
commit
2aae06ec8b
31
s/config.cpp
31
s/config.cpp
@ -170,7 +170,7 @@ namespace mongo {
|
||||
|
||||
if ( configHosts.empty() ) {
|
||||
if ( ! infer ) {
|
||||
out() << "--griddb or --infer required\n";
|
||||
out() << "--configdb or --infer required\n";
|
||||
exit(7);
|
||||
}
|
||||
stringstream sl, sr;
|
||||
@ -184,17 +184,12 @@ namespace mongo {
|
||||
right = sr.str();
|
||||
}
|
||||
else {
|
||||
stringstream sl, sr;
|
||||
sl << configHosts[0];
|
||||
hostLeft = sl.str();
|
||||
sl << ":" << Port;
|
||||
left = sl.str();
|
||||
hostLeft = getHost( configHosts[0] , false );
|
||||
left = getHost( configHosts[0] , true );
|
||||
|
||||
if ( configHosts.size() > 1 ) {
|
||||
sr << configHosts[1];
|
||||
hostRight = sr.str();
|
||||
sr << ":" << Port;
|
||||
right = sr.str();
|
||||
hostRight = getHost( configHosts[1] , false );
|
||||
right = getHost( configHosts[1] , true );
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,6 +235,22 @@ namespace mongo {
|
||||
return true;
|
||||
}
|
||||
|
||||
string ConfigServer::getHost( string name , bool withPort ){
|
||||
if ( name.find( ":" ) ){
|
||||
if ( withPort )
|
||||
return name;
|
||||
return name.substr( 0 , name.find( ":" ) );
|
||||
}
|
||||
|
||||
if ( withPort ){
|
||||
stringstream ss;
|
||||
ss << name << ":" << Port;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
ConfigServer configServer;
|
||||
Grid grid;
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ namespace mongo {
|
||||
call at startup, this will initiate connection to the grid db
|
||||
*/
|
||||
bool init( vector<string> configHosts , bool infer );
|
||||
|
||||
private:
|
||||
string getHost( string name , bool withPort );
|
||||
};
|
||||
|
||||
} // namespace mongo
|
||||
|
Loading…
Reference in New Issue
Block a user