summaryrefslogtreecommitdiff
path: root/src/mongo/executor/task_executor.cpp
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2019-05-13 18:24:36 -0400
committerJason Carey <jcarey@argv.me>2019-06-06 09:00:28 -0400
commitefa1ae064b9206f82136a8d14cbb86d47e8754b1 (patch)
treec4666fa197f837b5a0feaa8f980299a8eed7146a /src/mongo/executor/task_executor.cpp
parentb1ff28c63836aa13112cf3499574160a5950c6ec (diff)
downloadmongo-efa1ae064b9206f82136a8d14cbb86d47e8754b1.tar.gz
SERVER-41133 Add TE::scheduleRemoteCommandOnAny
Add support for a mode for the task executor where rather than targetting a single host, we target any of a set of hosts. This should behave identically to scheduleRemoteCommand, except that we concurrently get() connections from the connection pool for each host, preferring the first which is available
Diffstat (limited to 'src/mongo/executor/task_executor.cpp')
-rw-r--r--src/mongo/executor/task_executor.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/executor/task_executor.cpp b/src/mongo/executor/task_executor.cpp
index dea064860c7..83d69b525fd 100644
--- a/src/mongo/executor/task_executor.cpp
+++ b/src/mongo/executor/task_executor.cpp
@@ -79,6 +79,20 @@ TaskExecutor::RemoteCommandCallbackArgs::RemoteCommandCallbackArgs(
const ResponseStatus& theResponse)
: executor(theExecutor), myHandle(theHandle), request(theRequest), response(theResponse) {}
+TaskExecutor::RemoteCommandCallbackArgs::RemoteCommandCallbackArgs(
+ const RemoteCommandOnAnyCallbackArgs& other, size_t idx)
+ : executor(other.executor),
+ myHandle(other.myHandle),
+ request(other.request, idx),
+ response(other.response) {}
+
+TaskExecutor::RemoteCommandOnAnyCallbackArgs::RemoteCommandOnAnyCallbackArgs(
+ TaskExecutor* theExecutor,
+ const CallbackHandle& theHandle,
+ const RemoteCommandRequestOnAny& theRequest,
+ const ResponseOnAnyStatus& theResponse)
+ : executor(theExecutor), myHandle(theHandle), request(theRequest), response(theResponse) {}
+
TaskExecutor::CallbackState* TaskExecutor::getCallbackFromHandle(const CallbackHandle& cbHandle) {
return cbHandle.getCallback();
}
@@ -96,5 +110,15 @@ void TaskExecutor::setCallbackForHandle(CallbackHandle* cbHandle,
cbHandle->setCallback(std::move(callback));
}
+
+StatusWith<TaskExecutor::CallbackHandle> TaskExecutor::scheduleRemoteCommand(
+ const RemoteCommandRequest& request,
+ const RemoteCommandCallbackFn& cb,
+ const BatonHandle& baton) {
+ return scheduleRemoteCommandOnAny(request, [cb](const RemoteCommandOnAnyCallbackArgs& args) {
+ cb({args, 0});
+ });
+}
+
} // namespace executor
} // namespace mongo