diff options
author | Ben Shteinfeld <ben.shteinfeld@mongodb.com> | 2023-04-06 17:58:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-07 17:02:56 +0000 |
commit | 190f4f7f5def5af8ae8d992ddabaea06e216f743 (patch) | |
tree | b6e83dc4fc91c2bb659b67c911ae3ac76d6908c4 | |
parent | 3e3051fb5ce7dd2ae529b02275877365ca409960 (diff) | |
download | mongo-190f4f7f5def5af8ae8d992ddabaea06e216f743.tar.gz |
SERVER-75010 Introduce inShardedEnvironment() function to
MongoProcessInterface
This is a partial backport of
https://github.com/mongodb/mongo/commit/28c7db0e580afb4fe889f16370cf44c6f95f8cf3.
5 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp index e027c145652..38d6222a843 100644 --- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp @@ -332,6 +332,10 @@ std::string CommonMongodProcessInterface::getShardName(OperationContext* opCtx) return std::string(); } +bool CommonMongodProcessInterface::inShardedEnvironment(OperationContext* opCtx) const { + return ShardingState::get(opCtx)->enabled(); +} + std::vector<GenericCursor> CommonMongodProcessInterface::getIdleCursors( const boost::intrusive_ptr<ExpressionContext>& expCtx, CurrentOpUserMode userMode) const { return CursorManager::get(expCtx->opCtx)->getIdleCursors(expCtx->opCtx, userMode); diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h index 194cd48f51e..4a834a55251 100644 --- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h @@ -76,6 +76,8 @@ public: Pipeline* pipeline) final; std::string getShardName(OperationContext* opCtx) const final; + bool inShardedEnvironment(OperationContext* opCtx) const final; + boost::optional<Document> lookupSingleDocument( const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& nss, diff --git a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h index 370c6fcbeea..145ef26a85c 100644 --- a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h @@ -159,6 +159,11 @@ public: virtual bool isSharded(OperationContext* opCtx, const NamespaceString& ns) = 0; /** + * Returns whether this process is running as part of a sharded cluster. + */ + virtual bool inShardedEnvironment(OperationContext* opCtx) const = 0; + + /** * Advances the proxied write time associated with the client in ReplClientInfo to * be at least as high as the one tracked by the OperationTimeTracker associated with the * given operation context. diff --git a/src/mongo/db/pipeline/process_interface/mongos_process_interface.h b/src/mongo/db/pipeline/process_interface/mongos_process_interface.h index 6f7df75f65f..498e9d4287f 100644 --- a/src/mongo/db/pipeline/process_interface/mongos_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/mongos_process_interface.h @@ -66,6 +66,10 @@ public: bool isSharded(OperationContext* opCtx, const NamespaceString& nss) final; + bool inShardedEnvironment(OperationContext*) const final { + return true; + } + Status insert(const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& ns, std::vector<BSONObj>&& objs, diff --git a/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h index ab79ee53776..fd338e971fb 100644 --- a/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h @@ -194,6 +194,10 @@ public: MONGO_UNREACHABLE; } + bool inShardedEnvironment(OperationContext*) const override { + MONGO_UNREACHABLE; + } + std::string getHostAndPort(OperationContext* opCtx) const override { MONGO_UNREACHABLE; } |