Class MongoClientSettings
- java.lang.Object
-
- io.vertx.mongo.MongoClientSettings
-
public class MongoClientSettings extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MongoClientSettings()MongoClientSettings(JsonObject json)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetApplicationName()Gets the logical name of the application using this MongoClient.AutoEncryptionSettingsgetAutoEncryptionSettings()Gets the auto-encryption settings.ClusterSettingsgetClusterSettings()Gets the cluster settings.java.util.List<MongoCompressor>getCompressorList()ConnectionPoolSettingsgetConnectionPoolSettings()Gets the settings for the connection provider in a settings object.MongoCredentialgetCredential()Gets the credential.ReadConcerngetReadConcern()The read concern to use.ReadPreferencegetReadPreference()The read preference to use for queries, map-reduce, aggregation, and count.ServerSettingsgetServerSettings()Gets the server-specific settings wrapped in a settings object.SocketSettingsgetSocketSettings()Gets the connection-specific settings wrapped in a settings object.SslSettingsgetSslSettings()Gets the SSL settings.WriteConcerngetWriteConcern()The write concern to use.java.lang.BooleanisRetryReads()Returns true if reads should be retried if they fail due to a network error or other retryable error.java.lang.BooleanisRetryWrites()Returns true if writes should be retried if they fail due to a network error or other retryable error.MongoClientSettingssetApplicationName(java.lang.String applicationName)Sets the logical name of the application using this MongoClient.MongoClientSettingssetAutoEncryptionSettings(AutoEncryptionSettings autoEncryptionSettings)Sets the auto-encryption settingsMongoClientSettingssetClusterSettings(ClusterSettings block)Applies theClusterSettingsblock and then sets the clusterSettings.MongoClientSettingssetCompressorList(java.util.List<MongoCompressor> compressorList)Sets the compressors to use for compressing messages to the server.MongoClientSettingssetConnectionPoolSettings(ConnectionPoolSettings block)Applies theConnectionPoolSettingsblock and then sets the connectionPoolSettings.MongoClientSettingssetCredential(MongoCredential credential)Sets the credential.MongoClientSettingssetReadConcern(ReadConcern readConcern)Sets the read concern.MongoClientSettingssetReadPreference(ReadPreference readPreference)Sets the read preference.MongoClientSettingssetRetryReads(java.lang.Boolean retryReads)Sets whether reads should be retried if they fail due to a network error.MongoClientSettingssetRetryWrites(java.lang.Boolean retryWrites)Sets whether writes should be retried if they fail due to a network error.MongoClientSettingssetServerSettings(ServerSettings block)Applies theServerSettingsblock and then sets the serverSettings.MongoClientSettingssetSocketSettings(SocketSettings block)Applies theSocketSettingsblock and then sets the socketSettings.MongoClientSettingssetSslSettings(SslSettings block)Applies theSslSettingsblock and then sets the sslSettings.MongoClientSettingssetWriteConcern(WriteConcern writeConcern)Sets the write concern.JsonObjecttoJson()
-
-
-
Constructor Detail
-
MongoClientSettings
public MongoClientSettings()
-
MongoClientSettings
public MongoClientSettings(JsonObject json)
-
-
Method Detail
-
toJson
public JsonObject toJson()
-
setClusterSettings
public MongoClientSettings setClusterSettings(ClusterSettings block)
Applies theClusterSettingsblock and then sets the clusterSettings.- Parameters:
block- the block to apply to the ClusterSettings.- Returns:
- this
- See Also:
getClusterSettings()
-
getClusterSettings
public ClusterSettings getClusterSettings()
Gets the cluster settings.- Returns:
- the cluster settings
-
setSocketSettings
public MongoClientSettings setSocketSettings(SocketSettings block)
Applies theSocketSettingsblock and then sets the socketSettings.- Parameters:
block- the block to apply to the SocketSettings.- Returns:
- this
- See Also:
getSocketSettings()
-
getSocketSettings
public SocketSettings getSocketSettings()
Gets the connection-specific settings wrapped in a settings object. This settings object uses the values for connectTimeout, socketTimeout and socketKeepAlive.- Returns:
- a SocketSettings object populated with the connection settings from this
MongoClientSettingsinstance. - See Also:
SocketSettings
-
setConnectionPoolSettings
public MongoClientSettings setConnectionPoolSettings(ConnectionPoolSettings block)
Applies theConnectionPoolSettingsblock and then sets the connectionPoolSettings.- Parameters:
block- the block to apply to the ConnectionPoolSettings.- Returns:
- this
- See Also:
getConnectionPoolSettings()
-
getConnectionPoolSettings
public ConnectionPoolSettings getConnectionPoolSettings()
Gets the settings for the connection provider in a settings object. This settings object wraps the values for minConnectionPoolSize, maxConnectionPoolSize, maxWaitTime, maxConnectionIdleTime and maxConnectionLifeTime.- Returns:
- a ConnectionPoolSettings populated with the settings from this
MongoClientSettingsinstance that relate to the connection provider. - See Also:
ConnectionPoolSettings
-
setServerSettings
public MongoClientSettings setServerSettings(ServerSettings block)
Applies theServerSettingsblock and then sets the serverSettings.- Parameters:
block- the block to apply to the ServerSettings.- Returns:
- this
- See Also:
getServerSettings()
-
getServerSettings
public ServerSettings getServerSettings()
Gets the server-specific settings wrapped in a settings object. This settings object uses the heartbeatFrequency and minHeartbeatFrequency values from thisMongoClientSettingsinstance.- Returns:
- a ServerSettings
- See Also:
ServerSettings
-
setSslSettings
public MongoClientSettings setSslSettings(SslSettings block)
Applies theSslSettingsblock and then sets the sslSettings.- Parameters:
block- the block to apply to the SslSettings.- Returns:
- this
- See Also:
getSslSettings()
-
getSslSettings
public SslSettings getSslSettings()
Gets the SSL settings.- Returns:
- the SSL settings
-
setReadPreference
public MongoClientSettings setReadPreference(ReadPreference readPreference)
Sets the read preference.- Parameters:
readPreference- read preference- Returns:
- this
- See Also:
getReadPreference()
-
getReadPreference
public ReadPreference getReadPreference()
The read preference to use for queries, map-reduce, aggregation, and count.Default is
ReadPreference.primary().- Returns:
- the read preference
- See Also:
ReadPreference.primary()
-
setWriteConcern
public MongoClientSettings setWriteConcern(WriteConcern writeConcern)
Sets the write concern.- Parameters:
writeConcern- the write concern- Returns:
- this
- See Also:
getWriteConcern()
-
getWriteConcern
public WriteConcern getWriteConcern()
The write concern to use.Default is
WriteConcern.ACKNOWLEDGED.- Returns:
- the write concern
- See Also:
WriteConcern.ACKNOWLEDGED
-
setRetryWrites
public MongoClientSettings setRetryWrites(java.lang.Boolean 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:
isRetryWrites()- Since server release
- 3.6
-
isRetryWrites
public java.lang.Boolean isRetryWrites()
Returns true if writes should be retried if they fail due to a network error or other retryable error.Starting with the 3.11.0 release, the default value is true
- Returns:
- the retryWrites value
- Since server release
- 3.6
-
setRetryReads
public MongoClientSettings setRetryReads(java.lang.Boolean retryReads)
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:
isRetryReads()- Since server release
- 3.6
-
isRetryReads
public java.lang.Boolean isRetryReads()
Returns true if reads should be retried if they fail due to a network error or other retryable error. The default value is true.- Returns:
- the retryReads value
- Since:
- 3.11
- Since server release
- 3.6
-
setReadConcern
public MongoClientSettings setReadConcern(ReadConcern readConcern)
Sets the read concern.- Parameters:
readConcern- the read concern- Returns:
- this
- Since server release
- 3.2
- MongoDB documentation
- Read Concern
-
getReadConcern
public ReadConcern getReadConcern()
The read concern to use.- Returns:
- the read concern
- Since server release
- 3.2
- MongoDB documentation
- Read Concern
-
setCredential
public MongoClientSettings setCredential(MongoCredential credential)
Sets the credential.- Parameters:
credential- the credential- Returns:
- this
-
getCredential
public MongoCredential getCredential()
Gets the credential.- Returns:
- the credential, which may be null
-
setApplicationName
public MongoClientSettings setApplicationName(java.lang.String applicationName)
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:
getApplicationName()- Since server release
- 3.4
-
getApplicationName
public java.lang.String getApplicationName()
Gets 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.Default is null.
- Returns:
- the application name, which may be null
- Since server release
- 3.4
-
setCompressorList
public MongoClientSettings setCompressorList(java.util.List<MongoCompressor> compressorList)
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:
getCompressorList()- Since server release
- 3.4
-
getCompressorList
public java.util.List<MongoCompressor> getCompressorList()
-
setAutoEncryptionSettings
public MongoClientSettings setAutoEncryptionSettings(AutoEncryptionSettings autoEncryptionSettings)
Sets the auto-encryption settings- Parameters:
autoEncryptionSettings- the auto-encryption settings- Returns:
- this
- Since:
- 3.11
- See Also:
getAutoEncryptionSettings()
-
getAutoEncryptionSettings
public AutoEncryptionSettings getAutoEncryptionSettings()
Gets the auto-encryption settings.Client side encryption enables an application to specify what fields in a collection must be encrypted, and the driver automatically encrypts commands and decrypts results.
Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automatic encryption is not supported for operations on a database or view and will result in error. To bypass automatic encryption, set bypassAutoEncryption=true in ClientSideEncryptionOptions.
Explicit encryption/decryption and automatic decryption is a community feature, enabled with the new
com.mongodb.client.vault .ClientEncryptiontype. A MongoClient configured with bypassAutoEncryption=true will still automatically decrypt.Automatic encryption requires the authenticated user to have the listCollections privilege action.
Note: support for client side encryption is in beta. Backwards-breaking changes may be made before the final release.
- Returns:
- the auto-encryption settings, which may be null
- Since:
- 3.11
-
-