summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-08-18 16:56:31 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-08-18 19:27:49 -0400
commit5dd1be3ba35121f4ba501c322d48041ae748ac9c (patch)
tree4eac913fa66515a55e5d6129c11a97058dc93e3c /src
parent594d851e53c85b2711db41034f9d42e1a0a5c25d (diff)
downloadmongo-5dd1be3ba35121f4ba501c322d48041ae748ac9c.tar.gz
SERVER-19543 SERVER-19992 Move ConfigServerMode enum from ServerGlobalParams to CatalogManager
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/mongod_options.cpp9
-rw-r--r--src/mongo/db/repl/replication_info.cpp4
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.cpp8
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.h5
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_test.cpp7
-rw-r--r--src/mongo/db/server_options.h12
-rw-r--r--src/mongo/s/catalog/catalog_manager.h9
-rw-r--r--src/mongo/s/catalog/catalog_manager_mock.h4
-rw-r--r--src/mongo/s/catalog/forwarding_catalog_manager.cpp2
-rw-r--r--src/mongo/s/catalog/forwarding_catalog_manager.h2
-rw-r--r--src/mongo/s/catalog/legacy/catalog_manager_legacy.h4
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set.h4
-rw-r--r--src/mongo/s/client/sharding_connection_hook.cpp5
-rw-r--r--src/mongo/s/client/sharding_network_connection_hook.cpp5
-rw-r--r--src/mongo/s/grid.cpp8
-rw-r--r--src/mongo/s/grid.h7
16 files changed, 47 insertions, 48 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index 8f77e0071cc..fe0ef3be14f 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -44,9 +44,10 @@
#include "mongo/db/server_options.h"
#include "mongo/db/server_options_helpers.h"
#include "mongo/db/storage/mmap_v1/mmap_v1_options.h"
-#include "mongo/util/log.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/logger/console_appender.h"
#include "mongo/logger/message_event_utf8_encoder.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
@@ -1199,8 +1200,8 @@ Status storeMongodOptions(const moe::Environment& params, const std::vector<std:
params["sharding.clusterRole"].as<std::string>() == "configsvr") {
serverGlobalParams.configsvr = true;
serverGlobalParams.configsvrMode = replSettings.replSet.empty()
- ? ServerGlobalParams::ConfigServerMode::SCCC
- : ServerGlobalParams::ConfigServerMode::CSRS;
+ ? CatalogManager::ConfigServerMode::SCCC
+ : CatalogManager::ConfigServerMode::CSRS;
mmapv1GlobalOptions.smallfiles = true; // config server implies small files
// If we haven't explicitly specified a journal option, default journaling to true for
@@ -1228,7 +1229,7 @@ Status storeMongodOptions(const moe::Environment& params, const std::vector<std:
"Bad value for sharding.configsvrMode. "
" Only supported value is \"sccc\"");
}
- serverGlobalParams.configsvrMode = ServerGlobalParams::ConfigServerMode::SCCC;
+ serverGlobalParams.configsvrMode = CatalogManager::ConfigServerMode::SCCC;
}
if (params.count("sharding.archiveMovedChunks")) {
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 0db9b8a530b..b1e53cdd0a6 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -227,9 +227,9 @@ public:
appendReplicationInfo(txn, result, 0);
- if (serverGlobalParams.configsvrMode == ServerGlobalParams::ConfigServerMode::CSRS) {
+ if (serverGlobalParams.configsvrMode == CatalogManager::ConfigServerMode::CSRS) {
result.append("configsvr", 1);
- } else if (serverGlobalParams.configsvrMode == ServerGlobalParams::ConfigServerMode::SCCC) {
+ } else if (serverGlobalParams.configsvrMode == CatalogManager::ConfigServerMode::SCCC) {
result.append("configsvr", 0);
}
diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp
index 11f42433492..fb4821ecd15 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl.cpp
@@ -46,7 +46,7 @@
#include "mongo/db/repl/repl_set_request_votes_args.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/db/repl/rslog.h"
-#include "mongo/db/server_parameters.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/rpc/metadata/repl_set_metadata.h"
#include "mongo/util/hex.h"
#include "mongo/util/log.h"
@@ -1972,15 +1972,15 @@ MemberState TopologyCoordinatorImpl::getMemberState() const {
}
if (_rsConfig.isConfigServer()) {
- if (_options.configServerMode == ServerGlobalParams::ConfigServerMode::NONE) {
+ if (_options.configServerMode == CatalogManager::ConfigServerMode::NONE) {
return MemberState::RS_REMOVED;
}
- if (_options.configServerMode == ServerGlobalParams::ConfigServerMode::CSRS &&
+ if (_options.configServerMode == CatalogManager::ConfigServerMode::CSRS &&
!_options.storageEngineSupportsReadCommitted) {
return MemberState::RS_REMOVED;
}
} else {
- if (_options.configServerMode != ServerGlobalParams::ConfigServerMode::NONE) {
+ if (_options.configServerMode != CatalogManager::ConfigServerMode::NONE) {
return MemberState::RS_REMOVED;
}
}
diff --git a/src/mongo/db/repl/topology_coordinator_impl.h b/src/mongo/db/repl/topology_coordinator_impl.h
index 1ccb7d9cdba..17726760125 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.h
+++ b/src/mongo/db/repl/topology_coordinator_impl.h
@@ -39,7 +39,7 @@
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/repl/topology_coordinator.h"
-#include "mongo/db/server_options.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/util/time_support.h"
namespace mongo {
@@ -128,8 +128,7 @@ public:
// Whether or not this node is running as a config server, and if so whether it was started
// with --configsvrMode=SCCC.
- ServerGlobalParams::ConfigServerMode configServerMode{
- ServerGlobalParams::ConfigServerMode::NONE};
+ CatalogManager::ConfigServerMode configServerMode{CatalogManager::ConfigServerMode::NONE};
// Whether or not the storage engine supports read committed.
bool storageEngineSupportsReadCommitted{true};
diff --git a/src/mongo/db/repl/topology_coordinator_impl_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
index f56f01c2e69..cbe4e7d3fc7 100644
--- a/src/mongo/db/repl/topology_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/repl/topology_coordinator.h"
#include "mongo/db/repl/topology_coordinator_impl.h"
#include "mongo/db/server_options.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/net/hostandport.h"
@@ -5096,7 +5097,7 @@ TEST_F(TopoCoordTest, ProcessDeclareElectionWinner) {
TEST_F(TopoCoordTest, GetMemberStateConfigSvrNoReadCommitted) {
serverGlobalParams.configsvr = true;
TopologyCoordinatorImpl::Options options;
- options.configServerMode = ServerGlobalParams::ConfigServerMode::CSRS;
+ options.configServerMode = CatalogManager::ConfigServerMode::CSRS;
options.storageEngineSupportsReadCommitted = false;
setOptions(options);
@@ -5115,7 +5116,7 @@ TEST_F(TopoCoordTest, GetMemberStateConfigSvrNoReadCommitted) {
TEST_F(TopoCoordTest, GetMemberStateConfigSvrNoReadCommittedButInSCCCMode) {
serverGlobalParams.configsvr = true;
TopologyCoordinatorImpl::Options options;
- options.configServerMode = ServerGlobalParams::ConfigServerMode::SCCC;
+ options.configServerMode = CatalogManager::ConfigServerMode::SCCC;
options.storageEngineSupportsReadCommitted = false;
setOptions(options);
@@ -5137,7 +5138,7 @@ TEST_F(TopoCoordTest, GetMemberStateConfigSvrNoReadCommittedButInSCCCMode) {
TEST_F(TopoCoordTest, GetMemberStateValidConfigSvr) {
serverGlobalParams.configsvr = true;
TopologyCoordinatorImpl::Options options;
- options.configServerMode = ServerGlobalParams::ConfigServerMode::CSRS;
+ options.configServerMode = CatalogManager::ConfigServerMode::CSRS;
options.storageEngineSupportsReadCommitted = true;
setOptions(options);
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h
index b43ed8cd23f..0e6300e115a 100644
--- a/src/mongo/db/server_options.h
+++ b/src/mongo/db/server_options.h
@@ -29,6 +29,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/platform/process_id.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/util/net/listen.h" // For DEFAULT_MAX_CONN
namespace mongo {
@@ -43,7 +44,7 @@ struct ServerGlobalParams {
indexBuildRetry(true),
quiet(false),
configsvr(false),
- configsvrMode(ConfigServerMode::NONE),
+ configsvrMode(CatalogManager::ConfigServerMode::NONE),
cpu(false),
objcheck(true),
defaultProfile(0),
@@ -79,13 +80,8 @@ struct ServerGlobalParams {
bool quiet; // --quiet
- bool configsvr; // --configsvr
- enum class ConfigServerMode {
- NONE,
- SCCC,
- CSRS,
- };
- ConfigServerMode configsvrMode; // -- configsvrMode
+ bool configsvr; // --configsvr
+ CatalogManager::ConfigServerMode configsvrMode; // -- configsvrMode
bool cpu; // --cpu show cpu time periodically
diff --git a/src/mongo/s/catalog/catalog_manager.h b/src/mongo/s/catalog/catalog_manager.h
index 0979ee47d31..7bba6655e39 100644
--- a/src/mongo/s/catalog/catalog_manager.h
+++ b/src/mongo/s/catalog/catalog_manager.h
@@ -34,7 +34,6 @@
#include <vector>
#include "mongo/base/disallow_copying.h"
-#include "mongo/db/server_options.h"
#include "mongo/s/client/shard.h"
#include "mongo/s/optime_pair.h"
#include "mongo/stdx/memory.h"
@@ -84,6 +83,12 @@ class CatalogManager {
MONGO_DISALLOW_COPYING(CatalogManager);
public:
+ enum class ConfigServerMode {
+ NONE,
+ SCCC,
+ CSRS,
+ };
+
virtual ~CatalogManager() = default;
/**
@@ -101,7 +106,7 @@ public:
* Returns what type of catalog manager this is - CSRS for the CatalogManagerReplicaSet and
* SCCC for the CatalogManagerLegacy.
*/
- virtual ServerGlobalParams::ConfigServerMode getMode() = 0;
+ virtual ConfigServerMode getMode() = 0;
/**
* Creates a new database or updates the sharding status for an existing one. Cannot be
diff --git a/src/mongo/s/catalog/catalog_manager_mock.h b/src/mongo/s/catalog/catalog_manager_mock.h
index 2c553ff8414..23a58cdad11 100644
--- a/src/mongo/s/catalog/catalog_manager_mock.h
+++ b/src/mongo/s/catalog/catalog_manager_mock.h
@@ -41,8 +41,8 @@ public:
CatalogManagerMock();
~CatalogManagerMock();
- ServerGlobalParams::ConfigServerMode getMode() override {
- return ServerGlobalParams::ConfigServerMode::NONE;
+ ConfigServerMode getMode() override {
+ return ConfigServerMode::NONE;
}
Status startup() override;
diff --git a/src/mongo/s/catalog/forwarding_catalog_manager.cpp b/src/mongo/s/catalog/forwarding_catalog_manager.cpp
index a102b6fbbb5..e851e1adedf 100644
--- a/src/mongo/s/catalog/forwarding_catalog_manager.cpp
+++ b/src/mongo/s/catalog/forwarding_catalog_manager.cpp
@@ -86,7 +86,7 @@ ForwardingCatalogManager::ForwardingCatalogManager(ServiceContext* service,
ForwardingCatalogManager::~ForwardingCatalogManager() = default;
-ServerGlobalParams::ConfigServerMode ForwardingCatalogManager::getMode() {
+CatalogManager::ConfigServerMode ForwardingCatalogManager::getMode() {
return retry([this] { return _actual->getMode(); });
}
diff --git a/src/mongo/s/catalog/forwarding_catalog_manager.h b/src/mongo/s/catalog/forwarding_catalog_manager.h
index 923d7d3dce7..d20d1183fa1 100644
--- a/src/mongo/s/catalog/forwarding_catalog_manager.h
+++ b/src/mongo/s/catalog/forwarding_catalog_manager.h
@@ -51,7 +51,7 @@ public:
const std::string& distLockProcessId);
virtual ~ForwardingCatalogManager();
- ServerGlobalParams::ConfigServerMode getMode() override;
+ ConfigServerMode getMode() override;
Status startup() override;
diff --git a/src/mongo/s/catalog/legacy/catalog_manager_legacy.h b/src/mongo/s/catalog/legacy/catalog_manager_legacy.h
index 55626311234..56556e2f25c 100644
--- a/src/mongo/s/catalog/legacy/catalog_manager_legacy.h
+++ b/src/mongo/s/catalog/legacy/catalog_manager_legacy.h
@@ -45,8 +45,8 @@ public:
CatalogManagerLegacy();
~CatalogManagerLegacy();
- ServerGlobalParams::ConfigServerMode getMode() override {
- return ServerGlobalParams::ConfigServerMode::SCCC;
+ ConfigServerMode getMode() override {
+ return ConfigServerMode::SCCC;
}
/**
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set.h b/src/mongo/s/catalog/replset/catalog_manager_replica_set.h
index ab702d5970c..d0eff442591 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set.h
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set.h
@@ -48,8 +48,8 @@ public:
explicit CatalogManagerReplicaSet(std::unique_ptr<DistLockManager> distLockManager);
virtual ~CatalogManagerReplicaSet();
- ServerGlobalParams::ConfigServerMode getMode() override {
- return ServerGlobalParams::ConfigServerMode::CSRS;
+ ConfigServerMode getMode() override {
+ return ConfigServerMode::CSRS;
}
Status startup() override;
diff --git a/src/mongo/s/client/sharding_connection_hook.cpp b/src/mongo/s/client/sharding_connection_hook.cpp
index d46b347b6dc..d3ac3f876b2 100644
--- a/src/mongo/s/client/sharding_connection_hook.cpp
+++ b/src/mongo/s/client/sharding_connection_hook.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/internal_user_auth.h"
#include "mongo/db/client.h"
-#include "mongo/db/server_options.h"
#include "mongo/rpc/metadata/audit_metadata.h"
#include "mongo/s/client/scc_fast_query_handler.h"
#include "mongo/s/cluster_last_error_info.h"
@@ -114,8 +113,8 @@ void ShardingConnectionHook::onCreate(DBClientBase* conn) {
configServerModeNumber == 0 || configServerModeNumber == 1);
status = grid.checkIfCatalogNeedsSwapping(configServerModeNumber == 0
- ? ServerGlobalParams::ConfigServerMode::SCCC
- : ServerGlobalParams::ConfigServerMode::CSRS);
+ ? CatalogManager::ConfigServerMode::SCCC
+ : CatalogManager::ConfigServerMode::CSRS);
uassertStatusOK(status);
}
}
diff --git a/src/mongo/s/client/sharding_network_connection_hook.cpp b/src/mongo/s/client/sharding_network_connection_hook.cpp
index 3ca1fc002fb..d0a3f5472a0 100644
--- a/src/mongo/s/client/sharding_network_connection_hook.cpp
+++ b/src/mongo/s/client/sharding_network_connection_hook.cpp
@@ -31,7 +31,6 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/bson/util/bson_extract.h"
-#include "mongo/db/server_options.h"
#include "mongo/executor/remote_command_request.h"
#include "mongo/executor/remote_command_response.h"
#include "mongo/s/grid.h"
@@ -58,8 +57,8 @@ Status ShardingNetworkConnectionHook::validateHostImpl(
}
return grid.checkIfCatalogNeedsSwapping(configServerModeNumber == 0
- ? ServerGlobalParams::ConfigServerMode::SCCC
- : ServerGlobalParams::ConfigServerMode::CSRS);
+ ? CatalogManager::ConfigServerMode::SCCC
+ : CatalogManager::ConfigServerMode::CSRS);
}
StatusWith<boost::optional<executor::RemoteCommandRequest>>
diff --git a/src/mongo/s/grid.cpp b/src/mongo/s/grid.cpp
index 2aaf285b2b5..86e867cf41d 100644
--- a/src/mongo/s/grid.cpp
+++ b/src/mongo/s/grid.cpp
@@ -131,21 +131,21 @@ void Grid::clearForUnitTests() {
_cursorManager.reset();
}
-Status Grid::checkIfCatalogNeedsSwapping(ServerGlobalParams::ConfigServerMode desiredMode) {
+Status Grid::checkIfCatalogNeedsSwapping(CatalogManager::ConfigServerMode desiredMode) {
stdx::lock_guard<stdx::mutex> lk(_catalogManagerMutex);
auto currentMode = _catalogManager->getMode();
if (desiredMode == currentMode) {
return Status::OK();
}
- if (desiredMode == ServerGlobalParams::ConfigServerMode::CSRS) {
- invariant(currentMode == ServerGlobalParams::ConfigServerMode::SCCC);
+ if (desiredMode == CatalogManager::ConfigServerMode::CSRS) {
+ invariant(currentMode == CatalogManager::ConfigServerMode::SCCC);
return Status(ErrorCodes::IncompatibleCatalogManager,
"Need to swap sharding catalog manager. Config server "
"reports that it is in replica set mode, but we are still using the "
"legacy SCCC protocol for config server communication");
}
- invariant(currentMode == ServerGlobalParams::ConfigServerMode::CSRS);
+ invariant(currentMode == CatalogManager::ConfigServerMode::CSRS);
// TODO(spencer): Support downgrade.
return Status(ErrorCodes::IllegalOperation,
"Config server reports that it legacy SCCC mode, but we are already using "
diff --git a/src/mongo/s/grid.h b/src/mongo/s/grid.h
index 25edc60a5ea..6b5fe3e9ef9 100644
--- a/src/mongo/s/grid.h
+++ b/src/mongo/s/grid.h
@@ -31,7 +31,7 @@
#include <string>
#include <vector>
-#include "mongo/db/server_options.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/query/cluster_cursor_manager.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
@@ -41,7 +41,6 @@ namespace mongo {
class BSONObj;
class CatalogCache;
-class CatalogManager;
class DBConfig;
class OperationContext;
class SettingsType;
@@ -113,13 +112,13 @@ public:
}
/**
- * Compares desiredMode against _catalogManagerMode. Returns Status::OK() if they match,
+ * Compares desiredMode against _catalogManager->getMode(). Returns Status::OK() if they match,
* returns ErrorCodes::IncompatibleCatalogManger if desiredMode is CSRS and the current mode is
* SCCC. If desiredMode is SCCC and current mode is CSRS returns InvalidOperation as we do not
* support downgrade.
* TODO(spencer): Support downgrade.
*/
- Status checkIfCatalogNeedsSwapping(ServerGlobalParams::ConfigServerMode desiredMode);
+ Status checkIfCatalogNeedsSwapping(CatalogManager::ConfigServerMode desiredMode);
/**
* Clears the grid object so that it can be reused between test executions. This will not