MongoClientSettings.Builder (driver-core 5.4.0 API) (original) (raw)
Method Details
applyConnectionString
Takes the settings from the given
ConnectionString
and applies them to the builder
Parameters:
connectionString
- the connection string containing details of how to connect to MongoDB
Returns:
thisapplyToLoggerSettings
Parameters:
block
- the block to apply to the LoggerSettings.
Returns:
this
Since:
4.9
See Also:
* MongoClientSettings.getLoggerSettings()applyToClusterSettings
Parameters:
block
- the block to apply to the ClusterSettings.
Returns:
this
See Also:
* MongoClientSettings.getClusterSettings()applyToSocketSettings
Parameters:
block
- the block to apply to the SocketSettings.
Returns:
this
See Also:
* MongoClientSettings.getSocketSettings()applyToConnectionPoolSettings
Parameters:
block
- the block to apply to the ConnectionPoolSettings.
Returns:
this
See Also:
* MongoClientSettings.getConnectionPoolSettings()applyToServerSettings
Parameters:
block
- the block to apply to the ServerSettings.
Returns:
this
See Also:
* MongoClientSettings.getServerSettings()applyToSslSettings
Parameters:
block
- the block to apply to the SslSettings.
Returns:
this
See Also:
* MongoClientSettings.getSslSettings()readPreference
Sets the read preference.
Parameters:
readPreference
- read preference
Returns:
this
See Also:
* MongoClientSettings.getReadPreference()writeConcern
Sets the write concern.
Parameters:
writeConcern
- the write concern
Returns:
this
See Also:
* MongoClientSettings.getWriteConcern()retryWrites
Sets whether writes should be retried if they fail due to a network error.
Starting with the 3.11.0 release, the default value is true
Parameters:
retryWrites
- sets if writes should be retried if they fail due to a network error.
Returns:
this
See Also:
* MongoClientSettings.getRetryWrites()
Since server release
3.6retryReads
Sets whether reads should be retried if they fail due to a network error.
Parameters:
retryReads
- sets if reads should be retried if they fail due to a network error.
Returns:
this
Since:
3.11
See Also:
* MongoClientSettings.getRetryReads()
Since server release
3.6readConcern
Sets the read concern.
Parameters:
readConcern
- the read concern
Returns:
this
MongoDB documentation
Read Concern
Since server release
3.2credential
Sets the credential.
Parameters:
credential
- the credential
Returns:
thiscodecRegistry
Parameters:
codecRegistry
- the codec registry
Returns:
this
See Also:
* MongoClientSettings.getCodecRegistry()
* CodecRegistriestransportSettings
Parameters:
transportSettings
- the transport settings
Returns:
this
See Also:
* MongoClientSettings.getTransportSettings()addCommandListener
Adds the given command listener.
Parameters:
commandListener
- the command listener
Returns:
thiscommandListenerList
Sets the command listeners
Parameters:
commandListeners
- the list of command listeners
Returns:
thisapplicationName
Sets the logical name of the application using this MongoClient. The application name may be used by the client to identify the application to the server, for use in server logs, slow query logs, and profile collection.
Parameters:
applicationName
- the logical name of the application using this MongoClient. It may be null. The UTF-8 encoding may not exceed 128 bytes.
Returns:
this
See Also:
* MongoClientSettings.getApplicationName()
Since server release
3.4compressorList
Sets the compressors to use for compressing messages to the server. The driver will use the first compressor in the list that the server is configured to support.
Parameters:
compressorList
- the list of compressors to request
Returns:
this
See Also:
* MongoClientSettings.getCompressorList()
Since server release
3.4uuidRepresentation
Parameters:
uuidRepresentation
- the UUID representation, which may not be null
Returns:
this
Since:
3.12serverApi
Sets the server API to use when sending commands to the server.
This is required for some MongoDB deployments.
Parameters:
serverApi
- the server API, which may not be null
Returns:
this
Since:
4.3autoEncryptionSettings
Sets the auto-encryption settings
A separate, internalMongoClient
is created if any of the following are true:
*AutoEncryptionSettings.keyVaultClient
is not passed
*AutoEncryptionSettings.bypassAutomaticEncryption
isfalse
If an internalMongoClient
is created, it is configured with the same options as the parentMongoClient
exceptminPoolSize
is set to0
andAutoEncryptionSettings
is omitted.
Parameters:
autoEncryptionSettings
- the auto-encryption settings
Returns:
this
Since:
3.11
See Also:
* MongoClientSettings.getAutoEncryptionSettings()contextProvider
Sets the context provider
When used with the synchronous driver, this must be an instance ofcom.mongodb.client.SynchronousContextProvider
. When used with the reactive streams driver, this must be an instance ofcom.mongodb.reactivestreams.client.ReactiveContextProvider
.
Parameters:
contextProvider
- the context provider
Returns:
this
Since:
4.4dnsClient
Sets the DnsClient to use for resolving DNS queries.
If set, it will be used to resolve SRV and TXT records for mongodb+srv connections. Otherwise, implementation of DnsClientProvider will be discovered via ServiceLoader and used to create an instance of DnsClient. If no implementation is discovered, thencom.sun.jndi.dns.DnsContextFactory
will be used to resolve these records.
If applying a connection string to these settings, care must be taken to also pass the same DnsClient as an argument to the ConnectionString constructor.
Parameters:
dnsClient
- the DNS client
Returns:
the DNS client
Since:
4.10
See Also:
* ConnectionString(String, DnsClient)inetAddressResolver
Parameters:
inetAddressResolver
- the InetAddress provider
Returns:
the InetAddress resolver
Since:
4.10
See Also:
* MongoClientSettings.getInetAddressResolver()timeout
Sets the time limit for the full execution of an operation.
*null
means that the timeout mechanism for operations will defer to using:
*waitQueueTimeoutMS
: The maximum wait time in milliseconds that a thread may wait for a connection to become available
*socketTimeoutMS
: How long a send or receive on a socket can take before timing out.
*wTimeoutMS
: How long the server will wait for the write concern to be fulfilled before timing out.
*maxTimeMS
: The cumulative time limit for processing operations on a cursor. See: cursor.maxTimeMS.
*maxCommitTimeMS
: The maximum amount of time to allow a singlecommitTransaction
command to execute. See: TransactionOptions.getMaxCommitTime(java.util.concurrent.TimeUnit).
*0
means infinite timeout.
*> 0
The time limit to use for the full execution of an operation.
Parameters:
timeout
- the timeout
timeUnit
- the time unit
Returns:
this
Since:
5.2
See Also:
* MongoClientSettings.getTimeout(java.util.concurrent.TimeUnit)build
Build an instance of
MongoClientSettings
.
Returns:
the settings from this builder