diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-02-15 14:07:58 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-03-09 17:18:49 -0500 |
commit | b9e20190b647fea262a8f4e154bbf18d9934a3ba (patch) | |
tree | c61003bc12d86333fe7cfc717f23a89777e5cce3 /src/mongo/db/s/sharded_connection_info.cpp | |
parent | dbfc1e30a2e06732c5cd3d20aabfff67737f3521 (diff) | |
download | mongo-b9e20190b647fea262a8f4e154bbf18d9934a3ba.tar.gz |
SERVER-32198 Make ShardedConnectionInfo::getVersion return boost::optional
This allows the logic for making the shard version decision to be
concentrated in CollectionShardingState entirely.
Diffstat (limited to 'src/mongo/db/s/sharded_connection_info.cpp')
-rw-r--r-- | src/mongo/db/s/sharded_connection_info.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/mongo/db/s/sharded_connection_info.cpp b/src/mongo/db/s/sharded_connection_info.cpp index d9154ac7f42..338fcf3bd5e 100644 --- a/src/mongo/db/s/sharded_connection_info.cpp +++ b/src/mongo/db/s/sharded_connection_info.cpp @@ -32,18 +32,12 @@ #include "mongo/db/s/sharded_connection_info.h" -#include <boost/optional.hpp> -#include <boost/utility/in_place_factory.hpp> - #include "mongo/client/global_conn_pool.h" #include "mongo/db/client.h" #include "mongo/db/logical_time_metadata_hook.h" -#include "mongo/db/operation_context.h" #include "mongo/db/s/sharding_egress_metadata_hook_for_mongod.h" -#include "mongo/db/service_context.h" #include "mongo/platform/atomic_word.h" #include "mongo/rpc/metadata/egress_metadata_hook_list.h" -#include "mongo/s/chunk_version.h" #include "mongo/s/client/shard_connection.h" #include "mongo/s/client/sharding_connection_hook.h" #include "mongo/stdx/memory.h" @@ -60,9 +54,7 @@ AtomicUInt32 alreadyAddedHook{0}; } // namespace -ShardedConnectionInfo::ShardedConnectionInfo() { - _forceVersionOk = false; -} +ShardedConnectionInfo::ShardedConnectionInfo() = default; ShardedConnectionInfo::~ShardedConnectionInfo() = default; @@ -71,7 +63,7 @@ ShardedConnectionInfo* ShardedConnectionInfo::get(Client* client, bool create) { if (!current && create) { LOG(1) << "entering shard mode for connection"; - current = boost::in_place(); + current.emplace(); } return current ? ¤t.value() : nullptr; @@ -81,12 +73,12 @@ void ShardedConnectionInfo::reset(Client* client) { clientSCI(client) = boost::none; } -ChunkVersion ShardedConnectionInfo::getVersion(const std::string& ns) const { +boost::optional<ChunkVersion> ShardedConnectionInfo::getVersion(const std::string& ns) const { NSVersionMap::const_iterator it = _versions.find(ns); if (it != _versions.end()) { return it->second; } else { - return ChunkVersion::UNSHARDED(); + return boost::none; } } |