summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/dbdirectclient.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp4
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp11
-rw-r--r--src/mongo/db/s/sharding_initialization_mongod.cpp14
-rw-r--r--src/mongo/db/s/sharding_initialization_mongod_test.cpp24
-rw-r--r--src/mongo/db/s/sharding_initialization_op_observer_test.cpp6
-rw-r--r--src/mongo/db/s/sharding_mongod_test_fixture.cpp13
-rw-r--r--src/mongo/db/s/type_shard_identity.cpp4
8 files changed, 40 insertions, 38 deletions
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index bb1f5553906..04910a0faad 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -110,7 +110,7 @@ bool DBDirectClient::isReplicaSetMember() const {
}
ConnectionString::ConnectionType DBDirectClient::type() const {
- return ConnectionString::MASTER;
+ return ConnectionString::ConnectionType::kStandalone;
}
double DBDirectClient::getSoTimeout() const {
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
index 777b23622ee..a7b48597d72 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
@@ -521,8 +521,8 @@ TEST_F(AddShardTest, StandaloneGenerateName) {
TEST_F(AddShardTest, AddSCCCConnectionStringAsShard) {
std::unique_ptr<RemoteCommandTargeterMock> targeter(
std::make_unique<RemoteCommandTargeterMock>());
- auto invalidConn =
- ConnectionString("host1:12345,host2:12345,host3:12345", ConnectionString::INVALID);
+ auto invalidConn = ConnectionString("host1:12345,host2:12345,host3:12345",
+ ConnectionString::ConnectionType::kInvalid);
targeter->setConnectionStringReturnValue(invalidConn);
auto future = launchAsync([this, invalidConn] {
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
index b82c0b908e5..3fdb7828254 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
@@ -236,7 +236,8 @@ StatusWith<boost::optional<ShardType>> ShardingCatalogManager::_checkIfShardExis
if (proposedShardConnectionString.type() != existingShardConnStr.type()) {
return false;
}
- if (proposedShardConnectionString.type() == ConnectionString::SET &&
+ if (proposedShardConnectionString.type() ==
+ ConnectionString::ConnectionType::kReplicaSet &&
proposedShardConnectionString.getSetName() != existingShardConnStr.getSetName()) {
return false;
}
@@ -246,8 +247,8 @@ StatusWith<boost::optional<ShardType>> ShardingCatalogManager::_checkIfShardExis
return true;
};
- if (existingShardConnStr.type() == ConnectionString::SET &&
- proposedShardConnectionString.type() == ConnectionString::SET &&
+ if (existingShardConnStr.type() == ConnectionString::ConnectionType::kReplicaSet &&
+ proposedShardConnectionString.type() == ConnectionString::ConnectionType::kReplicaSet &&
existingShardConnStr.getSetName() == proposedShardConnectionString.getSetName()) {
// An existing shard has the same replica set name as the shard being added.
// If the options aren't the same, then this is an error,
@@ -533,7 +534,7 @@ StatusWith<std::string> ShardingCatalogManager::addShard(
const std::string* shardProposedName,
const ConnectionString& shardConnectionString,
const long long maxSize) {
- if (shardConnectionString.type() == ConnectionString::INVALID) {
+ if (!shardConnectionString) {
return {ErrorCodes::BadValue, "Invalid connection string"};
}
@@ -565,7 +566,7 @@ StatusWith<std::string> ShardingCatalogManager::addShard(
auto targeter = shard->getTargeter();
auto stopMonitoringGuard = makeGuard([&] {
- if (shardConnectionString.type() == ConnectionString::SET) {
+ if (shardConnectionString.type() == ConnectionString::ConnectionType::kReplicaSet) {
// This is a workaround for the case were we could have some bad shard being
// requested to be added and we put that bad connection string on the global replica set
// monitor registry. It needs to be cleaned up so that when a correct replica set is
diff --git a/src/mongo/db/s/sharding_initialization_mongod.cpp b/src/mongo/db/s/sharding_initialization_mongod.cpp
index 65265781d1e..777985d1eb4 100644
--- a/src/mongo/db/s/sharding_initialization_mongod.cpp
+++ b/src/mongo/db/s/sharding_initialization_mongod.cpp
@@ -442,7 +442,9 @@ void ShardingInitializationMongoD::initializeFromShardIdentity(
uassert(40372, "", shardingState->clusterId() == shardIdentity.getClusterId());
auto prevConfigsvrConnStr = shardRegistry->getConfigServerConnectionString();
- uassert(40373, "", prevConfigsvrConnStr.type() == ConnectionString::SET);
+ uassert(40373,
+ "",
+ prevConfigsvrConnStr.type() == ConnectionString::ConnectionType::kReplicaSet);
uassert(40374, "", prevConfigsvrConnStr.getSetName() == configSvrConnStr.getSetName());
return;
@@ -531,9 +533,9 @@ void initializeGlobalShardingStateForMongoD(OperationContext* opCtx,
};
ShardFactory::BuildersMap buildersMap{
- {ConnectionString::SET, std::move(setBuilder)},
- {ConnectionString::MASTER, std::move(masterBuilder)},
- {ConnectionString::LOCAL, std::move(localBuilder)},
+ {ConnectionString::ConnectionType::kReplicaSet, std::move(setBuilder)},
+ {ConnectionString::ConnectionType::kStandalone, std::move(masterBuilder)},
+ {ConnectionString::ConnectionType::kLocal, std::move(localBuilder)},
};
auto shardFactory =
@@ -571,9 +573,7 @@ void initializeGlobalShardingStateForMongoD(OperationContext* opCtx,
catCache->invalidateEntriesThatReferenceShard(removedShard);
}};
- uassert(ErrorCodes::BadValue,
- "Unrecognized connection string.",
- configCS.type() != ConnectionString::INVALID);
+ uassert(ErrorCodes::BadValue, "Unrecognized connection string.", configCS);
auto shardRegistry = std::make_unique<ShardRegistry>(
std::move(shardFactory), configCS, std::move(shardRemovalHooks));
diff --git a/src/mongo/db/s/sharding_initialization_mongod_test.cpp b/src/mongo/db/s/sharding_initialization_mongod_test.cpp
index a724a245f84..44b90529a89 100644
--- a/src/mongo/db/s/sharding_initialization_mongod_test.cpp
+++ b/src/mongo/db/s/sharding_initialization_mongod_test.cpp
@@ -172,7 +172,7 @@ TEST_F(ShardingInitializationMongoDTest, ValidShardIdentitySucceeds) {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
@@ -189,7 +189,7 @@ TEST_F(ShardingInitializationMongoDTest, InitWhilePreviouslyInErrorStateWillStay
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
@@ -222,7 +222,7 @@ TEST_F(ShardingInitializationMongoDTest, InitializeAgainWithMatchingShardIdentit
auto clusterID = OID::gen();
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(clusterID);
@@ -230,7 +230,7 @@ TEST_F(ShardingInitializationMongoDTest, InitializeAgainWithMatchingShardIdentit
ShardIdentityType shardIdentity2;
shardIdentity2.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity2.setShardName(kShardName);
shardIdentity2.setClusterId(clusterID);
@@ -255,7 +255,7 @@ TEST_F(ShardingInitializationMongoDTest, InitializeAgainWithMatchingReplSetNameS
auto clusterID = OID::gen();
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(clusterID);
@@ -263,7 +263,7 @@ TEST_F(ShardingInitializationMongoDTest, InitializeAgainWithMatchingReplSetNameS
ShardIdentityType shardIdentity2;
shardIdentity2.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "b:2,c:3", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "b:2,c:3", "config"));
shardIdentity2.setShardName(kShardName);
shardIdentity2.setClusterId(clusterID);
@@ -319,7 +319,7 @@ TEST_F(ShardingInitializationMongoDTest,
serverGlobalParams.overrideShardIdentity = [] {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
ASSERT_OK(shardIdentity.validate());
@@ -363,7 +363,7 @@ TEST_F(ShardingInitializationMongoDTest,
serverGlobalParams.overrideShardIdentity = [] {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
ASSERT_OK(shardIdentity.validate());
@@ -406,7 +406,7 @@ TEST_F(ShardingInitializationMongoDTest,
serverGlobalParams.overrideShardIdentity = [] {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
ASSERT_OK(shardIdentity.validate());
@@ -469,8 +469,8 @@ TEST_F(ShardingInitializationMongoDTest,
BSONObj validShardIdentity = [&] {
ShardIdentityType shardIdentity;
- shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ shardIdentity.setConfigsvrConnectionString(ConnectionString(
+ ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
ASSERT_OK(shardIdentity.validate());
@@ -516,7 +516,7 @@ TEST_F(ShardingInitializationMongoDTest,
BSONObj validShardIdentity = [&] {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
ASSERT_OK(shardIdentity.validate());
diff --git a/src/mongo/db/s/sharding_initialization_op_observer_test.cpp b/src/mongo/db/s/sharding_initialization_op_observer_test.cpp
index 563a6325454..019394f91e9 100644
--- a/src/mongo/db/s/sharding_initialization_op_observer_test.cpp
+++ b/src/mongo/db/s/sharding_initialization_op_observer_test.cpp
@@ -90,7 +90,7 @@ private:
TEST_F(ShardingInitializationOpObserverTest, GlobalInitGetsCalledAfterWriteCommits) {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
@@ -102,7 +102,7 @@ TEST_F(ShardingInitializationOpObserverTest, GlobalInitGetsCalledAfterWriteCommi
TEST_F(ShardingInitializationOpObserverTest, GlobalInitDoesntGetCalledIfWriteAborts) {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
@@ -128,7 +128,7 @@ TEST_F(ShardingInitializationOpObserverTest, GlobalInitDoesntGetCalledIfWriteAbo
TEST_F(ShardingInitializationOpObserverTest, GlobalInitDoesntGetsCalledIfNSIsNotForShardIdentity) {
ShardIdentityType shardIdentity;
shardIdentity.setConfigsvrConnectionString(
- ConnectionString(ConnectionString::SET, "a:1,b:2", "config"));
+ ConnectionString(ConnectionString::ConnectionType::kReplicaSet, "a:1,b:2", "config"));
shardIdentity.setShardName(kShardName);
shardIdentity.setClusterId(OID::gen());
diff --git a/src/mongo/db/s/sharding_mongod_test_fixture.cpp b/src/mongo/db/s/sharding_mongod_test_fixture.cpp
index 78bd0f861ae..d0ccaa291f8 100644
--- a/src/mongo/db/s/sharding_mongod_test_fixture.cpp
+++ b/src/mongo/db/s/sharding_mongod_test_fixture.cpp
@@ -192,14 +192,15 @@ std::unique_ptr<ShardRegistry> ShardingMongodTestFixture::makeShardRegistry(
return std::make_unique<ShardRemote>(shardId, connStr, targeterFactoryPtr->create(connStr));
};
- ShardFactory::BuilderCallable masterBuilder = [targeterFactoryPtr](
- const ShardId& shardId,
- const ConnectionString& connStr) {
+ ShardFactory::BuilderCallable standaloneBuilder = [targeterFactoryPtr](
+ const ShardId& shardId,
+ const ConnectionString& connStr) {
return std::make_unique<ShardRemote>(shardId, connStr, targeterFactoryPtr->create(connStr));
};
- ShardFactory::BuildersMap buildersMap{{ConnectionString::SET, std::move(setBuilder)},
- {ConnectionString::MASTER, std::move(masterBuilder)}};
+ ShardFactory::BuildersMap buildersMap{
+ {ConnectionString::ConnectionType::kReplicaSet, std::move(setBuilder)},
+ {ConnectionString::ConnectionType::kStandalone, std::move(standaloneBuilder)}};
// Only config servers use ShardLocal for now.
if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) {
@@ -209,7 +210,7 @@ std::unique_ptr<ShardRegistry> ShardingMongodTestFixture::makeShardRegistry(
};
buildersMap.insert(
std::pair<ConnectionString::ConnectionType, ShardFactory::BuilderCallable>(
- ConnectionString::LOCAL, std::move(localBuilder)));
+ ConnectionString::ConnectionType::kLocal, std::move(localBuilder)));
}
auto shardFactory =
diff --git a/src/mongo/db/s/type_shard_identity.cpp b/src/mongo/db/s/type_shard_identity.cpp
index 773333f59e5..673636f01b1 100644
--- a/src/mongo/db/s/type_shard_identity.cpp
+++ b/src/mongo/db/s/type_shard_identity.cpp
@@ -52,7 +52,7 @@ StatusWith<ShardIdentityType> ShardIdentityType::fromShardIdentityDocument(const
ShardIdentity::parse(IDLParserErrorContext("ShardIdentity"), shardIdentityBSON);
const auto& configsvrConnStr = shardIdentity.getConfigsvrConnectionString();
- if (configsvrConnStr.type() != ConnectionString::SET) {
+ if (configsvrConnStr.type() != ConnectionString::ConnectionType::kReplicaSet) {
return Status(ErrorCodes::UnsupportedFormat,
str::stream()
<< "config server connection string can only be replica sets: "
@@ -67,7 +67,7 @@ StatusWith<ShardIdentityType> ShardIdentityType::fromShardIdentityDocument(const
Status ShardIdentityType::validate() const {
const auto& configsvrConnStr = getConfigsvrConnectionString();
- if (configsvrConnStr.type() != ConnectionString::SET) {
+ if (configsvrConnStr.type() != ConnectionString::ConnectionType::kReplicaSet) {
return {ErrorCodes::UnsupportedFormat,
str::stream() << "config connection string can only be replica sets, got "
<< ConnectionString::typeToString(configsvrConnStr.type())};