summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/client/shard_registry.cpp18
-rw-r--r--src/mongo/s/client/shard_registry.h5
2 files changed, 11 insertions, 12 deletions
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp
index 41f4677094e..5d18387f63f 100644
--- a/src/mongo/s/client/shard_registry.cpp
+++ b/src/mongo/s/client/shard_registry.cpp
@@ -532,8 +532,8 @@ shared_ptr<Shard> ShardRegistryData::findByShardId(const ShardId& shardId) const
return _findByShardId(lk, shardId);
}
-shared_ptr<Shard> ShardRegistryData::_findByConnectionString(
- WithLock, const ConnectionString& connectionString) const {
+std::shared_ptr<Shard> ShardRegistryData::_findByConnectionString(
+ WithLock, const std::string& connectionString) const {
auto i = _connStringLookup.find(connectionString);
return (i != _connStringLookup.end()) ? i->second : nullptr;
}
@@ -559,12 +559,9 @@ shared_ptr<Shard> ShardRegistryData::_findShard(WithLock lk, ShardId const& shar
return shard;
}
- StatusWith<ConnectionString> swConnString = ConnectionString::parse(shardId.toString());
- if (swConnString.isOK()) {
- shard = _findByConnectionString(lk, swConnString.getValue());
- if (shard) {
- return shard;
- }
+ shard = _findByConnectionString(lk, shardId.toString());
+ if (shard) {
+ return shard;
}
StatusWith<HostAndPort> swHostAndPort = HostAndPort::parse(shardId.toString());
@@ -671,7 +668,8 @@ void ShardRegistryData::_addShard(WithLock lk,
for (const auto& host : oldConnString.getServers()) {
_hostLookup.erase(host);
}
- _connStringLookup.erase(oldConnString);
+
+ _connStringLookup.erase(connString.toString());
}
_shardIdLookup[shard->getId()] = shard;
@@ -693,7 +691,7 @@ void ShardRegistryData::_addShard(WithLock lk,
_hostLookup[HostAndPort("localhost")] = shard;
}
- _connStringLookup[connString] = shard;
+ _connStringLookup[connString.toString()] = shard;
for (const HostAndPort& hostAndPort : connString.getServers()) {
_hostLookup[hostAndPort] = shard;
diff --git a/src/mongo/s/client/shard_registry.h b/src/mongo/s/client/shard_registry.h
index 166f316e860..5ed94c5d143 100644
--- a/src/mongo/s/client/shard_registry.h
+++ b/src/mongo/s/client/shard_registry.h
@@ -116,6 +116,7 @@ public:
*/
void shardIdSetDifference(std::set<ShardId>& diff) const;
void toBSON(BSONObjBuilder* result) const;
+
/**
* If the shard with same replica set name as in the newConnString already exists then replace
* it with the shard built for the newConnString.
@@ -133,7 +134,7 @@ private:
auto _findByShardId(WithLock, ShardId const&) const -> std::shared_ptr<Shard>;
auto _findByHostAndPort(WithLock, const HostAndPort& hostAndPort) const
-> std::shared_ptr<Shard>;
- auto _findByConnectionString(WithLock, const ConnectionString& connectionString) const
+ auto _findByConnectionString(WithLock, const std::string& connectionString) const
-> std::shared_ptr<Shard>;
auto _findShard(WithLock lk, ShardId const& shardId) const -> std::shared_ptr<Shard>;
void _rebuildShard(WithLock, ConnectionString const& newConnString, ShardFactory* factory);
@@ -153,7 +154,7 @@ private:
stdx::unordered_map<HostAndPort, std::shared_ptr<Shard>> _hostLookup;
// Map of connection string to Shard
- std::map<ConnectionString, std::shared_ptr<Shard>> _connStringLookup;
+ std::map<std::string, std::shared_ptr<Shard>> _connStringLookup;
// store configShard separately to always have a reference
std::shared_ptr<Shard> _configShard;