summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2014-09-11 15:31:21 -0400
committerHari Khalsa <hkhalsa@10gen.com>2014-09-11 16:21:29 -0400
commit1a90996313ec83f0913bf2aef322193b0884f499 (patch)
tree8c93a84b2a7c3fbbedadd7e34c8c9ffd07b9eea7 /src/mongo
parentb6e5d1e2af49ebb2edfb6522ba744d344b73c4f6 (diff)
downloadmongo-1a90996313ec83f0913bf2aef322193b0884f499.tar.gz
SERVER-14668 split dbdirectclient out of instance.cpp
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/db/auth/authz_manager_external_state_d.cpp2
-rw-r--r--src/mongo/db/cloner.cpp2
-rw-r--r--src/mongo/db/commands/apply_ops.cpp7
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp2
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp3
-rw-r--r--src/mongo/db/commands/mr.h2
-rw-r--r--src/mongo/db/db.cpp1
-rw-r--r--src/mongo/db/dbcommands.cpp1
-rw-r--r--src/mongo/db/dbdirectclient.cpp197
-rw-r--r--src/mongo/db/dbdirectclient.h110
-rw-r--r--src/mongo/db/instance.cpp86
-rw-r--r--src/mongo/db/instance.h65
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp2
-rw-r--r--src/mongo/db/repl/master_slave.cpp2
-rw-r--r--src/mongo/db/repl/oplog.cpp2
-rw-r--r--src/mongo/db/repl/rs_config.cpp2
-rw-r--r--src/mongo/db/restapi.cpp2
-rw-r--r--src/mongo/db/ttl.cpp4
-rw-r--r--src/mongo/dbtests/clienttests.cpp1
-rw-r--r--src/mongo/dbtests/commandtests.cpp1
-rw-r--r--src/mongo/dbtests/config_server_fixture.h4
-rw-r--r--src/mongo/dbtests/dbhelper_tests.cpp1
-rw-r--r--src/mongo/dbtests/directclienttests.cpp2
-rw-r--r--src/mongo/dbtests/documentsourcetests.cpp4
-rw-r--r--src/mongo/dbtests/executor_registry.cpp2
-rw-r--r--src/mongo/dbtests/gle_test.cpp1
-rw-r--r--src/mongo/dbtests/gridfstest.cpp1
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp5
-rw-r--r--src/mongo/dbtests/jstests.cpp2
-rw-r--r--src/mongo/dbtests/matchertests.cpp16
-rw-r--r--src/mongo/dbtests/oplogstarttests.cpp1
-rw-r--r--src/mongo/dbtests/perf/perftest.cpp2
-rw-r--r--src/mongo/dbtests/perftests.cpp6
-rw-r--r--src/mongo/dbtests/plan_ranking.cpp2
-rw-r--r--src/mongo/dbtests/profile_test.cpp2
-rw-r--r--src/mongo/dbtests/query_multi_plan_runner.cpp8
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_and.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_collscan.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_count.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_delete.cpp1
-rw-r--r--src/mongo/dbtests/query_stage_distinct.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_fetch.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_keep.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_merge_sort.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_sort.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_subplan.cpp1
-rw-r--r--src/mongo/dbtests/query_stage_tests.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_update.cpp1
-rw-r--r--src/mongo/dbtests/querytests.cpp2
-rw-r--r--src/mongo/dbtests/repltests.cpp2
-rw-r--r--src/mongo/dbtests/sharding.cpp1
-rw-r--r--src/mongo/dbtests/threadedtests.cpp1
-rw-r--r--src/mongo/dbtests/updatetests.cpp2
-rw-r--r--src/mongo/tools/tool.cpp1
56 files changed, 375 insertions, 211 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index d87311fd0e1..75ae9a234f6 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -623,6 +623,7 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/dbeval.cpp",
"db/dbhelpers.cpp",
"db/instance.cpp",
+ "db/dbdirectclient.cpp",
"db/client.cpp",
"db/catalog/database.cpp",
"db/catalog/index_catalog.cpp",
diff --git a/src/mongo/db/auth/authz_manager_external_state_d.cpp b/src/mongo/db/auth/authz_manager_external_state_d.cpp
index 84798ef6d40..0d67973624d 100644
--- a/src/mongo/db/auth/authz_manager_external_state_d.cpp
+++ b/src/mongo/db/auth/authz_manager_external_state_d.cpp
@@ -41,8 +41,8 @@
#include "mongo/db/auth/user_name.h"
#include "mongo/db/client.h"
#include "mongo/db/dbhelpers.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/global_environment_experiment.h"
-#include "mongo/db/instance.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/storage/storage_engine.h"
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index bf60bd3ace9..8861ff4442e 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -45,9 +45,9 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/copydb.h"
#include "mongo/db/commands/rename_collection.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/index_builder.h"
-#include "mongo/db/instance.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/isself.h"
diff --git a/src/mongo/db/commands/apply_ops.cpp b/src/mongo/db/commands/apply_ops.cpp
index e4901cd303d..34e8bceeb17 100644
--- a/src/mongo/db/commands/apply_ops.cpp
+++ b/src/mongo/db/commands/apply_ops.cpp
@@ -35,13 +35,14 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
#include "mongo/db/auth/resource_pattern.h"
-#include "mongo/db/jsobj.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/dbhash.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/matcher.h"
-#include "mongo/db/repl/oplog.h"
#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/repl/oplog.h"
namespace mongo {
class ApplyOpsCmd : public Command {
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index fd3e8e6b57e..ba93d95bc54 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -37,9 +37,9 @@
#include "mongo/db/background.h"
#include "mongo/db/commands.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/instance.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database.h"
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 2e3bbb7969d..4477e62bec0 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -34,10 +34,11 @@
#include "mongo/db/commands/find_and_modify.h"
+#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
-#include "mongo/db/instance.h"
#include "mongo/db/projection.h"
#include "mongo/db/ops/delete.h"
#include "mongo/db/ops/update.h"
diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h
index 0566d60bb60..404e6a24072 100644
--- a/src/mongo/db/commands/mr.h
+++ b/src/mongo/db/commands/mr.h
@@ -36,7 +36,7 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/curop.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/jsobj.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/scripting/engine.h"
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index add54ab935e..e5b013ffc68 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -53,6 +53,7 @@
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/db.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/dbwebserver.h"
#include "mongo/db/global_environment_d.h"
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index ec08a4989a5..a2cce53daba 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -54,6 +54,7 @@
#include "mongo/db/commands/server_status.h"
#include "mongo/db/commands/shutdown.h"
#include "mongo/db/db.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_environment_d.h"
#include "mongo/db/index_builder.h"
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
new file mode 100644
index 00000000000..7d43034ad58
--- /dev/null
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -0,0 +1,197 @@
+/**
+ * Copyright (C) 2014 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/db/dbdirectclient.h"
+
+#include "mongo/db/client.h"
+#include "mongo/db/commands/count.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/operation_context.h"
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ // Called from scripting/engine.cpp and scripting/v8_db.cpp.
+ DBClientBase* createDirectClient(OperationContext* txn) {
+ return new DBDirectClient(txn);
+ }
+
+ namespace {
+
+ class GodScope {
+ MONGO_DISALLOW_COPYING(GodScope);
+ public:
+ GodScope(OperationContext* txn) : _txn(txn) {
+ _prev = _txn->getClient()->setGod(true);
+ }
+
+ ~GodScope() {
+ _txn->getClient()->setGod(_prev);
+ }
+
+ private:
+ bool _prev;
+ OperationContext* _txn;
+ };
+
+ } // namespace
+
+
+ DBDirectClient::DBDirectClient(OperationContext* txn) : _txn(txn) { }
+
+ bool DBDirectClient::isFailed() const {
+ return false;
+ }
+
+ bool DBDirectClient::isStillConnected() {
+ return true;
+ }
+
+ std::string DBDirectClient::toString() const {
+ return "DBDirectClient";
+ }
+
+ std::string DBDirectClient::getServerAddress() const {
+ return "localhost"; // TODO: should this have the port?
+ }
+
+ void DBDirectClient::sayPiggyBack(Message& toSend) {
+ // don't need to piggy back when connected locally
+ return say(toSend);
+ }
+
+ bool DBDirectClient::callRead(Message& toSend, Message& response) {
+ return call(toSend, response);
+ }
+
+ ConnectionString::ConnectionType DBDirectClient::type() const {
+ return ConnectionString::MASTER;
+ }
+
+ double DBDirectClient::getSoTimeout() const {
+ return 0;
+ }
+
+ bool DBDirectClient::lazySupported() const {
+ return true;
+ }
+
+ void DBDirectClient::setOpCtx(OperationContext* txn) {
+ _txn = txn;
+ }
+
+ QueryOptions DBDirectClient::_lookupAvailableOptions() {
+ // Exhaust mode is not available in DBDirectClient.
+ return QueryOptions(DBClientBase::_lookupAvailableOptions() & ~QueryOption_Exhaust);
+ }
+
+ bool DBDirectClient::call(Message& toSend,
+ Message& response,
+ bool assertOk,
+ string* actualServer) {
+
+ GodScope gs(_txn);
+ if (lastError._get()) {
+ lastError.startRequest(toSend, lastError._get());
+ }
+
+ DbResponse dbResponse;
+ assembleResponse(_txn, toSend, dbResponse, dummyHost);
+ verify(dbResponse.response);
+
+ // can get rid of this if we make response handling smarter
+ dbResponse.response->concat();
+ response = *dbResponse.response;
+
+ return true;
+ }
+
+ void DBDirectClient::say(Message& toSend, bool isRetry, string* actualServer) {
+ GodScope gs(_txn);
+ if (lastError._get()) {
+ lastError.startRequest(toSend, lastError._get());
+ }
+
+ DbResponse dbResponse;
+ assembleResponse(_txn, toSend, dbResponse, dummyHost);
+ }
+
+ auto_ptr<DBClientCursor> DBDirectClient::query(const string& ns,
+ Query query,
+ int nToReturn,
+ int nToSkip,
+ const BSONObj* fieldsToReturn,
+ int queryOptions,
+ int batchSize) {
+
+ return DBClientBase::query(ns,
+ query,
+ nToReturn,
+ nToSkip,
+ fieldsToReturn,
+ queryOptions,
+ batchSize);
+ }
+
+ void DBDirectClient::killCursor(long long id) {
+ // The killCursor command on the DB client is only used by sharding,
+ // so no need to have it for MongoD.
+ verify(!"killCursor should not be used in MongoD");
+ }
+
+ const HostAndPort DBDirectClient::dummyHost("0.0.0.0", 0);
+
+ unsigned long long DBDirectClient::count(const string& ns,
+ const BSONObj& query,
+ int options,
+ int limit,
+ int skip) {
+ if (skip < 0) {
+ warning() << "setting negative skip value: " << skip
+ << " to zero in query: " << query << endl;
+ skip = 0;
+ }
+
+ Lock::DBRead lk(_txn->lockState(), ns);
+ string errmsg;
+ int errCode;
+ long long res = runCount(_txn,
+ ns,
+ _countCmd(ns, query, options, limit, skip),
+ errmsg,
+ errCode);
+
+ if (res == -1) {
+ // namespace doesn't exist
+ return 0;
+ }
+ massert(errCode, str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0);
+ return (unsigned long long )res;
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/dbdirectclient.h b/src/mongo/db/dbdirectclient.h
new file mode 100644
index 00000000000..0a8b5122dd0
--- /dev/null
+++ b/src/mongo/db/dbdirectclient.h
@@ -0,0 +1,110 @@
+/**
+ * Copyright (C) 2014 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 "mongo/client/dbclientinterface.h"
+#include "mongo/db/dbmessage.h"
+#include "mongo/util/net/hostandport.h"
+
+namespace mongo {
+
+ class OperationContext;
+
+ /**
+ * Embedded calls to the local server using the DBClientBase API without going over the network.
+ *
+ * Caller does not need to lock, that is handled within.
+ *
+ * All operations are performed within the scope of a passed-in OperationContext (except when
+ * using the deprecated constructor). You must ensure that the OperationContext is valid when
+ * calling into any function. If you ever need to change the OperationContext, that can be done
+ * without the overhead of creating a new DBDirectClient by calling setOpCtx(), after which all
+ * operations will use the new OperationContext.
+ */
+ class DBDirectClient : public DBClientBase {
+ public:
+ static const HostAndPort dummyHost;
+
+ DBDirectClient(OperationContext* txn);
+
+ using DBClientBase::query;
+
+ // XXX: is this valid or useful?
+ void setOpCtx(OperationContext* txn);
+
+ virtual std::auto_ptr<DBClientCursor> query(const std::string &ns,
+ Query query,
+ int nToReturn = 0,
+ int nToSkip = 0,
+ const BSONObj* fieldsToReturn = 0,
+ int queryOptions = 0,
+ int batchSize = 0);
+
+ virtual bool isFailed() const;
+
+ virtual bool isStillConnected();
+
+ virtual std::string toString() const;
+
+ virtual std::string getServerAddress() const;
+
+ virtual bool call(Message& toSend,
+ Message& response,
+ bool assertOk = true,
+ std::string* actualServer = 0);
+
+ virtual void say(Message& toSend,
+ bool isRetry = false,
+ std::string* actualServer = 0);
+
+ virtual void sayPiggyBack(Message& toSend);
+
+ virtual void killCursor(long long cursorID);
+
+ virtual bool callRead(Message& toSend, Message& response);
+
+ virtual unsigned long long count(const std::string &ns,
+ const BSONObj& query = BSONObj(),
+ int options = 0,
+ int limit = 0,
+ int skip = 0);
+
+ virtual ConnectionString::ConnectionType type() const;
+
+ double getSoTimeout() const;
+
+ virtual bool lazySupported() const;
+
+ virtual QueryOptions _lookupAvailableOptions();
+
+ private:
+ OperationContext* _txn;
+ };
+
+} // namespace mongo
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 3495644750f..3aebe6ca895 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/commands/fsync.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/db.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/storage/storage_engine.h"
@@ -921,91 +922,6 @@ namespace mongo {
}
}
- DBDirectClient::DBDirectClient(OperationContext* txn)
- : _txn(txn)
- {}
-
- QueryOptions DBDirectClient::_lookupAvailableOptions() {
- // Exhaust mode is not available in DBDirectClient.
- return QueryOptions(DBClientBase::_lookupAvailableOptions() & ~QueryOption_Exhaust);
- }
-
-namespace {
- class GodScope {
- MONGO_DISALLOW_COPYING(GodScope);
- public:
- GodScope(OperationContext* txn) : _txn(txn) {
- _prev = _txn->getClient()->setGod(true);
- }
- ~GodScope() { _txn->getClient()->setGod(_prev); }
- private:
- bool _prev;
- OperationContext* _txn;
- };
-} // namespace
-
- bool DBDirectClient::call( Message &toSend, Message &response, bool assertOk , string * actualServer ) {
- GodScope gs(_txn);
- if ( lastError._get() )
- lastError.startRequest( toSend, lastError._get() );
- DbResponse dbResponse;
- assembleResponse(_txn, toSend, dbResponse, dummyHost);
- verify( dbResponse.response );
- dbResponse.response->concat(); // can get rid of this if we make response handling smarter
- response = *dbResponse.response;
- return true;
- }
-
- void DBDirectClient::say( Message &toSend, bool isRetry, string * actualServer ) {
- GodScope gs(_txn);
- if ( lastError._get() )
- lastError.startRequest( toSend, lastError._get() );
- DbResponse dbResponse;
- assembleResponse(_txn, toSend, dbResponse, dummyHost);
- }
-
- auto_ptr<DBClientCursor> DBDirectClient::query(const string &ns, Query query, int nToReturn , int nToSkip ,
- const BSONObj *fieldsToReturn , int queryOptions , int batchSize) {
-
- //if ( ! query.obj.isEmpty() || nToReturn != 0 || nToSkip != 0 || fieldsToReturn || queryOptions )
- return DBClientBase::query( ns , query , nToReturn , nToSkip , fieldsToReturn , queryOptions , batchSize );
- //
- //verify( query.obj.isEmpty() );
- //throw UserException( (string)"yay:" + ns );
- }
-
- void DBDirectClient::killCursor( long long id ) {
- // The killCursor command on the DB client is only used by sharding,
- // so no need to have it for MongoD.
- verify(!"killCursor should not be used in MongoD");
- }
-
- const HostAndPort DBDirectClient::dummyHost("0.0.0.0", 0);
-
- unsigned long long DBDirectClient::count(const string &ns, const BSONObj& query, int options, int limit, int skip ) {
- if ( skip < 0 ) {
- warning() << "setting negative skip value: " << skip
- << " to zero in query: " << query << endl;
- skip = 0;
- }
-
- Lock::DBRead lk(_txn->lockState(), ns);
- string errmsg;
- int errCode;
- long long res = runCount( _txn, ns, _countCmd( ns , query , options , limit , skip ) , errmsg, errCode );
- if ( res == -1 ) {
- // namespace doesn't exist
- return 0;
- }
- massert( errCode , str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0 );
- return (unsigned long long )res;
- }
-
- DBClientBase* createDirectClient(OperationContext* txn) {
- return new DBDirectClient(txn);
- }
-
-
static AtomicUInt32 shutdownInProgress(0);
bool inShutdown() {
diff --git a/src/mongo/db/instance.h b/src/mongo/db/instance.h
index d95f3b710f7..3b0453fddec 100644
--- a/src/mongo/db/instance.h
+++ b/src/mongo/db/instance.h
@@ -73,71 +73,6 @@ namespace mongo {
DbResponse& dbresponse,
const HostAndPort &client );
- /**
- * Embedded calls to the local server using the DBClientBase API without going over the network.
- *
- * Caller does not need to lock, that is handled within.
- *
- * All operations are performed within the scope of a passed-in OperationContext (except when
- * using the deprecated constructor). You must ensure that the OperationContext is valid when
- * calling into any function. If you ever need to change the OperationContext, that can be done
- * without the overhead of creating a new DBDirectClient by calling setOpCtx(), after which all
- * operations will use the new OperationContext.
- */
- class DBDirectClient : public DBClientBase {
- public:
- static const HostAndPort dummyHost;
-
- DBDirectClient(OperationContext* txn);
-
- void setOpCtx(OperationContext* txn) { _txn = txn; };
-
- using DBClientBase::query;
-
- virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0,
- const BSONObj *fieldsToReturn = 0, int queryOptions = 0, int batchSize = 0);
-
- virtual bool isFailed() const {
- return false;
- }
-
- virtual bool isStillConnected() {
- return true;
- }
-
- virtual std::string toString() const {
- return "DBDirectClient";
- }
- virtual std::string getServerAddress() const {
- return "localhost"; // TODO: should this have the port?
- }
- virtual bool call( Message &toSend, Message &response, bool assertOk=true , std::string * actualServer = 0 );
- virtual void say( Message &toSend, bool isRetry = false , std::string * actualServer = 0 );
- virtual void sayPiggyBack( Message &toSend ) {
- // don't need to piggy back when connected locally
- return say( toSend );
- }
-
- virtual void killCursor( long long cursorID );
-
- virtual bool callRead( Message& toSend , Message& response ) {
- return call( toSend , response );
- }
-
- virtual unsigned long long count(const std::string &ns, const BSONObj& query = BSONObj(), int options=0, int limit=0, int skip=0 );
-
- virtual ConnectionString::ConnectionType type() const { return ConnectionString::MASTER; }
-
- double getSoTimeout() const { return 0; }
-
- virtual bool lazySupported() const { return true; }
-
- virtual QueryOptions _lookupAvailableOptions();
-
- private:
- OperationContext* _txn;
- };
-
void maybeCreatePidFile();
} // namespace mongo
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index 9f4d4c5b653..1a923abc7b7 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -33,7 +33,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/pipeline/pipeline.h"
#include "mongo/db/query/get_executor.h"
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index 044ecf88029..939e1e37032 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -50,8 +50,8 @@
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/cloner.h"
#include "mongo/db/commands.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
-#include "mongo/db/instance.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/oplog.h"
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 5951826e130..d422133db2a 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -44,11 +44,11 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/dbhash.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/global_optime.h"
#include "mongo/db/index_builder.h"
-#include "mongo/db/instance.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/ops/update_lifecycle_impl.h"
diff --git a/src/mongo/db/repl/rs_config.cpp b/src/mongo/db/repl/rs_config.cpp
index ed7aaef0290..9017d7f715c 100644
--- a/src/mongo/db/repl/rs_config.cpp
+++ b/src/mongo/db/repl/rs_config.cpp
@@ -34,8 +34,8 @@
#include <boost/algorithm/string.hpp>
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
-#include "mongo/db/instance.h"
#include "mongo/db/repl/connections.h"
#include "mongo/db/repl/heartbeat.h"
#include "mongo/db/repl/isself.h"
diff --git a/src/mongo/db/restapi.cpp b/src/mongo/db/restapi.cpp
index e419aa0ccf9..931de5fff9e 100644
--- a/src/mongo/db/restapi.cpp
+++ b/src/mongo/db/restapi.cpp
@@ -38,9 +38,9 @@
#include "mongo/db/auth/user_name.h"
#include "mongo/db/background.h"
#include "mongo/db/clientcursor.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/dbwebserver.h"
-#include "mongo/db/instance.h"
#include "mongo/db/repl/master_slave.h"
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index 903654008d4..1d9989c54dc 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -42,11 +42,11 @@
#include "mongo/db/commands/fsync.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/catalog/database_holder.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/delete.h"
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/db/server_parameters.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/util/background.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp
index a3ffa92258c..0fcfa4adba9 100644
--- a/src/mongo/dbtests/clienttests.cpp
+++ b/src/mongo/dbtests/clienttests.cpp
@@ -31,6 +31,7 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
diff --git a/src/mongo/dbtests/commandtests.cpp b/src/mongo/dbtests/commandtests.cpp
index 364a73fcf84..124498b4be1 100644
--- a/src/mongo/dbtests/commandtests.cpp
+++ b/src/mongo/dbtests/commandtests.cpp
@@ -29,6 +29,7 @@
#include "mongo/platform/basic.h"
#include "mongo/db/concurrency/d_concurrency.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
diff --git a/src/mongo/dbtests/config_server_fixture.h b/src/mongo/dbtests/config_server_fixture.h
index abb03cc7165..077a2448768 100644
--- a/src/mongo/dbtests/config_server_fixture.h
+++ b/src/mongo/dbtests/config_server_fixture.h
@@ -28,10 +28,10 @@
#pragma once
-#include "mongo/db/instance.h"
+#include "mongo/client/dbclientinterface.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/wire_version.h"
-#include "mongo/client/dbclientinterface.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
diff --git a/src/mongo/dbtests/dbhelper_tests.cpp b/src/mongo/dbtests/dbhelper_tests.cpp
index 39045d542ad..4801b711a1c 100644
--- a/src/mongo/dbtests/dbhelper_tests.cpp
+++ b/src/mongo/dbtests/dbhelper_tests.cpp
@@ -28,6 +28,7 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/write_concern_options.h"
diff --git a/src/mongo/dbtests/directclienttests.cpp b/src/mongo/dbtests/directclienttests.cpp
index 9c96dc331fd..7111bb3a12a 100644
--- a/src/mongo/dbtests/directclienttests.cpp
+++ b/src/mongo/dbtests/directclienttests.cpp
@@ -32,7 +32,7 @@
#include "mongo/pch.h"
#include "mongo/db/db.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp
index 41e307d4fad..1a17bfa7c8c 100644
--- a/src/mongo/dbtests/documentsourcetests.cpp
+++ b/src/mongo/dbtests/documentsourcetests.cpp
@@ -34,13 +34,13 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
-#include "mongo/db/operation_context_noop.h"
+#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/db/pipeline/dependencies.h"
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/pipeline/expression_context.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/storage_options.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
namespace DocumentSourceTests {
diff --git a/src/mongo/dbtests/executor_registry.cpp b/src/mongo/dbtests/executor_registry.cpp
index ea9dfac1389..f594532285c 100644
--- a/src/mongo/dbtests/executor_registry.cpp
+++ b/src/mongo/dbtests/executor_registry.cpp
@@ -34,9 +34,9 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/gle_test.cpp b/src/mongo/dbtests/gle_test.cpp
index ded97a490e1..8c0d410b399 100644
--- a/src/mongo/dbtests/gle_test.cpp
+++ b/src/mongo/dbtests/gle_test.cpp
@@ -26,6 +26,7 @@
* then also delete it in the license file.
*/
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/util/assert_util.h"
diff --git a/src/mongo/dbtests/gridfstest.cpp b/src/mongo/dbtests/gridfstest.cpp
index 14c861ca58e..ca95149b83d 100644
--- a/src/mongo/dbtests/gridfstest.cpp
+++ b/src/mongo/dbtests/gridfstest.cpp
@@ -29,6 +29,7 @@
#include "mongo/pch.h"
#include "mongo/client/gridfs.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/util/assert_util.h"
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 5e3b2ddfb25..3640d52ddb2 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -28,14 +28,15 @@
* then also delete it in the license file.
*/
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_catalog.h"
+#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_environment_d.h"
#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/index/btree_based_bulk_access_method.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/catalog/collection.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/platform/cstdint.h"
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp
index 08bd04bce4f..322273fad8b 100644
--- a/src/mongo/dbtests/jstests.cpp
+++ b/src/mongo/dbtests/jstests.cpp
@@ -34,7 +34,7 @@
#include <limits>
#include "mongo/base/parse_number.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/json.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
diff --git a/src/mongo/dbtests/matchertests.cpp b/src/mongo/dbtests/matchertests.cpp
index efe21b9cb88..e4e1bc91316 100644
--- a/src/mongo/dbtests/matchertests.cpp
+++ b/src/mongo/dbtests/matchertests.cpp
@@ -29,8 +29,6 @@
* then also delete it in the license file.
*/
-#include "mongo/pch.h"
-
#include "mongo/db/json.h"
#include "mongo/db/matcher/matcher.h"
#include "mongo/db/operation_context_impl.h"
@@ -41,19 +39,9 @@ namespace MatcherTests {
class CollectionBase {
public:
- CollectionBase() : _ns( "unittests.matchertests" ) {
-
- }
-
- virtual ~CollectionBase() {
- OperationContextImpl txn;
- DBDirectClient client(&txn);
-
- client.dropCollection(_ns);
- }
+ CollectionBase() { }
- protected:
- const char * const _ns;
+ virtual ~CollectionBase() { }
};
template <typename M>
diff --git a/src/mongo/dbtests/oplogstarttests.cpp b/src/mongo/dbtests/oplogstarttests.cpp
index 2db30876b53..8dca89c0061 100644
--- a/src/mongo/dbtests/oplogstarttests.cpp
+++ b/src/mongo/dbtests/oplogstarttests.cpp
@@ -23,6 +23,7 @@
#include "mongo/dbtests/dbtests.h"
#include "mongo/db/db.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/oplogstart.h"
#include "mongo/db/exec/working_set.h"
#include "mongo/db/query/canonical_query.h"
diff --git a/src/mongo/dbtests/perf/perftest.cpp b/src/mongo/dbtests/perf/perftest.cpp
index e5bea30d802..b891dd92e94 100644
--- a/src/mongo/dbtests/perf/perftest.cpp
+++ b/src/mongo/dbtests/perf/perftest.cpp
@@ -35,7 +35,7 @@
#include "mongo/base/initializer.h"
#include "mongo/client/dbclientcursor.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/json.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp
index 9a0b54e30ad..345505e5ffa 100644
--- a/src/mongo/dbtests/perftests.cpp
+++ b/src/mongo/dbtests/perftests.cpp
@@ -42,13 +42,13 @@
#include <fstream>
#include "mongo/db/db.h"
+#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/json.h"
+#include "mongo/db/lasterror.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage/mmap_v1/durable_mapped_file.h"
#include "mongo/db/storage/mmap_v1/dur_stats.h"
-#include "mongo/db/instance.h"
-#include "mongo/db/json.h"
#include "mongo/db/storage/mmap_v1/btree/key.h"
-#include "mongo/db/lasterror.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/dbtests/framework_options.h"
#include "mongo/util/allocator.h"
diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp
index 9daf82e8f09..451c9907ffa 100644
--- a/src/mongo/dbtests/plan_ranking.cpp
+++ b/src/mongo/dbtests/plan_ranking.cpp
@@ -33,9 +33,9 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/multi_plan.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/get_executor.h"
diff --git a/src/mongo/dbtests/profile_test.cpp b/src/mongo/dbtests/profile_test.cpp
index 15e04854bf2..0f773933936 100644
--- a/src/mongo/dbtests/profile_test.cpp
+++ b/src/mongo/dbtests/profile_test.cpp
@@ -30,7 +30,7 @@
* This file contains tests for the profile command
*/
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/dbtests/query_multi_plan_runner.cpp b/src/mongo/dbtests/query_multi_plan_runner.cpp
index 04774eba73e..8878f68e282 100644
--- a/src/mongo/dbtests/query_multi_plan_runner.cpp
+++ b/src/mongo/dbtests/query_multi_plan_runner.cpp
@@ -30,21 +30,21 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/index_scan.h"
#include "mongo/db/exec/multi_plan.h"
#include "mongo/db/exec/plan_stage.h"
+#include "mongo/db/json.h"
+#include "mongo/db/matcher/expression_parser.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/query/query_planner_test_lib.h"
#include "mongo/db/query/stage_builder.h"
-#include "mongo/db/instance.h"
-#include "mongo/db/json.h"
-#include "mongo/db/matcher/expression_parser.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
namespace mongo {
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index 813e36f2486..4d998817425 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -29,11 +29,11 @@
#include "mongo/db/clientcursor.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/index_scan.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp
index 8fdd728d372..171e916b8c2 100644
--- a/src/mongo/dbtests/query_stage_and.cpp
+++ b/src/mongo/dbtests/query_stage_and.cpp
@@ -35,12 +35,12 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/and_hash.h"
#include "mongo/db/exec/and_sorted.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/index_scan.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp
index e1261940f1e..e403bf3d35b 100644
--- a/src/mongo/dbtests/query_stage_collscan.cpp
+++ b/src/mongo/dbtests/query_stage_collscan.cpp
@@ -33,9 +33,9 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/query/plan_executor.h"
diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp
index c316528ee4f..f66a2a527c4 100644
--- a/src/mongo/dbtests/query_stage_count.cpp
+++ b/src/mongo/dbtests/query_stage_count.cpp
@@ -30,11 +30,11 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/keep_mutations.h"
#include "mongo/db/exec/count_scan.h"
#include "mongo/db/exec/working_set.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp
index aee7d930d29..b2e6c9db085 100644
--- a/src/mongo/dbtests/query_stage_delete.cpp
+++ b/src/mongo/dbtests/query_stage_delete.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/delete.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_distinct.cpp b/src/mongo/dbtests/query_stage_distinct.cpp
index 4f219d13cb4..f7ca9d51911 100644
--- a/src/mongo/dbtests/query_stage_distinct.cpp
+++ b/src/mongo/dbtests/query_stage_distinct.cpp
@@ -28,9 +28,9 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/distinct_scan.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/index_bounds_builder.h"
diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp
index 42d7f86ec2f..7e0b6dcd2ee 100644
--- a/src/mongo/dbtests/query_stage_fetch.cpp
+++ b/src/mongo/dbtests/query_stage_fetch.cpp
@@ -34,10 +34,10 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/plan_stage.h"
#include "mongo/db/exec/mock_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_keep.cpp b/src/mongo/dbtests/query_stage_keep.cpp
index 9eced015261..ed72c84d9c1 100644
--- a/src/mongo/dbtests/query_stage_keep.cpp
+++ b/src/mongo/dbtests/query_stage_keep.cpp
@@ -34,11 +34,11 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/keep_mutations.h"
#include "mongo/db/exec/plan_stage.h"
#include "mongo/db/exec/working_set.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_merge_sort.cpp b/src/mongo/dbtests/query_stage_merge_sort.cpp
index 760539fbd61..cfd9aa8a0c5 100644
--- a/src/mongo/dbtests/query_stage_merge_sort.cpp
+++ b/src/mongo/dbtests/query_stage_merge_sort.cpp
@@ -28,11 +28,11 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/index_scan.h"
#include "mongo/db/exec/plan_stage.h"
#include "mongo/db/exec/merge_sort.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp
index 6d19eb40a69..2b2573505a6 100644
--- a/src/mongo/dbtests/query_stage_sort.cpp
+++ b/src/mongo/dbtests/query_stage_sort.cpp
@@ -28,11 +28,11 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/mock_stage.h"
#include "mongo/db/exec/plan_stage.h"
#include "mongo/db/exec/sort.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp
index 7bd9cdc9fa0..1d72dccca7d 100644
--- a/src/mongo/dbtests/query_stage_subplan.cpp
+++ b/src/mongo/dbtests/query_stage_subplan.cpp
@@ -28,6 +28,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/subplan.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp
index d61c23698bf..db4af0563a3 100644
--- a/src/mongo/dbtests/query_stage_tests.cpp
+++ b/src/mongo/dbtests/query_stage_tests.cpp
@@ -28,9 +28,9 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/index_scan.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp
index cacc98424b9..2eabf36361b 100644
--- a/src/mongo/dbtests/query_stage_update.cpp
+++ b/src/mongo/dbtests/query_stage_update.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/eof.h"
#include "mongo/db/exec/update.h"
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index a14d3e620b3..865e71ed153 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -32,11 +32,11 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/clientcursor.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_environment_d.h"
#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/global_optime.h"
-#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/query/new_find.h"
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index 6422cccd15c..e4b48da6fff 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -34,7 +34,7 @@
#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/mutable_bson_test_utils.h"
#include "mongo/db/db.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/json.h"
#include "mongo/db/repl/master_slave.h"
#include "mongo/db/repl/oplog.h"
diff --git a/src/mongo/dbtests/sharding.cpp b/src/mongo/dbtests/sharding.cpp
index 73501e551ea..d1bf8d7cb9f 100644
--- a/src/mongo/dbtests/sharding.cpp
+++ b/src/mongo/dbtests/sharding.cpp
@@ -32,6 +32,7 @@
#include "mongo/client/dbclientmockcursor.h"
#include "mongo/client/parallel.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/config_server_fixture.h"
#include "mongo/dbtests/dbtests.h"
diff --git a/src/mongo/dbtests/threadedtests.cpp b/src/mongo/dbtests/threadedtests.cpp
index 054aadbac7c..d84ea1ff2ae 100644
--- a/src/mongo/dbtests/threadedtests.cpp
+++ b/src/mongo/dbtests/threadedtests.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/lock_state.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/platform/atomic_word.h"
diff --git a/src/mongo/dbtests/updatetests.cpp b/src/mongo/dbtests/updatetests.cpp
index cbdcc346dc8..5c67372f2ed 100644
--- a/src/mongo/dbtests/updatetests.cpp
+++ b/src/mongo/dbtests/updatetests.cpp
@@ -34,7 +34,7 @@
#include "mongo/bson/mutable/mutable_bson_test_utils.h"
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/db.h"
-#include "mongo/db/instance.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/ops/update.h"
diff --git a/src/mongo/tools/tool.cpp b/src/mongo/tools/tool.cpp
index 07abc3069b9..22ce4e7548d 100644
--- a/src/mongo/tools/tool.cpp
+++ b/src/mongo/tools/tool.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/authz_manager_external_state_mock.h"
#include "mongo/db/client.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/global_environment_d.h"
#include "mongo/db/json.h"