diff options
Diffstat (limited to 'src/mongo/s/commands/cluster_rwc_defaults_commands.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_rwc_defaults_commands.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp index 3587c6cda59..44ff531a3a4 100644 --- a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp +++ b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp @@ -36,7 +36,6 @@ #include "mongo/db/commands/rwc_defaults_commands_gen.h" #include "mongo/db/namespace_string.h" #include "mongo/db/read_write_concern_defaults.h" -#include "mongo/db/rw_concern_default_gen.h" #include "mongo/s/cluster_commands_helpers.h" #include "mongo/s/grid.h" #include "mongo/util/log.h" @@ -72,7 +71,7 @@ public: // Quickly pick up the new defaults by setting them in the cache. auto newDefaults = RWConcernDefault::parse( IDLParserErrorContext("ClusterSetDefaultRWConcern"), cmdResponse.response); - ReadWriteConcernDefaults::get(opCtx).setDefault(std::move(newDefaults)); + ReadWriteConcernDefaults::get(opCtx).setDefault(opCtx, std::move(newDefaults)); CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.response, &result); return true; @@ -113,20 +112,23 @@ class ClusterGetDefaultRWConcernCommand final : public TypedCommand<ClusterGetDefaultRWConcernCommand> { public: using Request = GetDefaultRWConcern; - using Response = RWConcernDefault; class Invocation final : public InvocationBase { public: using InvocationBase::InvocationBase; - Response typedRun(OperationContext* opCtx) { - if (request().getInMemory() && *request().getInMemory()) { - auto rwc = - ReadWriteConcernDefaults::get(opCtx->getServiceContext()).getDefault(opCtx); - rwc.setInMemory(true); - return rwc; + GetDefaultRWConcernResponse typedRun(OperationContext* opCtx) { + auto& rwcDefaults = ReadWriteConcernDefaults::get(opCtx->getServiceContext()); + if (request().getInMemory().value_or(false)) { + const auto rwcDefault = rwcDefaults.getDefault(opCtx); + GetDefaultRWConcernResponse response; + response.setRWConcernDefault(rwcDefault); + response.setLocalUpdateWallClockTime(rwcDefault.localUpdateWallClockTime()); + response.setInMemory(true); + return response; } + // If not asking for the in-memory defaults, fetch them from the config server GetDefaultRWConcern configsvrRequest; configsvrRequest.setDbName(request().getDbName()); @@ -140,8 +142,8 @@ public: uassertStatusOK(cmdResponse.commandStatus); - return Response::parse(IDLParserErrorContext("ClusterGetDefaultRWConcernResponse"), - cmdResponse.response); + return GetDefaultRWConcernResponse::parse( + IDLParserErrorContext("ClusterGetDefaultRWConcernResponse"), cmdResponse.response); } private: |