summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_current_op.h
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
commit959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch)
treeacc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/db/pipeline/document_source_current_op.h
parent76588293975fc059cf076779e4283e6ffaf8afff (diff)
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/db/pipeline/document_source_current_op.h')
-rw-r--r--src/mongo/db/pipeline/document_source_current_op.h75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/mongo/db/pipeline/document_source_current_op.h b/src/mongo/db/pipeline/document_source_current_op.h
index 49e0be6c35d..4cc53475e4b 100644
--- a/src/mongo/db/pipeline/document_source_current_op.h
+++ b/src/mongo/db/pipeline/document_source_current_op.h
@@ -45,6 +45,14 @@ public:
static constexpr StringData kStageName = "$currentOp"_sd;
+ static constexpr ConnMode kDefaultConnMode = ConnMode::kExcludeIdle;
+ static constexpr SessionMode kDefaultSessionMode = SessionMode::kIncludeIdle;
+ static constexpr UserMode kDefaultUserMode = UserMode::kExcludeOthers;
+ static constexpr LocalOpsMode kDefaultLocalOpsMode = LocalOpsMode::kRemoteShardOps;
+ static constexpr TruncationMode kDefaultTruncationMode = TruncationMode::kNoTruncation;
+ static constexpr CursorMode kDefaultCursorMode = CursorMode::kExcludeCursors;
+ static constexpr BacktraceMode kDefaultBacktraceMode = BacktraceMode::kExcludeBacktrace;
+
class LiteParsed final : public LiteParsedDocumentSource {
public:
static std::unique_ptr<LiteParsed> parse(const NamespaceString& nss,
@@ -98,29 +106,28 @@ public:
static boost::intrusive_ptr<DocumentSourceCurrentOp> create(
const boost::intrusive_ptr<ExpressionContext>& pExpCtx,
- ConnMode includeIdleConnections = ConnMode::kExcludeIdle,
- SessionMode includeIdleSessions = SessionMode::kIncludeIdle,
- UserMode includeOpsFromAllUsers = UserMode::kExcludeOthers,
- LocalOpsMode showLocalOpsOnMongoS = LocalOpsMode::kRemoteShardOps,
- TruncationMode truncateOps = TruncationMode::kNoTruncation,
- CursorMode idleCursors = CursorMode::kExcludeCursors,
- BacktraceMode backtrace = BacktraceMode::kExcludeBacktrace);
+ boost::optional<ConnMode> includeIdleConnections = boost::none,
+ boost::optional<SessionMode> includeIdleSessions = boost::none,
+ boost::optional<UserMode> includeOpsFromAllUsers = boost::none,
+ boost::optional<LocalOpsMode> showLocalOpsOnMongoS = boost::none,
+ boost::optional<TruncationMode> truncateOps = boost::none,
+ boost::optional<CursorMode> idleCursors = boost::none,
+ boost::optional<BacktraceMode> backtrace = boost::none);
const char* getSourceName() const final;
StageConstraints constraints(Pipeline::SplitState pipeState) const final {
- StageConstraints constraints(StreamType::kStreaming,
- PositionRequirement::kFirst,
- (_showLocalOpsOnMongoS == LocalOpsMode::kLocalMongosOps
- ? HostTypeRequirement::kLocalOnly
- : HostTypeRequirement::kAnyShard),
- DiskUseRequirement::kNoDiskUse,
- FacetRequirement::kNotAllowed,
- TransactionRequirement::kNotAllowed,
- LookupRequirement::kAllowed,
- (_showLocalOpsOnMongoS == LocalOpsMode::kLocalMongosOps
- ? UnionRequirement::kNotAllowed
- : UnionRequirement::kAllowed));
+ bool showLocalOps =
+ _showLocalOpsOnMongoS.value_or(kDefaultLocalOpsMode) == LocalOpsMode::kLocalMongosOps;
+ StageConstraints constraints(
+ StreamType::kStreaming,
+ PositionRequirement::kFirst,
+ (showLocalOps ? HostTypeRequirement::kLocalOnly : HostTypeRequirement::kAnyShard),
+ DiskUseRequirement::kNoDiskUse,
+ FacetRequirement::kNotAllowed,
+ TransactionRequirement::kNotAllowed,
+ LookupRequirement::kAllowed,
+ (showLocalOps ? UnionRequirement::kNotAllowed : UnionRequirement::kAllowed));
constraints.isIndependentOfAnyCollection = true;
constraints.requiresInputDocSource = false;
@@ -134,17 +141,17 @@ public:
static boost::intrusive_ptr<DocumentSource> createFromBson(
BSONElement spec, const boost::intrusive_ptr<ExpressionContext>& pExpCtx);
- Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final;
+ Value serialize(const SerializationOptions& opts = SerializationOptions{}) const final override;
private:
DocumentSourceCurrentOp(const boost::intrusive_ptr<ExpressionContext>& pExpCtx,
- ConnMode includeIdleConnections,
- SessionMode includeIdleSessions,
- UserMode includeOpsFromAllUsers,
- LocalOpsMode showLocalOpsOnMongoS,
- TruncationMode truncateOps,
- CursorMode idleCursors,
- BacktraceMode backtrace)
+ boost::optional<ConnMode> includeIdleConnections,
+ boost::optional<SessionMode> includeIdleSessions,
+ boost::optional<UserMode> includeOpsFromAllUsers,
+ boost::optional<LocalOpsMode> showLocalOpsOnMongoS,
+ boost::optional<TruncationMode> truncateOps,
+ boost::optional<CursorMode> idleCursors,
+ boost::optional<BacktraceMode> backtrace)
: DocumentSource(kStageName, pExpCtx),
_includeIdleConnections(includeIdleConnections),
_includeIdleSessions(includeIdleSessions),
@@ -156,13 +163,13 @@ private:
GetNextResult doGetNext() final;
- ConnMode _includeIdleConnections = ConnMode::kExcludeIdle;
- SessionMode _includeIdleSessions = SessionMode::kIncludeIdle;
- UserMode _includeOpsFromAllUsers = UserMode::kExcludeOthers;
- LocalOpsMode _showLocalOpsOnMongoS = LocalOpsMode::kRemoteShardOps;
- TruncationMode _truncateOps = TruncationMode::kNoTruncation;
- CursorMode _idleCursors = CursorMode::kExcludeCursors;
- BacktraceMode _backtrace = BacktraceMode::kExcludeBacktrace;
+ boost::optional<ConnMode> _includeIdleConnections;
+ boost::optional<SessionMode> _includeIdleSessions;
+ boost::optional<UserMode> _includeOpsFromAllUsers;
+ boost::optional<LocalOpsMode> _showLocalOpsOnMongoS;
+ boost::optional<TruncationMode> _truncateOps;
+ boost::optional<CursorMode> _idleCursors;
+ boost::optional<BacktraceMode> _backtrace;
std::string _shardName;