Skip to content

Commit 27cb3e4

Browse files
author
Chris Cho
authored
DOCSP-19171: max hosts setting (#174)
* DOCSP-19171: max hosts setting
1 parent e7822a1 commit 27cb3e4

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

snooty.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "java"
2-
title = "Java"
2+
title = "Java Sync"
33
toc_landing_pages = [
44
"/fundamentals/connection",
55
"/fundamentals/crud",

source/fundamentals/connection/mongoclientsettings.txt

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The following sections describe commonly used settings:
2929
MongoClient Settings
3030
--------------------
3131

32-
You can control the behavior of your ``MongoClient`` by creating and passing in a
32+
You can control the behavior of your ``MongoClient`` by creating and passing in a
3333
`MongoClientSettings <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.html>`__
3434
object to the `MongoClients.create() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoClients.html#create(com.mongodb.MongoClientSettings)>`__
3535
method.
@@ -52,7 +52,7 @@ settings to modify the driver's behavior:
5252
* - ``addCommandListener()``
5353
- Adds a listener for :ref:`command events <command-events-java>`.
5454

55-
* - ``applicationName()``
55+
* - ``applicationName()``
5656
- Sets the logical name of the application using the ``MongoClient``.
5757

5858
* - ``applyConnectionString()``
@@ -74,7 +74,7 @@ settings to modify the driver's behavior:
7474
- Applies the ``SslSettings.Builder`` block and then sets the :ref:`TLS/SSL settings <mcs-ssl-settings>`.
7575

7676
* - ``autoEncryptionSettings()``
77-
- | Sets the :ref:`auto-encryption settings <auto-encryption-decryption-java>`.
77+
- | Sets the :ref:`auto-encryption settings <auto-encryption-decryption-java>`.
7878
|
7979
| If you omit ``keyVaultClient`` or set
8080
| ``bypassAutomaticEncryption`` to false in your
@@ -97,7 +97,7 @@ settings to modify the driver's behavior:
9797
* - ``credential()``
9898
- Sets the :ref:`credential <authentication-mechanisms-java>`.
9999

100-
* - ``readConcern()``
100+
* - ``readConcern()``
101101
- Sets the :manual:`read concern </reference/read-concern/>`.
102102

103103
* - ``readPreference()``
@@ -106,10 +106,10 @@ settings to modify the driver's behavior:
106106
* - ``retryReads()``
107107
- Whether the driver should :manual:`retry reads </core/retryable-reads/>` if a network error occurs.
108108

109-
* - ``retryWrites()``
109+
* - ``retryWrites()``
110110
- Whether the driver should :manual:`retry writes </core/retryable-writes/>` if a network error occurs.
111111

112-
* - ``serverApi()``
112+
* - ``serverApi()``
113113
- Sets the :ref:`server API <versioned-api-java>` to use when sending commands to the server.
114114

115115
* - ``streamFactoryFactory()``
@@ -118,7 +118,7 @@ settings to modify the driver's behavior:
118118
* - ``uuidRepresentation()``
119119
- Sets the UUID representation to use when encoding instances of UUID and decoding BSON binary values with subtype of 3.
120120

121-
* - ``writeConcern()``
121+
* - ``writeConcern()``
122122
- Sets the :manual:`write concern </reference/write-concern/>`.
123123

124124
.. _connection-string-example:
@@ -186,22 +186,22 @@ settings to modify the driver's behavior:
186186
* - Method
187187
- Description
188188

189-
* - ``addClusterListener()``
189+
* - ``addClusterListener()``
190190
- Adds a listener for cluster-related events.
191191

192-
* - ``applyConnectionString()``
192+
* - ``applyConnectionString()``
193193
- Uses the settings from a ``ConnectionString`` object.
194194

195195
* - ``applySettings()``
196196
- Uses the cluster settings specified in a ``ClusterSettings`` object.
197197

198-
* - ``hosts()``
198+
* - ``hosts()``
199199
- Sets all the specified locations of a Mongo server.
200200

201201
* - ``localThreshold()``
202202
- Sets the amount of time that a server’s round trip can take and still be eligible for server selection.
203203

204-
* - ``mode()``
204+
* - ``mode()``
205205
- Sets how to connect to a MongoDB server.
206206

207207
* - ``requiredClusterType()``
@@ -218,23 +218,30 @@ settings to modify the driver's behavior:
218218

219219
* - ``srvHost()``
220220
- Sets the host name to use to look up an SRV DNS record to find the MongoDB hosts.
221-
221+
222222
.. note::
223-
223+
224224
When setting ``srvHost``, the driver does not process any
225-
associated TXT records associated with the host.
225+
associated TXT records associated with the host.
226226

227227
If you want to enable the processing of TXT records, you must
228-
specify the SRV host in the connection string using the
228+
specify the SRV host in the connection string using the
229229
``applyConnectionString()`` method.
230230

231231
.. code-block:: java
232232
:emphasize-lines: 3
233-
233+
234234
MongoClient mongoClient = MongoClients.create(
235235
MongoClientSettings.builder()
236236
.applyConnectionString(new ConnectionString("mongodb+srv://host1.acme.com")))
237237

238+
* - ``srvMaxHosts()``
239+
- | Sets the maximum number of hosts the driver can connect to when using
240+
the DNS seedlist (SRV) connection protocol, identified by the
241+
``mongodb+srv`` connection string prefix.
242+
|
243+
| Throws an exception if you are not using the SRV connection protocol.
244+
238245
Example
239246
~~~~~~~
240247

@@ -273,7 +280,7 @@ settings to modify the driver's behavior:
273280
* - Method
274281
- Description
275282

276-
* - ``applyConnectionString()``
283+
* - ``applyConnectionString()``
277284
- Uses the settings from a ``ConnectionString`` object.
278285

279286
* - ``applySettings()``
@@ -312,7 +319,7 @@ Connection Pool Settings
312319
------------------------
313320

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

317324
The following table describes all the methods you can chain to your
318325
settings to modify the driver's behavior:
@@ -324,10 +331,10 @@ settings to modify the driver's behavior:
324331
* - Method
325332
- Description
326333

327-
* - ``addConnectionPoolListener()``
334+
* - ``addConnectionPoolListener()``
328335
- Adds a listener for connection pool-related events.
329336

330-
* - ``applyConnectionString()``
337+
* - ``applyConnectionString()``
331338
- Uses the settings from a ``ConnectionString`` object.
332339

333340
* - ``applySettings()``
@@ -354,6 +361,7 @@ settings to modify the driver's behavior:
354361
* - ``minSize()``
355362
- Sets the minimum amount of connections associated with a connection pool.
356363

364+
357365
.. note::
358366

359367
This ``maxSize`` and ``minSize`` settings apply to each server
@@ -401,10 +409,10 @@ settings to modify the driver's behavior:
401409
* - ``addServerListener()``
402410
- Adds a listener for server-related events.
403411

404-
* - ``addServerMonitorListener()``
412+
* - ``addServerMonitorListener()``
405413
- Adds a listener for server monitor-related events.
406414

407-
* - ``applyConnectionString()``
415+
* - ``applyConnectionString()``
408416
- Uses the settings from a ``ConnectionString`` object.
409417

410418
* - ``applySettings()``
@@ -421,7 +429,7 @@ Example
421429

422430
This example specifies the following driver behavior in a MongoDB server:
423431

424-
- The minimum interval for server monitoring checks to be at least ``700 MILLISECONDS``
432+
- The minimum interval for server monitoring checks to be at least ``700 MILLISECONDS``
425433
- The cluster monitor to attempt reaching a server every ``15 SECONDS``
426434

427435
.. literalinclude:: /includes/fundamentals/code-snippets/mcs.java
@@ -450,7 +458,7 @@ settings to modify the driver's behavior:
450458
* - Method
451459
- Description
452460

453-
* - ``applyConnectionString()``
461+
* - ``applyConnectionString()``
454462
- Uses the settings from a ``ConnectionString`` object.
455463

456464
* - ``applySettings()``

0 commit comments

Comments
 (0)