summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-02-13 12:57:29 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-02-13 17:18:20 -0500
commitf8af7207e2359a119b29b6d4e4c6945cc0bf1a8a (patch)
treeab3a58e47fc318f743a68b1ea9d283c6e439b6fb /src/mongo
parentd3b53c3acae86649f56b44c47258b38e76023457 (diff)
downloadmongo-f8af7207e2359a119b29b6d4e4c6945cc0bf1a8a.tar.gz
SERVER-29908 Create skeleton libraries for the sharding subsystem
Splits the sharding sybsystem into 3 main libraries, which are currently mostly empty, but we will start moving code from all the other existing libraries into them. The libraries are: s/sharding_api, db/s/sharding_api and db/s/sharding_runtime
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/SConscript2
-rw-r--r--src/mongo/client/global_conn_pool.cpp36
-rw-r--r--src/mongo/db/SConscript20
-rw-r--r--src/mongo/db/commands/SConscript4
-rw-r--r--src/mongo/db/commands/dbcommands.cpp13
-rw-r--r--src/mongo/db/conn_pool_options.cpp104
-rw-r--r--src/mongo/db/conn_pool_options.h74
-rw-r--r--src/mongo/db/dbhelpers.cpp10
-rw-r--r--src/mongo/db/dbhelpers.h4
-rw-r--r--src/mongo/db/repl/SConscript4
-rw-r--r--src/mongo/db/repl/oplog.cpp1
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp3
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp2
-rw-r--r--src/mongo/db/s/SConscript44
-rw-r--r--src/mongo/db/views/durable_view_catalog.cpp1
-rw-r--r--src/mongo/s/SConscript86
-rw-r--r--src/mongo/s/catalog/SConscript1
-rw-r--r--src/mongo/s/client/SConscript39
-rw-r--r--src/mongo/s/client/shard_connection.cpp32
-rw-r--r--src/mongo/s/client/shard_registry.cpp1
-rw-r--r--src/mongo/s/commands/SConscript8
-rw-r--r--src/mongo/s/commands/cluster_commands_helpers.cpp1
-rw-r--r--src/mongo/s/query/SConscript1
-rw-r--r--src/mongo/s/query/async_results_merger.cpp6
-rw-r--r--src/mongo/s/query/async_results_merger.h7
-rw-r--r--src/mongo/s/write_ops/SConscript17
-rw-r--r--src/mongo/s/write_ops/batch_downconvert.cpp4
-rw-r--r--src/mongo/s/write_ops/batch_downconvert.h8
28 files changed, 193 insertions, 340 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 0c6f230519c..bdb4aaa2688 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -294,7 +294,6 @@ env.Library(
LIBDEPS_PRIVATE=[
'db/catalog/health_log',
'db/commands/core',
- 'db/conn_pool_options',
'db/dbdirectclient',
'db/ftdc/ftdc_mongod',
'db/index_d',
@@ -410,7 +409,6 @@ env.Install(
LIBDEPS=[
'db/commands/core',
'db/commands/server_status',
- 'db/conn_pool_options',
'db/ftdc/ftdc_mongos',
'db/logical_time_metadata_hook',
'db/mongodandmongos',
diff --git a/src/mongo/client/global_conn_pool.cpp b/src/mongo/client/global_conn_pool.cpp
index 19dbf7018e2..1db19094217 100644
--- a/src/mongo/client/global_conn_pool.cpp
+++ b/src/mongo/client/global_conn_pool.cpp
@@ -30,7 +30,43 @@
#include "mongo/client/global_conn_pool.h"
+#include "mongo/base/init.h"
+#include "mongo/db/server_parameters.h"
+
namespace mongo {
+namespace {
+
+// Maximum connections per host the connection pool should store
+int maxConnsPerHost(200);
+ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
+ maxConnsPerHostParameter(ServerParameterSet::getGlobal(),
+ "connPoolMaxConnsPerHost",
+ &maxConnsPerHost);
+
+// Maximum in-use connections per host in the global connection pool
+int maxInUseConnsPerHost(std::numeric_limits<int>::max());
+ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
+ maxInUseConnsPerHostParameter(ServerParameterSet::getGlobal(),
+ "connPoolMaxInUseConnsPerHost",
+ &maxInUseConnsPerHost);
+
+// Amount of time, in minutes, to keep idle connections in the global connection pool
+int globalConnPoolIdleTimeout(std::numeric_limits<int>::max());
+ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
+ globalConnPoolIdleTimeoutParameter(ServerParameterSet::getGlobal(),
+ "globalConnPoolIdleTimeoutMinutes",
+ &globalConnPoolIdleTimeout);
+
+MONGO_INITIALIZER(InitializeGlobalConnectionPool)(InitializerContext* context) {
+ globalConnPool.setName("connection pool");
+ globalConnPool.setMaxPoolSize(maxConnsPerHost);
+ globalConnPool.setMaxInUse(maxInUseConnsPerHost);
+ globalConnPool.setIdleTimeout(globalConnPoolIdleTimeout);
+
+ return Status::OK();
+}
+
+} // namespace
DBConnectionPool globalConnPool;
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 6f59c76a4e3..0a3f7c5b422 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -951,9 +951,9 @@ env.Library(
"repl/sync_tail",
"repl/topology_coordinator",
"rw_concern_d",
- "s/collection_metadata",
"s/commands_db_s",
- "s/sharding",
+ "s/sharding_api_d",
+ "s/sharding_runtime_d",
"startup_warnings_mongod",
"stats/counters",
"stats/serveronly_stats",
@@ -1158,12 +1158,11 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/s/write_ops/cluster_write_op',
'logical_session_id',
'sessions_collection',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/s/query/cluster_query',
+ '$BUILD_DIR/mongo/s/sharding_api',
'sessions_collection_rs',
],
)
@@ -1582,19 +1581,6 @@ env.Library(
)
env.Library(
- target='conn_pool_options',
- source=[
- 'conn_pool_options.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/client/clientdriver',
- '$BUILD_DIR/mongo/db/server_parameters',
- '$BUILD_DIR/mongo/s/client/sharding_client',
- ],
-)
-
-env.Library(
target='cursor_server_params',
source=[
'cursor_server_params.cpp',
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 3835fe5d0c2..cd960452750 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -106,7 +106,7 @@ env.Library(
'$BUILD_DIR/mongo/db/stats/timer_stats',
'$BUILD_DIR/mongo/db/views/views',
'$BUILD_DIR/mongo/logger/parse_log_component_settings',
- '$BUILD_DIR/mongo/s/client/sharding_client',
+ '$BUILD_DIR/mongo/s/sharding_legacy_api',
'$BUILD_DIR/mongo/s/coreshard',
'$BUILD_DIR/mongo/s/write_ops/batch_write_types',
'$BUILD_DIR/mongo/scripting/scripting_common',
@@ -242,7 +242,7 @@ env.Library(
'$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/db/stats/serveronly_stats',
'$BUILD_DIR/mongo/db/views/views_mongod',
- '$BUILD_DIR/mongo/s/client/parallel',
+ '$BUILD_DIR/mongo/s/sharding_legacy_api',
'core',
'current_op_common',
'dcommands_fcv',
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 3282474b0db..ad3969c72f5 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -30,12 +30,9 @@
#include "mongo/platform/basic.h"
-#include <array>
#include <time.h>
-#include "mongo/base/disallow_copying.h"
#include "mongo/base/simple_string_data_comparator.h"
-#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/bson/util/bson_extract.h"
@@ -49,10 +46,10 @@
#include "mongo/db/auth/user_management_commands_parser.h"
#include "mongo/db/auth/user_name.h"
#include "mongo/db/background.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/coll_mod.h"
-#include "mongo/db/catalog/collection.h"
-#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/create_collection.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/drop_collection.h"
#include "mongo/db/catalog/drop_database.h"
#include "mongo/db/catalog/index_key_validate.h"
@@ -90,8 +87,6 @@
#include "mongo/db/server_parameters.h"
#include "mongo/db/stats/storage_stats.h"
#include "mongo/db/write_concern.h"
-#include "mongo/s/chunk_version.h"
-#include "mongo/s/grid.h"
#include "mongo/s/stale_exception.h"
#include "mongo/scripting/engine.h"
#include "mongo/util/fail_point_service.h"
@@ -106,6 +101,7 @@ using std::string;
using std::stringstream;
using std::unique_ptr;
+namespace {
class CmdShutdownMongoD : public CmdShutdown {
public:
@@ -574,7 +570,6 @@ public:
}
} cmdCreate;
-
class CmdFileMD5 : public BasicCommand {
public:
CmdFileMD5() : BasicCommand("filemd5") {}
@@ -747,7 +742,6 @@ public:
} cmdFileMD5;
-
class CmdDatasize : public ErrmsgCommandDeprecated {
virtual string parseNs(const string& dbname, const BSONObj& cmdObj) const {
return CommandHelpers::parseNsFullyQualified(dbname, cmdObj);
@@ -1129,4 +1123,5 @@ public:
}
} availableQueryOptionsCmd;
+} // namespace
} // namespace mongo
diff --git a/src/mongo/db/conn_pool_options.cpp b/src/mongo/db/conn_pool_options.cpp
deleted file mode 100644
index 851687fc7ff..00000000000
--- a/src/mongo/db/conn_pool_options.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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/platform/basic.h"
-
-#include "mongo/db/conn_pool_options.h"
-
-#include <limits>
-
-#include "mongo/base/init.h"
-#include "mongo/client/connpool.h"
-#include "mongo/client/global_conn_pool.h"
-#include "mongo/db/server_parameters.h"
-#include "mongo/s/client/shard_connection.h"
-
-namespace mongo {
-
-int ConnPoolOptions::maxConnsPerHost(200);
-int ConnPoolOptions::maxShardedConnsPerHost(200);
-
-int ConnPoolOptions::maxInUseConnsPerHost(std::numeric_limits<int>::max());
-int ConnPoolOptions::maxShardedInUseConnsPerHost(std::numeric_limits<int>::max());
-
-int ConnPoolOptions::globalConnPoolIdleTimeout(std::numeric_limits<int>::max());
-int ConnPoolOptions::shardedConnPoolIdleTimeout(std::numeric_limits<int>::max());
-
-namespace {
-
-ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
- maxConnsPerHostParameter(ServerParameterSet::getGlobal(),
- "connPoolMaxConnsPerHost",
- &ConnPoolOptions::maxConnsPerHost);
-
-ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
- maxShardedConnsPerHostParameter(ServerParameterSet::getGlobal(),
- "connPoolMaxShardedConnsPerHost",
- &ConnPoolOptions::maxShardedConnsPerHost);
-
-ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
- maxInUseConnsPerHostParameter(ServerParameterSet::getGlobal(),
- "connPoolMaxInUseConnsPerHost",
- &ConnPoolOptions::maxInUseConnsPerHost);
-
-ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
- maxShardedInUseConnsPerHostParameter(ServerParameterSet::getGlobal(),
- "connPoolMaxShardedInUseConnsPerHost",
- &ConnPoolOptions::maxShardedInUseConnsPerHost);
-
-ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
- globalConnPoolIdleTimeoutParameter(ServerParameterSet::getGlobal(),
- "globalConnPoolIdleTimeoutMinutes",
- &ConnPoolOptions::globalConnPoolIdleTimeout);
-
-ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
- shardedConnPoolIdleTimeoutParameter(ServerParameterSet::getGlobal(),
- "shardedConnPoolIdleTimeoutMinutes",
- &ConnPoolOptions::shardedConnPoolIdleTimeout);
-
-MONGO_INITIALIZER(InitializeConnectionPools)(InitializerContext* context) {
- // Initialize the sharded and unsharded outgoing connection pools
- // NOTES:
- // - All mongods and mongoses have both pools
- // - The connection hooks for sharding are added on startup (mongos) or on first sharded
- // operation (mongod)
-
- globalConnPool.setName("connection pool");
- globalConnPool.setMaxPoolSize(ConnPoolOptions::maxConnsPerHost);
- globalConnPool.setMaxInUse(ConnPoolOptions::maxInUseConnsPerHost);
- globalConnPool.setIdleTimeout(ConnPoolOptions::globalConnPoolIdleTimeout);
-
- shardConnectionPool.setName("sharded connection pool");
- shardConnectionPool.setMaxPoolSize(ConnPoolOptions::maxShardedConnsPerHost);
- shardConnectionPool.setMaxInUse(ConnPoolOptions::maxShardedInUseConnsPerHost);
- shardConnectionPool.setIdleTimeout(ConnPoolOptions::shardedConnPoolIdleTimeout);
-
- return Status::OK();
-}
-}
-}
diff --git a/src/mongo/db/conn_pool_options.h b/src/mongo/db/conn_pool_options.h
deleted file mode 100644
index 9394a156d6a..00000000000
--- a/src/mongo/db/conn_pool_options.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * 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/util/duration.h"
-
-namespace mongo {
-
-// NOTE:
-// The connection pools themselves are placed in different files and are currently hard to move
-// due to spaghetti dependencies.
-// TODO: Extract conn pools from driver files and shardconnection.cpp
-
-/**
- * Struct namespace for connection pool options on mongos and mongod
- */
-struct ConnPoolOptions {
- /**
- * Maximum connections per host the connection pool should store.
- */
- static int maxConnsPerHost;
-
- /**
- * Maximum connections per host the sharded conn pool should store.
- */
- static int maxShardedConnsPerHost;
-
- /**
- * Maximum in-use connections per host in the global connection pool.
- */
- static int maxInUseConnsPerHost;
-
- /**
- * Maximum in-use connections per host in the sharded connection pool.
- */
- static int maxShardedInUseConnsPerHost;
-
- /**
- * Amount of time, in minutes, to keep idle connections in the global connection pool.
- */
- static int globalConnPoolIdleTimeout;
-
- /**
- * Amount of time, in minutes, to keep idle connections in the sharded connection pool.
- */
- static int shardedConnPoolIdleTimeout;
-};
-}
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 966d8a0c06c..d8645f93f36 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -35,9 +35,7 @@
#include <boost/filesystem/operations.hpp>
#include <fstream>
-#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_create.h"
-#include "mongo/db/db.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/index/btree_access_method.h"
@@ -54,11 +52,8 @@
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/query_planner.h"
-#include "mongo/db/range_arithmetic.h"
#include "mongo/db/repl/repl_client_info.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/collection_sharding_state.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/data_protector.h"
@@ -74,15 +69,12 @@
namespace mongo {
using std::unique_ptr;
-using std::endl;
using std::ios_base;
using std::ofstream;
using std::set;
using std::string;
using std::stringstream;
-using logger::LogComponent;
-
/* fetch a single object from collection ns that matches query
set your db SavedContext first
*/
diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h
index c92cf49f96d..0166a413041 100644
--- a/src/mongo/db/dbhelpers.h
+++ b/src/mongo/db/dbhelpers.h
@@ -31,15 +31,17 @@
#include <boost/filesystem/path.hpp>
#include <memory>
-#include "mongo/db/db.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/record_id.h"
#include "mongo/db/storage/data_protector.h"
namespace mongo {
class Collection;
+class Database;
class DataProtector;
class OperationContext;
+class QueryRequest;
/**
* db helpers are helper functions and classes that let us easily manipulate the local
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index cb0d219cd12..69f284f3af4 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -506,7 +506,7 @@ env.Library(
'rslog',
'$BUILD_DIR/mongo/db/catalog/catalog_helpers',
'$BUILD_DIR/mongo/db/catalog/database_holder',
- '$BUILD_DIR/mongo/db/s/sharding',
+ '$BUILD_DIR/mongo/db/s/sharding_runtime_d',
'$BUILD_DIR/mongo/util/fail_point',
'$BUILD_DIR/mongo/db/dbhelpers',
'$BUILD_DIR/mongo/db/query_exec',
@@ -578,7 +578,7 @@ env.Library(
'repl_coordinator_interface',
'roll_back_local_operations',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
- '$BUILD_DIR/mongo/db/s/sharding',
+ '$BUILD_DIR/mongo/db/s/sharding_runtime_d',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/write_ops',
'$BUILD_DIR/mongo/util/net/network',
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 36a7df1ed51..73e45e962f8 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/create_collection.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/drop_collection.h"
#include "mongo/db/catalog/drop_database.h"
#include "mongo/db/catalog/drop_indexes.h"
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 7a73c7e20ee..5b76eb1c42f 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -39,8 +39,9 @@
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_manager_global.h"
-#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/rename_collection.h"
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index f6ca06237cd..38fbde8f10d 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -33,8 +33,8 @@
#include <initializer_list>
#include <utility>
-#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/index_create.h"
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 82c3f51f3f8..509d75f5e6b 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -4,18 +4,34 @@ Import("env")
env = env.Clone()
+# This is the main library to use for consumers of sharding on a mongod shard. It will pull the
+# version checking and document filtering functionality.
+#
+# This is the only library, which should be referenced directly outside of mongo/s/ and mongo/db/s/
env.Library(
- target='collection_metadata',
+ target='sharding_api_d',
source=[
'collection_metadata.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/range_arithmetic',
- '$BUILD_DIR/mongo/db/service_context',
- '$BUILD_DIR/mongo/s/common_s',
- '$BUILD_DIR/mongo/s/routing_table',
+ '$BUILD_DIR/mongo/s/sharding_routing_table',
+ ],
+)
+
+env.Library(
+ target='sharding_runtime_d',
+ source=[
+ 'migration_destination_manager.cpp',
+ 'session_catalog_migration_destination.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/db/db_raii',
+ '$BUILD_DIR/mongo/db/dbhelpers',
+ '$BUILD_DIR/mongo/db/repl/oplog',
+ '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
+ '$BUILD_DIR/mongo/db/rw_concern_d',
+ 'sharding',
],
)
@@ -56,14 +72,12 @@ env.Library(
'metadata_manager.cpp',
'migration_chunk_cloner_source.cpp',
'migration_chunk_cloner_source_legacy.cpp',
- 'migration_destination_manager.cpp',
'migration_source_manager.cpp',
'migration_util.cpp',
'move_timing_helper.cpp',
'namespace_metadata_change_notifications.cpp',
'operation_sharding_state.cpp',
'read_only_catalog_cache_loader.cpp',
- 'session_catalog_migration_destination.cpp',
'session_catalog_migration_source.cpp',
'shard_identity_rollback_notifier.cpp',
'shard_metadata_util.cpp',
@@ -87,7 +101,6 @@ env.Library(
'$BUILD_DIR/mongo/db/commands/dcommands_fcv',
'$BUILD_DIR/mongo/db/commands/server_status',
'$BUILD_DIR/mongo/db/common',
- '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
'$BUILD_DIR/mongo/s/client/shard_local',
'$BUILD_DIR/mongo/s/coreshard',
'$BUILD_DIR/mongo/s/is_mongos',
@@ -95,8 +108,8 @@ env.Library(
'$BUILD_DIR/mongo/s/sharding_task_executor',
'$BUILD_DIR/mongo/util/elapsed_tracker',
'balancer',
- 'collection_metadata',
'migration_types',
+ 'sharding_api_d',
'type_shard_identity',
],
LIBDEPS_TAGS=[
@@ -160,11 +173,12 @@ env.Library(
'$BUILD_DIR/mongo/db/catalog/collection_options',
'$BUILD_DIR/mongo/db/commands/dcommands_fcv',
'$BUILD_DIR/mongo/db/repl/read_concern_args',
- '$BUILD_DIR/mongo/db/s/balancer',
'$BUILD_DIR/mongo/executor/network_interface',
'$BUILD_DIR/mongo/s/catalog/sharding_catalog_client',
'$BUILD_DIR/mongo/s/client/sharding_client',
'$BUILD_DIR/mongo/s/coreshard',
+ 'balancer',
+ 'type_shard_identity',
],
)
@@ -207,16 +221,12 @@ env.Library(
'$BUILD_DIR/mongo/db/bson/dotted_path_support',
'$BUILD_DIR/mongo/db/commands/dcommands_fcv',
'$BUILD_DIR/mongo/db/commands/server_status',
- '$BUILD_DIR/mongo/db/db_raii',
- '$BUILD_DIR/mongo/db/dbhelpers',
'$BUILD_DIR/mongo/db/index_d',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_global',
- '$BUILD_DIR/mongo/db/rw_concern_d',
'$BUILD_DIR/mongo/s/commands/shared_cluster_commands',
'balancer',
- 'collection_metadata',
- 'sharding',
'sharding_catalog_manager',
+ 'sharding_runtime_d',
],
)
@@ -321,7 +331,7 @@ env.CppUnitTest(
'$BUILD_DIR/mongo/db/ops/write_ops_exec',
'$BUILD_DIR/mongo/s/catalog/sharding_catalog_client_mock',
'$BUILD_DIR/mongo/s/shard_server_test_fixture',
- 'sharding',
+ 'sharding_runtime_d',
]
)
diff --git a/src/mongo/db/views/durable_view_catalog.cpp b/src/mongo/db/views/durable_view_catalog.cpp
index bfec32e9409..90ac1f4f95b 100644
--- a/src/mongo/db/views/durable_view_catalog.cpp
+++ b/src/mongo/db/views/durable_view_catalog.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/concurrency/d_concurrency.h"
+#include "mongo/db/curop.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript
index 8c40b164e7a..250708fa8c2 100644
--- a/src/mongo/s/SConscript
+++ b/src/mongo/s/SConscript
@@ -17,6 +17,55 @@ env.SConscript(
],
)
+# This is the main library to use for consumers of sharding. It will pull the routing and targeting
+# functionality.
+#
+# This is the only library, which should be referenced directly outside of mongo/s/ and mongo/db/s/
+env.Library(
+ target='sharding_api',
+ source=[
+ 'write_ops/cluster_write.cpp',
+ ],
+ LIBDEPS=[
+ 'query/cluster_query',
+ 'write_ops/cluster_write_op',
+ ],
+)
+
+# This library contains legacy sharding functionality, which should not be included in any new
+# development.
+env.Library(
+ target='sharding_legacy_api',
+ source=[
+ 'client/parallel.cpp',
+ 'client/shard_connection.cpp',
+ 'client/version_manager.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/client/clientdriver',
+ '$BUILD_DIR/mongo/db/lasterror',
+ 'cluster_last_error_info',
+ 'grid',
+ 'sharding_routing_table',
+ ],
+)
+
+env.Library(
+ target='sharding_routing_table',
+ source=[
+ 'chunk.cpp',
+ 'chunk_manager.cpp',
+ 'shard_key_pattern.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/db/matcher/expressions',
+ '$BUILD_DIR/mongo/db/query/query_planner',
+ '$BUILD_DIR/mongo/db/storage/key_string',
+ '$BUILD_DIR/mongo/db/update/update_common',
+ 'common_s',
+ ],
+)
+
# Functionality for initializing global sharding state
env.Library(
target='sharding_initialization',
@@ -221,23 +270,6 @@ env.CppUnitTest('request_types_test',
)
env.Library(
- target='routing_table',
- source=[
- 'chunk.cpp',
- 'chunk_manager.cpp',
- 'shard_key_pattern.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/db/matcher/expressions',
- '$BUILD_DIR/mongo/db/query/query_planner',
- '$BUILD_DIR/mongo/db/storage/key_string',
- '$BUILD_DIR/mongo/db/update/update_common',
- 'common_s',
- ],
-)
-
-
-env.Library(
target='sharding_task_executor',
source=[
'sharding_task_executor.cpp',
@@ -246,7 +278,7 @@ env.Library(
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/executor/thread_pool_task_executor',
'$BUILD_DIR/mongo/s/client/sharding_client',
- '$BUILD_DIR/mongo/s/cluster_last_error_info',
+ 'cluster_last_error_info',
],
)
@@ -275,7 +307,7 @@ env.Library(
'$BUILD_DIR/mongo/db/logical_time_metadata_hook',
'client/shard_interface',
'query/cluster_cursor_manager',
- 'routing_table',
+ 'sharding_routing_table',
],
)
@@ -299,7 +331,7 @@ env.Library(
)
env.CppUnitTest(
- target='routing_table_test',
+ target='sharding_routing_table_test',
source=[
'catalog_cache_refresh_test.cpp',
'catalog_cache_test_fixture.cpp',
@@ -367,3 +399,17 @@ env.CppUnitTest(
'sharding_test_fixture',
]
)
+
+env.CppUnitTest(
+ target='sharding_legacy_api_test',
+ source=[
+ 'client/shard_connection_test.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/db/service_context_noop_init',
+ '$BUILD_DIR/mongo/dbtests/mocklib',
+ '$BUILD_DIR/mongo/util/net/network',
+ 'client/sharding_connection_hook',
+ 'sharding_legacy_api',
+ ]
+)
diff --git a/src/mongo/s/catalog/SConscript b/src/mongo/s/catalog/SConscript
index 1913fee75d6..9960139fb73 100644
--- a/src/mongo/s/catalog/SConscript
+++ b/src/mongo/s/catalog/SConscript
@@ -78,7 +78,6 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/repl/read_concern_args',
- '$BUILD_DIR/mongo/db/s/type_shard_identity',
'$BUILD_DIR/mongo/executor/network_interface',
'$BUILD_DIR/mongo/s/client/sharding_client',
'$BUILD_DIR/mongo/s/coreshard',
diff --git a/src/mongo/s/client/SConscript b/src/mongo/s/client/SConscript
index 5a5019433bb..1089e992f52 100644
--- a/src/mongo/s/client/SConscript
+++ b/src/mongo/s/client/SConscript
@@ -7,19 +7,14 @@ env = env.Clone()
env.Library(
target='sharding_client',
source=[
- 'shard_connection.cpp',
'shard_remote.cpp',
- 'version_manager.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/client/clientdriver',
'$BUILD_DIR/mongo/client/fetcher',
'$BUILD_DIR/mongo/db/commands',
'$BUILD_DIR/mongo/db/lasterror',
'$BUILD_DIR/mongo/executor/task_executor_pool',
'$BUILD_DIR/mongo/s/grid',
- '$BUILD_DIR/mongo/s/routing_table',
- '$BUILD_DIR/mongo/s/cluster_last_error_info',
'shard_interface',
],
)
@@ -31,41 +26,9 @@ env.Library(
'sharding_network_connection_hook.cpp',
],
LIBDEPS=[
- 'sharding_client',
- '$BUILD_DIR/mongo/client/clientdriver',
- '$BUILD_DIR/mongo/s/coreshard',
- ],
-)
-
-env.Library(
- target='parallel',
- source=[
- 'parallel.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/db/bson/dotted_path_support',
'$BUILD_DIR/mongo/s/coreshard',
- '$BUILD_DIR/mongo/util/net/network',
- 'sharding_client',
- ],
-)
-
-env.CppUnitTest(
- target='sharding_client_test',
- source=[
- 'shard_connection_test.cpp',
+ '$BUILD_DIR/mongo/s/sharding_legacy_api'
],
- LIBDEPS=[
- 'sharding_client',
- 'sharding_connection_hook',
- '$BUILD_DIR/mongo/client/remote_command_retry_scheduler',
- '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
- '$BUILD_DIR/mongo/db/service_context_noop_init',
- '$BUILD_DIR/mongo/dbtests/mocklib',
- '$BUILD_DIR/mongo/s/coreshard',
- '$BUILD_DIR/mongo/util/net/network',
- ]
)
env.CppUnitTest(
diff --git a/src/mongo/s/client/shard_connection.cpp b/src/mongo/s/client/shard_connection.cpp
index 0e7dfb0b845..2aa50893ecf 100644
--- a/src/mongo/s/client/shard_connection.cpp
+++ b/src/mongo/s/client/shard_connection.cpp
@@ -34,7 +34,9 @@
#include <set>
+#include "mongo/base/init.h"
#include "mongo/db/lasterror.h"
+#include "mongo/db/server_parameters.h"
#include "mongo/s/chunk_manager.h"
#include "mongo/s/client/shard.h"
#include "mongo/s/client/shard_registry.h"
@@ -339,6 +341,36 @@ void ActiveClientConnections::appendInfo(BSONObjBuilder* b) const {
thread_local std::unique_ptr<ClientConnections> ClientConnections::_perThread;
+// Maximum connections per host the sharded conn pool should store
+int maxShardedConnsPerHost(200);
+ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
+ maxShardedConnsPerHostParameter(ServerParameterSet::getGlobal(),
+ "connPoolMaxShardedConnsPerHost",
+ &maxShardedConnsPerHost);
+
+// Maximum in-use connections per host in the sharded connection pool
+int maxShardedInUseConnsPerHost(std::numeric_limits<int>::max());
+ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
+ maxShardedInUseConnsPerHostParameter(ServerParameterSet::getGlobal(),
+ "connPoolMaxShardedInUseConnsPerHost",
+ &maxShardedInUseConnsPerHost);
+
+// Amount of time, in minutes, to keep idle connections in the sharded connection pool
+int shardedConnPoolIdleTimeout(std::numeric_limits<int>::max());
+ExportedServerParameter<int, ServerParameterType::kStartupOnly> //
+ shardedConnPoolIdleTimeoutParameter(ServerParameterSet::getGlobal(),
+ "shardedConnPoolIdleTimeoutMinutes",
+ &shardedConnPoolIdleTimeout);
+
+MONGO_INITIALIZER(InitializeShardedConnectionPool)(InitializerContext* context) {
+ shardConnectionPool.setName("sharded connection pool");
+ shardConnectionPool.setMaxPoolSize(maxShardedConnsPerHost);
+ shardConnectionPool.setMaxInUse(maxShardedInUseConnsPerHost);
+ shardConnectionPool.setIdleTimeout(shardedConnPoolIdleTimeout);
+
+ return Status::OK();
+}
+
} // namespace
DBConnectionPool shardConnectionPool;
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp
index 0ef7d72a497..3dfbb716bac 100644
--- a/src/mongo/s/client/shard_registry.cpp
+++ b/src/mongo/s/client/shard_registry.cpp
@@ -52,7 +52,6 @@
#include "mongo/s/catalog/sharding_catalog_client.h"
#include "mongo/s/catalog/type_shard.h"
#include "mongo/s/client/shard.h"
-#include "mongo/s/client/shard_connection.h"
#include "mongo/s/client/shard_factory.h"
#include "mongo/s/grid.h"
#include "mongo/stdx/memory.h"
diff --git a/src/mongo/s/commands/SConscript b/src/mongo/s/commands/SConscript
index aa8279ed2f1..6d2771746ab 100644
--- a/src/mongo/s/commands/SConscript
+++ b/src/mongo/s/commands/SConscript
@@ -17,8 +17,6 @@ env.Library(
'$BUILD_DIR/mongo/db/commands/killcursors_common',
'$BUILD_DIR/mongo/db/commands/current_op_common',
'$BUILD_DIR/mongo/s/async_requests_sender',
- '$BUILD_DIR/mongo/s/client/parallel',
- '$BUILD_DIR/mongo/s/coreshard',
]
)
@@ -94,11 +92,9 @@ env.Library(
'$BUILD_DIR/mongo/db/views/views',
'$BUILD_DIR/mongo/executor/async_multicaster',
'$BUILD_DIR/mongo/rpc/client_metadata',
- '$BUILD_DIR/mongo/s/async_requests_sender',
- '$BUILD_DIR/mongo/s/client/parallel',
'$BUILD_DIR/mongo/s/coreshard',
- '$BUILD_DIR/mongo/s/query/cluster_query',
- '$BUILD_DIR/mongo/s/write_ops/cluster_write_op',
+ '$BUILD_DIR/mongo/s/sharding_api',
+ '$BUILD_DIR/mongo/s/sharding_legacy_api',
'$BUILD_DIR/mongo/s/write_ops/cluster_write_op_conversion',
'$BUILD_DIR/mongo/transport/transport_layer_common',
'shared_cluster_commands',
diff --git a/src/mongo/s/commands/cluster_commands_helpers.cpp b/src/mongo/s/commands/cluster_commands_helpers.cpp
index bb4775f2e30..50e170fec57 100644
--- a/src/mongo/s/commands/cluster_commands_helpers.cpp
+++ b/src/mongo/s/commands/cluster_commands_helpers.cpp
@@ -40,7 +40,6 @@
#include "mongo/rpc/write_concern_error_detail.h"
#include "mongo/s/catalog/type_collection.h"
#include "mongo/s/catalog_cache.h"
-#include "mongo/s/client/parallel.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/create_database_gen.h"
diff --git a/src/mongo/s/query/SConscript b/src/mongo/s/query/SConscript
index 342b5e06823..43d2fc5c7e5 100644
--- a/src/mongo/s/query/SConscript
+++ b/src/mongo/s/query/SConscript
@@ -77,7 +77,6 @@ env.Library(
"$BUILD_DIR/mongo/s/async_requests_sender",
"$BUILD_DIR/mongo/s/client/sharding_client",
"$BUILD_DIR/mongo/db/pipeline/pipeline",
- "$BUILD_DIR/mongo/s/coreshard",
],
LIBDEPS_PRIVATE=[
"$BUILD_DIR/mongo/db/pipeline/document_source_lookup",
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index 343e0e64f35..8f80a4b64ab 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -40,8 +40,6 @@
#include "mongo/db/query/killcursors_request.h"
#include "mongo/executor/remote_command_request.h"
#include "mongo/executor/remote_command_response.h"
-#include "mongo/s/client/shard_registry.h"
-#include "mongo/s/grid.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
@@ -721,10 +719,6 @@ bool AsyncResultsMerger::RemoteCursorData::exhausted() const {
return cursorId == 0;
}
-std::shared_ptr<Shard> AsyncResultsMerger::RemoteCursorData::getShard() {
- return grid.shardRegistry()->getShardNoReload(shardHostAndPort.toString());
-}
-
//
// AsyncResultsMerger::MergingComparator
//
diff --git a/src/mongo/s/query/async_results_merger.h b/src/mongo/s/query/async_results_merger.h
index e8d13fa79cd..0a441016060 100644
--- a/src/mongo/s/query/async_results_merger.h
+++ b/src/mongo/s/query/async_results_merger.h
@@ -97,7 +97,7 @@ public:
* In order to be destroyed, either the ARM must have been kill()'ed or all cursors must have
* been exhausted. This is so that any unexhausted cursors are cleaned up by the ARM.
*/
- virtual ~AsyncResultsMerger();
+ ~AsyncResultsMerger();
/**
* Returns true if all of the remote cursors are exhausted.
@@ -230,11 +230,6 @@ private:
*/
bool exhausted() const;
- /**
- * Returns the Shard object associated with this remote cursor.
- */
- std::shared_ptr<Shard> getShard();
-
// Used when merging tailable awaitData cursors in sorted order. In order to return any
// result to the client we have to know that no shard will ever return anything that sorts
// before it. This object represents a promise from the remote that it will never return a
diff --git a/src/mongo/s/write_ops/SConscript b/src/mongo/s/write_ops/SConscript
index 138c7e8083d..89401a022d6 100644
--- a/src/mongo/s/write_ops/SConscript
+++ b/src/mongo/s/write_ops/SConscript
@@ -28,7 +28,6 @@ env.Library(
'batch_write_exec.cpp',
'batch_write_op.cpp',
'chunk_manager_targeter.cpp',
- 'cluster_write.cpp',
'write_op.cpp',
],
LIBDEPS=[
@@ -47,9 +46,7 @@ env.Library(
'batch_downconvert.cpp',
],
LIBDEPS=[
- 'cluster_write_op',
- '$BUILD_DIR/mongo/db/dbmessage',
- '$BUILD_DIR/mongo/db/lasterror',
+ 'batch_write_types',
],
)
@@ -60,23 +57,22 @@ env.CppUnitTest(
'batched_command_response_test.cpp',
],
LIBDEPS=[
- 'batch_write_types',
'$BUILD_DIR/mongo/db/ops/write_ops_parsers_test_helpers',
+ 'batch_write_types',
]
)
env.CppUnitTest(
target='cluster_write_op_test',
source=[
- 'write_op_test.cpp',
- 'batch_write_op_test.cpp',
'batch_write_exec_test.cpp',
+ 'batch_write_op_test.cpp',
+ 'write_op_test.cpp',
],
LIBDEPS=[
- 'cluster_write_op',
- '$BUILD_DIR/mongo/db/range_arithmetic',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/s/sharding_test_fixture',
+ 'cluster_write_op',
]
)
@@ -86,9 +82,6 @@ env.CppUnitTest(
'batch_downconvert_test.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
- '$BUILD_DIR/mongo/db/service_context_noop_init',
- 'cluster_write_op',
'cluster_write_op_conversion',
]
)
diff --git a/src/mongo/s/write_ops/batch_downconvert.cpp b/src/mongo/s/write_ops/batch_downconvert.cpp
index c2af9e7db30..4356b79f08c 100644
--- a/src/mongo/s/write_ops/batch_downconvert.cpp
+++ b/src/mongo/s/write_ops/batch_downconvert.cpp
@@ -30,9 +30,7 @@
#include "mongo/s/write_ops/batch_downconvert.h"
-#include "mongo/bson/util/builder.h"
-#include "mongo/db/write_concern_options.h"
-#include "mongo/util/assert_util.h"
+#include "mongo/bson/bsonmisc.h"
namespace mongo {
diff --git a/src/mongo/s/write_ops/batch_downconvert.h b/src/mongo/s/write_ops/batch_downconvert.h
index dd33b8c1924..69b44513e30 100644
--- a/src/mongo/s/write_ops/batch_downconvert.h
+++ b/src/mongo/s/write_ops/batch_downconvert.h
@@ -28,14 +28,10 @@
#pragma once
-#include <string>
-
+#include "mongo/base/status.h"
#include "mongo/base/string_data.h"
#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/timestamp.h"
-#include "mongo/s/write_ops/batch_write_exec.h"
-#include "mongo/s/write_ops/batched_command_request.h"
-#include "mongo/s/write_ops/batched_command_response.h"
+#include "mongo/rpc/write_concern_error_detail.h"
#include "mongo/s/write_ops/write_error_detail.h"
namespace mongo {