summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-07-16 13:55:15 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-07-17 10:20:27 -0400
commita104bc1eab07388a4dc5b9930ecdd355ea93dd87 (patch)
treedafa61a7a1b1d5cb1e38a1c80c067c5ad30b7da2
parentd7e9b92a8117edab8869c132a4f7bfae3d3ff2ff (diff)
downloadmongo-a104bc1eab07388a4dc5b9930ecdd355ea93dd87.tar.gz
SERVER-19001 Move RemoteCommandRequest/RemoteCommandResponse into task_executor_interface library.
Also, move those types into the executor namespace and remove the RemoteCommandRunner interface type.
-rw-r--r--src/mongo/client/SConscript22
-rw-r--r--src/mongo/client/fetcher.cpp4
-rw-r--r--src/mongo/client/fetcher_test.cpp4
-rw-r--r--src/mongo/client/remote_command_runner.h70
-rw-r--r--src/mongo/client/remote_command_runner_impl.cpp3
-rw-r--r--src/mongo/client/remote_command_runner_impl.h11
-rw-r--r--src/mongo/db/SConscript1
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/base_cloner_test_fixture.cpp3
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change.cpp2
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change.h6
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change_test.cpp2
-rw-r--r--src/mongo/db/repl/data_replicator.h4
-rw-r--r--src/mongo/db/repl/data_replicator_test.cpp2
-rw-r--r--src/mongo/db/repl/elect_cmd_runner.cpp2
-rw-r--r--src/mongo/db/repl/elect_cmd_runner.h4
-rw-r--r--src/mongo/db/repl/elect_cmd_runner_test.cpp2
-rw-r--r--src/mongo/db/repl/election_winner_declarer.cpp2
-rw-r--r--src/mongo/db/repl/election_winner_declarer.h4
-rw-r--r--src/mongo/db/repl/election_winner_declarer_test.cpp2
-rw-r--r--src/mongo/db/repl/freshness_checker.cpp2
-rw-r--r--src/mongo/db/repl/freshness_checker.h4
-rw-r--r--src/mongo/db/repl/freshness_checker_test.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp3
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp3
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/replication_executor.cpp2
-rw-r--r--src/mongo/db/repl/replication_executor.h7
-rw-r--r--src/mongo/db/repl/replication_executor_test_fixture.h1
-rw-r--r--src/mongo/db/repl/reporter.cpp2
-rw-r--r--src/mongo/db/repl/reporter_test.cpp2
-rw-r--r--src/mongo/db/repl/scatter_gather_algorithm.h4
-rw-r--r--src/mongo/db/repl/scatter_gather_runner.cpp2
-rw-r--r--src/mongo/db/repl/scatter_gather_test.cpp2
-rw-r--r--src/mongo/db/repl/vote_requester.cpp2
-rw-r--r--src/mongo/db/repl/vote_requester.h4
-rw-r--r--src/mongo/db/repl/vote_requester_test.cpp4
-rw-r--r--src/mongo/executor/SConscript11
-rw-r--r--src/mongo/executor/network_interface_asio.h3
-rw-r--r--src/mongo/executor/network_test_env.h1
-rw-r--r--src/mongo/executor/remote_command_request.cpp (renamed from src/mongo/client/remote_command_runner.cpp)12
-rw-r--r--src/mongo/executor/remote_command_request.h88
-rw-r--r--src/mongo/executor/remote_command_response.cpp44
-rw-r--r--src/mongo/executor/remote_command_response.h57
-rw-r--r--src/mongo/executor/task_executor.h3
-rw-r--r--src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_add_shard_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_log_action_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp2
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h1
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_upgrade_test.cpp2
-rw-r--r--src/mongo/s/client/shard_registry.cpp4
-rw-r--r--src/mongo/s/query/async_cluster_client_cursor.cpp7
-rw-r--r--src/mongo/s/query/async_cluster_client_cursor.h4
-rw-r--r--src/mongo/s/query/async_cluster_client_cursor_test.cpp3
64 files changed, 332 insertions, 133 deletions
diff --git a/src/mongo/client/SConscript b/src/mongo/client/SConscript
index 51c93d81ae9..265dc22e2c2 100644
--- a/src/mongo/client/SConscript
+++ b/src/mongo/client/SConscript
@@ -94,31 +94,21 @@ env.Library(
)
env.Library(
- target='remote_command_runner',
- source=[
- 'remote_command_runner.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/bson/bson',
- '$BUILD_DIR/mongo/db/common',
- '$BUILD_DIR/mongo/rpc/metadata',
- '$BUILD_DIR/mongo/util/foundation',
- '$BUILD_DIR/mongo/util/net/hostandport',
- ]
-)
-
-env.Library(
target='remote_command_runner_impl',
source=[
'remote_command_runner_impl.cpp',
],
LIBDEPS=[
- 'connection_pool',
- 'remote_command_runner',
+ '$BUILD_DIR/mongo/bson/bson',
+ '$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/query/command_request_response',
'$BUILD_DIR/mongo/db/query/lite_parsed_query',
+ '$BUILD_DIR/mongo/executor/task_executor_interface',
'$BUILD_DIR/mongo/rpc/metadata',
'$BUILD_DIR/mongo/rpc/protocol',
+ '$BUILD_DIR/mongo/util/foundation',
+ '$BUILD_DIR/mongo/util/net/hostandport',
+ 'connection_pool',
]
)
diff --git a/src/mongo/client/fetcher.cpp b/src/mongo/client/fetcher.cpp
index 48a0dfe35a1..986e483ffff 100644
--- a/src/mongo/client/fetcher.cpp
+++ b/src/mongo/client/fetcher.cpp
@@ -41,6 +41,10 @@
namespace mongo {
namespace {
+
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
+
using RemoteCommandCallbackArgs = executor::TaskExecutor::RemoteCommandCallbackArgs;
const char* kCursorFieldName = "cursor";
const char* kCursorIdFieldName = "id";
diff --git a/src/mongo/client/fetcher_test.cpp b/src/mongo/client/fetcher_test.cpp
index 65ec00395e0..ba3360b5903 100644
--- a/src/mongo/client/fetcher_test.cpp
+++ b/src/mongo/client/fetcher_test.cpp
@@ -128,7 +128,7 @@ void FetcherTest::scheduleNetworkResponse(const BSONObj& obj) {
void FetcherTest::scheduleNetworkResponse(const BSONObj& obj, Milliseconds millis) {
NetworkInterfaceMock* net = getNet();
ASSERT_TRUE(net->hasReadyRequests());
- RemoteCommandResponse response(obj, BSONObj(), millis);
+ executor::RemoteCommandResponse response(obj, BSONObj(), millis);
TaskExecutor::ResponseStatus responseStatus(response);
net->scheduleResponse(net->getNextReadyRequest(), net->now(), responseStatus);
}
@@ -137,7 +137,7 @@ void FetcherTest::scheduleNetworkResponseFor(const BSONObj& filter, const BSONOb
NetworkInterfaceMock* net = getNet();
ASSERT_TRUE(net->hasReadyRequests());
Milliseconds millis(0);
- RemoteCommandResponse response(obj, BSONObj(), millis);
+ executor::RemoteCommandResponse response(obj, BSONObj(), millis);
TaskExecutor::ResponseStatus responseStatus(response);
auto req = net->getNextReadyRequest();
ASSERT_EQ(req->getRequest().cmdObj[0], filter[0]);
diff --git a/src/mongo/client/remote_command_runner.h b/src/mongo/client/remote_command_runner.h
index 26beca31497..0c83fd59508 100644
--- a/src/mongo/client/remote_command_runner.h
+++ b/src/mongo/client/remote_command_runner.h
@@ -32,6 +32,8 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/db/jsobj.h"
+#include "mongo/executor/remote_command_request.h"
+#include "mongo/executor/remote_command_response.h"
#include "mongo/rpc/metadata.h"
#include "mongo/util/net/hostandport.h"
#include "mongo/util/time_support.h"
@@ -41,72 +43,8 @@ namespace mongo {
template <typename T>
class StatusWith;
-/**
- * Type of object describing a command to execute against a remote MongoDB node.
- */
-struct RemoteCommandRequest {
- // Indicates that there is no timeout for the request to complete
- static const Milliseconds kNoTimeout;
-
- // Indicates that there is no expiration time by when the request needs to complete
- static const Date_t kNoExpirationDate;
-
- RemoteCommandRequest() : timeout(kNoTimeout), expirationDate(kNoExpirationDate) {}
-
- RemoteCommandRequest(const HostAndPort& theTarget,
- const std::string& theDbName,
- const BSONObj& theCmdObj,
- const BSONObj& metadataObj,
- const Milliseconds timeoutMillis = kNoTimeout)
- : target(theTarget),
- dbname(theDbName),
- metadata(metadataObj),
- cmdObj(theCmdObj),
- timeout(timeoutMillis) {
- if (timeoutMillis == kNoTimeout) {
- expirationDate = kNoExpirationDate;
- }
- }
-
- RemoteCommandRequest(const HostAndPort& theTarget,
- const std::string& theDbName,
- const BSONObj& theCmdObj,
- const Milliseconds timeoutMillis = kNoTimeout)
- : target(theTarget), dbname(theDbName), cmdObj(theCmdObj), timeout(timeoutMillis) {
- if (timeoutMillis == kNoTimeout) {
- expirationDate = kNoExpirationDate;
- }
- }
-
- std::string toString() const;
-
- HostAndPort target;
- std::string dbname;
- BSONObj metadata{rpc::makeEmptyMetadata()};
- BSONObj cmdObj;
- Milliseconds timeout;
-
- // Deadline by when the request must be completed
- Date_t expirationDate;
-};
-
-
-/**
- * Type of object describing the response of previously sent RemoteCommandRequest.
- */
-struct RemoteCommandResponse {
- RemoteCommandResponse() : data(), elapsedMillis(Milliseconds(0)) {}
-
- RemoteCommandResponse(BSONObj dataObj, BSONObj metadataObj, Milliseconds millis)
- : data(std::move(dataObj)), metadata(std::move(metadataObj)), elapsedMillis(millis) {}
-
- std::string toString() const;
-
- BSONObj data;
- BSONObj metadata;
- Milliseconds elapsedMillis;
-};
-
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
/**
* Abstract interface used for executing commands against a MongoDB instance and retrieving
diff --git a/src/mongo/client/remote_command_runner_impl.cpp b/src/mongo/client/remote_command_runner_impl.cpp
index 88742d1e61f..063ec931784 100644
--- a/src/mongo/client/remote_command_runner_impl.cpp
+++ b/src/mongo/client/remote_command_runner_impl.cpp
@@ -42,6 +42,9 @@
namespace mongo {
namespace {
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
+
/**
* Calculates the timeout for a network operation expiring at "expDate", given
* that it is now "nowDate".
diff --git a/src/mongo/client/remote_command_runner_impl.h b/src/mongo/client/remote_command_runner_impl.h
index 2f763e5ffc7..258bd3804a9 100644
--- a/src/mongo/client/remote_command_runner_impl.h
+++ b/src/mongo/client/remote_command_runner_impl.h
@@ -29,11 +29,15 @@
#pragma once
#include "mongo/client/connection_pool.h"
-#include "mongo/client/remote_command_runner.h"
+#include "mongo/executor/remote_command_request.h"
+#include "mongo/executor/remote_command_response.h"
namespace mongo {
-class RemoteCommandRunnerImpl : public RemoteCommandRunner {
+template <typename T>
+class StatusWith;
+
+class RemoteCommandRunnerImpl {
public:
RemoteCommandRunnerImpl(int messagingPortTags);
virtual ~RemoteCommandRunnerImpl();
@@ -43,7 +47,8 @@ public:
*/
void shutdown();
- virtual StatusWith<RemoteCommandResponse> runCommand(const RemoteCommandRequest& request);
+ virtual StatusWith<executor::RemoteCommandResponse> runCommand(
+ const executor::RemoteCommandRequest& request);
private:
// The connection pool on which to send requests
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 13e35745d2d..920e08ca950 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -430,7 +430,6 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/client/clientdriver',
- '$BUILD_DIR/mongo/client/remote_command_runner',
'$BUILD_DIR/mongo/logger/parse_log_component_settings',
'$BUILD_DIR/mongo/scripting/scripting_common',
'$BUILD_DIR/mongo/util/cmdline_utils/cmdline_utils',
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index dfd9127b3c6..660198f7f47 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -61,7 +61,6 @@ env.Library(
'database_task',
'task_runner',
'storage_interface',
- '$BUILD_DIR/mongo/client/remote_command_runner',
'$BUILD_DIR/mongo/executor/network_interface',
'$BUILD_DIR/mongo/executor/task_executor_interface',
'$BUILD_DIR/mongo/util/foundation',
diff --git a/src/mongo/db/repl/base_cloner_test_fixture.cpp b/src/mongo/db/repl/base_cloner_test_fixture.cpp
index 2c0a4a126b6..ea57b00133a 100644
--- a/src/mongo/db/repl/base_cloner_test_fixture.cpp
+++ b/src/mongo/db/repl/base_cloner_test_fixture.cpp
@@ -38,6 +38,9 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
+
const HostAndPort BaseClonerTest::target("localhost", -1);
const NamespaceString BaseClonerTest::nss("db.coll");
const BSONObj BaseClonerTest::idIndexSpec = BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
diff --git a/src/mongo/db/repl/check_quorum_for_config_change.cpp b/src/mongo/db/repl/check_quorum_for_config_change.cpp
index 437dca34701..4d944c9101d 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change.cpp
+++ b/src/mongo/db/repl/check_quorum_for_config_change.cpp
@@ -45,6 +45,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
QuorumChecker::QuorumChecker(const ReplicaSetConfig* rsConfig, int myIndex)
: _rsConfig(rsConfig),
_myIndex(myIndex),
diff --git a/src/mongo/db/repl/check_quorum_for_config_change.h b/src/mongo/db/repl/check_quorum_for_config_change.h
index 5d33c01f4c1..f5cc2795281 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change.h
+++ b/src/mongo/db/repl/check_quorum_for_config_change.h
@@ -60,8 +60,8 @@ public:
QuorumChecker(const ReplicaSetConfig* rsConfig, int myIndex);
virtual ~QuorumChecker();
- virtual std::vector<RemoteCommandRequest> getRequests() const;
- virtual void processResponse(const RemoteCommandRequest& request,
+ virtual std::vector<executor::RemoteCommandRequest> getRequests() const;
+ virtual void processResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response);
virtual bool hasReceivedSufficientResponses() const;
@@ -82,7 +82,7 @@ private:
/**
* Updates the QuorumChecker state based on the data from a single heartbeat response.
*/
- void _tabulateHeartbeatResponse(const RemoteCommandRequest& request,
+ void _tabulateHeartbeatResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response);
// Pointer to the replica set configuration for which we're checking quorum.
diff --git a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp
index cd39fecf18b..475992e83fe 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp
+++ b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp
@@ -64,6 +64,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class CheckQuorumTest : public mongo::unittest::Test {
protected:
diff --git a/src/mongo/db/repl/data_replicator.h b/src/mongo/db/repl/data_replicator.h
index bff81058859..bd3fd86101e 100644
--- a/src/mongo/db/repl/data_replicator.h
+++ b/src/mongo/db/repl/data_replicator.h
@@ -65,8 +65,8 @@ using Event = ReplicationExecutor::EventHandle;
using Handle = ReplicationExecutor::CallbackHandle;
using LockGuard = stdx::lock_guard<stdx::mutex>;
using NextAction = Fetcher::NextAction;
-using Request = RemoteCommandRequest;
-using Response = RemoteCommandResponse;
+using Request = executor::RemoteCommandRequest;
+using Response = executor::RemoteCommandResponse;
using TimestampStatus = StatusWith<Timestamp>;
using UniqueLock = stdx::unique_lock<stdx::mutex>;
diff --git a/src/mongo/db/repl/data_replicator_test.cpp b/src/mongo/db/repl/data_replicator_test.cpp
index e28b3b1fd1e..d6c5dadfacc 100644
--- a/src/mongo/db/repl/data_replicator_test.cpp
+++ b/src/mongo/db/repl/data_replicator_test.cpp
@@ -56,6 +56,8 @@ namespace {
using namespace mongo;
using namespace mongo::repl;
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using LockGuard = stdx::lock_guard<stdx::mutex>;
using UniqueLock = stdx::unique_lock<stdx::mutex>;
using mutex = stdx::mutex;
diff --git a/src/mongo/db/repl/elect_cmd_runner.cpp b/src/mongo/db/repl/elect_cmd_runner.cpp
index c0d958c428e..15bf827b1da 100644
--- a/src/mongo/db/repl/elect_cmd_runner.cpp
+++ b/src/mongo/db/repl/elect_cmd_runner.cpp
@@ -42,6 +42,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
ElectCmdRunner::Algorithm::Algorithm(const ReplicaSetConfig& rsConfig,
int selfIndex,
const std::vector<HostAndPort>& targets,
diff --git a/src/mongo/db/repl/elect_cmd_runner.h b/src/mongo/db/repl/elect_cmd_runner.h
index 21295991f26..ad12703b68e 100644
--- a/src/mongo/db/repl/elect_cmd_runner.h
+++ b/src/mongo/db/repl/elect_cmd_runner.h
@@ -57,8 +57,8 @@ public:
OID round);
virtual ~Algorithm();
- virtual std::vector<RemoteCommandRequest> getRequests() const;
- virtual void processResponse(const RemoteCommandRequest& request,
+ virtual std::vector<executor::RemoteCommandRequest> getRequests() const;
+ virtual void processResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response);
virtual bool hasReceivedSufficientResponses() const;
diff --git a/src/mongo/db/repl/elect_cmd_runner_test.cpp b/src/mongo/db/repl/elect_cmd_runner_test.cpp
index 561fa8e5b1f..5635f177cc0 100644
--- a/src/mongo/db/repl/elect_cmd_runner_test.cpp
+++ b/src/mongo/db/repl/elect_cmd_runner_test.cpp
@@ -48,6 +48,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class ElectCmdRunnerTest : public mongo::unittest::Test {
public:
diff --git a/src/mongo/db/repl/election_winner_declarer.cpp b/src/mongo/db/repl/election_winner_declarer.cpp
index 55016dc373a..9cb43a4c54b 100644
--- a/src/mongo/db/repl/election_winner_declarer.cpp
+++ b/src/mongo/db/repl/election_winner_declarer.cpp
@@ -41,6 +41,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
ElectionWinnerDeclarer::Algorithm::Algorithm(const std::string& setName,
long long winnerId,
long long term,
diff --git a/src/mongo/db/repl/election_winner_declarer.h b/src/mongo/db/repl/election_winner_declarer.h
index 8c5fa995880..c73f2ca3419 100644
--- a/src/mongo/db/repl/election_winner_declarer.h
+++ b/src/mongo/db/repl/election_winner_declarer.h
@@ -57,8 +57,8 @@ public:
long long term,
const std::vector<HostAndPort>& targets);
virtual ~Algorithm();
- virtual std::vector<RemoteCommandRequest> getRequests() const;
- virtual void processResponse(const RemoteCommandRequest& request,
+ virtual std::vector<executor::RemoteCommandRequest> getRequests() const;
+ virtual void processResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response);
virtual bool hasReceivedSufficientResponses() const;
diff --git a/src/mongo/db/repl/election_winner_declarer_test.cpp b/src/mongo/db/repl/election_winner_declarer_test.cpp
index f1bdb7e5af7..ce7cf5f7952 100644
--- a/src/mongo/db/repl/election_winner_declarer_test.cpp
+++ b/src/mongo/db/repl/election_winner_declarer_test.cpp
@@ -45,6 +45,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using unittest::assertGet;
bool stringContains(const std::string& haystack, const std::string& needle) {
diff --git a/src/mongo/db/repl/freshness_checker.cpp b/src/mongo/db/repl/freshness_checker.cpp
index ca1d665dd81..71b7b2e419b 100644
--- a/src/mongo/db/repl/freshness_checker.cpp
+++ b/src/mongo/db/repl/freshness_checker.cpp
@@ -46,6 +46,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
FreshnessChecker::Algorithm::Algorithm(Timestamp lastOpTimeApplied,
const ReplicaSetConfig& rsConfig,
int selfIndex,
diff --git a/src/mongo/db/repl/freshness_checker.h b/src/mongo/db/repl/freshness_checker.h
index 11515bfc0ad..43dd77eee69 100644
--- a/src/mongo/db/repl/freshness_checker.h
+++ b/src/mongo/db/repl/freshness_checker.h
@@ -64,8 +64,8 @@ public:
int selfIndex,
const std::vector<HostAndPort>& targets);
virtual ~Algorithm();
- virtual std::vector<RemoteCommandRequest> getRequests() const;
- virtual void processResponse(const RemoteCommandRequest& request,
+ virtual std::vector<executor::RemoteCommandRequest> getRequests() const;
+ virtual void processResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response);
virtual bool hasReceivedSufficientResponses() const;
ElectionAbortReason shouldAbortElection() const;
diff --git a/src/mongo/db/repl/freshness_checker_test.cpp b/src/mongo/db/repl/freshness_checker_test.cpp
index e476a0e6034..a8a269b627b 100644
--- a/src/mongo/db/repl/freshness_checker_test.cpp
+++ b/src/mongo/db/repl/freshness_checker_test.cpp
@@ -49,6 +49,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using unittest::assertGet;
bool stringContains(const std::string& haystack, const std::string& needle) {
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
index b187ccd74c2..1eb90c747ac 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
@@ -49,6 +49,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class ReplCoordElectTest : public ReplCoordTest {
protected:
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
index 2125f152d17..82c322e4b24 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
@@ -49,6 +49,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class ReplCoordElectV1Test : public ReplCoordTest {
protected:
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index dd8652f5f8d..0c12e546e47 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -62,6 +62,8 @@ typedef ReplicationExecutor::CallbackHandle CBHandle;
} // namespace
+using executor::RemoteCommandRequest;
+
void ReplicationCoordinatorImpl::_doMemberHeartbeat(ReplicationExecutor::CallbackArgs cbData,
const HostAndPort& target,
int targetIndex) {
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
index f992bf8e94b..fa9843b15ad 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
@@ -48,6 +48,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class ReplCoordHBTest : public ReplCoordTest {
protected:
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
index 51c23f53c1b..6ab99d225f1 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
@@ -48,6 +48,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class ReplCoordHBV1Test : public ReplCoordTest {
protected:
diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
index 6255e799d67..a40521f9bf0 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -48,6 +48,9 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
+
typedef ReplicationCoordinator::ReplSetReconfigArgs ReplSetReconfigArgs;
TEST_F(ReplCoordTest, ReconfigBeforeInitialized) {
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index ab6edb18c0e..87f4ebb9462 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -69,6 +69,9 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
+
typedef ReplicationCoordinator::ReplSetReconfigArgs ReplSetReconfigArgs;
Status kInterruptedStatus(ErrorCodes::Interrupted, "operation was interrupted");
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index d76a7fb4c63..ef5a28e3616 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -57,6 +57,8 @@ bool stringContains(const std::string& haystack, const std::string& needle) {
} // namespace
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
ReplicaSetConfig ReplCoordTest::assertMakeRSConfig(const BSONObj& configBson) {
ReplicaSetConfig config;
diff --git a/src/mongo/db/repl/replication_executor.cpp b/src/mongo/db/repl/replication_executor.cpp
index 990737d96db..ff1918416a0 100644
--- a/src/mongo/db/repl/replication_executor.cpp
+++ b/src/mongo/db/repl/replication_executor.cpp
@@ -49,6 +49,8 @@ stdx::function<void()> makeNoExcept(const stdx::function<void()>& fn);
} // namespace
using executor::NetworkInterface;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
ReplicationExecutor::ReplicationExecutor(NetworkInterface* netInterface,
StorageInterface* storageInterface,
diff --git a/src/mongo/db/repl/replication_executor.h b/src/mongo/db/repl/replication_executor.h
index f20a288b40c..31bf37c505f 100644
--- a/src/mongo/db/repl/replication_executor.h
+++ b/src/mongo/db/repl/replication_executor.h
@@ -34,7 +34,6 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/base/string_data.h"
-#include "mongo/client/remote_command_runner.h"
#include "mongo/db/concurrency/lock_manager_defs.h"
#include "mongo/db/repl/task_runner.h"
#include "mongo/executor/task_executor.h"
@@ -119,7 +118,7 @@ public:
void waitForEvent(const EventHandle& event) override;
StatusWith<CallbackHandle> scheduleWork(const CallbackFn& work) override;
StatusWith<CallbackHandle> scheduleWorkAt(Date_t when, const CallbackFn& work) override;
- StatusWith<CallbackHandle> scheduleRemoteCommand(const RemoteCommandRequest& request,
+ StatusWith<CallbackHandle> scheduleRemoteCommand(const executor::RemoteCommandRequest& request,
const RemoteCommandCallbackFn& cb) override;
void cancel(const CallbackHandle& cbHandle) override;
void wait(const CallbackHandle& cbHandle) override;
@@ -262,8 +261,8 @@ private:
*/
void finishShutdown();
- void _finishRemoteCommand(const RemoteCommandRequest& request,
- const StatusWith<RemoteCommandResponse>& response,
+ void _finishRemoteCommand(const executor::RemoteCommandRequest& request,
+ const StatusWith<executor::RemoteCommandResponse>& response,
const CallbackHandle& cbHandle,
const uint64_t expectedHandleGeneration,
const RemoteCommandCallbackFn& cb);
diff --git a/src/mongo/db/repl/replication_executor_test_fixture.h b/src/mongo/db/repl/replication_executor_test_fixture.h
index f2e8257f4c8..f7bd59a8672 100644
--- a/src/mongo/db/repl/replication_executor_test_fixture.h
+++ b/src/mongo/db/repl/replication_executor_test_fixture.h
@@ -29,6 +29,7 @@
#pragma once
#include "mongo/stdx/memory.h"
+#include "mongo/db/repl/replication_executor.h"
#include "mongo/executor/task_executor_test_fixture.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/db/repl/reporter.cpp b/src/mongo/db/repl/reporter.cpp
index 23f797fe51c..fbbc4d64d33 100644
--- a/src/mongo/db/repl/reporter.cpp
+++ b/src/mongo/db/repl/reporter.cpp
@@ -38,6 +38,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
Reporter::Reporter(ReplicationExecutor* executor,
PrepareReplSetUpdatePositionCommandFn prepareReplSetUpdatePositionCommandFn,
const HostAndPort& target)
diff --git a/src/mongo/db/repl/reporter_test.cpp b/src/mongo/db/repl/reporter_test.cpp
index 6781341d07d..c5533d7adb2 100644
--- a/src/mongo/db/repl/reporter_test.cpp
+++ b/src/mongo/db/repl/reporter_test.cpp
@@ -39,6 +39,8 @@ namespace {
using namespace mongo;
using namespace mongo::repl;
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
class MockProgressManager {
public:
diff --git a/src/mongo/db/repl/scatter_gather_algorithm.h b/src/mongo/db/repl/scatter_gather_algorithm.h
index c5e06e4d3c9..a622473c5ee 100644
--- a/src/mongo/db/repl/scatter_gather_algorithm.h
+++ b/src/mongo/db/repl/scatter_gather_algorithm.h
@@ -57,12 +57,12 @@ public:
/**
* Returns the list of requests that should be sent.
*/
- virtual std::vector<RemoteCommandRequest> getRequests() const = 0;
+ virtual std::vector<executor::RemoteCommandRequest> getRequests() const = 0;
/**
* Method to call once for each received response.
*/
- virtual void processResponse(const RemoteCommandRequest& request,
+ virtual void processResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response) = 0;
/**
diff --git a/src/mongo/db/repl/scatter_gather_runner.cpp b/src/mongo/db/repl/scatter_gather_runner.cpp
index 6161f71db63..16c778399d0 100644
--- a/src/mongo/db/repl/scatter_gather_runner.cpp
+++ b/src/mongo/db/repl/scatter_gather_runner.cpp
@@ -41,6 +41,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
ScatterGatherRunner::ScatterGatherRunner(ScatterGatherAlgorithm* algorithm)
: _algorithm(algorithm), _started(false) {}
diff --git a/src/mongo/db/repl/scatter_gather_test.cpp b/src/mongo/db/repl/scatter_gather_test.cpp
index 8721a201ab0..6e4c11a65e0 100644
--- a/src/mongo/db/repl/scatter_gather_test.cpp
+++ b/src/mongo/db/repl/scatter_gather_test.cpp
@@ -42,6 +42,8 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
/**
* Algorithm for testing the ScatterGatherRunner, which will finish running when finish() is
diff --git a/src/mongo/db/repl/vote_requester.cpp b/src/mongo/db/repl/vote_requester.cpp
index c23bd7d6916..5f0683d0aee 100644
--- a/src/mongo/db/repl/vote_requester.cpp
+++ b/src/mongo/db/repl/vote_requester.cpp
@@ -42,6 +42,8 @@
namespace mongo {
namespace repl {
+using executor::RemoteCommandRequest;
+
VoteRequester::Algorithm::Algorithm(const ReplicaSetConfig& rsConfig,
long long candidateId,
long long term,
diff --git a/src/mongo/db/repl/vote_requester.h b/src/mongo/db/repl/vote_requester.h
index 8000d12ddb8..673af6c0415 100644
--- a/src/mongo/db/repl/vote_requester.h
+++ b/src/mongo/db/repl/vote_requester.h
@@ -66,8 +66,8 @@ public:
bool dryRun,
OpTime lastOplogEntry);
virtual ~Algorithm();
- virtual std::vector<RemoteCommandRequest> getRequests() const;
- virtual void processResponse(const RemoteCommandRequest& request,
+ virtual std::vector<executor::RemoteCommandRequest> getRequests() const;
+ virtual void processResponse(const executor::RemoteCommandRequest& request,
const ResponseStatus& response);
virtual bool hasReceivedSufficientResponses() const;
diff --git a/src/mongo/db/repl/vote_requester_test.cpp b/src/mongo/db/repl/vote_requester_test.cpp
index 98543df392d..d169344c2e6 100644
--- a/src/mongo/db/repl/vote_requester_test.cpp
+++ b/src/mongo/db/repl/vote_requester_test.cpp
@@ -45,10 +45,10 @@ namespace repl {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using unittest::assertGet;
-using RemoteCommandRequest = RemoteCommandRequest;
-
bool stringContains(const std::string& haystack, const std::string& needle) {
return haystack.find(needle) != std::string::npos;
}
diff --git a/src/mongo/executor/SConscript b/src/mongo/executor/SConscript
index 6083b988bf5..38f4a6dc9c3 100644
--- a/src/mongo/executor/SConscript
+++ b/src/mongo/executor/SConscript
@@ -5,14 +5,20 @@ Import("env")
env.InjectThirdPartyIncludePaths('asio')
env.Library(target='task_executor_interface',
- source=['task_executor.cpp',],
+ source=[
+ 'remote_command_request.cpp',
+ 'remote_command_response.cpp',
+ 'task_executor.cpp',
+ ],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/service_context',
+ '$BUILD_DIR/mongo/rpc/metadata',
+ '$BUILD_DIR/mongo/util/net/hostandport',
])
env.Library(target='network_interface',
source=['network_interface.cpp',],
LIBDEPS=[
+ 'task_executor_interface',
])
env.Library(target='network_interface_impl', # TODO: rename to thread_pool_network_interface
@@ -99,6 +105,5 @@ env.CppUnitTest(
LIBDEPS=[
'thread_pool_task_executor',
'task_executor_test_fixture',
- '$BUILD_DIR/mongo/client/remote_command_runner',
]
)
diff --git a/src/mongo/executor/network_interface_asio.h b/src/mongo/executor/network_interface_asio.h
index d291619bd55..0f82c2c618d 100644
--- a/src/mongo/executor/network_interface_asio.h
+++ b/src/mongo/executor/network_interface_asio.h
@@ -37,8 +37,9 @@
#include "mongo/base/status.h"
#include "mongo/client/connection_pool.h"
-#include "mongo/client/remote_command_runner.h"
#include "mongo/executor/network_interface.h"
+#include "mongo/executor/remote_command_request.h"
+#include "mongo/executor/remote_command_response.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/rpc/protocol.h"
#include "mongo/stdx/condition_variable.h"
diff --git a/src/mongo/executor/network_test_env.h b/src/mongo/executor/network_test_env.h
index 17e97318765..bfec66d570f 100644
--- a/src/mongo/executor/network_test_env.h
+++ b/src/mongo/executor/network_test_env.h
@@ -43,7 +43,6 @@ namespace mongo {
class BSONObj;
class CatalogManagerReplicaSet;
class DistLockManagerMock;
-struct RemoteCommandRequest;
class ShardRegistry;
template <typename T>
class StatusWith;
diff --git a/src/mongo/client/remote_command_runner.cpp b/src/mongo/executor/remote_command_request.cpp
index 84899cd2429..f9b2bb10533 100644
--- a/src/mongo/client/remote_command_runner.cpp
+++ b/src/mongo/executor/remote_command_request.cpp
@@ -28,11 +28,12 @@
#include "mongo/platform/basic.h"
-#include "mongo/client/remote_command_runner.h"
+#include "mongo/executor/remote_command_request.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
+namespace executor {
const Milliseconds RemoteCommandRequest::kNoTimeout{-1};
const Date_t RemoteCommandRequest::kNoExpirationDate{Date_t::max()};
@@ -49,12 +50,5 @@ std::string RemoteCommandRequest::toString() const {
return out;
}
-std::string RemoteCommandResponse::toString() const {
- str::stream out;
- out << "RemoteResponse -- "
- << " cmd:" << data.toString();
-
- return out;
-}
-
+} // namespace executor
} // namespace mongo
diff --git a/src/mongo/executor/remote_command_request.h b/src/mongo/executor/remote_command_request.h
new file mode 100644
index 00000000000..325455ec1da
--- /dev/null
+++ b/src/mongo/executor/remote_command_request.h
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include <string>
+
+#include "mongo/db/jsobj.h"
+#include "mongo/util/net/hostandport.h"
+#include "mongo/rpc/metadata.h"
+#include "mongo/util/time_support.h"
+
+namespace mongo {
+namespace executor {
+
+/**
+ * Type of object describing a command to execute against a remote MongoDB node.
+ */
+struct RemoteCommandRequest {
+ // Indicates that there is no timeout for the request to complete
+ static const Milliseconds kNoTimeout;
+
+ // Indicates that there is no expiration time by when the request needs to complete
+ static const Date_t kNoExpirationDate;
+
+ RemoteCommandRequest() = default;
+
+ RemoteCommandRequest(const HostAndPort& theTarget,
+ const std::string& theDbName,
+ const BSONObj& theCmdObj,
+ const BSONObj& metadataObj,
+ const Milliseconds timeoutMillis = kNoTimeout)
+ : target(theTarget),
+ dbname(theDbName),
+ metadata(metadataObj),
+ cmdObj(theCmdObj),
+ timeout(timeoutMillis) {
+ if (timeoutMillis == kNoTimeout) {
+ expirationDate = kNoExpirationDate;
+ }
+ }
+
+ RemoteCommandRequest(const HostAndPort& theTarget,
+ const std::string& theDbName,
+ const BSONObj& theCmdObj,
+ const Milliseconds timeoutMillis = kNoTimeout)
+ : RemoteCommandRequest(
+ theTarget, theDbName, theCmdObj, rpc::makeEmptyMetadata(), timeoutMillis) {}
+
+ std::string toString() const;
+
+ HostAndPort target;
+ std::string dbname;
+ BSONObj metadata{rpc::makeEmptyMetadata()};
+ BSONObj cmdObj;
+ Milliseconds timeout = kNoTimeout;
+
+ // Deadline by when the request must be completed
+ Date_t expirationDate = kNoExpirationDate;
+};
+
+} // namespace executor
+} // namespace mongo
diff --git a/src/mongo/executor/remote_command_response.cpp b/src/mongo/executor/remote_command_response.cpp
new file mode 100644
index 00000000000..a27d6856f24
--- /dev/null
+++ b/src/mongo/executor/remote_command_response.cpp
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/executor/remote_command_response.h"
+
+#include "mongo/util/mongoutils/str.h"
+
+namespace mongo {
+namespace executor {
+
+std::string RemoteCommandResponse::toString() const {
+ return str::stream() << "RemoteResponse -- "
+ << " cmd:" << data.toString();
+}
+
+} // namespace executor
+} // namespace mongo
diff --git a/src/mongo/executor/remote_command_response.h b/src/mongo/executor/remote_command_response.h
new file mode 100644
index 00000000000..0f3e1c9ce0e
--- /dev/null
+++ b/src/mongo/executor/remote_command_response.h
@@ -0,0 +1,57 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include <string>
+
+#include "mongo/db/jsobj.h"
+#include "mongo/util/time_support.h"
+
+namespace mongo {
+namespace executor {
+
+
+/**
+ * Type of object describing the response of previously sent RemoteCommandRequest.
+ */
+struct RemoteCommandResponse {
+ RemoteCommandResponse() = default;
+
+ RemoteCommandResponse(BSONObj dataObj, BSONObj metadataObj, Milliseconds millis)
+ : data(std::move(dataObj)), metadata(std::move(metadataObj)), elapsedMillis(millis) {}
+
+ std::string toString() const;
+
+ BSONObj data;
+ BSONObj metadata;
+ Milliseconds elapsedMillis = {};
+};
+
+} // namespace executor
+} // namespace mongo
diff --git a/src/mongo/executor/task_executor.h b/src/mongo/executor/task_executor.h
index e143e38a112..64b47ace5eb 100644
--- a/src/mongo/executor/task_executor.h
+++ b/src/mongo/executor/task_executor.h
@@ -35,7 +35,8 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/base/string_data.h"
-#include "mongo/client/remote_command_runner.h"
+#include "mongo/executor/remote_command_request.h"
+#include "mongo/executor/remote_command_response.h"
#include "mongo/stdx/functional.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp b/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
index 2b854e2574f..7fbe52eea03 100644
--- a/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
+++ b/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
@@ -57,6 +57,8 @@ namespace mongo {
using std::vector;
using executor::NetworkInterfaceMock;
using executor::NetworkTestEnv;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
namespace {
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_add_shard_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_add_shard_test.cpp
index 8fae1009e1f..0dbbeaab975 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_add_shard_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_add_shard_test.cpp
@@ -50,6 +50,8 @@
namespace mongo {
namespace {
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using std::vector;
using unittest::assertGet;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp
index ad0b5419e00..d9591850d25 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp
@@ -44,6 +44,8 @@
namespace mongo {
namespace {
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using std::string;
using std::vector;
using stdx::chrono::milliseconds;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_action_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_action_test.cpp
index 87ed6feed18..f0cf6218fa8 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_action_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_action_test.cpp
@@ -48,6 +48,8 @@ namespace mongo {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using executor::TaskExecutor;
using unittest::assertGet;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp
index 6b7aa701404..970fadff866 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp
@@ -53,6 +53,8 @@ namespace mongo {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using executor::TaskExecutor;
using std::string;
using std::vector;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp
index abebed0a533..c366a48aee5 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp
@@ -60,6 +60,8 @@ namespace mongo {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using executor::TaskExecutor;
using std::set;
using std::string;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp
index 3bcb5e23023..d2e0c890eaa 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp
@@ -61,6 +61,8 @@ namespace mongo {
namespace {
using executor::NetworkInterfaceMock;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using executor::TaskExecutor;
using std::string;
using std::vector;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp
index d906566aaab..48778885397 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp
@@ -57,6 +57,8 @@ namespace mongo {
using executor::NetworkInterfaceMock;
using executor::NetworkTestEnv;
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using unittest::assertGet;
using std::string;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h
index 15f69603ad5..574944460f1 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h
@@ -40,7 +40,6 @@ namespace mongo {
class BSONObj;
class CatalogManagerReplicaSet;
class DistLockManagerMock;
-struct RemoteCommandRequest;
class RemoteCommandTargeterFactoryMock;
class RemoteCommandTargeterMock;
class ShardRegistry;
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_upgrade_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_upgrade_test.cpp
index 4afe452b8ba..51afc7b40b3 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_upgrade_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_upgrade_test.cpp
@@ -42,6 +42,8 @@
namespace mongo {
namespace {
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
using std::vector;
using CatalogManagerReplSetTest = CatalogManagerReplSetTestFixture;
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp
index 5d79a794871..50e0d19d592 100644
--- a/src/mongo/s/client/shard_registry.cpp
+++ b/src/mongo/s/client/shard_registry.cpp
@@ -314,10 +314,10 @@ StatusWith<std::vector<BSONObj>> ShardRegistry::exhaustiveFind(const HostAndPort
StatusWith<BSONObj> ShardRegistry::runCommand(const HostAndPort& host,
const std::string& dbName,
const BSONObj& cmdObj) {
- StatusWith<RemoteCommandResponse> responseStatus =
+ StatusWith<executor::RemoteCommandResponse> responseStatus =
Status(ErrorCodes::InternalError, "Internal error running command");
- RemoteCommandRequest request(host, dbName, cmdObj, kConfigCommandTimeout);
+ executor::RemoteCommandRequest request(host, dbName, cmdObj, kConfigCommandTimeout);
auto callStatus =
_executor->scheduleRemoteCommand(request,
[&responseStatus](const RemoteCommandCallbackArgs& args) {
diff --git a/src/mongo/s/query/async_cluster_client_cursor.cpp b/src/mongo/s/query/async_cluster_client_cursor.cpp
index c7e22e973a9..e406365350b 100644
--- a/src/mongo/s/query/async_cluster_client_cursor.cpp
+++ b/src/mongo/s/query/async_cluster_client_cursor.cpp
@@ -32,10 +32,11 @@
#include "mongo/s/query/async_cluster_client_cursor.h"
-#include "mongo/client/remote_command_runner.h"
#include "mongo/db/query/getmore_request.h"
#include "mongo/db/query/getmore_response.h"
#include "mongo/db/query/killcursors_request.h"
+#include "mongo/executor/remote_command_request.h"
+#include "mongo/executor/remote_command_response.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/scopeguard.h"
@@ -202,7 +203,7 @@ StatusWith<executor::TaskExecutor::EventHandle> AsyncClusterClientCursor::nextEv
.toBSON()
: _params.cmdObj;
- RemoteCommandRequest request(
+ executor::RemoteCommandRequest request(
remote.hostAndPort, _params.nsString.db().toString(), cmdObj);
auto callbackStatus = _executor->scheduleRemoteCommand(
@@ -336,7 +337,7 @@ void AsyncClusterClientCursor::scheduleKillCursors_inlock() {
if (remote.status.isOK() && remote.cursorId && !remote.exhausted()) {
BSONObj cmdObj = KillCursorsRequest(_params.nsString, {*remote.cursorId}).toBSON();
- RemoteCommandRequest request(
+ executor::RemoteCommandRequest request(
remote.hostAndPort, _params.nsString.db().toString(), cmdObj);
_executor->scheduleRemoteCommand(
diff --git a/src/mongo/s/query/async_cluster_client_cursor.h b/src/mongo/s/query/async_cluster_client_cursor.h
index 32eb12cb04e..27e4b34bc6c 100644
--- a/src/mongo/s/query/async_cluster_client_cursor.h
+++ b/src/mongo/s/query/async_cluster_client_cursor.h
@@ -36,10 +36,10 @@
#include "mongo/base/status_with.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/db/clientcursor.h"
-#include "mongo/db/repl/replication_executor.h"
+#include "mongo/executor/task_executor.h"
#include "mongo/s/query/cluster_client_cursor_params.h"
-#include "mongo/util/net/hostandport.h"
#include "mongo/stdx/mutex.h"
+#include "mongo/util/net/hostandport.h"
namespace mongo {
diff --git a/src/mongo/s/query/async_cluster_client_cursor_test.cpp b/src/mongo/s/query/async_cluster_client_cursor_test.cpp
index b70480d999c..de2a8196bad 100644
--- a/src/mongo/s/query/async_cluster_client_cursor_test.cpp
+++ b/src/mongo/s/query/async_cluster_client_cursor_test.cpp
@@ -43,6 +43,9 @@ namespace mongo {
namespace {
+using executor::RemoteCommandRequest;
+using executor::RemoteCommandResponse;
+
class AsyncClusterClientCursorTest : public repl::ReplicationExecutorTest {
public:
AsyncClusterClientCursorTest()