@NotThreadSafe public static final class ClusterSettings.Builder extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
ClusterSettings.Builder |
addClusterListener(ClusterListener clusterListener)
Adds a cluster listener.
|
ClusterSettings.Builder |
applyConnectionString(ConnectionString connectionString)
Takes the settings from the given
ConnectionString and applies them to the builder |
ClusterSettings.Builder |
applySettings(ClusterSettings clusterSettings)
Applies the clusterSettings to the builder
|
ClusterSettings |
build()
Build the settings from the builder.
|
ClusterSettings.Builder |
description(java.lang.String description)
Deprecated.
|
ClusterSettings.Builder |
hosts(java.util.List<ServerAddress> hosts)
Sets the hosts for the cluster.
|
ClusterSettings.Builder |
localThreshold(long localThreshold,
java.util.concurrent.TimeUnit timeUnit)
Sets the local threshold.
|
ClusterSettings.Builder |
maxWaitQueueSize(int maxWaitQueueSize)
Deprecated.
in the next major release, wait queue size limitations will be removed
|
ClusterSettings.Builder |
mode(ClusterConnectionMode mode)
Sets the mode for this cluster.
|
ClusterSettings.Builder |
requiredClusterType(ClusterType requiredClusterType)
Sets the required cluster type for the cluster.
|
ClusterSettings.Builder |
requiredReplicaSetName(java.lang.String requiredReplicaSetName)
Sets the required replica set name for the cluster.
|
ClusterSettings.Builder |
serverSelectionTimeout(long serverSelectionTimeout,
java.util.concurrent.TimeUnit timeUnit)
Sets the timeout to apply when selecting a server.
|
ClusterSettings.Builder |
serverSelector(ServerSelector serverSelector)
Adds a server selector for the cluster to apply before selecting a server.
|
ClusterSettings.Builder |
srvHost(java.lang.String srvHost)
Sets the host name to use in order to look up an SRV DNS record to find the MongoDB hosts.
|
public ClusterSettings.Builder applySettings(ClusterSettings clusterSettings)
Note: Overwrites all existing settings
clusterSettings - the clusterSettings@Deprecated public ClusterSettings.Builder description(java.lang.String description)
MongoClientSettings.Builder.applicationName(String)description - the user defined description of the MongoClientpublic ClusterSettings.Builder srvHost(java.lang.String srvHost)
Note that when setting srvHost via ClusterSettings.Builder, the driver will NOT process any associated TXT records
associated with the host. In order to enable the processing of TXT records while still using MongoClientSettings,
specify the SRV host via connection string and apply the connection string to the settings, e.g.
MongoClientSettings.builder().applyConnectionString(new ConnectionString("mongodb+srv://host1.acme.com")) .
srvHost - the SRV host nameMongoClientSettings.Builder.applyConnectionString(ConnectionString),
applyConnectionString(ConnectionString)public ClusterSettings.Builder hosts(java.util.List<ServerAddress> hosts)
hosts - the seed list of hostspublic ClusterSettings.Builder mode(ClusterConnectionMode mode)
mode - the cluster connection modepublic ClusterSettings.Builder requiredReplicaSetName(java.lang.String requiredReplicaSetName)
requiredReplicaSetName - the required replica set name.public ClusterSettings.Builder requiredClusterType(ClusterType requiredClusterType)
requiredClusterType - the required cluster typepublic ClusterSettings.Builder localThreshold(long localThreshold, java.util.concurrent.TimeUnit timeUnit)
localThreshold - the acceptable latency difference, in milliseconds, which must be >= 0timeUnit - the time unitjava.lang.IllegalArgumentException - if localThreshold < 0public ClusterSettings.Builder serverSelector(ServerSelector serverSelector)
serverSelector - the server selector to apply as selector.ClusterSettings.getServerSelector()public ClusterSettings.Builder serverSelectionTimeout(long serverSelectionTimeout, java.util.concurrent.TimeUnit timeUnit)
MongoTimeoutException will be thrown. The default value is 30 seconds.
A value of 0 means that it will timeout immediately if no server is available. A negative value means to wait indefinitely.
serverSelectionTimeout - the timeouttimeUnit - the time unit@Deprecated public ClusterSettings.Builder maxWaitQueueSize(int maxWaitQueueSize)
This is the maximum number of concurrent operations allowed to wait for a server to become available. All further operations will get an exception immediately.
Default is 500.
maxWaitQueueSize - the number of threads that are allowed to be waiting for a connection.public ClusterSettings.Builder addClusterListener(ClusterListener clusterListener)
clusterListener - the non-null cluster listenerpublic ClusterSettings.Builder applyConnectionString(ConnectionString connectionString)
ConnectionString and applies them to the builderconnectionString - the connection string containing details of how to connect to MongoDBpublic ClusterSettings build()
Copyright © 2010 - 2023 Adobe. All Rights Reserved