summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-09-08 14:04:38 -0400
committerDavid Storch <david.storch@10gen.com>2015-09-10 15:54:55 -0400
commit1422edf755dba283ca300365977e379ddb75a4a7 (patch)
tree66279e9c75eb1f44e590915f5b0638235324e276 /src/mongo/s/commands
parent07ffaa3ca05b1aed1163b53756d642a886df0818 (diff)
downloadmongo-1422edf755dba283ca300365977e379ddb75a4a7.tar.gz
SERVER-20194 SERVER-18849 add support for querying SCCC mode config servers in the new mongos query path
Diffstat (limited to 'src/mongo/s/commands')
-rw-r--r--src/mongo/s/commands/cluster_commands_common.cpp71
-rw-r--r--src/mongo/s/commands/cluster_commands_common.h16
-rw-r--r--src/mongo/s/commands/cluster_is_master_cmd.cpp13
-rw-r--r--src/mongo/s/commands/cluster_pipeline_cmd.cpp1
-rw-r--r--src/mongo/s/commands/commands_public.cpp1
5 files changed, 3 insertions, 99 deletions
diff --git a/src/mongo/s/commands/cluster_commands_common.cpp b/src/mongo/s/commands/cluster_commands_common.cpp
index 06151028bd7..6600a400aa6 100644
--- a/src/mongo/s/commands/cluster_commands_common.cpp
+++ b/src/mongo/s/commands/cluster_commands_common.cpp
@@ -216,75 +216,4 @@ bool appendEmptyResultSet(BSONObjBuilder& result, Status status, const std::stri
return Command::appendCommandStatus(result, status);
}
-namespace {
-Status storePossibleCursorLegacy(const std::string& server, const BSONObj& cmdResult) {
- if (cmdResult["ok"].trueValue() && cmdResult.hasField("cursor")) {
- BSONElement cursorIdElt = cmdResult.getFieldDotted("cursor.id");
-
- if (cursorIdElt.type() != mongo::NumberLong) {
- return Status(ErrorCodes::TypeMismatch,
- str::stream() << "expected \"cursor.id\" field from shard "
- << "response to have NumberLong type, instead "
- << "got: " << typeName(cursorIdElt.type()));
- }
-
- const long long cursorId = cursorIdElt.Long();
- if (cursorId != 0) {
- BSONElement cursorNsElt = cmdResult.getFieldDotted("cursor.ns");
- if (cursorNsElt.type() != mongo::String) {
- return Status(ErrorCodes::TypeMismatch,
- str::stream() << "expected \"cursor.ns\" field from "
- << "shard response to have String type, "
- << "instead got: " << typeName(cursorNsElt.type()));
- }
-
- const std::string cursorNs = cursorNsElt.String();
- cursorCache.storeRef(server, cursorId, cursorNs);
- }
- }
-
- return Status::OK();
-}
-} // namespace
-
-StatusWith<BSONObj> storePossibleCursor(const std::string& server,
- const BSONObj& cmdResult,
- executor::TaskExecutor* executor,
- ClusterCursorManager* cursorManager) {
- if (!useClusterClientCursor) {
- Status status = storePossibleCursorLegacy(server, cmdResult);
- return (status.isOK() ? StatusWith<BSONObj>(cmdResult) : StatusWith<BSONObj>(status));
- }
-
- if (!cmdResult["ok"].trueValue() || !cmdResult.hasField("cursor")) {
- return cmdResult;
- }
-
- auto incomingCursorResponse = CursorResponse::parseFromBSON(cmdResult);
- if (!incomingCursorResponse.isOK()) {
- return incomingCursorResponse.getStatus();
- }
-
- if (incomingCursorResponse.getValue().cursorId == CursorId(0)) {
- return cmdResult;
- }
-
- ClusterClientCursorParams params(incomingCursorResponse.getValue().nss);
- params.remotes.emplace_back(HostAndPort(server), incomingCursorResponse.getValue().cursorId);
-
- auto ccc = stdx::make_unique<ClusterClientCursorImpl>(executor, std::move(params));
- auto pinnedCursor =
- cursorManager->registerCursor(std::move(ccc),
- incomingCursorResponse.getValue().nss,
- ClusterCursorManager::CursorType::NamespaceNotSharded,
- ClusterCursorManager::CursorLifetime::Mortal);
- CursorId clusterCursorId = pinnedCursor.getCursorId();
- pinnedCursor.returnCursor(ClusterCursorManager::CursorState::NotExhausted);
-
- CursorResponse outgoingCursorResponse(incomingCursorResponse.getValue().nss,
- clusterCursorId,
- incomingCursorResponse.getValue().batch);
- return outgoingCursorResponse.toBSON(CursorResponse::ResponseType::InitialResponse);
-}
-
} // namespace mongo
diff --git a/src/mongo/s/commands/cluster_commands_common.h b/src/mongo/s/commands/cluster_commands_common.h
index 0cb815e8a07..68a2f9cdd7f 100644
--- a/src/mongo/s/commands/cluster_commands_common.h
+++ b/src/mongo/s/commands/cluster_commands_common.h
@@ -136,20 +136,4 @@ int getUniqueCodeFromCommandResults(const std::vector<Strategy::CommandResult>&
*/
bool appendEmptyResultSet(BSONObjBuilder& result, Status status, const std::string& ns);
-/**
- * Utility function to create a cursor based on existing cursor on a remote instance. 'cmdResult'
- * must be the response object generated upon creation of the cursor. The cursor is created using
- * 'executor', and the cursor is stored with 'cursorManager' (unless 'useClusterClientCursor' is
- * set to false, in which case the cursor is stored with the 'cursorCache' singleton).
- *
- * If 'cmdResult' does not describe a command cursor response document or no cursor is specified,
- * returns 'cmdResult'. If a parsing error occurs, returns an error Status. Otherwise, returns a
- * BSONObj response document describing the newly-created cursor, which is suitable for returning to
- * the client.
- */
-StatusWith<BSONObj> storePossibleCursor(const std::string& server,
- const BSONObj& cmdResult,
- executor::TaskExecutor* executor,
- ClusterCursorManager* cursorManager);
-
} // namespace mongo
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp
index e3e0dfbd84c..5104a6a1d78 100644
--- a/src/mongo/s/commands/cluster_is_master_cmd.cpp
+++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp
@@ -72,20 +72,9 @@ public:
result.appendNumber("maxWriteBatchSize", BatchedCommandRequest::kMaxWriteBatchSize);
result.appendDate("localTime", jsTime());
- // Mongos can only send the wire version indicating find and getMore commands support if the
- // config server mode has been upgraded to CSRS.
- //
- // TODO: This special case will no longer be required for 3.4.
- auto catalogManager = grid.catalogManager(txn);
- int maxVersionToSend = maxWireVersion;
- if (maxVersionToSend == WireVersion::FIND_COMMAND &&
- catalogManager->getMode() != CatalogManager::ConfigServerMode::CSRS) {
- maxVersionToSend = WireVersion::RELEASE_2_7_7;
- }
-
// Mongos tries to keep exactly the same version range of the server for which
// it is compiled.
- result.append("maxWireVersion", maxVersionToSend);
+ result.append("maxWireVersion", maxWireVersion);
result.append("minWireVersion", minWireVersion);
return true;
diff --git a/src/mongo/s/commands/cluster_pipeline_cmd.cpp b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
index 2aa61a38b1f..b0acca177a3 100644
--- a/src/mongo/s/commands/cluster_pipeline_cmd.cpp
+++ b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
@@ -51,6 +51,7 @@
#include "mongo/s/commands/cluster_commands_common.h"
#include "mongo/s/config.h"
#include "mongo/s/grid.h"
+#include "mongo/s/query/store_possible_cursor.h"
#include "mongo/s/stale_exception.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp
index 048c82e92b8..f8de635c022 100644
--- a/src/mongo/s/commands/commands_public.cpp
+++ b/src/mongo/s/commands/commands_public.cpp
@@ -56,6 +56,7 @@
#include "mongo/s/commands/run_on_all_shards_cmd.h"
#include "mongo/s/config.h"
#include "mongo/s/grid.h"
+#include "mongo/s/query/store_possible_cursor.h"
#include "mongo/s/stale_exception.h"
#include "mongo/s/version_manager.h"
#include "mongo/scripting/engine.h"