Skip to content

Commit 7ebb16b

Browse files
committed
connection pool
1 parent ec0829c commit 7ebb16b

File tree

3 files changed

+141
-88
lines changed

3 files changed

+141
-88
lines changed

source/connection/specify-connection-options/connection-options.txt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ parameters of the connection URI to specify the behavior of the client.
1717
- Type
1818
- Description
1919

20-
* - **minPoolSize**
21-
- integer
22-
- Specifies the minimum number of connections that must exist at
23-
any moment in a single connection pool.
20+
.. * - **minPoolSize**
21+
.. - integer
22+
.. - Specifies the minimum number of connections that must exist at
23+
.. any moment in a single connection pool.
2424

25-
| **Default**: ``0``
25+
.. | **Default**: ``0``
2626

27-
* - **maxPoolSize**
28-
- integer
29-
- Specifies the maximum number of connections that a connection
30-
pool can have at a given time.
27+
.. * - **maxPoolSize**
28+
.. - integer
29+
.. - Specifies the maximum number of connections that a connection
30+
.. pool can have at a given time.
3131

32-
| **Default**: ``100``
32+
.. | **Default**: ``100``
3333

34-
* - **waitQueueTimeoutMS**
35-
- integer
36-
- Specifies the maximum amount of time, in milliseconds that a
37-
thread can wait for a connection to become available.
34+
.. * - **waitQueueTimeoutMS**
35+
.. - integer
36+
.. - Specifies the maximum amount of time, in milliseconds that a
37+
.. thread can wait for a connection to become available.
3838

39-
| **Default**: ``120000`` (120 seconds)
39+
.. | **Default**: ``120000`` (120 seconds)
4040

4141
* - **serverSelectionTimeoutMS**
4242
- integer
@@ -121,14 +121,14 @@ parameters of the connection URI to specify the behavior of the client.
121121

122122
| **Default**: ``0``
123123

124-
* - **maxIdleTimeMS**
125-
- integer
126-
- Specifies the maximum amount of time, in milliseconds, that the driver
127-
allows a pooled connection to idle before closing the
128-
connection. A value of ``0`` indicates that there is no upper bound
129-
on how long the driver allows a pooled connection to be idle.
124+
.. * - **maxIdleTimeMS**
125+
.. - integer
126+
.. - Specifies the maximum amount of time, in milliseconds, that the driver
127+
.. allows a pooled connection to idle before closing the
128+
.. connection. A value of ``0`` indicates that there is no upper bound
129+
.. on how long the driver allows a pooled connection to be idle.
130130

131-
| **Default**: ``0``
131+
.. | **Default**: ``0``
132132

133133
* - **maxLifeTimeMS**
134134
- integer
@@ -285,12 +285,12 @@ parameters of the connection URI to specify the behavior of the client.
285285

286286
| **Default**: ``false``
287287

288-
* - **maxConnecting**
289-
- integer
290-
- Specifies the maximum number of connections a pool can establish
291-
concurrently.
288+
.. * - **maxConnecting**
289+
.. - integer
290+
.. - Specifies the maximum number of connections a pool can establish
291+
.. concurrently.
292292

293-
| **Default**: ``2``
293+
.. | **Default**: ``2``
294294

295295
* - **srvServiceName**
296296
- string

source/connection/specify-connection-options/connection-pools.txt

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,75 @@ see the corresponding syntax:
114114

115115
*Default*: ``120000`` (120 seconds)
116116

