summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/op_observer/SConscript1
-rw-r--r--src/mongo/db/op_observer/op_observer_impl.cpp7
-rw-r--r--src/mongo/db/op_observer/oplog_writer.h11
-rw-r--r--src/mongo/db/op_observer/oplog_writer_impl.cpp8
-rw-r--r--src/mongo/db/op_observer/oplog_writer_impl.h15
-rw-r--r--src/mongo/db/op_observer/oplog_writer_mock.h15
-rw-r--r--src/mongo/db/op_observer/oplog_writer_transaction_proxy.cpp4
-rw-r--r--src/mongo/db/op_observer/oplog_writer_transaction_proxy.h15
-rw-r--r--src/mongo/embedded/oplog_writer_embedded.h15
9 files changed, 43 insertions, 48 deletions
diff --git a/src/mongo/db/op_observer/SConscript b/src/mongo/db/op_observer/SConscript
index cd35f4fead5..708ee03379a 100644
--- a/src/mongo/db/op_observer/SConscript
+++ b/src/mongo/db/op_observer/SConscript
@@ -35,6 +35,7 @@ env.Library(
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/repl/oplog',
+ '$BUILD_DIR/mongo/db/shard_role_api',
],
)
diff --git a/src/mongo/db/op_observer/op_observer_impl.cpp b/src/mongo/db/op_observer/op_observer_impl.cpp
index 39a4c11f07a..22b7facdede 100644
--- a/src/mongo/db/op_observer/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer/op_observer_impl.cpp
@@ -628,11 +628,6 @@ void OpObserverImpl::onInserts(OperationContext* opCtx,
txnParticipant.addTransactionOperation(opCtx, operation);
}
} else {
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn =
- [&shardingWriteRouter](const BSONObj& doc) {
- return shardingWriteRouter.getReshardingDestinedRecipient(doc);
- };
-
// Ensure well-formed embedded ReplOperation for logging.
// This means setting optype, nss, and object at the minimum.
MutableOplogEntry oplogEntryTemplate;
@@ -650,7 +645,7 @@ void OpObserverImpl::onInserts(OperationContext* opCtx,
first,
last,
std::move(fromMigrate),
- getDestinedRecipientFn,
+ shardingWriteRouter,
coll);
if (!opTimeList.empty())
lastOpTime = opTimeList.back();
diff --git a/src/mongo/db/op_observer/oplog_writer.h b/src/mongo/db/op_observer/oplog_writer.h
index d038c0fa8f4..cb804858198 100644
--- a/src/mongo/db/op_observer/oplog_writer.h
+++ b/src/mongo/db/op_observer/oplog_writer.h
@@ -29,17 +29,14 @@
#pragma once
-#include <boost/optional.hpp>
#include <cstddef> // for std::size_t
-#include <functional>
#include <vector>
-#include "mongo/bson/bsonobj.h"
#include "mongo/db/operation_context.h"
-#include "mongo/db/repl/oplog.h" // for InsertStatement and OplogLink
-#include "mongo/db/repl/oplog_entry.h" // for MutableOplogEntry
+#include "mongo/db/repl/oplog.h" // for InsertStatement and OplogLink
+#include "mongo/db/repl/oplog_entry.h" // for MutableOplogEntry
+#include "mongo/db/s/sharding_write_router.h"
#include "mongo/db/session/logical_session_id.h" // for StmtId
-#include "mongo/db/shard_id.h"
namespace mongo {
@@ -81,7 +78,7 @@ public:
std::vector<InsertStatement>::const_iterator begin,
std::vector<InsertStatement>::const_iterator end,
std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
+ const ShardingWriteRouter& shardingWriteRouter,
const CollectionPtr& collectionPtr) = 0;
/**
diff --git a/src/mongo/db/op_observer/oplog_writer_impl.cpp b/src/mongo/db/op_observer/oplog_writer_impl.cpp
index 3bb4e13512e..6c272491f5b 100644
--- a/src/mongo/db/op_observer/oplog_writer_impl.cpp
+++ b/src/mongo/db/op_observer/oplog_writer_impl.cpp
@@ -46,8 +46,14 @@ std::vector<repl::OpTime> OplogWriterImpl::logInsertOps(
std::vector<InsertStatement>::const_iterator begin,
std::vector<InsertStatement>::const_iterator end,
std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
+ const ShardingWriteRouter& shardingWriteRouter,
const CollectionPtr& collectionPtr) {
+
+ std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn =
+ [&shardingWriteRouter](const BSONObj& doc) {
+ return shardingWriteRouter.getReshardingDestinedRecipient(doc);
+ };
+
return repl::logInsertOps(
opCtx, oplogEntryTemplate, begin, end, fromMigrate, getDestinedRecipientFn, collectionPtr);
}
diff --git a/src/mongo/db/op_observer/oplog_writer_impl.h b/src/mongo/db/op_observer/oplog_writer_impl.h
index 24071c4e015..6497d18898d 100644
--- a/src/mongo/db/op_observer/oplog_writer_impl.h
+++ b/src/mongo/db/op_observer/oplog_writer_impl.h
@@ -46,14 +46,13 @@ public:
repl::OplogLink* oplogLink,
const std::vector<StmtId>& stmtIds) override;
- std::vector<repl::OpTime> logInsertOps(
- OperationContext* opCtx,
- repl::MutableOplogEntry* oplogEntryTemplate,
- std::vector<InsertStatement>::const_iterator begin,
- std::vector<InsertStatement>::const_iterator end,
- std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
- const CollectionPtr& collectionPtr) override;
+ std::vector<repl::OpTime> logInsertOps(OperationContext* opCtx,
+ repl::MutableOplogEntry* oplogEntryTemplate,
+ std::vector<InsertStatement>::const_iterator begin,
+ std::vector<InsertStatement>::const_iterator end,
+ std::vector<bool> fromMigrate,
+ const ShardingWriteRouter& shardingWriteRouter,
+ const CollectionPtr& collectionPtr) override;
repl::OpTime logOp(OperationContext* opCtx, repl::MutableOplogEntry* oplogEntry) override;
diff --git a/src/mongo/db/op_observer/oplog_writer_mock.h b/src/mongo/db/op_observer/oplog_writer_mock.h
index 5acdab44907..0018b651960 100644
--- a/src/mongo/db/op_observer/oplog_writer_mock.h
+++ b/src/mongo/db/op_observer/oplog_writer_mock.h
@@ -46,14 +46,13 @@ public:
repl::OplogLink* oplogLink,
const std::vector<StmtId>& stmtIds) override {}
- std::vector<repl::OpTime> logInsertOps(
- OperationContext* opCtx,
- repl::MutableOplogEntry* oplogEntryTemplate,
- std::vector<InsertStatement>::const_iterator begin,
- std::vector<InsertStatement>::const_iterator end,
- std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
- const CollectionPtr& collectionPtr) override {
+ std::vector<repl::OpTime> logInsertOps(OperationContext* opCtx,
+ repl::MutableOplogEntry* oplogEntryTemplate,
+ std::vector<InsertStatement>::const_iterator begin,
+ std::vector<InsertStatement>::const_iterator end,
+ std::vector<bool> fromMigrate,
+ const ShardingWriteRouter& shardingWriteRouter,
+ const CollectionPtr& collectionPtr) override {
return {};
}
diff --git a/src/mongo/db/op_observer/oplog_writer_transaction_proxy.cpp b/src/mongo/db/op_observer/oplog_writer_transaction_proxy.cpp
index 677d7c34cae..832e0a983b0 100644
--- a/src/mongo/db/op_observer/oplog_writer_transaction_proxy.cpp
+++ b/src/mongo/db/op_observer/oplog_writer_transaction_proxy.cpp
@@ -48,14 +48,14 @@ std::vector<repl::OpTime> OplogWriterTransactionProxy::logInsertOps(
std::vector<InsertStatement>::const_iterator begin,
std::vector<InsertStatement>::const_iterator end,
std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
+ const ShardingWriteRouter& shardingWriteRouter,
const CollectionPtr& collectionPtr) {
return _targetOplogWriter->logInsertOps(opCtx,
oplogEntryTemplate,
begin,
end,
std::move(fromMigrate),
- getDestinedRecipientFn,
+ shardingWriteRouter,
collectionPtr);
}
diff --git a/src/mongo/db/op_observer/oplog_writer_transaction_proxy.h b/src/mongo/db/op_observer/oplog_writer_transaction_proxy.h
index b6a2cee4c8b..fc0a2c7ee4d 100644
--- a/src/mongo/db/op_observer/oplog_writer_transaction_proxy.h
+++ b/src/mongo/db/op_observer/oplog_writer_transaction_proxy.h
@@ -53,14 +53,13 @@ public:
repl::OplogLink* oplogLink,
const std::vector<StmtId>& stmtIds) override;
- std::vector<repl::OpTime> logInsertOps(
- OperationContext* opCtx,
- repl::MutableOplogEntry* oplogEntryTemplate,
- std::vector<InsertStatement>::const_iterator begin,
- std::vector<InsertStatement>::const_iterator end,
- std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
- const CollectionPtr& collectionPtr) override;
+ std::vector<repl::OpTime> logInsertOps(OperationContext* opCtx,
+ repl::MutableOplogEntry* oplogEntryTemplate,
+ std::vector<InsertStatement>::const_iterator begin,
+ std::vector<InsertStatement>::const_iterator end,
+ std::vector<bool> fromMigrate,
+ const ShardingWriteRouter& shardingWriteRouter,
+ const CollectionPtr& collectionPtr) override;
repl::OpTime logOp(OperationContext* opCtx, repl::MutableOplogEntry* oplogEntry) override;
diff --git a/src/mongo/embedded/oplog_writer_embedded.h b/src/mongo/embedded/oplog_writer_embedded.h
index cd7fd0fb12a..f87ded553c3 100644
--- a/src/mongo/embedded/oplog_writer_embedded.h
+++ b/src/mongo/embedded/oplog_writer_embedded.h
@@ -46,14 +46,13 @@ public:
repl::OplogLink* oplogLink,
const std::vector<StmtId>& stmtIds) override {}
- std::vector<repl::OpTime> logInsertOps(
- OperationContext* opCtx,
- repl::MutableOplogEntry* oplogEntryTemplate,
- std::vector<InsertStatement>::const_iterator begin,
- std::vector<InsertStatement>::const_iterator end,
- std::vector<bool> fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
- const CollectionPtr& collectionPtr) override {
+ std::vector<repl::OpTime> logInsertOps(OperationContext* opCtx,
+ repl::MutableOplogEntry* oplogEntryTemplate,
+ std::vector<InsertStatement>::const_iterator begin,
+ std::vector<InsertStatement>::const_iterator end,
+ std::vector<bool> fromMigrate,
+ const ShardingWriteRouter& shardingWriteRouter,
+ const CollectionPtr& collectionPtr) override {
return {};
}