summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2022-02-07 16:50:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-07 20:30:56 +0000
commit522da292b8e89d6288916f744f318cb1f32ac8a8 (patch)
treeae361da0444a406929da01bfb50786ba8387a1b1 /src
parentccd044ecf761baf8a8cb6487b2ebe676e6611599 (diff)
downloadmongo-522da292b8e89d6288916f744f318cb1f32ac8a8.tar.gz
SERVER-63331 Remove useless methods from BatchCommandResponse
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/balancer/balancer.h1
-rw-r--r--src/mongo/db/s/balancer/cluster_statistics.h7
-rw-r--r--src/mongo/db/s/balancer/type_migration.h1
-rw-r--r--src/mongo/db/s/drop_collection_coordinator.h1
-rw-r--r--src/mongo/db/s/sharding_ddl_coordinator_service.cpp10
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client.h10
-rw-r--r--src/mongo/s/chunk_manager.h1
-rw-r--r--src/mongo/s/cluster_commands_helpers.h1
-rw-r--r--src/mongo/s/commands/cluster_command_test_fixture.cpp1
-rw-r--r--src/mongo/s/commands/cluster_command_test_fixture.h1
-rw-r--r--src/mongo/s/commands/cluster_explain.h1
-rw-r--r--src/mongo/s/commands/strategy.cpp7
-rw-r--r--src/mongo/s/commands/strategy.h12
-rw-r--r--src/mongo/s/query/cluster_aggregation_planner.cpp2
-rw-r--r--src/mongo/s/query/cluster_client_cursor.h2
-rw-r--r--src/mongo/s/query/cluster_client_cursor_impl.cpp2
-rw-r--r--src/mongo/s/query/cluster_client_cursor_impl.h2
-rw-r--r--src/mongo/s/query/cluster_client_cursor_mock.cpp2
-rw-r--r--src/mongo/s/query/cluster_client_cursor_mock.h2
-rw-r--r--src/mongo/s/query/cluster_client_cursor_params.h9
-rw-r--r--src/mongo/s/query/cluster_find.cpp4
-rw-r--r--src/mongo/s/query/store_possible_cursor.cpp2
-rw-r--r--src/mongo/s/query/store_possible_cursor.h2
-rw-r--r--src/mongo/s/request_types/balance_chunk_request_type.h2
-rw-r--r--src/mongo/s/write_ops/batch_write_exec.cpp3
-rw-r--r--src/mongo/s/write_ops/batch_write_op.cpp4
-rw-r--r--src/mongo/s/write_ops/batch_write_op_test.cpp2
-rw-r--r--src/mongo/s/write_ops/batched_command_response.cpp50
-rw-r--r--src/mongo/s/write_ops/batched_command_response.h29
-rw-r--r--src/mongo/s/write_ops/batched_upsert_detail.h4
30 files changed, 36 insertions, 141 deletions
diff --git a/src/mongo/db/s/balancer/balancer.h b/src/mongo/db/s/balancer/balancer.h
index f1a48015382..c3ea9b0578f 100644
--- a/src/mongo/db/s/balancer/balancer.h
+++ b/src/mongo/db/s/balancer/balancer.h
@@ -33,7 +33,6 @@
#include "mongo/db/s/balancer/balancer_chunk_selection_policy.h"
#include "mongo/db/s/balancer/balancer_random.h"
#include "mongo/platform/mutex.h"
-#include "mongo/s/grid.h"
#include "mongo/stdx/condition_variable.h"
#include "mongo/stdx/thread.h"
diff --git a/src/mongo/db/s/balancer/cluster_statistics.h b/src/mongo/db/s/balancer/cluster_statistics.h
index 71c7ce9484f..868c59d774a 100644
--- a/src/mongo/db/s/balancer/cluster_statistics.h
+++ b/src/mongo/db/s/balancer/cluster_statistics.h
@@ -29,19 +29,18 @@
#pragma once
-#include <memory>
#include <set>
#include <string>
#include <vector>
-#include "mongo/s/client/shard.h"
+#include "mongo/base/status_with.h"
+#include "mongo/db/namespace_string.h"
+#include "mongo/s/shard_id.h"
namespace mongo {
class BSONObj;
class OperationContext;
-template <typename T>
-class StatusWith;
/**
* This interface serves as means for obtaining data distribution and shard utilization statistics
diff --git a/src/mongo/db/s/balancer/type_migration.h b/src/mongo/db/s/balancer/type_migration.h
index d51f4464781..823ed76c9e8 100644
--- a/src/mongo/db/s/balancer/type_migration.h
+++ b/src/mongo/db/s/balancer/type_migration.h
@@ -33,7 +33,6 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/s/balancer/balancer_policy.h"
#include "mongo/s/chunk_version.h"
-#include "mongo/s/client/shard.h"
namespace mongo {
diff --git a/src/mongo/db/s/drop_collection_coordinator.h b/src/mongo/db/s/drop_collection_coordinator.h
index 373ba5d05ae..1f43b204de4 100644
--- a/src/mongo/db/s/drop_collection_coordinator.h
+++ b/src/mongo/db/s/drop_collection_coordinator.h
@@ -33,7 +33,6 @@
#include "mongo/db/s/collection_sharding_runtime.h"
#include "mongo/db/s/drop_collection_coordinator_document_gen.h"
#include "mongo/db/s/sharding_ddl_coordinator.h"
-#include "mongo/s/grid.h"
namespace mongo {
diff --git a/src/mongo/db/s/sharding_ddl_coordinator_service.cpp b/src/mongo/db/s/sharding_ddl_coordinator_service.cpp
index a39f2847f81..1c01f4882dc 100644
--- a/src/mongo/db/s/sharding_ddl_coordinator_service.cpp
+++ b/src/mongo/db/s/sharding_ddl_coordinator_service.cpp
@@ -35,22 +35,22 @@
#include "mongo/base/checked_cast.h"
#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/pipeline/aggregate_command_gen.h"
#include "mongo/db/pipeline/document_source_count.h"
#include "mongo/db/pipeline/expression_context.h"
-#include "mongo/db/s/database_sharding_state.h"
-#include "mongo/db/s/operation_sharding_state.h"
-#include "mongo/db/s/sharding_ddl_coordinator.h"
-#include "mongo/logv2/log.h"
-
#include "mongo/db/s/collmod_coordinator.h"
#include "mongo/db/s/create_collection_coordinator.h"
+#include "mongo/db/s/database_sharding_state.h"
#include "mongo/db/s/drop_collection_coordinator.h"
#include "mongo/db/s/drop_database_coordinator.h"
#include "mongo/db/s/move_primary_coordinator.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/refine_collection_shard_key_coordinator.h"
#include "mongo/db/s/rename_collection_coordinator.h"
#include "mongo/db/s/reshard_collection_coordinator.h"
#include "mongo/db/s/set_allow_migrations_coordinator.h"
+#include "mongo/db/s/sharding_ddl_coordinator.h"
+#include "mongo/logv2/log.h"
namespace mongo {
namespace {
diff --git a/src/mongo/s/catalog/sharding_catalog_client.h b/src/mongo/s/catalog/sharding_catalog_client.h
index 60df2570447..05ea0bf1658 100644
--- a/src/mongo/s/catalog/sharding_catalog_client.h
+++ b/src/mongo/s/catalog/sharding_catalog_client.h
@@ -34,16 +34,15 @@
#include <string>
#include <vector>
+#include "mongo/client/read_preference.h"
#include "mongo/db/keys_collection_document_gen.h"
#include "mongo/db/repl/optime_with.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/s/catalog/type_shard.h"
-#include "mongo/s/client/shard.h"
namespace mongo {
-class BatchedCommandRequest;
-class BatchedCommandResponse;
struct BSONArray;
class BSONArrayBuilder;
class BSONObj;
@@ -54,13 +53,8 @@ class CollectionType;
class ConnectionString;
class DatabaseType;
class LogicalTime;
-class NamespaceString;
class OperationContext;
-class ShardingCatalogManager;
class ShardKeyPattern;
-class Status;
-template <typename T>
-class StatusWith;
class TagsType;
class VersionType;
diff --git a/src/mongo/s/chunk_manager.h b/src/mongo/s/chunk_manager.h
index 3a3c6ec5a7a..51378b1417a 100644
--- a/src/mongo/s/chunk_manager.h
+++ b/src/mongo/s/chunk_manager.h
@@ -37,7 +37,6 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/query/collation/collator_interface.h"
#include "mongo/s/chunk.h"
-#include "mongo/s/client/shard.h"
#include "mongo/s/database_version.h"
#include "mongo/s/resharding/type_collection_fields_gen.h"
#include "mongo/s/shard_key_pattern.h"
diff --git a/src/mongo/s/cluster_commands_helpers.h b/src/mongo/s/cluster_commands_helpers.h
index b5872e4b933..46cc2be72f5 100644
--- a/src/mongo/s/cluster_commands_helpers.h
+++ b/src/mongo/s/cluster_commands_helpers.h
@@ -41,7 +41,6 @@
#include "mongo/rpc/write_concern_error_detail.h"
#include "mongo/s/async_requests_sender.h"
#include "mongo/s/catalog_cache.h"
-#include "mongo/s/commands/strategy.h"
namespace mongo {
diff --git a/src/mongo/s/commands/cluster_command_test_fixture.cpp b/src/mongo/s/commands/cluster_command_test_fixture.cpp
index 6b1daa92292..49b3c7771e1 100644
--- a/src/mongo/s/commands/cluster_command_test_fixture.cpp
+++ b/src/mongo/s/commands/cluster_command_test_fixture.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/logical_time_validator.h"
#include "mongo/db/read_write_concern_defaults.h"
#include "mongo/db/vector_clock.h"
+#include "mongo/s/commands/strategy.h"
#include "mongo/util/fail_point.h"
#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/tick_source_mock.h"
diff --git a/src/mongo/s/commands/cluster_command_test_fixture.h b/src/mongo/s/commands/cluster_command_test_fixture.h
index 3f379052ff9..b1e3a84588c 100644
--- a/src/mongo/s/commands/cluster_command_test_fixture.h
+++ b/src/mongo/s/commands/cluster_command_test_fixture.h
@@ -33,7 +33,6 @@
#include "mongo/db/read_write_concern_defaults_cache_lookup_mock.h"
#include "mongo/s/catalog_cache_test_fixture.h"
-#include "mongo/s/commands/strategy.h"
namespace mongo {
diff --git a/src/mongo/s/commands/cluster_explain.h b/src/mongo/s/commands/cluster_explain.h
index 60570c855d3..f1ff6716de8 100644
--- a/src/mongo/s/commands/cluster_explain.h
+++ b/src/mongo/s/commands/cluster_explain.h
@@ -33,7 +33,6 @@
#include "mongo/db/query/explain_options.h"
#include "mongo/s/async_requests_sender.h"
-#include "mongo/s/commands/strategy.h"
namespace mongo {
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index b9d903e6685..668241285ce 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -98,8 +98,6 @@
#include "mongo/util/str.h"
#include "mongo/util/timer.h"
-using namespace fmt::literals;
-
namespace mongo {
namespace {
@@ -884,7 +882,7 @@ void ParseAndRunCommand::RunAndRetry::_setup() {
if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern &&
!TransactionRouter::get(opCtx) &&
(!readConcernArgs.getArgsAtClusterTime() || readConcernArgs.wasAtClusterTimeSelected())) {
- auto atClusterTime = [](OperationContext* opCtx, ReadConcernArgs& readConcernArgs) {
+ auto atClusterTime = [](OperationContext* opCtx, repl::ReadConcernArgs& readConcernArgs) {
const auto latestKnownTime = VectorClock::get(opCtx)->getTime();
// Choose a time after the user-supplied afterClusterTime.
auto afterClusterTime = readConcernArgs.getArgsAfterClusterTime();
@@ -1025,7 +1023,7 @@ void ParseAndRunCommand::RunAndRetry::_onSnapshotError(Status& status) {
auto opCtx = _parc->_rec->getOpCtx();
if (auto txnRouter = TransactionRouter::get(opCtx);
- !txnRouter && !ReadConcernArgs::get(opCtx).wasAtClusterTimeSelected()) {
+ !txnRouter && !repl::ReadConcernArgs::get(opCtx).wasAtClusterTimeSelected()) {
// Non-transaction snapshot read. The client sent readConcern: {level: "snapshot",
// atClusterTime: T}, where T is older than minSnapshotHistoryWindowInSeconds, retrying
// won't succeed.
@@ -1282,4 +1280,5 @@ Future<DbResponse> Strategy::clientCommand(std::shared_ptr<RequestExecutionConte
return runner->run();
});
}
+
} // namespace mongo
diff --git a/src/mongo/s/commands/strategy.h b/src/mongo/s/commands/strategy.h
index 03b9088f9d4..1e04130f657 100644
--- a/src/mongo/s/commands/strategy.h
+++ b/src/mongo/s/commands/strategy.h
@@ -29,22 +29,10 @@
#pragma once
-#include <atomic>
-
-#include "mongo/client/connection_string.h"
-#include "mongo/db/query/explain_options.h"
#include "mongo/db/request_execution_context.h"
-#include "mongo/s/client/shard.h"
namespace mongo {
-class DbMessage;
-struct DbResponse;
-class Message;
-class NamespaceString;
-class OperationContext;
-class FindCommandRequest;
-
/**
* Legacy interface for processing client read/write/cmd requests.
*/
diff --git a/src/mongo/s/query/cluster_aggregation_planner.cpp b/src/mongo/s/query/cluster_aggregation_planner.cpp
index c9867f4eb78..6062c02e6ba 100644
--- a/src/mongo/s/query/cluster_aggregation_planner.cpp
+++ b/src/mongo/s/query/cluster_aggregation_planner.cpp
@@ -250,7 +250,7 @@ BSONObj establishMergingMongosCursor(OperationContext* opCtx,
ClusterClientCursorParams params(requestedNss,
APIParameters::get(opCtx),
ReadPreferenceSetting::get(opCtx),
- ReadConcernArgs::get(opCtx));
+ repl::ReadConcernArgs::get(opCtx));
params.originatingCommandObj = CurOp::get(opCtx)->opDescription().getOwned();
params.tailableMode = pipelineForMerging->getContext()->tailableMode;
diff --git a/src/mongo/s/query/cluster_client_cursor.h b/src/mongo/s/query/cluster_client_cursor.h
index 62302030988..8ff611eb308 100644
--- a/src/mongo/s/query/cluster_client_cursor.h
+++ b/src/mongo/s/query/cluster_client_cursor.h
@@ -189,7 +189,7 @@ public:
/**
* Returns the readConcern for this cursor.
*/
- virtual boost::optional<ReadConcernArgs> getReadConcern() const = 0;
+ virtual boost::optional<repl::ReadConcernArgs> getReadConcern() const = 0;
/**
* Returns the creation date of the cursor.
diff --git a/src/mongo/s/query/cluster_client_cursor_impl.cpp b/src/mongo/s/query/cluster_client_cursor_impl.cpp
index 9df37343455..73be5a7512a 100644
--- a/src/mongo/s/query/cluster_client_cursor_impl.cpp
+++ b/src/mongo/s/query/cluster_client_cursor_impl.cpp
@@ -233,7 +233,7 @@ boost::optional<ReadPreferenceSetting> ClusterClientCursorImpl::getReadPreferenc
return _params.readPreference;
}
-boost::optional<ReadConcernArgs> ClusterClientCursorImpl::getReadConcern() const {
+boost::optional<repl::ReadConcernArgs> ClusterClientCursorImpl::getReadConcern() const {
return _params.readConcern;
}
diff --git a/src/mongo/s/query/cluster_client_cursor_impl.h b/src/mongo/s/query/cluster_client_cursor_impl.h
index 59c60b43808..2529254cfce 100644
--- a/src/mongo/s/query/cluster_client_cursor_impl.h
+++ b/src/mongo/s/query/cluster_client_cursor_impl.h
@@ -106,7 +106,7 @@ public:
boost::optional<ReadPreferenceSetting> getReadPreference() const final;
- boost::optional<ReadConcernArgs> getReadConcern() const final;
+ boost::optional<repl::ReadConcernArgs> getReadConcern() const final;
Date_t getCreatedDate() const final;
diff --git a/src/mongo/s/query/cluster_client_cursor_mock.cpp b/src/mongo/s/query/cluster_client_cursor_mock.cpp
index 31926830901..567f3450499 100644
--- a/src/mongo/s/query/cluster_client_cursor_mock.cpp
+++ b/src/mongo/s/query/cluster_client_cursor_mock.cpp
@@ -164,7 +164,7 @@ boost::optional<ReadPreferenceSetting> ClusterClientCursorMock::getReadPreferenc
return boost::none;
}
-boost::optional<ReadConcernArgs> ClusterClientCursorMock::getReadConcern() const {
+boost::optional<repl::ReadConcernArgs> ClusterClientCursorMock::getReadConcern() const {
return boost::none;
}
diff --git a/src/mongo/s/query/cluster_client_cursor_mock.h b/src/mongo/s/query/cluster_client_cursor_mock.h
index 4b687df6203..bc2991ecf89 100644
--- a/src/mongo/s/query/cluster_client_cursor_mock.h
+++ b/src/mongo/s/query/cluster_client_cursor_mock.h
@@ -96,7 +96,7 @@ public:
boost::optional<ReadPreferenceSetting> getReadPreference() const final;
- boost::optional<ReadConcernArgs> getReadConcern() const final;
+ boost::optional<repl::ReadConcernArgs> getReadConcern() const final;
Date_t getCreatedDate() const final;
diff --git a/src/mongo/s/query/cluster_client_cursor_params.h b/src/mongo/s/query/cluster_client_cursor_params.h
index b0fae249884..a1fbd0fca04 100644
--- a/src/mongo/s/query/cluster_client_cursor_params.h
+++ b/src/mongo/s/query/cluster_client_cursor_params.h
@@ -50,15 +50,10 @@
#include "mongo/util/net/hostandport.h"
namespace mongo {
-namespace executor {
-class TaskExecutor;
-}
class OperationContext;
class RouterExecStage;
-using repl::ReadConcernArgs;
-
/**
* The resulting ClusterClientCursor will take ownership of the existing remote cursor, generating
* results based on the cursor's current state.
@@ -71,7 +66,7 @@ struct ClusterClientCursorParams {
ClusterClientCursorParams(NamespaceString nss,
APIParameters apiParameters,
boost::optional<ReadPreferenceSetting> readPref = boost::none,
- boost::optional<ReadConcernArgs> readConcernArgs = boost::none)
+ boost::optional<repl::ReadConcernArgs> readConcernArgs = boost::none)
: nsString(std::move(nss)), apiParameters(std::move(apiParameters)) {
if (readPref) {
readPreference = std::move(readPref.get());
@@ -156,7 +151,7 @@ struct ClusterClientCursorParams {
boost::optional<ReadPreferenceSetting> readPreference;
// Set if a readConcern must be respected throughout the lifetime of the cursor.
- boost::optional<ReadConcernArgs> readConcern;
+ boost::optional<repl::ReadConcernArgs> readConcern;
// Whether the client indicated that it is willing to receive partial results in the case of an
// unreachable host.
diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp
index af29d47f6d7..7bcd83f248c 100644
--- a/src/mongo/s/query/cluster_find.cpp
+++ b/src/mongo/s/query/cluster_find.cpp
@@ -228,7 +228,7 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx,
// Construct the query and parameters. Defer setting skip and limit here until
// we determine if the query is targeting multi-shards or a single shard below.
ClusterClientCursorParams params(
- query.nss(), APIParameters::get(opCtx), readPref, ReadConcernArgs::get(opCtx));
+ query.nss(), APIParameters::get(opCtx), readPref, repl::ReadConcernArgs::get(opCtx));
params.originatingCommandObj = CurOp::get(opCtx)->opDescription().getOwned();
params.batchSize = findCommand.getBatchSize();
params.tailableMode = query_request_helper::getTailableMode(findCommand);
@@ -417,7 +417,7 @@ Status setUpOperationContextStateForGetMore(OperationContext* opCtx,
if (auto readConcern = cursor->getReadConcern()) {
// Used to return "atClusterTime" in cursor replies to clients for snapshot reads.
- ReadConcernArgs::get(opCtx) = *readConcern;
+ repl::ReadConcernArgs::get(opCtx) = *readConcern;
}
auto apiParamsFromClient = APIParameters::get(opCtx);
diff --git a/src/mongo/s/query/store_possible_cursor.cpp b/src/mongo/s/query/store_possible_cursor.cpp
index 51c7612e059..9560a139bbe 100644
--- a/src/mongo/s/query/store_possible_cursor.cpp
+++ b/src/mongo/s/query/store_possible_cursor.cpp
@@ -102,7 +102,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
ClusterClientCursorParams params(incomingCursorResponse.getValue().getNSS(),
APIParameters::get(opCtx),
boost::none,
- ReadConcernArgs::get(opCtx));
+ repl::ReadConcernArgs::get(opCtx));
params.remotes.emplace_back();
auto& remoteCursor = params.remotes.back();
remoteCursor.setShardId(shardId.toString());
diff --git a/src/mongo/s/query/store_possible_cursor.h b/src/mongo/s/query/store_possible_cursor.h
index 43157322b0b..59f0a79c38a 100644
--- a/src/mongo/s/query/store_possible_cursor.h
+++ b/src/mongo/s/query/store_possible_cursor.h
@@ -33,8 +33,8 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/query/tailable_mode.h"
-#include "mongo/s/client/shard.h"
#include "mongo/s/query/owned_remote_cursor.h"
+#include "mongo/s/shard_id.h"
namespace mongo {
diff --git a/src/mongo/s/request_types/balance_chunk_request_type.h b/src/mongo/s/request_types/balance_chunk_request_type.h
index 04c513c70de..1386e15fcc4 100644
--- a/src/mongo/s/request_types/balance_chunk_request_type.h
+++ b/src/mongo/s/request_types/balance_chunk_request_type.h
@@ -32,8 +32,8 @@
#include <boost/optional.hpp>
#include "mongo/s/catalog/type_chunk.h"
-#include "mongo/s/client/shard.h"
#include "mongo/s/request_types/migration_secondary_throttle_options.h"
+#include "mongo/s/shard_id.h"
namespace mongo {
diff --git a/src/mongo/s/write_ops/batch_write_exec.cpp b/src/mongo/s/write_ops/batch_write_exec.cpp
index 757c4c29a69..509f242db11 100644
--- a/src/mongo/s/write_ops/batch_write_exec.cpp
+++ b/src/mongo/s/write_ops/batch_write_exec.cpp
@@ -286,8 +286,7 @@ void BatchWriteExec::executeBatch(OperationContext* opCtx,
if (responseStatus.isOK()) {
std::string errMsg;
if (!batchedCommandResponse.parseBSON(response.swResponse.getValue().data,
- &errMsg) ||
- !batchedCommandResponse.isValid(&errMsg)) {
+ &errMsg)) {
responseStatus = {ErrorCodes::FailedToParse, errMsg};
}
}
diff --git a/src/mongo/s/write_ops/batch_write_op.cpp b/src/mongo/s/write_ops/batch_write_op.cpp
index ecf57cd2e8f..e78924ae529 100644
--- a/src/mongo/s/write_ops/batch_write_op.cpp
+++ b/src/mongo/s/write_ops/batch_write_op.cpp
@@ -711,7 +711,6 @@ void BatchWriteOp::noteBatchError(const TargetedWriteBatch& targetedBatch,
emulatedResponse.addToErrDetails(errorClone.release());
}
- dassert(emulatedResponse.isValid(nullptr));
noteBatchResponse(targetedBatch, emulatedResponse, nullptr);
}
@@ -766,7 +765,6 @@ void BatchWriteOp::buildClientResponse(BatchedCommandResponse* batchResp) {
// For non-verbose, it's all we need.
if (!_clientRequest.isVerboseWC()) {
- dassert(batchResp->isValid(nullptr));
return;
}
@@ -844,8 +842,6 @@ void BatchWriteOp::buildClientResponse(BatchedCommandResponse* batchResp) {
_numModified >= 0) {
batchResp->setNModified(_numModified);
}
-
- dassert(batchResp->isValid(nullptr));
}
int BatchWriteOp::numWriteOpsIn(WriteOpState opState) const {
diff --git a/src/mongo/s/write_ops/batch_write_op_test.cpp b/src/mongo/s/write_ops/batch_write_op_test.cpp
index 7632d70a6ed..2d0012cbabb 100644
--- a/src/mongo/s/write_ops/batch_write_op_test.cpp
+++ b/src/mongo/s/write_ops/batch_write_op_test.cpp
@@ -86,14 +86,12 @@ void buildResponse(int n, BatchedCommandResponse* response) {
response->clear();
response->setStatus(Status::OK());
response->setN(n);
- ASSERT(response->isValid(nullptr));
}
void buildErrResponse(int code, const std::string& message, BatchedCommandResponse* response) {
response->clear();
response->setN(0);
response->setStatus({ErrorCodes::Error(code), message});
- ASSERT(response->isValid(nullptr));
}
void addError(int code, const std::string& message, int index, BatchedCommandResponse* response) {
diff --git a/src/mongo/s/write_ops/batched_command_response.cpp b/src/mongo/s/write_ops/batched_command_response.cpp
index e50bc74699f..fe010d2a235 100644
--- a/src/mongo/s/write_ops/batched_command_response.cpp
+++ b/src/mongo/s/write_ops/batched_command_response.cpp
@@ -64,21 +64,6 @@ BatchedCommandResponse::~BatchedCommandResponse() {
unsetUpsertDetails();
}
-bool BatchedCommandResponse::isValid(std::string* errMsg) const {
- std::string dummy;
- if (errMsg == nullptr) {
- errMsg = &dummy;
- }
-
- // All the mandatory fields must be present.
- if (!_isStatusSet) {
- *errMsg = stream() << "missing status fields";
- return false;
- }
-
- return true;
-}
-
BSONObj BatchedCommandResponse::toBSON() const {
BSONObjBuilder builder;
@@ -257,9 +242,6 @@ void BatchedCommandResponse::clear() {
_n = 0;
_isNSet = false;
- _singleUpserted = BSONObj();
- _isSingleUpsertedSet = false;
-
if (_upsertDetails.get()) {
for (std::vector<BatchedUpsertDetail*>::const_iterator it = _upsertDetails->begin();
it != _upsertDetails->end();
@@ -287,10 +269,6 @@ void BatchedCommandResponse::clear() {
_wcErrDetails.reset();
}
-std::string BatchedCommandResponse::toString() const {
- return toBSON().toString();
-}
-
void BatchedCommandResponse::setStatus(Status status) {
_status = std::move(status);
_isStatusSet = true;
@@ -301,14 +279,6 @@ void BatchedCommandResponse::setNModified(long long n) {
_isNModifiedSet = true;
}
-void BatchedCommandResponse::unsetNModified() {
- _isNModifiedSet = false;
-}
-
-bool BatchedCommandResponse::isNModified() const {
- return _isNModifiedSet;
-}
-
long long BatchedCommandResponse::getNModified() const {
if (_isNModifiedSet) {
return _nModified;
@@ -322,14 +292,6 @@ void BatchedCommandResponse::setN(long long n) {
_isNSet = true;
}
-void BatchedCommandResponse::unsetN() {
- _isNSet = false;
-}
-
-bool BatchedCommandResponse::isNSet() const {
- return _isNSet;
-}
-
long long BatchedCommandResponse::getN() const {
if (_isNSet) {
return _n;
@@ -393,10 +355,6 @@ void BatchedCommandResponse::setLastOp(repl::OpTime lastOp) {
_isLastOpSet = true;
}
-void BatchedCommandResponse::unsetLastOp() {
- _isLastOpSet = false;
-}
-
bool BatchedCommandResponse::isLastOpSet() const {
return _isLastOpSet;
}
@@ -411,10 +369,6 @@ void BatchedCommandResponse::setElectionId(const OID& electionId) {
_isElectionIdSet = true;
}
-void BatchedCommandResponse::unsetElectionId() {
- _isElectionIdSet = false;
-}
-
bool BatchedCommandResponse::isElectionIdSet() const {
return _isElectionIdSet;
}
@@ -466,10 +420,6 @@ void BatchedCommandResponse::setWriteConcernError(WriteConcernErrorDetail* error
_wcErrDetails.reset(error);
}
-void BatchedCommandResponse::unsetWriteConcernError() {
- _wcErrDetails.reset();
-}
-
bool BatchedCommandResponse::isWriteConcernErrorSet() const {
return _wcErrDetails.get();
}
diff --git a/src/mongo/s/write_ops/batched_command_response.h b/src/mongo/s/write_ops/batched_command_response.h
index e81b682f450..e93c2010fb2 100644
--- a/src/mongo/s/write_ops/batched_command_response.h
+++ b/src/mongo/s/write_ops/batched_command_response.h
@@ -50,10 +50,6 @@ class BatchedCommandResponse {
BatchedCommandResponse& operator=(const BatchedCommandResponse&) = delete;
public:
- //
- // schema declarations
- //
-
static const BSONField<long long> n;
static const BSONField<long long> nModified;
static const BSONField<std::vector<BatchedUpsertDetail*>> upsertDetails;
@@ -64,14 +60,13 @@ public:
BatchedCommandResponse();
~BatchedCommandResponse();
+
BatchedCommandResponse(BatchedCommandResponse&&) = default;
BatchedCommandResponse& operator=(BatchedCommandResponse&&) = default;
- bool isValid(std::string* errMsg) const;
BSONObj toBSON() const;
bool parseBSON(const BSONObj& source, std::string* errMsg);
void clear();
- std::string toString() const;
//
// individual field accessors
@@ -92,14 +87,15 @@ public:
return _status.isOK();
}
+ /**
+ * Converts the specified command response into a status, based on all of its contents.
+ */
+ Status toStatus() const;
+
void setNModified(long long n);
- void unsetNModified();
- bool isNModified() const;
long long getNModified() const;
void setN(long long n);
- void unsetN();
- bool isNSet() const;
long long getN() const;
void setUpsertDetails(const std::vector<BatchedUpsertDetail*>& upsertDetails);
@@ -111,12 +107,10 @@ public:
const BatchedUpsertDetail* getUpsertDetailsAt(std::size_t pos) const;
void setLastOp(repl::OpTime lastOp);
- void unsetLastOp();
bool isLastOpSet() const;
repl::OpTime getLastOp() const;
void setElectionId(const OID& electionId);
- void unsetElectionId();
bool isElectionIdSet() const;
OID getElectionId() const;
@@ -129,18 +123,12 @@ public:
const WriteErrorDetail* getErrDetailsAt(std::size_t pos) const;
void setWriteConcernError(WriteConcernErrorDetail* error);
- void unsetWriteConcernError();
bool isWriteConcernErrorSet() const;
const WriteConcernErrorDetail* getWriteConcernError() const;
bool isErrorLabelsSet() const;
const std::vector<std::string>& getErrorLabels() const;
- /**
- * Converts the specified command response into a status, based on all of its contents.
- */
- Status toStatus() const;
-
private:
// Convention: (M)andatory, (O)ptional
@@ -156,11 +144,6 @@ private:
long long _nModified;
bool _isNModifiedSet;
- // (O) "promoted" _upserted, if the corresponding request contained only one batch item
- // Should only be present if _upserted is not.
- BSONObj _singleUpserted;
- bool _isSingleUpsertedSet;
-
// (O) Array of upserted items' _id's
// Should only be present if _singleUpserted is not.
std::unique_ptr<std::vector<BatchedUpsertDetail*>> _upsertDetails;
diff --git a/src/mongo/s/write_ops/batched_upsert_detail.h b/src/mongo/s/write_ops/batched_upsert_detail.h
index c4eb49868f9..c012f2b906c 100644
--- a/src/mongo/s/write_ops/batched_upsert_detail.h
+++ b/src/mongo/s/write_ops/batched_upsert_detail.h
@@ -36,8 +36,8 @@
namespace mongo {
/**
- * This class represents the layout and content of an idem inside the 'upserted' array
- * of a write command's response (see batched_command_response.h)
+ * This class represents the layout and content of an idem inside the 'upserted' array of a write
+ * command's response (see BatchedCommandResponse).
*/
class BatchedUpsertDetail {
BatchedUpsertDetail(const BatchedUpsertDetail&) = delete;