117-
To learn more about connection string options, see the
118-
:ref:`Connection Options <connection-options>`
119-
guide.
120-
121117
.. tab:: MongoClientSettings
122-
:tabid: MongoClient
118+
:tabid: MongoClient
119+
120+
Chain the `applyToConnectionPoolSettings() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html#applyToConnectionPoolSettings(com.mongodb.Block)>`__ method to modify the way the driver manages its connection pool.
121+
122+
The following table describes the methods you can chain to your settings to modify the driver's behavior:
123+
124+
.. list-table::
125+
:widths: 40 60
126+
:header-rows: 1
127+
128+
* - Method
129+
- Description
130+
131+
* - ``addConnectionPoolListener()``
132+
- Adds a listener for connection pool-related events.
133+
134+
* - ``applyConnectionString()``
135+
- Uses the settings from a ``ConnectionString`` object.
136+
137+
* - ``applySettings()``
138+
- Uses the connection pool settings specified in a
139+
``ConnectionPoolSettings`` object.
140+
141+
* - ``maintenanceFrequency()``
142+
- Sets the frequency for running a maintenance job.
143+
144+
* - ``maintenanceInitialDelay()``
145+
- Sets the time to wait before running the first maintenance job.
146+
147+
* - ``maxConnectionIdleTime()``
148+
- Sets the maximum time a connection can be idle before it's closed.
149+
150+
* - ``maxConnectionLifeTime()``
151+
- Sets the maximum time a pooled connection can be alive before it's
152+
closed.
153+
154+
* - ``maxSize()``
155+
- | Sets the maximum number of connections associated with a connection
156+
pool.
157+
|
158+
| **Default**: ``100``
159+
160+
* - ``maxWaitTime()``
161+
- | Sets the maximum time to wait for an available connection.
162+
|
163+
| **Default**: ``2 minutes``
164+
165+
* - ``minSize()``
166+
- | Sets the minimum number of connections associated with a connection
167+
pool.
168+
|
169+
| **Default**: ``0``
170+
171+
.. note::
172+
173+
This ``maxSize`` and ``minSize`` settings apply to each server in the cluster you connect the driver to.
174+
175+
For example, assume you connect the driver to a cluster with three``mongos`` servers. This means that there can be at most ``maxSize`` connections and at least ``minSize`` connections to each ``mongos`` server.
123176

124-
.. literalinclude:: /includes/fundamentals/code-snippets/ConnectionPool.java
125-
:start-after: begin MongoSettings
126-
:end-before: end MongoSettings
127-
:language: java
128-
:dedent:
177+
.. literalinclude:: /includes/fundamentals/code-snippets/ConnectionPool.java
178+
:start-after: begin MongoSettings
179+
:end-before: end MongoSettings
180+
:language: java
181+
:dedent:
129182

130-
For more information on configuring you connection pool by using a
131-
``MongoClientSettings`` object see the Connection Pool Settings section
132-
of the :ref:`<specify-mongoclient-settings>` guide.
183+
For more information on configuring you connection pool by using a
184+
``MongoClientSettings`` object see the Connection Pool Settings section
185+
of the :ref:`<specify-mongoclient-settings>` guide.
133186

134187
Additional Information
135188
----------------------

source/connection/specify-connection-options/mongoclientsettings.txt

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ connection behavior:
7373
- Applies the ``ClusterSettings.Builder`` block and then sets the
7474
:ref:`cluster settings <mcs-cluster-settings>`.
7575

76-
* - ``applyToConnectionPoolSettings()``
77-
- Applies the ``ConnectionPoolSettings.Builder`` block and then sets the
78-
:ref:`connection pool settings <mcs-connectionpool-settings>`.
76+
.. * - ``applyToConnectionPoolSettings()``
77+
.. - Applies the ``ConnectionPoolSettings.Builder`` block and then sets the
78+
.. :ref:`connection pool settings <mcs-connectionpool-settings>`.
7979

8080
* - ``applyToLoggerSettings()``
8181
- Applies the ``LoggerSettings.Builder`` block and then sets the
@@ -308,68 +308,68 @@ regardless of the type of MongoDB cluster it's a part of:
308308
Connection Pool Settings
309309
------------------------
310310

311-
Chain the `applyToConnectionPoolSettings() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html#applyToConnectionPoolSettings(com.mongodb.Block)>`__
312-
method to modify the way the driver manages its connection pool.
311+
.. Chain the `applyToConnectionPoolSettings() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html#applyToConnectionPoolSettings(com.mongodb.Block)>`__
312+
.. method to modify the way the driver manages its connection pool.
313313

