summaryrefslogtreecommitdiff
path: root/src/mongo/s/query
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-08-28 01:59:12 -0400
committerJason Rassi <rassi@10gen.com>2015-08-28 12:52:28 -0400
commit66028bde22d641a1fbf96e7e3f76554e059cc221 (patch)
tree393f4caf65643ea416858152a34396c5696ff3b6 /src/mongo/s/query
parent622dae556361380471b4ce0ef4e761e2342a6adb (diff)
downloadmongo-66028bde22d641a1fbf96e7e3f76554e059cc221.tar.gz
SERVER-19569 Combine getmore_response.h with cursor_responses.h
Diffstat (limited to 'src/mongo/s/query')
-rw-r--r--src/mongo/s/query/async_results_merger.cpp18
-rw-r--r--src/mongo/s/query/async_results_merger_test.cpp44
-rw-r--r--src/mongo/s/query/cluster_find.cpp6
-rw-r--r--src/mongo/s/query/cluster_find.h8
4 files changed, 38 insertions, 38 deletions
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index 73f67095547..5a1992cc280 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -32,8 +32,8 @@
#include "mongo/s/query/async_results_merger.h"
+#include "mongo/db/query/cursor_response.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"
@@ -333,37 +333,37 @@ void AsyncResultsMerger::handleBatchResponse(
return;
}
- auto getMoreParseStatus = GetMoreResponse::parseFromBSON(cbData.response.getValue().data);
+ auto getMoreParseStatus = CursorResponse::parseFromBSON(cbData.response.getValue().data);
if (!getMoreParseStatus.isOK()) {
remote.status = getMoreParseStatus.getStatus();
return;
}
- auto getMoreResponse = getMoreParseStatus.getValue();
+ auto cursorResponse = getMoreParseStatus.getValue();
// If we have a cursor established, and we get a non-zero cursorid that is not equal to the
// established cursorid, we will fail the operation.
- if (remote.cursorId && getMoreResponse.cursorId != 0 &&
- *remote.cursorId != getMoreResponse.cursorId) {
+ if (remote.cursorId && cursorResponse.cursorId != 0 &&
+ *remote.cursorId != cursorResponse.cursorId) {
remote.status = Status(ErrorCodes::BadValue,
str::stream() << "Expected cursorid " << *remote.cursorId
- << " but received " << getMoreResponse.cursorId);
+ << " but received " << cursorResponse.cursorId);
return;
}
// Mark that we've gotten a valid response back from 'remote' at least once.
remote.gotFirstResponse = true;
- remote.cursorId = getMoreResponse.cursorId;
+ remote.cursorId = cursorResponse.cursorId;
- for (const auto& obj : getMoreResponse.batch) {
+ for (const auto& obj : cursorResponse.batch) {
remote.docBuffer.push(obj);
++remote.fetchedCount;
}
// If we're doing a sorted merge, then we have to make sure to put this remote onto the
// merge queue.
- if (!_params.sort.isEmpty() && !getMoreResponse.batch.empty()) {
+ if (!_params.sort.isEmpty() && !cursorResponse.batch.empty()) {
_mergeQueue.push(remoteIndex);
}
diff --git a/src/mongo/s/query/async_results_merger_test.cpp b/src/mongo/s/query/async_results_merger_test.cpp
index 7542d182f66..aeac1010fb0 100644
--- a/src/mongo/s/query/async_results_merger_test.cpp
+++ b/src/mongo/s/query/async_results_merger_test.cpp
@@ -31,12 +31,12 @@
#include "mongo/s/query/async_results_merger.h"
#include "mongo/db/json.h"
+#include "mongo/db/query/cursor_response.h"
#include "mongo/db/query/getmore_request.h"
-#include "mongo/db/query/getmore_response.h"
#include "mongo/db/query/lite_parsed_query.h"
-#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
#include "mongo/executor/network_interface_mock.h"
#include "mongo/executor/task_executor.h"
+#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
#include "mongo/stdx/memory.h"
#include "mongo/unittest/unittest.h"
@@ -98,10 +98,10 @@ protected:
/**
* Schedules a list of getMore responses to be returned by the mock network.
*/
- void scheduleNetworkResponses(std::vector<GetMoreResponse> responses) {
+ void scheduleNetworkResponses(std::vector<CursorResponse> responses) {
std::vector<BSONObj> objs;
- for (const auto& getMoreResponse : responses) {
- objs.push_back(getMoreResponse.toBSON());
+ for (const auto& cursorResponse : responses) {
+ objs.push_back(cursorResponse.toBSON());
}
scheduleNetworkResponseObjs(objs);
}
@@ -177,7 +177,7 @@ TEST_F(AsyncResultsMergerTest, ClusterFind) {
ASSERT_FALSE(arm->ready());
// First shard responds.
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {
fromjson("{_id: 1}"), fromjson("{_id: 2}"), fromjson("{_id: 3}")};
responses.emplace_back(_nss, CursorId(0), batch1);
@@ -220,7 +220,7 @@ TEST_F(AsyncResultsMergerTest, ClusterFindAndGetMore) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(10), batch1);
std::vector<BSONObj> batch2 = {fromjson("{_id: 3}"), fromjson("{_id: 4}")};
@@ -290,7 +290,7 @@ TEST_F(AsyncResultsMergerTest, ClusterFindSorted) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 5}"), fromjson("{_id: 6}")};
responses.emplace_back(_nss, CursorId(0), batch1);
std::vector<BSONObj> batch2 = {fromjson("{_id: 3}"), fromjson("{_id: 9}")};
@@ -324,7 +324,7 @@ TEST_F(AsyncResultsMergerTest, ClusterFindAndGetMoreSorted) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 5}"), fromjson("{_id: 6}")};
responses.emplace_back(_nss, CursorId(1), batch1);
std::vector<BSONObj> batch2 = {fromjson("{_id: 3}"), fromjson("{_id: 4}")};
@@ -393,7 +393,7 @@ TEST_F(AsyncResultsMergerTest, ClusterFindInitialBatchSizeIsZero) {
// Both shards give back empty responses. Second shard doesn't have any results so it
// sends back a cursor id of zero.
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
responses.emplace_back(_nss, CursorId(1), std::vector<BSONObj>());
responses.emplace_back(_nss, CursorId(0), std::vector<BSONObj>());
scheduleNetworkResponses(responses);
@@ -444,7 +444,7 @@ TEST_F(AsyncResultsMergerTest, StreamResultsFromOneShardIfOtherDoesntRespond) {
ASSERT_FALSE(arm->ready());
// Both shards respond with the first batch.
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(1), batch1);
std::vector<BSONObj> batch2 = {fromjson("{_id: 3}"), fromjson("{_id: 4}")};
@@ -510,7 +510,7 @@ TEST_F(AsyncResultsMergerTest, ErrorOnMismatchedCursorIds) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {
fromjson("{_id: 1}"), fromjson("{_id: 2}"), fromjson("{_id: 3}")};
responses.emplace_back(_nss, CursorId(123), batch1);
@@ -552,10 +552,10 @@ TEST_F(AsyncResultsMergerTest, BadResponseReceivedFromShard) {
ASSERT_FALSE(arm->ready());
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
- BSONObj response1 = GetMoreResponse(_nss, CursorId(123), batch1).toBSON();
+ BSONObj response1 = CursorResponse(_nss, CursorId(123), batch1).toBSON();
BSONObj response2 = fromjson("{foo: 'bar'}");
std::vector<BSONObj> batch3 = {fromjson("{_id: 4}"), fromjson("{_id: 5}")};
- BSONObj response3 = GetMoreResponse(_nss, CursorId(456), batch3).toBSON();
+ BSONObj response3 = CursorResponse(_nss, CursorId(456), batch3).toBSON();
scheduleNetworkResponseObjs({response1, response2, response3});
executor->waitForEvent(readyEvent);
@@ -576,7 +576,7 @@ TEST_F(AsyncResultsMergerTest, ErrorReceivedFromShard) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(1), batch1);
std::vector<BSONObj> batch2 = {fromjson("{_id: 3}"), fromjson("{_id: 4}")};
@@ -607,7 +607,7 @@ TEST_F(AsyncResultsMergerTest, ErrorCantScheduleEventBeforeLastSignaled) {
// Error to call nextEvent() before the previous event is signaled.
ASSERT_NOT_OK(arm->nextEvent().getStatus());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(0), batch);
scheduleNetworkResponses(responses);
@@ -673,7 +673,7 @@ TEST_F(AsyncResultsMergerTest, KillAllBatchesReceived) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(0), batch1);
std::vector<BSONObj> batch2 = {fromjson("{_id: 3}"), fromjson("{_id: 4}")};
@@ -697,7 +697,7 @@ TEST_F(AsyncResultsMergerTest, KillTwoOutstandingBatches) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(0), batch1);
scheduleNetworkResponses(responses);
@@ -722,7 +722,7 @@ TEST_F(AsyncResultsMergerTest, NextEventErrorsAfterKill) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(1), batch1);
scheduleNetworkResponses(responses);
@@ -754,7 +754,7 @@ TEST_F(AsyncResultsMergerTest, TailableBasic) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(123), batch1);
scheduleNetworkResponses(responses);
@@ -797,7 +797,7 @@ TEST_F(AsyncResultsMergerTest, TailableEmptyBatch) {
ASSERT_FALSE(arm->ready());
// Remote responds with an empty batch and a non-zero cursor id.
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch;
responses.emplace_back(_nss, CursorId(123), batch);
scheduleNetworkResponses(responses);
@@ -819,7 +819,7 @@ TEST_F(AsyncResultsMergerTest, GetMoreBatchSizes) {
auto readyEvent = unittest::assertGet(arm->nextEvent());
ASSERT_FALSE(arm->ready());
- std::vector<GetMoreResponse> responses;
+ std::vector<CursorResponse> responses;
std::vector<BSONObj> batch1 = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
responses.emplace_back(_nss, CursorId(1), batch1);
diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp
index 73d41cfc3be..71286aacf33 100644
--- a/src/mongo/s/query/cluster_find.cpp
+++ b/src/mongo/s/query/cluster_find.cpp
@@ -268,8 +268,8 @@ StatusWith<CursorId> ClusterFind::runQuery(OperationContext* txn,
<< " times without establishing shard version."};
}
-StatusWith<GetMoreResponse> ClusterFind::runGetMore(OperationContext* txn,
- const GetMoreRequest& request) {
+StatusWith<CursorResponse> ClusterFind::runGetMore(OperationContext* txn,
+ const GetMoreRequest& request) {
auto cursorManager = grid.getCursorManager();
auto pinnedCursor = cursorManager->checkOutCursor(request.nss, request.cursorid);
@@ -308,7 +308,7 @@ StatusWith<GetMoreResponse> ClusterFind::runGetMore(OperationContext* txn,
CursorId idToReturn = (cursorState == ClusterCursorManager::CursorState::Exhausted)
? CursorId(0)
: request.cursorid;
- return GetMoreResponse(request.nss, idToReturn, std::move(batch), startingFrom);
+ return CursorResponse(request.nss, idToReturn, std::move(batch), startingFrom);
}
} // namespace mongo
diff --git a/src/mongo/s/query/cluster_find.h b/src/mongo/s/query/cluster_find.h
index c441204851a..7958f6b46d4 100644
--- a/src/mongo/s/query/cluster_find.h
+++ b/src/mongo/s/query/cluster_find.h
@@ -32,7 +32,7 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/db/cursor_id.h"
-#include "mongo/db/query/getmore_response.h"
+#include "mongo/db/query/cursor_response.h"
namespace mongo {
@@ -65,10 +65,10 @@ public:
std::vector<BSONObj>* results);
/**
- * Executes the getMore request 'request', and on success returns a GetMoreResponse.
+ * Executes the getMore request 'request', and on success returns a CursorResponse.
*/
- static StatusWith<GetMoreResponse> runGetMore(OperationContext* txn,
- const GetMoreRequest& request);
+ static StatusWith<CursorResponse> runGetMore(OperationContext* txn,
+ const GetMoreRequest& request);
};
} // namespace mongo