summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-07-07 17:57:48 -0400
committerBenety Goh <benety@mongodb.com>2016-07-11 16:18:06 -0400
commit8ba242d0eb3b0276977a2c94059427c8101851d6 (patch)
tree78b1cf0b5852f93105b989142c9812916a4486bf /src
parent01fffc205a72311405ad97151364daf894f3c667 (diff)
downloadmongo-8ba242d0eb3b0276977a2c94059427c8101851d6.tar.gz
SERVER-24945 convert DatabasesCloner to use TaskExecutor
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/SConscript6
-rw-r--r--src/mongo/db/repl/databases_cloner.cpp2
-rw-r--r--src/mongo/db/repl/databases_cloner.h10
-rw-r--r--src/mongo/db/repl/databases_cloner_test.cpp20
4 files changed, 20 insertions, 18 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index a77dc406882..3c140167fa6 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -799,7 +799,11 @@ env.CppUnitTest(
LIBDEPS=[
'databases_cloner',
'oplog_entry',
- 'replication_executor_test_fixture',
+ 'replmocks',
+ '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
+ '$BUILD_DIR/mongo/db/commands_test_crutch',
+ '$BUILD_DIR/mongo/db/service_context_noop_init',
+ '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture',
],
)
diff --git a/src/mongo/db/repl/databases_cloner.cpp b/src/mongo/db/repl/databases_cloner.cpp
index d505972e84a..8bb003ad843 100644
--- a/src/mongo/db/repl/databases_cloner.cpp
+++ b/src/mongo/db/repl/databases_cloner.cpp
@@ -63,7 +63,7 @@ const size_t numListDatabasesRetries = 1;
DatabasesCloner::DatabasesCloner(StorageInterface* si,
- ReplicationExecutor* exec,
+ executor::TaskExecutor* exec,
HostAndPort source,
IncludeDbFilterFn includeDbPred,
OnFinishFn finishFn)
diff --git a/src/mongo/db/repl/databases_cloner.h b/src/mongo/db/repl/databases_cloner.h
index 05d0da09f83..b9189052446 100644
--- a/src/mongo/db/repl/databases_cloner.h
+++ b/src/mongo/db/repl/databases_cloner.h
@@ -40,7 +40,7 @@
#include "mongo/db/repl/base_cloner.h"
#include "mongo/db/repl/collection_cloner.h"
#include "mongo/db/repl/database_cloner.h"
-#include "mongo/db/repl/replication_executor.h"
+#include "mongo/executor/task_executor.h"
#include "mongo/stdx/condition_variable.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/net/hostandport.h"
@@ -49,8 +49,8 @@ namespace mongo {
namespace repl {
namespace {
-using CBHStatus = StatusWith<ReplicationExecutor::CallbackHandle>;
-using CommandCallbackArgs = ReplicationExecutor::RemoteCommandCallbackArgs;
+using CBHStatus = StatusWith<executor::TaskExecutor::CallbackHandle>;
+using CommandCallbackArgs = executor::TaskExecutor::RemoteCommandCallbackArgs;
using UniqueLock = stdx::unique_lock<stdx::mutex>;
} // namespace.
@@ -63,7 +63,7 @@ public:
using IncludeDbFilterFn = stdx::function<bool(const BSONObj& dbInfo)>;
using OnFinishFn = stdx::function<void(const Status&)>;
DatabasesCloner(StorageInterface* si,
- ReplicationExecutor* exec,
+ executor::TaskExecutor* exec,
HostAndPort source,
IncludeDbFilterFn includeDbPred,
OnFinishFn finishFn);
@@ -111,7 +111,7 @@ private:
//
mutable stdx::mutex _mutex; // (S)
Status _status{ErrorCodes::NotYetInitialized, ""}; // (M) If it is not OK, we stop everything.
- ReplicationExecutor* _exec; // (R) executor to schedule things with
+ executor::TaskExecutor* _exec; // (R) executor to schedule things with
HostAndPort _source; // (R) The source to use, until we get an error
bool _active = false; // (M) false until we start
std::vector<std::shared_ptr<DatabaseCloner>> _databaseCloners; // (M) database cloners by name
diff --git a/src/mongo/db/repl/databases_cloner_test.cpp b/src/mongo/db/repl/databases_cloner_test.cpp
index 8a5d964dcff..23e24ad28c6 100644
--- a/src/mongo/db/repl/databases_cloner_test.cpp
+++ b/src/mongo/db/repl/databases_cloner_test.cpp
@@ -39,7 +39,6 @@
#include "mongo/db/repl/oplog_entry.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_executor.h"
-#include "mongo/db/repl/replication_executor_test_fixture.h"
#include "mongo/db/repl/reporter.h"
#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/repl/storage_interface_mock.h"
@@ -47,6 +46,7 @@
#include "mongo/db/repl/sync_source_selector.h"
#include "mongo/db/repl/update_position_args.h"
#include "mongo/executor/network_interface_mock.h"
+#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/fail_point_service.h"
@@ -84,12 +84,10 @@ struct StorageInterfaceResults {
};
-class DBsClonerTest : public ReplicationExecutorTest {
+class DBsClonerTest : public executor::ThreadPoolExecutorTest {
public:
DBsClonerTest() : _storageInterface{} {}
- void postExecutorThreadLaunch() override{};
-
StorageInterface& getStorage() {
return _storageInterface;
}
@@ -108,7 +106,7 @@ public:
NetworkInterfaceMock* net = getNet();
Milliseconds millis(0);
RemoteCommandResponse response(obj, BSONObj(), millis);
- ReplicationExecutor::ResponseStatus responseStatus(response);
+ executor::TaskExecutor::ResponseStatus responseStatus(response);
net->scheduleResponse(noi, net->now(), responseStatus);
}
@@ -143,7 +141,7 @@ public:
protected:
void setUp() override {
- ReplicationExecutorTest::setUp();
+ executor::ThreadPoolExecutorTest::setUp();
launchExecutorThread();
_storageInterface.createOplogFn = [this](OperationContext* txn,
@@ -189,7 +187,7 @@ protected:
}
void tearDown() override {
- ReplicationExecutorTest::tearDown();
+ executor::ThreadPoolExecutorTest::tearDown();
}
/**
@@ -283,7 +281,7 @@ protected:
stdx::mutex mutex;
stdx::condition_variable cvDone;
DatabasesCloner cloner{&getStorage(),
- &getReplExecutor(),
+ &getExecutor(),
HostAndPort{"local:1234"},
[](const BSONObj&) { return true; },
[&](const Status& status) {
@@ -321,7 +319,7 @@ TEST_F(DBsClonerTest, FailsOnListDatabases) {
Status result{Status::OK()};
Status expectedResult{ErrorCodes::BadValue, "foo"};
DatabasesCloner cloner{&getStorage(),
- &getReplExecutor(),
+ &getExecutor(),
HostAndPort{"local:1234"},
[](const BSONObj&) { return true; },
[&result](const Status& status) {
@@ -341,7 +339,7 @@ TEST_F(DBsClonerTest, FailsOnListDatabases) {
TEST_F(DBsClonerTest, FailsOnListCollectionsOnOnlyDatabase) {
Status result{Status::OK()};
DatabasesCloner cloner{&getStorage(),
- &getReplExecutor(),
+ &getExecutor(),
HostAndPort{"local:1234"},
[](const BSONObj&) { return true; },
[&result](const Status& status) {
@@ -369,7 +367,7 @@ TEST_F(DBsClonerTest, FailsOnListCollectionsOnFirstOfTwoDatabases) {
Status result{Status::OK()};
Status expectedStatus{ErrorCodes::NoSuchKey, "fake"};
DatabasesCloner cloner{&getStorage(),
- &getReplExecutor(),
+ &getExecutor(),
HostAndPort{"local:1234"},
[](const BSONObj&) { return true; },
[&result](const Status& status) {