diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/s/mongos_options.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/s/mongos_options.cpp')
-rw-r--r-- | src/mongo/s/mongos_options.cpp | 330 |
1 files changed, 164 insertions, 166 deletions
diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp index 02fffb8230a..489235cc749 100644 --- a/src/mongo/s/mongos_options.cpp +++ b/src/mongo/s/mongos_options.cpp @@ -52,241 +52,239 @@ namespace mongo { - MongosGlobalParams mongosGlobalParams; +MongosGlobalParams mongosGlobalParams; - Status addMongosOptions(moe::OptionSection* options) { +Status addMongosOptions(moe::OptionSection* options) { + moe::OptionSection general_options("General options"); - moe::OptionSection general_options("General options"); - - Status ret = addGeneralServerOptions(&general_options); - if (!ret.isOK()) { - return ret; - } + Status ret = addGeneralServerOptions(&general_options); + if (!ret.isOK()) { + return ret; + } #if defined(_WIN32) - moe::OptionSection windows_scm_options("Windows Service Control Manager options"); + moe::OptionSection windows_scm_options("Windows Service Control Manager options"); - ret = addWindowsServerOptions(&windows_scm_options); - if (!ret.isOK()) { - return ret; - } + ret = addWindowsServerOptions(&windows_scm_options); + if (!ret.isOK()) { + return ret; + } #endif #ifdef MONGO_CONFIG_SSL - moe::OptionSection ssl_options("SSL options"); + moe::OptionSection ssl_options("SSL options"); - ret = addSSLServerOptions(&ssl_options); - if (!ret.isOK()) { - return ret; - } + ret = addSSLServerOptions(&ssl_options); + if (!ret.isOK()) { + return ret; + } #endif - moe::OptionSection sharding_options("Sharding options"); + moe::OptionSection sharding_options("Sharding options"); - sharding_options.addOptionChaining("sharding.configDB", "configdb", moe::String, - "1 or 3 comma separated config servers"); + sharding_options.addOptionChaining( + "sharding.configDB", "configdb", moe::String, "1 or 3 comma separated config servers"); - sharding_options.addOptionChaining("replication.localPingThresholdMs", "localThreshold", - moe::Int, "ping time (in ms) for a node to be considered local (default 15ms)"); + sharding_options.addOptionChaining( + "replication.localPingThresholdMs", + "localThreshold", + moe::Int, + "ping time (in ms) for a node to be considered local (default 15ms)"); - sharding_options.addOptionChaining("test", "test", moe::Switch, "just run unit tests") - .setSources(moe::SourceAllLegacy); + sharding_options.addOptionChaining("test", "test", moe::Switch, "just run unit tests") + .setSources(moe::SourceAllLegacy); - sharding_options.addOptionChaining("upgrade", "upgrade", moe::Switch, - "upgrade meta data version") - .setSources(moe::SourceAllLegacy); + sharding_options.addOptionChaining( + "upgrade", "upgrade", moe::Switch, "upgrade meta data version") + .setSources(moe::SourceAllLegacy); - sharding_options.addOptionChaining("sharding.chunkSize", "chunkSize", moe::Int, - "maximum amount of data per chunk"); + sharding_options.addOptionChaining( + "sharding.chunkSize", "chunkSize", moe::Int, "maximum amount of data per chunk"); - sharding_options.addOptionChaining("net.http.JSONPEnabled", "jsonp", moe::Switch, - "allow JSONP access via http (has security implications)") - .setSources(moe::SourceAllLegacy); + sharding_options.addOptionChaining("net.http.JSONPEnabled", + "jsonp", + moe::Switch, + "allow JSONP access via http (has security implications)") + .setSources(moe::SourceAllLegacy); - sharding_options.addOptionChaining("noscripting", "noscripting", moe::Switch, - "disable scripting engine") - .setSources(moe::SourceAllLegacy); + sharding_options.addOptionChaining( + "noscripting", "noscripting", moe::Switch, "disable scripting engine") + .setSources(moe::SourceAllLegacy); - options->addSection(general_options); + options->addSection(general_options); #if defined(_WIN32) - options->addSection(windows_scm_options); + options->addSection(windows_scm_options); #endif - options->addSection(sharding_options); + options->addSection(sharding_options); #ifdef MONGO_CONFIG_SSL - options->addSection(ssl_options); + options->addSection(ssl_options); #endif - options->addOptionChaining("noAutoSplit", "noAutoSplit", moe::Switch, - "do not send split commands with writes") - .hidden() - .setSources(moe::SourceAllLegacy); + options->addOptionChaining("noAutoSplit", + "noAutoSplit", + moe::Switch, + "do not send split commands with writes") + .hidden() + .setSources(moe::SourceAllLegacy); - options->addOptionChaining("sharding.autoSplit", "", moe::Bool, - "send split commands with writes") - .setSources(moe::SourceYAMLConfig); + options->addOptionChaining( + "sharding.autoSplit", "", moe::Bool, "send split commands with writes") + .setSources(moe::SourceYAMLConfig); - return Status::OK(); - } + return Status::OK(); +} - void printMongosHelp(const moe::OptionSection& options) { - std::cout << options.helpString() << std::endl; - }; +void printMongosHelp(const moe::OptionSection& options) { + std::cout << options.helpString() << std::endl; +}; - bool handlePreValidationMongosOptions(const moe::Environment& params, - const std::vector<std::string>& args) { - if (params.count("help") && - params["help"].as<bool>() == true) { - printMongosHelp(moe::startupOptions); - return false; - } - if (params.count("version") && - params["version"].as<bool>() == true) { - printShardingVersionInfo(true); - return false; - } - if (params.count("test") && - params["test"].as<bool>() == true) { - ::mongo::logger::globalLogDomain()->setMinimumLoggedSeverity( - ::mongo::logger::LogSeverity::Debug(5)); - StartupTest::runTests(); - return false; - } - - return true; +bool handlePreValidationMongosOptions(const moe::Environment& params, + const std::vector<std::string>& args) { + if (params.count("help") && params["help"].as<bool>() == true) { + printMongosHelp(moe::startupOptions); + return false; + } + if (params.count("version") && params["version"].as<bool>() == true) { + printShardingVersionInfo(true); + return false; + } + if (params.count("test") && params["test"].as<bool>() == true) { + ::mongo::logger::globalLogDomain()->setMinimumLoggedSeverity( + ::mongo::logger::LogSeverity::Debug(5)); + StartupTest::runTests(); + return false; } - Status validateMongosOptions(const moe::Environment& params) { + return true; +} - Status ret = validateServerOptions(params); - if (!ret.isOK()) { - return ret; - } +Status validateMongosOptions(const moe::Environment& params) { + Status ret = validateServerOptions(params); + if (!ret.isOK()) { + return ret; + } - return Status::OK(); + return Status::OK(); +} + +Status canonicalizeMongosOptions(moe::Environment* params) { + Status ret = canonicalizeServerOptions(params); + if (!ret.isOK()) { + return ret; } - Status canonicalizeMongosOptions(moe::Environment* params) { +#ifdef MONGO_CONFIG_SSL + ret = canonicalizeSSLServerOptions(params); + if (!ret.isOK()) { + return ret; + } +#endif - Status ret = canonicalizeServerOptions(params); + // "sharding.autoSplit" comes from the config file, so override it if "noAutoSplit" is set + // since that comes from the command line. + if (params->count("noAutoSplit")) { + Status ret = + params->set("sharding.autoSplit", moe::Value(!(*params)["noAutoSplit"].as<bool>())); if (!ret.isOK()) { return ret; } - -#ifdef MONGO_CONFIG_SSL - ret = canonicalizeSSLServerOptions(params); + ret = params->remove("noAutoSplit"); if (!ret.isOK()) { return ret; } -#endif - - // "sharding.autoSplit" comes from the config file, so override it if "noAutoSplit" is set - // since that comes from the command line. - if (params->count("noAutoSplit")) { - Status ret = params->set("sharding.autoSplit", - moe::Value(!(*params)["noAutoSplit"].as<bool>())); - if (!ret.isOK()) { - return ret; - } - ret = params->remove("noAutoSplit"); - if (!ret.isOK()) { - return ret; - } - } - - return Status::OK(); } - Status storeMongosOptions(const moe::Environment& params, - const std::vector<std::string>& args) { + return Status::OK(); +} - Status ret = storeServerOptions(params, args); - if (!ret.isOK()) { - return ret; - } - - if ( params.count( "sharding.chunkSize" ) ) { - int csize = params["sharding.chunkSize"].as<int>(); +Status storeMongosOptions(const moe::Environment& params, const std::vector<std::string>& args) { + Status ret = storeServerOptions(params, args); + if (!ret.isOK()) { + return ret; + } - // validate chunksize before proceeding - if ( csize == 0 ) { - return Status(ErrorCodes::BadValue, "error: need a non-zero chunksize"); - } + if (params.count("sharding.chunkSize")) { + int csize = params["sharding.chunkSize"].as<int>(); - if ( !Chunk::setMaxChunkSizeSizeMB( csize ) ) { - return Status(ErrorCodes::BadValue, "MaxChunkSize invalid"); - } + // validate chunksize before proceeding + if (csize == 0) { + return Status(ErrorCodes::BadValue, "error: need a non-zero chunksize"); } - if (params.count( "net.port" ) ) { - int port = params["net.port"].as<int>(); - if ( port <= 0 || port > 65535 ) { - return Status(ErrorCodes::BadValue, - "error: port number must be between 1 and 65535"); - } + if (!Chunk::setMaxChunkSizeSizeMB(csize)) { + return Status(ErrorCodes::BadValue, "MaxChunkSize invalid"); } + } - if ( params.count( "replication.localPingThresholdMs" ) ) { - serverGlobalParams.defaultLocalThresholdMillis = - params["replication.localPingThresholdMs"].as<int>(); + if (params.count("net.port")) { + int port = params["net.port"].as<int>(); + if (port <= 0 || port > 65535) { + return Status(ErrorCodes::BadValue, "error: port number must be between 1 and 65535"); } + } - if (params.count("net.http.JSONPEnabled")) { - serverGlobalParams.jsonp = params["net.http.JSONPEnabled"].as<bool>(); - } + if (params.count("replication.localPingThresholdMs")) { + serverGlobalParams.defaultLocalThresholdMillis = + params["replication.localPingThresholdMs"].as<int>(); + } - if (params.count("noscripting")) { - // This option currently has no effect for mongos - } + if (params.count("net.http.JSONPEnabled")) { + serverGlobalParams.jsonp = params["net.http.JSONPEnabled"].as<bool>(); + } - if (params.count("sharding.autoSplit")) { - Chunk::ShouldAutoSplit = params["sharding.autoSplit"].as<bool>(); - if (Chunk::ShouldAutoSplit == false) { - warning() << "running with auto-splitting disabled"; - } - } + if (params.count("noscripting")) { + // This option currently has no effect for mongos + } - if ( ! params.count( "sharding.configDB" ) ) { - return Status(ErrorCodes::BadValue, "error: no args for --configdb"); + if (params.count("sharding.autoSplit")) { + Chunk::ShouldAutoSplit = params["sharding.autoSplit"].as<bool>(); + if (Chunk::ShouldAutoSplit == false) { + warning() << "running with auto-splitting disabled"; } + } - { - std::string configdbString = params["sharding.configDB"].as<std::string>(); + if (!params.count("sharding.configDB")) { + return Status(ErrorCodes::BadValue, "error: no args for --configdb"); + } - auto configdbConnectionString = ConnectionString::parse(configdbString); - if (!configdbConnectionString.isOK()) { - return Status(ErrorCodes::BadValue, - str::stream() << "Invalid configdb connection string: " - << configdbConnectionString.getStatus().toString()); - } + { + std::string configdbString = params["sharding.configDB"].as<std::string>(); - mongosGlobalParams.configdbs = configdbConnectionString.getValue(); + auto configdbConnectionString = ConnectionString::parse(configdbString); + if (!configdbConnectionString.isOK()) { + return Status(ErrorCodes::BadValue, + str::stream() << "Invalid configdb connection string: " + << configdbConnectionString.getStatus().toString()); } - std::vector<HostAndPort> configServers = mongosGlobalParams.configdbs.getServers(); + mongosGlobalParams.configdbs = configdbConnectionString.getValue(); + } - if (!(mongosGlobalParams.configdbs.type() == ConnectionString::SYNC) && - !(mongosGlobalParams.configdbs.type() == ConnectionString::SET && - configServers.size() == 1)) { - return Status(ErrorCodes::BadValue, - "Must have either 3 node old-style config servers, or a single server " - "replica set config server"); - } + std::vector<HostAndPort> configServers = mongosGlobalParams.configdbs.getServers(); - if (configServers.size() < 3) { - warning() << "running with less than 3 config servers should be done only for testing " - "purposes and is not recommended for production"; - } + if (!(mongosGlobalParams.configdbs.type() == ConnectionString::SYNC) && + !(mongosGlobalParams.configdbs.type() == ConnectionString::SET && + configServers.size() == 1)) { + return Status(ErrorCodes::BadValue, + "Must have either 3 node old-style config servers, or a single server " + "replica set config server"); + } - if (params.count("upgrade")) { - mongosGlobalParams.upgrade = params["upgrade"].as<bool>(); - } + if (configServers.size() < 3) { + warning() << "running with less than 3 config servers should be done only for testing " + "purposes and is not recommended for production"; + } - return Status::OK(); + if (params.count("upgrade")) { + mongosGlobalParams.upgrade = params["upgrade"].as<bool>(); } -} // namespace mongo + return Status::OK(); +} + +} // namespace mongo |