diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2018-01-29 12:28:22 -0500 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2018-02-14 02:14:33 -0500 |
commit | 8dc33796371e1226bc2a53481e80cf0fd8142371 (patch) | |
tree | 5cc0a9a53829f11c284ee6440be48ec72a67b87f | |
parent | 2dc87c711cb0bf85fdc8dd1d65b5a83e144509fa (diff) | |
download | mongo-8dc33796371e1226bc2a53481e80cf0fd8142371.tar.gz |
SERVER-32951 Add lib for embedded options where we can have a different set of startup options. Also reduce dependencies on embedded.
22 files changed, 517 insertions, 112 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript index bdb4aaa2688..ee98793a053 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -301,6 +301,7 @@ env.Library( 'db/keys_collection_client_direct', 'db/kill_sessions_local', 'db/logical_session_cache_factory_mongod', + 'db/mongod_options', 'db/mongodandmongos', 'db/op_observer_d', 'db/query_exec', diff --git a/src/mongo/client/embedded/SConscript b/src/mongo/client/embedded/SConscript index 805420fca0e..516fea02977 100644 --- a/src/mongo/client/embedded/SConscript +++ b/src/mongo/client/embedded/SConscript @@ -56,6 +56,19 @@ env.Library('repl_coordinator_embedded', ) env.Library( + target="embedded_options", + source=[ + 'embedded_options.cpp', + 'embedded_options_init.cpp', + ], + LIBDEPS=[ + '$BUILD_DIR/mongo/db/server_options', + '$BUILD_DIR/mongo/db/storage/storage_options', + '$BUILD_DIR/mongo/util/options_parser/options_parser', + ], +) + +env.Library( target='embedded', source=[ 'embedded.cpp', @@ -68,16 +81,15 @@ env.Library( '$BUILD_DIR/mongo/db/catalog/catalog_impl', '$BUILD_DIR/mongo/db/commands/dcommands', '$BUILD_DIR/mongo/db/dbdirectclient', - '$BUILD_DIR/mongo/db/mongod_options', '$BUILD_DIR/mongo/db/op_observer_d', '$BUILD_DIR/mongo/db/repair_database_and_check_version', '$BUILD_DIR/mongo/db/repl/replication_info', '$BUILD_DIR/mongo/db/repl/storage_interface_impl', '$BUILD_DIR/mongo/db/startup_warnings_mongod', '$BUILD_DIR/mongo/db/storage/wiredtiger/storage_wiredtiger', - '$BUILD_DIR/mongo/mongod_options_init', '$BUILD_DIR/mongo/util/net/network', '$BUILD_DIR/mongo/util/version_impl', + 'embedded_options', 'repl_coordinator_embedded', 'service_context_embedded', 'service_entry_point_embedded', diff --git a/src/mongo/client/embedded/embedded.cpp b/src/mongo/client/embedded/embedded.cpp index 1b07f0f65ba..9e1c71ec791 100644 --- a/src/mongo/client/embedded/embedded.cpp +++ b/src/mongo/client/embedded/embedded.cpp @@ -30,7 +30,7 @@ #include "mongo/platform/basic.h" -#include "embedded.h" +#include "mongo/client/embedded/embedded.h" #include "mongo/base/checked_cast.h" #include "mongo/base/initializer.h" @@ -45,10 +45,10 @@ #include "mongo/db/commands/fsync_locked.h" #include "mongo/db/concurrency/lock_state.h" #include "mongo/db/dbdirectclient.h" +#include "mongo/db/global_settings.h" #include "mongo/db/index_rebuilder.h" #include "mongo/db/kill_sessions_local.h" #include "mongo/db/log_process_details.h" -#include "mongo/db/mongod_options.h" #include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/repair_database_and_check_version.h" diff --git a/src/mongo/client/embedded/embedded_options.cpp b/src/mongo/client/embedded/embedded_options.cpp new file mode 100644 index 00000000000..97b3483b1c1 --- /dev/null +++ b/src/mongo/client/embedded/embedded_options.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl + +#include "mongo/client/embedded/embedded_options.h" + +#include "mongo/db/server_options.h" +#include "mongo/db/server_options_helpers.h" +#include "mongo/db/storage/storage_options.h" + +#include <boost/filesystem.hpp> +#include <string> + +namespace mongo { +namespace embedded { + +using std::string; + +Status addOptions(optionenvironment::OptionSection* options) { + moe::OptionSection general_options("General options"); + + Status ret = addBaseServerOptions(&general_options); + if (!ret.isOK()) { + return ret; + } + + moe::OptionSection storage_options("Storage options"); + +#ifdef _WIN32 + boost::filesystem::path currentPath = boost::filesystem::current_path(); + + std::string defaultPath = currentPath.root_name().string() + storageGlobalParams.kDefaultDbPath; + storage_options.addOptionChaining("storage.dbPath", + "dbpath", + optionenvironment::String, + std::string("directory for datafiles - defaults to ") + + storageGlobalParams.kDefaultDbPath + " which is " + + defaultPath + " based on the current working drive"); + +#else + storage_options.addOptionChaining("storage.dbPath", + "dbpath", + optionenvironment::String, + std::string("directory for datafiles - defaults to ") + + storageGlobalParams.kDefaultDbPath); + +#endif + + storage_options.addOptionChaining("storage.repairPath", + "repairpath", + optionenvironment::String, + "root directory for repair files - defaults to dbpath"); + + options->addSection(general_options).transitional_ignore(); + options->addSection(storage_options).transitional_ignore(); + + return Status::OK(); +} + +Status canonicalizeOptions(optionenvironment::Environment* params) { + + Status ret = canonicalizeServerOptions(params); + if (!ret.isOK()) { + return ret; + } + + return Status::OK(); +} + +Status storeOptions(const moe::Environment& params) { + if (params.count("storage.dbPath")) { + storageGlobalParams.dbpath = params["storage.dbPath"].as<string>(); + if (params.count("processManagement.fork") && storageGlobalParams.dbpath[0] != '/') { + // we need to change dbpath if we fork since we change + // cwd to "/" + // fork only exists on *nix + // so '/' is safe + storageGlobalParams.dbpath = serverGlobalParams.cwd + "/" + storageGlobalParams.dbpath; + } + } +#ifdef _WIN32 + if (storageGlobalParams.dbpath.size() > 1 && + storageGlobalParams.dbpath[storageGlobalParams.dbpath.size() - 1] == '/') { + // size() check is for the unlikely possibility of --dbpath "/" + storageGlobalParams.dbpath = + storageGlobalParams.dbpath.erase(storageGlobalParams.dbpath.size() - 1); + } +#endif + + if (!params.count("net.port")) { + if (params.count("sharding.clusterRole")) { + std::string clusterRole = params["sharding.clusterRole"].as<std::string>(); + if (clusterRole == "configsvr") { + serverGlobalParams.port = ServerGlobalParams::ConfigServerPort; + } else if (clusterRole == "shardsvr") { + serverGlobalParams.port = ServerGlobalParams::ShardServerPort; + } else { + StringBuilder sb; + sb << "Bad value for sharding.clusterRole: " << clusterRole + << ". Supported modes are: (configsvr|shardsvr)"; + return Status(ErrorCodes::BadValue, sb.str()); + } + } + } else { + if (serverGlobalParams.port < 0 || serverGlobalParams.port > 65535) { + return Status(ErrorCodes::BadValue, "bad --port number"); + } + } + +#ifdef _WIN32 + // If dbPath is a default value, prepend with drive name so log entries are explicit + // We must resolve the dbpath before it stored in repairPath in the default case. + if (storageGlobalParams.dbpath == storageGlobalParams.kDefaultDbPath || + storageGlobalParams.dbpath == storageGlobalParams.kDefaultConfigDbPath) { + boost::filesystem::path currentPath = boost::filesystem::current_path(); + storageGlobalParams.dbpath = currentPath.root_name().string() + storageGlobalParams.dbpath; + } +#endif + + // needs to be after things like --configsvr parsing, thus here. + if (params.count("storage.repairPath")) { + storageGlobalParams.repairpath = params["storage.repairPath"].as<string>(); + if (!storageGlobalParams.repairpath.size()) { + return Status(ErrorCodes::BadValue, "repairpath is empty"); + } + + if (storageGlobalParams.dur && + !str::startsWith(storageGlobalParams.repairpath, storageGlobalParams.dbpath)) { + return Status(ErrorCodes::BadValue, + "You must use a --repairpath that is a subdirectory of --dbpath when " + "using journaling"); + } + } else { + storageGlobalParams.repairpath = storageGlobalParams.dbpath; + } + + return Status::OK(); +} + +} // namespace embedded +} // namespace mongo diff --git a/src/mongo/client/embedded/embedded_options.h b/src/mongo/client/embedded/embedded_options.h new file mode 100644 index 00000000000..126a4da6a25 --- /dev/null +++ b/src/mongo/client/embedded/embedded_options.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/base/status.h" +#include "mongo/util/options_parser/environment.h" +#include "mongo/util/options_parser/option_section.h" + +namespace mongo { +namespace embedded { + +Status addOptions(optionenvironment::OptionSection* options); + +/** + * Canonicalize options for the given environment. + * + * For example, the options "dur", "nodur", "journal", "nojournal", and + * "storage.journaling.enabled" should all be merged into "storage.journaling.enabled". + */ +Status canonicalizeOptions(optionenvironment::Environment* params); + +Status storeOptions(const optionenvironment::Environment& params); +} // namespace embedded +} // namespace mongo diff --git a/src/mongo/client/embedded/embedded_options_init.cpp b/src/mongo/client/embedded/embedded_options_init.cpp new file mode 100644 index 00000000000..2e838ab4668 --- /dev/null +++ b/src/mongo/client/embedded/embedded_options_init.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/client/embedded/embedded_options.h" + +#include "mongo/util/options_parser/startup_option_init.h" +#include "mongo/util/options_parser/startup_options.h" + +namespace mongo { +namespace embedded { + +MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(EmbeddedOptions)(InitializerContext* context) { + return addOptions(&optionenvironment::startupOptions); +} + +MONGO_INITIALIZER_GENERAL(EmbeddedOptions, + ("BeginStartupOptionValidation", "AllFailPointsRegistered"), + ("EndStartupOptionValidation")) +(InitializerContext* context) { + // Run validation, but tell the Environment that we don't want it to be set as "valid", + // since we may be making it invalid in the canonicalization process. + Status ret = optionenvironment::startupOptionsParsed.validate(false); + if (!ret.isOK()) { + return ret; + } + ret = canonicalizeOptions(&optionenvironment::startupOptionsParsed); + if (!ret.isOK()) { + return ret; + } + ret = optionenvironment::startupOptionsParsed.validate(); + if (!ret.isOK()) { + return ret; + } + return Status::OK(); +} + +MONGO_INITIALIZER_GENERAL(EmbeddedOptions_Store, + ("BeginStartupOptionStorage"), + ("EndStartupOptionStorage")) +(InitializerContext* context) { + return storeOptions(optionenvironment::startupOptionsParsed); +} + +} // namespace embedded +} // namespace mongo diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 0a3f7c5b422..add6bdc1be1 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -414,6 +414,16 @@ env.Library( ], ) +env.Library( + target="global_settings", + source=[ + "global_settings.cpp", + ], + LIBDEPS=[ + 'repl/repl_settings', + ], +) + # mongod options env.Library( target="mongod_options", @@ -427,6 +437,9 @@ env.Library( 'server_options', 'storage/storage_options', ], + LIBDEPS_PRIVATE=[ + 'global_settings', + ] ) env.Library( diff --git a/src/mongo/db/auth/SConscript b/src/mongo/db/auth/SConscript index 8752e0cec57..f59413c99a7 100644 --- a/src/mongo/db/auth/SConscript +++ b/src/mongo/db/auth/SConscript @@ -80,7 +80,7 @@ env.Library( '$BUILD_DIR/mongo/bson/util/bson_extract', '$BUILD_DIR/mongo/db/catalog/document_validation', '$BUILD_DIR/mongo/db/common', - '$BUILD_DIR/mongo/db/mongod_options', + '$BUILD_DIR/mongo/db/global_settings', '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/pipeline/lite_parsed_document_source', '$BUILD_DIR/mongo/db/service_context', diff --git a/src/mongo/db/auth/authorization_manager.cpp b/src/mongo/db/auth/authorization_manager.cpp index f0ebdba5881..5ab5df70ee7 100644 --- a/src/mongo/db/auth/authorization_manager.cpp +++ b/src/mongo/db/auth/authorization_manager.cpp @@ -54,8 +54,8 @@ #include "mongo/db/auth/user_document_parser.h" #include "mongo/db/auth/user_name.h" #include "mongo/db/auth/user_name_hash.h" +#include "mongo/db/global_settings.h" #include "mongo/db/jsobj.h" -#include "mongo/db/mongod_options.h" #include "mongo/platform/compiler.h" #include "mongo/platform/unordered_map.h" #include "mongo/stdx/memory.h" diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript index eafad310962..92a508ffeff 100644 --- a/src/mongo/db/catalog/SConscript +++ b/src/mongo/db/catalog/SConscript @@ -290,6 +290,7 @@ env.Library( ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/logical_clock', + '$BUILD_DIR/mongo/db/storage/mmap_v1/mmap_v1_options', ], ) diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index e1aacd2c12d..364b86232b4 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -71,6 +71,7 @@ #include "mongo/db/dbmessage.h" #include "mongo/db/exec/working_set_common.h" #include "mongo/db/ftdc/ftdc_mongod.h" +#include "mongo/db/global_settings.h" #include "mongo/db/index_names.h" #include "mongo/db/index_rebuilder.h" #include "mongo/db/initialize_server_global_state.h" diff --git a/src/mongo/db/global_settings.cpp b/src/mongo/db/global_settings.cpp new file mode 100644 index 00000000000..cf2f799f256 --- /dev/null +++ b/src/mongo/db/global_settings.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/db/global_settings.h" + +namespace mongo { + +MongodGlobalParams mongodGlobalParams; + +namespace { +repl::ReplSettings globalReplSettings; +} // namespace + +void setGlobalReplSettings(const repl::ReplSettings& settings) { + globalReplSettings = settings; +} + +const repl::ReplSettings& getGlobalReplSettings() { + return globalReplSettings; +} + +} // namespace mongo diff --git a/src/mongo/db/global_settings.h b/src/mongo/db/global_settings.h new file mode 100644 index 00000000000..3842eb9d075 --- /dev/null +++ b/src/mongo/db/global_settings.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/repl/repl_settings.h" + +namespace mongo { +struct MongodGlobalParams { + bool scriptingEnabled = true; // Use "security.javascriptEnabled" to set this variable. Or use + // --noscripting which will set it to false. + + boost::optional<std::vector<std::string>> whitelistedClusterNetwork; +}; + +extern MongodGlobalParams mongodGlobalParams; + +void setGlobalReplSettings(const repl::ReplSettings& settings); +const repl::ReplSettings& getGlobalReplSettings(); +} // namespace mongo diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index f77dce0fcc5..e63df877d1c 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -40,6 +40,7 @@ #include "mongo/bson/util/builder.h" #include "mongo/config.h" #include "mongo/db/db.h" +#include "mongo/db/global_settings.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/server_options.h" #include "mongo/db/server_options_helpers.h" @@ -56,8 +57,6 @@ namespace mongo { using std::cout; using std::endl; -MongodGlobalParams mongodGlobalParams; - Status addMongodOptions(moe::OptionSection* options) { moe::OptionSection general_options("General options"); @@ -1298,16 +1297,4 @@ Status storeMongodOptions(const moe::Environment& params) { return Status::OK(); } -namespace { -repl::ReplSettings globalReplSettings; -} // namespace - -void setGlobalReplSettings(const repl::ReplSettings& settings) { - globalReplSettings = settings; -} - -const repl::ReplSettings& getGlobalReplSettings() { - return globalReplSettings; -} - } // namespace mongo diff --git a/src/mongo/db/mongod_options.h b/src/mongo/db/mongod_options.h index f4b8d197526..51d2bbb5fda 100644 --- a/src/mongo/db/mongod_options.h +++ b/src/mongo/db/mongod_options.h @@ -46,16 +46,8 @@ class Environment; namespace moe = mongo::optionenvironment; -struct MongodGlobalParams { - bool scriptingEnabled = true; // --noscripting - - boost::optional<std::vector<std::string>> whitelistedClusterNetwork; -}; - extern bool skipShardingConfigurationChecks; -extern MongodGlobalParams mongodGlobalParams; - Status addMongodOptions(moe::OptionSection* options); void printMongodHelp(const moe::OptionSection& options); @@ -87,7 +79,4 @@ Status canonicalizeMongodOptions(moe::Environment* params); StatusWith<repl::ReplSettings> parseMongodReplicationOptions(const moe::Environment& params); Status storeMongodOptions(const moe::Environment& params); - -void setGlobalReplSettings(const repl::ReplSettings& settings); -const repl::ReplSettings& getGlobalReplSettings(); } diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp index 98f0f9f08c6..c3b525ba8a1 100644 --- a/src/mongo/db/server_options_helpers.cpp +++ b/src/mongo/db/server_options_helpers.cpp @@ -98,28 +98,11 @@ CODE facilitynames[] = {{"auth", LOG_AUTH}, {"cron", LOG_CRON}, {"daemon } // namespace -Status addGeneralServerOptions(moe::OptionSection* options) { +Status addBaseServerOptions(moe::OptionSection* options) { StringBuilder portInfoBuilder; - StringBuilder maxConnInfoBuilder; - std::stringstream unixSockPermsBuilder; portInfoBuilder << "specify port number - " << ServerGlobalParams::DefaultDBPort << " by default"; - maxConnInfoBuilder << "max number of simultaneous connections - " << DEFAULT_MAX_CONN - << " by default"; - unixSockPermsBuilder << "permissions to set on UNIX domain socket file - " - << "0" << std::oct << DEFAULT_UNIX_PERMS << " by default"; - - options->addOptionChaining("help", "help,h", moe::Switch, "show this usage information") - .setSources(moe::SourceAllLegacy); - - options->addOptionChaining("version", "version", moe::Switch, "show version information") - .setSources(moe::SourceAllLegacy); - - options - ->addOptionChaining( - "config", "config,f", moe::String, "configuration file specifying additional options") - .setSources(moe::SourceAllLegacy); // The verbosity level can be set at startup in the following ways. Note that if multiple // methods for setting the verbosity are specified simultaneously, the verbosity will be set @@ -186,45 +169,6 @@ Status addGeneralServerOptions(moe::OptionSection* options) { options ->addOptionChaining( - "net.bindIp", - "bind_ip", - moe::String, - "comma separated list of ip addresses to listen on - localhost by default") - .incompatibleWith("bind_ip_all"); - - options - ->addOptionChaining("net.bindIpAll", "bind_ip_all", moe::Switch, "bind to all ip addresses") - .incompatibleWith("bind_ip"); - - options->addOptionChaining( - "net.ipv6", "ipv6", moe::Switch, "enable IPv6 support (disabled by default)"); - - options - ->addOptionChaining( - "net.listenBacklog", "listenBacklog", moe::Int, "set socket listen backlog size") - .setDefault(moe::Value(SOMAXCONN)); - - options->addOptionChaining( - "net.maxIncomingConnections", "maxConns", moe::Int, maxConnInfoBuilder.str().c_str()); - - options - ->addOptionChaining("net.transportLayer", - "transportLayer", - moe::String, - "sets the ingress transport layer implementation") - .hidden() - .setDefault(moe::Value("asio")); - - options - ->addOptionChaining("net.serviceExecutor", - "serviceExecutor", - moe::String, - "sets the service executor implementation") - .hidden() - .setDefault(moe::Value("synchronous")); - - options - ->addOptionChaining( "logpath", "logpath", moe::String, @@ -281,6 +225,93 @@ Status addGeneralServerOptions(moe::OptionSection* options) { "Desired format for timestamps in log messages. One of ctime, " "iso8601-utc or iso8601-local"); + options + ->addOptionChaining( + "setParameter", "setParameter", moe::StringMap, "Set a configurable parameter") + .composing(); + + /* support for -vv -vvvv etc. */ + for (string s = "vv"; s.length() <= 12; s.append("v")) { + options->addOptionChaining(s.c_str(), s.c_str(), moe::Switch, "verbose") + .hidden() + .setSources(moe::SourceAllLegacy); + } + + options + ->addOptionChaining("systemLog.traceAllExceptions", + "traceExceptions", + moe::Switch, + "log stack traces for every exception") + .hidden(); + + return Status::OK(); +} + +Status addGeneralServerOptions(moe::OptionSection* options) { + auto baseResult = addBaseServerOptions(options); + if (!baseResult.isOK()) { + return baseResult; + } + + StringBuilder maxConnInfoBuilder; + std::stringstream unixSockPermsBuilder; + + maxConnInfoBuilder << "max number of simultaneous connections - " << DEFAULT_MAX_CONN + << " by default"; + unixSockPermsBuilder << "permissions to set on UNIX domain socket file - " + << "0" << std::oct << DEFAULT_UNIX_PERMS << " by default"; + + options->addOptionChaining("help", "help,h", moe::Switch, "show this usage information") + .setSources(moe::SourceAllLegacy); + + options->addOptionChaining("version", "version", moe::Switch, "show version information") + .setSources(moe::SourceAllLegacy); + + options + ->addOptionChaining( + "config", "config,f", moe::String, "configuration file specifying additional options") + .setSources(moe::SourceAllLegacy); + + + options + ->addOptionChaining( + "net.bindIp", + "bind_ip", + moe::String, + "comma separated list of ip addresses to listen on - localhost by default") + .incompatibleWith("bind_ip_all"); + + options + ->addOptionChaining("net.bindIpAll", "bind_ip_all", moe::Switch, "bind to all ip addresses") + .incompatibleWith("bind_ip"); + + options->addOptionChaining( + "net.ipv6", "ipv6", moe::Switch, "enable IPv6 support (disabled by default)"); + + options + ->addOptionChaining( + "net.listenBacklog", "listenBacklog", moe::Int, "set socket listen backlog size") + .setDefault(moe::Value(SOMAXCONN)); + + options->addOptionChaining( + "net.maxIncomingConnections", "maxConns", moe::Int, maxConnInfoBuilder.str().c_str()); + + options + ->addOptionChaining("net.transportLayer", + "transportLayer", + moe::String, + "sets the ingress transport layer implementation") + .hidden() + .setDefault(moe::Value("asio")); + + options + ->addOptionChaining("net.serviceExecutor", + "serviceExecutor", + moe::String, + "sets the service executor implementation") + .hidden() + .setDefault(moe::Value("synchronous")); + #if MONGO_ENTERPRISE_VERSION options->addOptionChaining("security.redactClientLogData", "redactClientLogData", @@ -312,11 +343,6 @@ Status addGeneralServerOptions(moe::OptionSection* options) { options ->addOptionChaining( - "setParameter", "setParameter", moe::StringMap, "Set a configurable parameter") - .composing(); - - options - ->addOptionChaining( "security.transitionToAuth", "transitionToAuth", moe::Switch, @@ -360,13 +386,6 @@ Status addGeneralServerOptions(moe::OptionSection* options) { #endif - /* support for -vv -vvvv etc. */ - for (string s = "vv"; s.length() <= 12; s.append("v")) { - options->addOptionChaining(s.c_str(), s.c_str(), moe::Switch, "verbose") - .hidden() - .setSources(moe::SourceAllLegacy); - } - options ->addOptionChaining("objcheck", "objcheck", @@ -394,13 +413,6 @@ Status addGeneralServerOptions(moe::OptionSection* options) { .setSources(moe::SourceYAMLConfig); options - ->addOptionChaining("systemLog.traceAllExceptions", - "traceExceptions", - moe::Switch, - "log stack traces for every exception") - .hidden(); - - options ->addOptionChaining("enableExperimentalStorageDetailsCmd", "enableExperimentalStorageDetailsCmd", moe::Switch, diff --git a/src/mongo/db/server_options_helpers.h b/src/mongo/db/server_options_helpers.h index 88002c7228b..0c8fa5f0e9c 100644 --- a/src/mongo/db/server_options_helpers.h +++ b/src/mongo/db/server_options_helpers.h @@ -41,6 +41,16 @@ class Environment; namespace moe = mongo::optionenvironment; +/** + * Base server options that are available in all applications, standalone and embedded. + * + * Included by addGeneralServerOptions, don't call both. + */ +Status addBaseServerOptions(moe::OptionSection* options); + +/** + * General server options for most standalone applications. Includes addBaseServerOptions. + */ Status addGeneralServerOptions(moe::OptionSection* options); Status addWindowsServerOptions(moe::OptionSection* options); diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript index 1d6b1461a24..d4647b0708b 100644 --- a/src/mongo/db/storage/wiredtiger/SConscript +++ b/src/mongo/db/storage/wiredtiger/SConscript @@ -55,7 +55,7 @@ if wiredtiger: '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/concurrency/write_conflict_exception', '$BUILD_DIR/mongo/db/index/index_descriptor', - '$BUILD_DIR/mongo/db/mongod_options', + '$BUILD_DIR/mongo/db/global_settings', '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/repl/repl_settings', '$BUILD_DIR/mongo/db/server_options_core', diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index 7f0adbd589e..1a4e2b0d66b 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -39,9 +39,9 @@ #include "mongo/base/checked_cast.h" #include "mongo/db/catalog/index_catalog_entry.h" #include "mongo/db/concurrency/write_conflict_exception.h" +#include "mongo/db/global_settings.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/json.h" -#include "mongo/db/mongod_options.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/key_string.h" diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index dc7178966c0..159b5820877 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -54,8 +54,8 @@ #include "mongo/db/commands/server_status_metric.h" #include "mongo/db/concurrency/locker.h" #include "mongo/db/concurrency/write_conflict_exception.h" +#include "mongo/db/global_settings.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/mongod_options.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/server_options.h" #include "mongo/db/server_parameters.h" diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 2ad0ddb8d7c..ec9c63c266a 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -40,7 +40,7 @@ #include "mongo/bson/util/builder.h" #include "mongo/db/concurrency/locker.h" #include "mongo/db/concurrency/write_conflict_exception.h" -#include "mongo/db/mongod_options.h" +#include "mongo/db/global_settings.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/repl_settings.h" diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index 90d9dff9f08..31889025b92 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -36,7 +36,7 @@ #include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h" #include "mongo/base/error_codes.h" -#include "mongo/db/mongod_options.h" +#include "mongo/db/global_settings.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/storage/journal_listener.h" #include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h" |