314-
The following table describes the methods you can chain to your
315-
settings to modify the driver's behavior:
314+
.. The following table describes the methods you can chain to your
315+
.. settings to modify the driver's behavior:
316316

317-
.. list-table::
318-
:widths: 40 60
319-
:header-rows: 1
317+
.. .. list-table::
318+
.. :widths: 40 60
319+
.. :header-rows: 1
320320

321-
* - Method
322-
- Description
321+
.. * - Method
322+
.. - Description
323323

324-
* - ``addConnectionPoolListener()``
325-
- Adds a listener for connection pool-related events.
324+
.. * - ``addConnectionPoolListener()``
325+
.. - Adds a listener for connection pool-related events.
326326

327-
* - ``applyConnectionString()``
328-
- Uses the settings from a ``ConnectionString`` object.
327+
.. * - ``applyConnectionString()``
328+
.. - Uses the settings from a ``ConnectionString`` object.
329329

330-
* - ``applySettings()``
331-
- Uses the connection pool settings specified in a
332-
``ConnectionPoolSettings`` object.
330+
.. * - ``applySettings()``
331+
.. - Uses the connection pool settings specified in a
332+
.. ``ConnectionPoolSettings`` object.
333333

334-
* - ``maintenanceFrequency()``
335-
- Sets the frequency for running a maintenance job.
334+
.. * - ``maintenanceFrequency()``
335+
.. - Sets the frequency for running a maintenance job.
336336

337-
* - ``maintenanceInitialDelay()``
338-
- Sets the time to wait before running the first maintenance job.
337+
.. * - ``maintenanceInitialDelay()``
338+
.. - Sets the time to wait before running the first maintenance job.
339339

340-
* - ``maxConnectionIdleTime()``
341-
- Sets the maximum time a connection can be idle before it's closed.
340+
.. * - ``maxConnectionIdleTime()``
341+
.. - Sets the maximum time a connection can be idle before it's closed.
342342

343-
* - ``maxConnectionLifeTime()``
344-
- Sets the maximum time a pooled connection can be alive before it's
345-
closed.
343+
.. * - ``maxConnectionLifeTime()``
344+
.. - Sets the maximum time a pooled connection can be alive before it's
345+
.. closed.
346346

347-
* - ``maxSize()``
348-
- | Sets the maximum number of connections associated with a connection
349-
pool.
350-
|
351-
| **Default**: ``100``
347+
.. * - ``maxSize()``
348+
.. - | Sets the maximum number of connections associated with a connection
349+
.. pool.
350+
.. |
351+
.. | **Default**: ``100``
352352

353-
* - ``maxWaitTime()``
354-
- | Sets the maximum time to wait for an available connection.
355-
|
356-
| **Default**: ``2 minutes``
353+
.. * - ``maxWaitTime()``
354+
.. - | Sets the maximum time to wait for an available connection.
355+
.. |
356+
.. | **Default**: ``2 minutes``
357357

358-
* - ``minSize()``
359-
- | Sets the minimum number of connections associated with a connection
360-
pool.
361-
|
362-
| **Default**: ``0``
358+
.. * - ``minSize()``
359+
.. - | Sets the minimum number of connections associated with a connection
360+
.. pool.
361+
.. |
362+
.. | **Default**: ``0``
363363

364364

365-
.. note::
365+
.. .. note::
366366

367-
This ``maxSize`` and ``minSize`` settings apply to each server
368-
in the cluster you connect the driver to.
367+
.. This ``maxSize`` and ``minSize`` settings apply to each server
368+
.. in the cluster you connect the driver to.
369369

370-
For example, assume you connect the driver to a cluster with three
371-
``mongos`` servers. This means that there can be at most ``maxSize``
372-
connections and at least ``minSize`` connections to each ``mongos`` server.
370+
.. For example, assume you connect the driver to a cluster with three
371+
.. ``mongos`` servers. This means that there can be at most ``maxSize``
372+
.. connections and at least ``minSize`` connections to each ``mongos`` server.
373373

374374
Example
375375
~~~~~~~

0 commit comments

Comments
 (0)