summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2016-11-07 15:39:49 -0500
committerJason Carey <jcarey@argv.me>2016-11-07 16:10:01 -0500
commitb6c29702d8dcadb6c1ee90a876fac4117e0ca062 (patch)
treedea8e8b05c619b21a557639499c729696fe81ad3 /src/mongo/executor
parentd4a7ae574011cf40e7785c439969904954e18db2 (diff)
downloadmongo-b6c29702d8dcadb6c1ee90a876fac4117e0ca062.tar.gz
SERVER-25027 Configurable connpool in mongos
Export server parameters for sharding connection pool
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/connection_pool.cpp8
-rw-r--r--src/mongo/executor/connection_pool.h12
-rw-r--r--src/mongo/executor/network_interface_factory.cpp5
-rw-r--r--src/mongo/executor/network_interface_factory.h4
4 files changed, 19 insertions, 10 deletions
diff --git a/src/mongo/executor/connection_pool.cpp b/src/mongo/executor/connection_pool.cpp
index ad5ee9f7338..eb4b9effb97 100644
--- a/src/mongo/executor/connection_pool.cpp
+++ b/src/mongo/executor/connection_pool.cpp
@@ -172,9 +172,11 @@ private:
State _state;
};
-Milliseconds const ConnectionPool::kDefaultRefreshTimeout = Seconds(20);
-Milliseconds const ConnectionPool::kDefaultRefreshRequirement = Seconds(60);
-Milliseconds const ConnectionPool::kDefaultHostTimeout = Minutes(5);
+constexpr Milliseconds ConnectionPool::kDefaultHostTimeout;
+size_t const ConnectionPool::kDefaultMaxConns = std::numeric_limits<size_t>::max();
+size_t const ConnectionPool::kDefaultMinConns = 1;
+constexpr Milliseconds ConnectionPool::kDefaultRefreshRequirement;
+constexpr Milliseconds ConnectionPool::kDefaultRefreshTimeout;
const Status ConnectionPool::kConnectionStateUnknown =
Status(ErrorCodes::InternalError, "Connection is in an unknown state");
diff --git a/src/mongo/executor/connection_pool.h b/src/mongo/executor/connection_pool.h
index a7b1428ca99..492ba6fe7da 100644
--- a/src/mongo/executor/connection_pool.h
+++ b/src/mongo/executor/connection_pool.h
@@ -68,9 +68,11 @@ public:
using GetConnectionCallback = stdx::function<void(StatusWith<ConnectionHandle>)>;
- static const Milliseconds kDefaultRefreshTimeout;
- static const Milliseconds kDefaultRefreshRequirement;
- static const Milliseconds kDefaultHostTimeout;
+ static constexpr Milliseconds kDefaultHostTimeout = Milliseconds(300000); // 5mins
+ static const size_t kDefaultMaxConns;
+ static const size_t kDefaultMinConns;
+ static constexpr Milliseconds kDefaultRefreshRequirement = Milliseconds(60000); // 1min
+ static constexpr Milliseconds kDefaultRefreshTimeout = Milliseconds(20000); // 20secs
static const Status kConnectionStateUnknown;
@@ -81,14 +83,14 @@ public:
* The minimum number of connections to keep alive while the pool is in
* operation
*/
- size_t minConnections = 1;
+ size_t minConnections = kDefaultMinConns;
/**
* The maximum number of connections to spawn for a host. This includes
* pending connections in setup and connections checked out of the pool
* as well as the obvious live connections in the pool.
*/
- size_t maxConnections = std::numeric_limits<size_t>::max();
+ size_t maxConnections = kDefaultMaxConns;
/**
* Amount of time to wait before timing out a refresh attempt
diff --git a/src/mongo/executor/network_interface_factory.cpp b/src/mongo/executor/network_interface_factory.cpp
index 8a3f0e8f7cc..2dc7d3f5845 100644
--- a/src/mongo/executor/network_interface_factory.cpp
+++ b/src/mongo/executor/network_interface_factory.cpp
@@ -36,6 +36,7 @@
#include "mongo/executor/async_stream_factory.h"
#include "mongo/executor/async_stream_interface.h"
#include "mongo/executor/async_timer_asio.h"
+#include "mongo/executor/connection_pool.h"
#include "mongo/executor/network_connection_hook.h"
#include "mongo/executor/network_interface_asio.h"
#include "mongo/rpc/metadata/metadata_hook.h"
@@ -52,12 +53,14 @@ std::unique_ptr<NetworkInterface> makeNetworkInterface(std::string instanceName)
std::unique_ptr<NetworkInterface> makeNetworkInterface(
std::string instanceName,
std::unique_ptr<NetworkConnectionHook> hook,
- std::unique_ptr<rpc::EgressMetadataHook> metadataHook) {
+ std::unique_ptr<rpc::EgressMetadataHook> metadataHook,
+ ConnectionPool::Options connPoolOptions) {
NetworkInterfaceASIO::Options options{};
options.instanceName = std::move(instanceName);
options.networkConnectionHook = std::move(hook);
options.metadataHook = std::move(metadataHook);
options.timerFactory = stdx::make_unique<AsyncTimerFactoryASIO>();
+ options.connectionPoolOptions = connPoolOptions;
#ifdef MONGO_CONFIG_SSL
if (SSLManagerInterface* manager = getSSLManager()) {
diff --git a/src/mongo/executor/network_interface_factory.h b/src/mongo/executor/network_interface_factory.h
index 20fe061081a..7aa8a8cdce5 100644
--- a/src/mongo/executor/network_interface_factory.h
+++ b/src/mongo/executor/network_interface_factory.h
@@ -31,6 +31,7 @@
#include <memory>
#include <string>
+#include "mongo/executor/connection_pool.h"
#include "mongo/executor/network_interface.h"
namespace mongo {
@@ -54,7 +55,8 @@ std::unique_ptr<NetworkInterface> makeNetworkInterface(std::string instanceName)
std::unique_ptr<NetworkInterface> makeNetworkInterface(
std::string instanceName,
std::unique_ptr<NetworkConnectionHook> hook,
- std::unique_ptr<rpc::EgressMetadataHook> metadataHook);
+ std::unique_ptr<rpc::EgressMetadataHook> metadataHook,
+ ConnectionPool::Options options = ConnectionPool::Options());
} // namespace executor
} // namespace mongo