summaryrefslogtreecommitdiff
path: root/src/mongo/s/mongos_options.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-04-15 15:01:04 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-04-16 16:02:49 -0400
commitcd6f9bd7744324e725368db67934c5fa23e85347 (patch)
treedc6d0f2af2adfcd7252079b08dbe6b3eefbc943b /src/mongo/s/mongos_options.cpp
parent492e26db0702abd8b44794fb718f76b26afecefd (diff)
downloadmongo-cd6f9bd7744324e725368db67934c5fa23e85347.tar.gz
SERVER-18071 Parse mongos 'configdb' command line parameter into a ConnectionString rather than a vector of strings
Diffstat (limited to 'src/mongo/s/mongos_options.cpp')
-rw-r--r--src/mongo/s/mongos_options.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp
index 05d2ecf9f07..ab111163d92 100644
--- a/src/mongo/s/mongos_options.cpp
+++ b/src/mongo/s/mongos_options.cpp
@@ -255,15 +255,29 @@ namespace mongo {
return Status(ErrorCodes::BadValue, "error: no args for --configdb");
}
- splitStringDelim(params["sharding.configDB"].as<std::string>(),
- &mongosGlobalParams.configdbs, ',');
- if (mongosGlobalParams.configdbs.size() != 1 && mongosGlobalParams.configdbs.size() != 3) {
+ std::string configdbString = params["sharding.configDB"].as<std::string>();
+ try {
+ std::string errmsg;
+ mongosGlobalParams.configdbs = ConnectionString::parse(configdbString, errmsg);
+
+ if (!mongosGlobalParams.configdbs.isValid()) {
+ return Status(ErrorCodes::BadValue,
+ str::stream() << "Invalid configdb connection string: " << errmsg);
+ }
+ } catch (const DBException& e) {
+ return Status(ErrorCodes::BadValue,
+ str::stream() << "Invalid configdb connection string: " << e.what());
+ }
+
+ std::vector<HostAndPort> configServers = mongosGlobalParams.configdbs.getServers();
+
+ if (configServers.size() != 1 && configServers.size() != 3) {
return Status(ErrorCodes::BadValue, "need either 1 or 3 configdbs");
}
- if (mongosGlobalParams.configdbs.size() == 1) {
+ if (configServers.size() == 1) {
warning() << "running with 1 config server should be done only for testing purposes "
- << "and is not recommended for production" << endl;
+ << "and is not recommended for production" << endl;
}
if (params.count("upgrade")) {