diff options
author | Randolph Tan <randolph@10gen.com> | 2017-03-09 17:16:55 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2017-03-10 13:11:07 -0500 |
commit | a8d1a9d89f374969266ffddee158fef03cdbf174 (patch) | |
tree | 4b3d58ca3ac4be55b4395d746331c60479a38590 /src/mongo | |
parent | a067d77c06242aed80ccbf9e6d03b6a054849ffa (diff) | |
download | mongo-a8d1a9d89f374969266ffddee158fef03cdbf174.tar.gz |
SERVER-27750 Always attach the configsvr metadata in ShardingEgress*Hooks
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/s/sharded_connection_info.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.h | 3 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_initialization_mongod.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/server.cpp | 6 | ||||
-rw-r--r-- | src/mongo/s/sharding_egress_metadata_hook.cpp | 7 | ||||
-rw-r--r-- | src/mongo/s/sharding_egress_metadata_hook.h | 10 | ||||
-rw-r--r-- | src/mongo/s/sharding_egress_metadata_hook_for_mongos.cpp | 3 | ||||
-rw-r--r-- | src/mongo/s/sharding_egress_metadata_hook_for_mongos.h | 3 | ||||
-rw-r--r-- | src/mongo/s/sharding_test_fixture.cpp | 5 |
10 files changed, 11 insertions, 35 deletions
diff --git a/src/mongo/db/s/sharded_connection_info.cpp b/src/mongo/db/s/sharded_connection_info.cpp index fea550317aa..7a09849417f 100644 --- a/src/mongo/db/s/sharded_connection_info.cpp +++ b/src/mongo/db/s/sharded_connection_info.cpp @@ -109,13 +109,13 @@ void ShardedConnectionInfo::addHook(ServiceContext* service) { auto unshardedHookList = stdx::make_unique<rpc::EgressMetadataHookList>(); unshardedHookList->addHook(stdx::make_unique<rpc::LogicalTimeMetadataHook>(service)); - unshardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>(false)); + unshardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>()); globalConnPool.addHook(new ShardingConnectionHook(false, std::move(unshardedHookList))); auto shardedHookList = stdx::make_unique<rpc::EgressMetadataHookList>(); shardedHookList->addHook(stdx::make_unique<rpc::LogicalTimeMetadataHook>(service)); - shardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>(true)); + shardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>()); shardConnectionPool.addHook(new ShardingConnectionHook(true, std::move(shardedHookList))); diff --git a/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.cpp b/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.cpp index 24295466ed9..99603ce0ed4 100644 --- a/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.cpp +++ b/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.cpp @@ -40,9 +40,6 @@ namespace mongo { namespace rpc { -ShardingEgressMetadataHookForMongod::ShardingEgressMetadataHookForMongod(bool shardedConnection) - : ShardingEgressMetadataHook(shardedConnection) {} - void ShardingEgressMetadataHookForMongod::_saveGLEStats(const BSONObj& metadata, StringData hostString) {} diff --git a/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.h b/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.h index 3c07f847f72..f9032ef6945 100644 --- a/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.h +++ b/src/mongo/db/s/sharding_egress_metadata_hook_for_mongod.h @@ -34,9 +34,6 @@ namespace mongo { namespace rpc { class ShardingEgressMetadataHookForMongod final : public ShardingEgressMetadataHook { -public: - ShardingEgressMetadataHookForMongod(bool shardedConnection); - private: void _saveGLEStats(const BSONObj& metadata, StringData hostString) override; diff --git a/src/mongo/db/s/sharding_initialization_mongod.cpp b/src/mongo/db/s/sharding_initialization_mongod.cpp index 2e536dbbb0b..b329a325423 100644 --- a/src/mongo/db/s/sharding_initialization_mongod.cpp +++ b/src/mongo/db/s/sharding_initialization_mongod.cpp @@ -92,7 +92,7 @@ Status initializeGlobalShardingStateForMongod(OperationContext* opCtx, auto hookList = stdx::make_unique<rpc::EgressMetadataHookList>(); hookList->addHook( stdx::make_unique<rpc::LogicalTimeMetadataHook>(opCtx->getServiceContext())); - hookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>(false)); + hookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>()); return hookList; }, [](ShardingCatalogClient* catalogClient, std::unique_ptr<executor::TaskExecutor> executor) diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index d3a797b3a49..7255c8810de 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -207,7 +207,7 @@ static Status initializeSharding(OperationContext* opCtx) { auto hookList = stdx::make_unique<rpc::EgressMetadataHookList>(); hookList->addHook( stdx::make_unique<rpc::LogicalTimeMetadataHook>(opCtx->getServiceContext())); - hookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongos>(false)); + hookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongos>()); return hookList; }, [](ShardingCatalogClient* catalogClient, std::unique_ptr<executor::TaskExecutor> executor) { @@ -260,7 +260,7 @@ static ExitCode runMongosServer() { auto unshardedHookList = stdx::make_unique<rpc::EgressMetadataHookList>(); unshardedHookList->addHook( stdx::make_unique<rpc::LogicalTimeMetadataHook>(getGlobalServiceContext())); - unshardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongos>(false)); + unshardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongos>()); // Add sharding hooks to both connection pools - ShardingConnectionHook includes auth hooks globalConnPool.addHook(new ShardingConnectionHook(false, std::move(unshardedHookList))); @@ -268,7 +268,7 @@ static ExitCode runMongosServer() { auto shardedHookList = stdx::make_unique<rpc::EgressMetadataHookList>(); shardedHookList->addHook( stdx::make_unique<rpc::LogicalTimeMetadataHook>(getGlobalServiceContext())); - shardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongos>(true)); + shardedHookList->addHook(stdx::make_unique<rpc::ShardingEgressMetadataHookForMongos>()); shardConnectionPool.addHook(new ShardingConnectionHook(true, std::move(shardedHookList))); diff --git a/src/mongo/s/sharding_egress_metadata_hook.cpp b/src/mongo/s/sharding_egress_metadata_hook.cpp index cc4823a3384..254483068d6 100644 --- a/src/mongo/s/sharding_egress_metadata_hook.cpp +++ b/src/mongo/s/sharding_egress_metadata_hook.cpp @@ -50,18 +50,11 @@ namespace rpc { using std::shared_ptr; -ShardingEgressMetadataHook::ShardingEgressMetadataHook(bool shardedConnection) - : _isShardedConnection(shardedConnection) {} - Status ShardingEgressMetadataHook::writeRequestMetadata(OperationContext* opCtx, BSONObjBuilder* metadataBob) { try { audit::writeImpersonatedUsersToMetadata(opCtx, metadataBob); - ClientMetadataIsMasterState::writeToMetadata(opCtx, metadataBob); - if (!_isShardedConnection) { - return Status::OK(); - } rpc::ConfigServerMetadata(_getConfigServerOpTime()).writeToMetadata(metadataBob); return Status::OK(); } catch (...) { diff --git a/src/mongo/s/sharding_egress_metadata_hook.h b/src/mongo/s/sharding_egress_metadata_hook.h index 87442ebe0f3..d872949b531 100644 --- a/src/mongo/s/sharding_egress_metadata_hook.h +++ b/src/mongo/s/sharding_egress_metadata_hook.h @@ -41,12 +41,11 @@ class Shard; namespace rpc { +/** + * Hooks for handling configsvr optime, client metadata and auth metadata for sharding. + */ class ShardingEgressMetadataHook : public rpc::EgressMetadataHook { public: - /** - * Pass true to shardedConnection if the hook is intended for connections with shard versions. - */ - ShardingEgressMetadataHook(bool shardedConnection); virtual ~ShardingEgressMetadataHook() = default; Status readReplyMetadata(StringData replySource, const BSONObj& metadataObj) override; @@ -74,9 +73,6 @@ protected: * metadata in the response object from running a command. */ virtual Status _advanceConfigOptimeFromShard(ShardId shardId, const BSONObj& metadataObj); - -private: - bool _isShardedConnection; }; } // namespace rpc diff --git a/src/mongo/s/sharding_egress_metadata_hook_for_mongos.cpp b/src/mongo/s/sharding_egress_metadata_hook_for_mongos.cpp index 1ae82a7c64e..f355054f92b 100644 --- a/src/mongo/s/sharding_egress_metadata_hook_for_mongos.cpp +++ b/src/mongo/s/sharding_egress_metadata_hook_for_mongos.cpp @@ -41,9 +41,6 @@ namespace mongo { namespace rpc { -ShardingEgressMetadataHookForMongos::ShardingEgressMetadataHookForMongos(bool shardedConnection) - : ShardingEgressMetadataHook(shardedConnection) {} - void ShardingEgressMetadataHookForMongos::_saveGLEStats(const BSONObj& metadata, StringData hostString) { if (!haveClient()) { diff --git a/src/mongo/s/sharding_egress_metadata_hook_for_mongos.h b/src/mongo/s/sharding_egress_metadata_hook_for_mongos.h index 2e5bfe62434..9cba4226df2 100644 --- a/src/mongo/s/sharding_egress_metadata_hook_for_mongos.h +++ b/src/mongo/s/sharding_egress_metadata_hook_for_mongos.h @@ -34,9 +34,6 @@ namespace mongo { namespace rpc { class ShardingEgressMetadataHookForMongos final : public ShardingEgressMetadataHook { -public: - ShardingEgressMetadataHookForMongos(bool shardedConnection); - private: void _saveGLEStats(const BSONObj& metadata, StringData hostString) override; diff --git a/src/mongo/s/sharding_test_fixture.cpp b/src/mongo/s/sharding_test_fixture.cpp index 4068545c113..59d3762925f 100644 --- a/src/mongo/s/sharding_test_fixture.cpp +++ b/src/mongo/s/sharding_test_fixture.cpp @@ -108,15 +108,14 @@ void ShardingTestFixture::setUp() { // Set up executor pool used for most operations. auto fixedNet = stdx::make_unique<executor::NetworkInterfaceMock>(); - fixedNet->setEgressMetadataHook(stdx::make_unique<ShardingEgressMetadataHookForMongos>(false)); + fixedNet->setEgressMetadataHook(stdx::make_unique<ShardingEgressMetadataHookForMongos>()); _mockNetwork = fixedNet.get(); auto fixedExec = makeThreadPoolTestExecutor(std::move(fixedNet)); _networkTestEnv = stdx::make_unique<NetworkTestEnv>(fixedExec.get(), _mockNetwork); _executor = fixedExec.get(); auto netForPool = stdx::make_unique<executor::NetworkInterfaceMock>(); - netForPool->setEgressMetadataHook( - stdx::make_unique<ShardingEgressMetadataHookForMongos>(false)); + netForPool->setEgressMetadataHook(stdx::make_unique<ShardingEgressMetadataHookForMongos>()); auto execForPool = makeThreadPoolTestExecutor(std::move(netForPool)); std::vector<std::unique_ptr<executor::TaskExecutor>> executorsForPool; executorsForPool.emplace_back(std::move(execForPool)); |